[fix] 修复 Il2CppDefGeneratorCommand 中生成 PlaceHolder Assembly列表时未包含 preserveHotUpdateAssemblies的bug

main
walon 2023-01-11 17:41:44 +08:00
parent 6834a17968
commit 5a50778821
9 changed files with 26 additions and 22 deletions

View File

@ -24,8 +24,8 @@ namespace HybridCLR.Editor.BuildProcessors
Debug.Log($"[FilterHotFixAssemblies] disabled"); Debug.Log($"[FilterHotFixAssemblies] disabled");
return assemblies; return assemblies;
} }
List<string> allHotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNames; List<string> allHotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
List<string> allHotupdateDllFiles = SettingsUtil.HotUpdateAssemblyFiles; List<string> allHotupdateDllFiles = SettingsUtil.HotUpdateAssemblyFilesExcludePreserved;
// 检查是否重复填写 // 检查是否重复填写
var hotUpdateDllSet = new HashSet<string>(); var hotUpdateDllSet = new HashSet<string>();

View File

@ -92,7 +92,7 @@ namespace HybridCLR.Editor.BuildProcessors
{ {
var patcher = new ScriptingAssembliesJsonPatcher(); var patcher = new ScriptingAssembliesJsonPatcher();
patcher.Load(file); patcher.Load(file);
patcher.AddScriptingAssemblies(SettingsUtil.PatchingHotUpdateAssemblyFiles); patcher.AddScriptingAssemblies(SettingsUtil.HotUpdateAssemblyFilesIncludePreserved);
patcher.Save(file); patcher.Save(file);
} }
} }
@ -123,7 +123,7 @@ namespace HybridCLR.Editor.BuildProcessors
{ {
var binFile = new UnityBinFile(); var binFile = new UnityBinFile();
binFile.Load(binPath); binFile.Load(binPath);
binFile.AddScriptingAssemblies(SettingsUtil.PatchingHotUpdateAssemblyFiles); binFile.AddScriptingAssemblies(SettingsUtil.HotUpdateAssemblyFilesIncludePreserved);
binFile.Save(binPath); binFile.Save(binPath);
Debug.Log($"[PatchScriptingAssemblyList] patch {binPath}"); Debug.Log($"[PatchScriptingAssemblyList] patch {binPath}");
} }
@ -142,7 +142,7 @@ namespace HybridCLR.Editor.BuildProcessors
foreach (string binPath in binFiles) foreach (string binPath in binFiles)
{ {
var patcher = new Dataunity3dPatcher(); var patcher = new Dataunity3dPatcher();
patcher.ApplyPatch(binPath, SettingsUtil.PatchingHotUpdateAssemblyFiles); patcher.ApplyPatch(binPath, SettingsUtil.HotUpdateAssemblyFilesIncludePreserved);
Debug.Log($"[PatchScriptingAssemblyList] patch {binPath}"); Debug.Log($"[PatchScriptingAssemblyList] patch {binPath}");
} }
return true; return true;

View File

@ -24,7 +24,7 @@ namespace HybridCLR.Editor.Commands
public static void GenerateAOTGenericReference(BuildTarget target) public static void GenerateAOTGenericReference(BuildTarget target)
{ {
var gs = SettingsUtil.HybridCLRSettings; var gs = SettingsUtil.HybridCLRSettings;
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNames; List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames)) using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
{ {

View File

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

View File

@ -24,7 +24,7 @@ namespace HybridCLR.Editor.Commands
{ {
var ls = SettingsUtil.HybridCLRSettings; var ls = SettingsUtil.HybridCLRSettings;
List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNames; List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies), HybridCLRSettings.Instance.collectAssetReferenceTypes); var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies), HybridCLRSettings.Instance.collectAssetReferenceTypes);
var refTypes = analyzer.CollectRefs(hotfixAssemblies); var refTypes = analyzer.CollectRefs(hotfixAssemblies);

View File

@ -54,7 +54,7 @@ namespace HybridCLR.Editor.Commands
public static void GenerateMethodBridge(BuildTarget target) public static void GenerateMethodBridge(BuildTarget target)
{ {
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNames; List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames)) using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
{ {
var analyzer = new Analyzer(new Analyzer.Options var analyzer = new Analyzer(new Analyzer.Options

View File

@ -29,7 +29,7 @@ namespace HybridCLR.Editor.Commands
public static void GenerateReversePInvokeWrapper(BuildTarget target) public static void GenerateReversePInvokeWrapper(BuildTarget target)
{ {
List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNames; List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
using (var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls))) using (var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls)))
{ {
var analyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls); var analyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls);

View File

@ -65,9 +65,9 @@ namespace HybridCLR.Editor
} }
/// <summary> /// <summary>
/// 所有热更新dll列表。放到此列表中的dll在打包时OnFilterAssemblies回调中被过滤 /// 热更新dll列表。不包含 preserveHotUpdateAssemblies
/// </summary> /// </summary>
public static List<string> HotUpdateAssemblyNames public static List<string> HotUpdateAssemblyNamesExcludePreserved
{ {
get get
{ {
@ -84,31 +84,35 @@ namespace HybridCLR.Editor
} }
} }
public static List<string> HotUpdateAssemblyFiles => HotUpdateAssemblyNames.Select(dll => dll + ".dll").ToList(); public static List<string> HotUpdateAssemblyFilesExcludePreserved => HotUpdateAssemblyNamesExcludePreserved.Select(dll => dll + ".dll").ToList();
public static List<string> PatchingHotUpdateAssemblyFiles
public static List<string> HotUpdateAssemblyNamesIncludePreserved
{ {
get get
{ {
List<string> patchingList = HotUpdateAssemblyFiles; List<string> allAsses = HotUpdateAssemblyNamesExcludePreserved;
string[] preserveAssemblyNames = HybridCLRSettings.Instance.preserveHotUpdateAssemblies; string[] preserveAssemblyNames = HybridCLRSettings.Instance.preserveHotUpdateAssemblies;
if (preserveAssemblyNames != null && preserveAssemblyNames.Length > 0) if (preserveAssemblyNames != null && preserveAssemblyNames.Length > 0)
{ {
foreach(var assemblyName in preserveAssemblyNames) foreach (var assemblyName in preserveAssemblyNames)
{ {
string dllFileName = assemblyName + ".dll"; if (allAsses.Contains(assemblyName))
if (patchingList.Contains(dllFileName))
{ {
throw new Exception($"[PatchingHotUpdateAssemblyFiles] assembly:'{assemblyName}' 重复"); throw new Exception($"[HotUpdateAssemblyNamesIncludePreserved] assembly:'{assemblyName}' 重复");
} }
patchingList.Add(dllFileName); allAsses.Add(assemblyName);
} }
} }
return patchingList; return allAsses;
} }
} }
public static List<string> HotUpdateAssemblyFilesIncludePreserved => HotUpdateAssemblyNamesIncludePreserved.Select(ass => ass + ".dll").ToList();
public static List<string> AOTAssemblyNames => HybridCLRSettings.Instance.patchAOTAssemblies.ToList();
public static HybridCLRSettings HybridCLRSettings => HybridCLRSettings.Instance; public static HybridCLRSettings HybridCLRSettings => HybridCLRSettings.Instance;
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "com.focus-creative-games.hybridclr_unity", "name": "com.focus-creative-games.hybridclr_unity",
"version": "1.1.17", "version": "1.1.18",
"displayName": "HybridCLR", "displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime", "category": "Runtime",