From ef70a49ae26c375925c9ad3ccfb98240b13411c0 Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 5 Jan 2023 21:38:32 +0800 Subject: [PATCH] =?UTF-8?q?[change]=20Il2CppDefGenerator=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B0=86=E7=83=AD=E6=9B=B4=E6=96=B0dll?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=94=9F=E6=88=90=E5=88=B0=20Il2CppCompatibl?= =?UTF-8?q?eDefs.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Commands/Il2CppDefGeneratorCommand.cs | 2 ++ Editor/Il2CppDef/Il2CppDefGenerator.cs | 27 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Editor/Commands/Il2CppDefGeneratorCommand.cs b/Editor/Commands/Il2CppDefGeneratorCommand.cs index 6a9e175..3030686 100644 --- a/Editor/Commands/Il2CppDefGeneratorCommand.cs +++ b/Editor/Commands/Il2CppDefGeneratorCommand.cs @@ -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); diff --git a/Editor/Il2CppDef/Il2CppDefGenerator.cs b/Editor/Il2CppDef/Il2CppDefGenerator.cs index ae1a8c0..8728c65 100644 --- a/Editor/Il2CppDef/Il2CppDefGenerator.cs +++ b/Editor/Il2CppDef/Il2CppDefGenerator.cs @@ -15,8 +15,12 @@ namespace HybridCLR.Editor.Il2CppDef { public class Options { + public List 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 lines = new List(); + + 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}"); + } } }