[change] Il2CppDefGenerator命令新增将热更新dll列表生成到 Il2CppCompatibleDefs.cpp

main
walon 2023-01-05 21:38:32 +08:00
parent 83c336a5ce
commit ef70a49ae2
2 changed files with 29 additions and 0 deletions

View File

@ -18,7 +18,9 @@ namespace HybridCLR.Editor.Commands
var options = new Il2CppDef.Il2CppDefGenerator.Options()
{
UnityVersion = Application.unityVersion,
HotUpdateAssemblies = SettingsUtil.HotUpdateAssemblyNames,
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/il2cpp-config.h",
OutputFile2 = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/Il2CppCompatibleDef.cpp",
};
var g = new Il2CppDef.Il2CppDefGenerator(options);

View File

@ -15,8 +15,12 @@ namespace HybridCLR.Editor.Il2CppDef
{
public class Options
{
public List<string> HotUpdateAssemblies { get; set; }
public string OutputFile { get; set; }
public string OutputFile2 { get; set; }
public string UnityVersion { get; set; }
}
@ -30,6 +34,12 @@ namespace HybridCLR.Editor.Il2CppDef
private static readonly Regex s_unityVersionPat = new Regex(@"(\d+)\.(\d+)\.(\d+)");
public void Generate()
{
GenerateIl2CppConfig();
GeneratePlaceHolderAssemblies();
}
private void GenerateIl2CppConfig()
{
var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile));
@ -55,5 +65,22 @@ namespace HybridCLR.Editor.Il2CppDef
frr.Commit(_options.OutputFile);
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile}");
}
private void GeneratePlaceHolderAssemblies()
{
var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile2));
List<string> lines = new List<string>();
foreach (var ass in _options.HotUpdateAssemblies)
{
lines.Add($"\t\t\"{ass}\",");
}
frr.Replace("PLACE_HOLDER", string.Join("\n", lines));
frr.Commit(_options.OutputFile2);
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile2}");
}
}
}