mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-20 07:22:39 +08:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a5238bcd29 | |||
| 12dd5d8685 | |||
| feb8ed3206 | |||
| 6939d16b6c | |||
| ca143691aa | |||
| f62a2fedb0 | |||
| 2effa79f6d | |||
| 00cedc166f | |||
| 0e04a66c91 | |||
| 00f94335c3 | |||
| 1a23268b03 | |||
| 947b15e7d9 | |||
| b40d62e16e | |||
| c8acfef61d | |||
| e5c3bfa184 | |||
| 8afdcb985d | |||
| 9bb1b6054e | |||
| a107f43173 | |||
| ef0db32fc1 | |||
| f0230149ce | |||
| 0edd822101 | |||
| 419c3a98f6 | |||
| 0401d638a1 | |||
| 4ea1798700 | |||
| 6be8b2671e | |||
| 38615500fb | |||
| e7fac5b0b8 | |||
| bc6e285b92 | |||
| abc70a7ffc | |||
| eee3dbaa69 | |||
| 45d97d758f | |||
| b066cc50fa | |||
| 93f855f8ae | |||
| 5270f307b9 | |||
| f36da3529a | |||
| 521db6e38c | |||
| c85adbe65b | |||
| b9ea9b21f3 |
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
@@ -74,6 +75,10 @@ namespace HybridCLR.Editor.ABI
|
||||
case ElementType.ValueType:
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDef();
|
||||
if (typeDef == null)
|
||||
{
|
||||
throw new Exception($"type:{type} 未能找到定义。请尝试 `HybridCLR/Genergate/LinkXml`,然后Build一次生成AOT dll,再重新生成桥接函数");
|
||||
}
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
return CreateTypeInfo(typeDef.GetEnumUnderlyingType());
|
||||
|
||||
@@ -74,11 +74,11 @@ namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (sa != null && typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.ExplicitLayout))
|
||||
if (typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.ExplicitLayout))
|
||||
{
|
||||
int offset = (int)field.FieldOffset.Value;
|
||||
totalSize = Math.Max(totalSize, offset + fs);
|
||||
if (offset > sa.ClassSize)
|
||||
if (sa != null && offset > sa.ClassSize)
|
||||
{
|
||||
useSLSize = false;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace HybridCLR.Editor.ABI
|
||||
totalSize = (totalSize + fa - 1) / fa * fa;
|
||||
}
|
||||
totalSize += fs;
|
||||
if (sa != null && typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.SequentialLayout) && totalSize > sa.ClassSize)
|
||||
if (sa != null && totalSize > sa.ClassSize)
|
||||
{
|
||||
useSLSize = false;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
|
||||
public static void CopyStripDlls(string srcStripDllPath, BuildTarget target)
|
||||
{
|
||||
if (!SettingsUtil.Enable)
|
||||
{
|
||||
Debug.Log($"[CopyStrippedAOTAssemblies] disabled");
|
||||
return;
|
||||
}
|
||||
Debug.Log($"[CopyStrippedAOTAssemblies] CopyScripDlls. src:{srcStripDllPath} target:{target}");
|
||||
|
||||
var dstPath = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -23,11 +24,12 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
Debug.Log($"[FilterHotFixAssemblies] disabled");
|
||||
return assemblies;
|
||||
}
|
||||
List<string> allHotUpdateDllFiles = SettingsUtil.HotUpdateAssemblyFiles;
|
||||
List<string> allHotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNames;
|
||||
List<string> allHotupdateDllFiles = SettingsUtil.HotUpdateAssemblyFiles;
|
||||
|
||||
// 检查是否重复填写
|
||||
var hotUpdateDllSet = new HashSet<string>();
|
||||
foreach(var hotUpdateDll in allHotUpdateDllFiles)
|
||||
foreach(var hotUpdateDll in allHotUpdateDllNames)
|
||||
{
|
||||
if (!hotUpdateDllSet.Add(hotUpdateDll))
|
||||
{
|
||||
@@ -35,18 +37,20 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
}
|
||||
}
|
||||
|
||||
var assResolver = MetaUtil.CreateHotUpdateAssemblyResolver(EditorUserBuildSettings.activeBuildTarget, allHotUpdateDllNames);
|
||||
// 检查是否填写了正确的dll名称
|
||||
foreach (var hotUpdateDll in allHotUpdateDllFiles)
|
||||
foreach (var hotUpdateDllName in allHotUpdateDllNames)
|
||||
{
|
||||
if (assemblies.All(ass => !ass.EndsWith(hotUpdateDll)))
|
||||
string hotUpdateDllFile = hotUpdateDllName + ".dll";
|
||||
if (assemblies.All(ass => !ass.EndsWith(hotUpdateDllFile)) && string.IsNullOrEmpty(assResolver.ResolveAssembly(hotUpdateDllName, false)))
|
||||
{
|
||||
throw new Exception($"热更新 assembly:{hotUpdateDll} 不存在,请检查拼写错误");
|
||||
throw new Exception($"热更新 assembly:{hotUpdateDllFile} 不存在,请检查拼写错误");
|
||||
}
|
||||
Debug.Log($"[FilterHotFixAssemblies] 过滤热更新assembly:{hotUpdateDll}");
|
||||
Debug.Log($"[FilterHotFixAssemblies] 过滤热更新assembly:{hotUpdateDllFile}");
|
||||
}
|
||||
|
||||
// 将热更dll从打包列表中移除
|
||||
return assemblies.Where(ass => allHotUpdateDllFiles.All(dll => !ass.EndsWith(dll, StringComparison.OrdinalIgnoreCase))).ToArray();
|
||||
return assemblies.Where(ass => allHotupdateDllFiles.All(dll => !ass.EndsWith(dll, StringComparison.OrdinalIgnoreCase))).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,23 +14,19 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
|
||||
[MenuItem("HybridCLR/Generate/AOTGenericReference", priority = 102)]
|
||||
public static void GenerateAOTGenericReference()
|
||||
public static void CompileAndGenerateAOTGenericReference()
|
||||
{
|
||||
GenerateAOTGenericReference(true);
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
GenerateAOTGenericReference(target);
|
||||
}
|
||||
|
||||
public static void GenerateAOTGenericReference(bool compileDll)
|
||||
public static void GenerateAOTGenericReference(BuildTarget target)
|
||||
{
|
||||
// 此处理论会有点问题,打每个平台的时候,都得针对当前平台生成桥接函数
|
||||
// 但影响不大,先这样吧
|
||||
if (compileDll)
|
||||
{
|
||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
}
|
||||
|
||||
var gs = SettingsUtil.HybridCLRSettings;
|
||||
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNames;
|
||||
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget), SettingsUtil.HotUpdateAssemblyNames))
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
|
||||
{
|
||||
var analyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
using HybridCLR.Editor.DHE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
public static class DifferentialHybridExecutionCommand
|
||||
{
|
||||
[MenuItem("HybridCLR/Generate/DHEAssemblyList", priority = 110)]
|
||||
public static void GenerateAssemblyList()
|
||||
{
|
||||
var options = new AssemblyListGenerator.Options()
|
||||
{
|
||||
DifferentialHybridAssembyList = (HybridCLRSettings.Instance.differentialHybridAssemblies ?? Array.Empty<string>()).ToList(),
|
||||
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/Il2CppCompatibleDef.cpp",
|
||||
};
|
||||
|
||||
var g = new AssemblyListGenerator(options);
|
||||
g.Generate();
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("HybridCLR/Generate/DHEAssemblyOptionDatas", priority = 111)]
|
||||
public static void GenerateAssemblyOptionDatas()
|
||||
{
|
||||
GenerateAssemblyOptionDatas(true);
|
||||
}
|
||||
|
||||
public static void GenerateAssemblyOptionDatas(bool compileDll)
|
||||
{
|
||||
if (compileDll)
|
||||
{
|
||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
}
|
||||
string[] differentialHybridAssemblyList = HybridCLRSettings.Instance.differentialHybridAssemblies;
|
||||
if (differentialHybridAssemblyList == null || differentialHybridAssemblyList.Length == 0)
|
||||
{
|
||||
Debug.Log("[DifferentialHybridExecutionCommand.GenerateAssemblyOptionDatas] differentialHybridAssemblies is empty. skip generation.");
|
||||
return;
|
||||
}
|
||||
var options = new AssemblyOptionDataGenerator.Options()
|
||||
{
|
||||
DifferentialHybridAssembyList = differentialHybridAssemblyList.ToList(),
|
||||
OutputDir = $"{SettingsUtil.ProjectDir}/{HybridCLRSettings.Instance.differentialHybridOptionOutputDir}",
|
||||
};
|
||||
|
||||
var g = new AssemblyOptionDataGenerator(options);
|
||||
g.Generate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
var options = new Il2CppDef.Il2CppDefGenerator.Options()
|
||||
{
|
||||
UnityVersion = UnityEngine.Application.unityVersion,
|
||||
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/Il2CppCompatibleDef.h",
|
||||
UnityVersion = Application.unityVersion,
|
||||
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/il2cpp-config.h",
|
||||
};
|
||||
|
||||
var g = new Il2CppDef.Il2CppDefGenerator(options);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using HybridCLR.Editor.Link;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
@@ -14,41 +15,21 @@ namespace HybridCLR.Editor.Commands
|
||||
[MenuItem("HybridCLR/Generate/LinkXml", priority = 100)]
|
||||
public static void GenerateLinkXml()
|
||||
{
|
||||
GenerateLinkXml(true);
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
GenerateLinkXml(target);
|
||||
}
|
||||
|
||||
public static void GenerateLinkXml(bool compileDll)
|
||||
public static void GenerateLinkXml(BuildTarget target)
|
||||
{
|
||||
if (compileDll)
|
||||
{
|
||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
}
|
||||
|
||||
var ls = SettingsUtil.HybridCLRSettings;
|
||||
|
||||
var allAssByNames = new Dictionary<string, Assembly>();
|
||||
foreach (var ass in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
allAssByNames[ass.GetName().Name] = ass;
|
||||
}
|
||||
List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNames;
|
||||
|
||||
var hotfixAssembles = new List<Assembly>();
|
||||
foreach(var assName in SettingsUtil.HotUpdateAssemblyNames)
|
||||
{
|
||||
if (allAssByNames.TryGetValue(assName, out var ass))
|
||||
{
|
||||
hotfixAssembles.Add(ass);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"assembly:{assName} 不存在");
|
||||
}
|
||||
}
|
||||
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies), HybridCLRSettings.Instance.collectAssetReferenceTypes);
|
||||
var refTypes = analyzer.CollectRefs(hotfixAssemblies);
|
||||
|
||||
var analyzer = new Analyzer(Meta.MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget), HybridCLRSettings.Instance.collectAssetReferenceTypes);
|
||||
var refTypes = analyzer.CollectRefs(hotfixAssembles);
|
||||
|
||||
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssembles.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
|
||||
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
|
||||
var linkXmlWriter = new LinkXmlWriter();
|
||||
linkXmlWriter.Write($"{Application.dataPath}/{ls.outputLinkFile}", refTypes);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
@@ -42,25 +42,20 @@ namespace HybridCLR.Editor.Commands
|
||||
g.PrepareMethods();
|
||||
g.Generate();
|
||||
Debug.LogFormat("== output:{0} ==", outputFile);
|
||||
CleanIl2CppBuildCache();
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/Generate/MethodBridge", priority = 101)]
|
||||
public static void GenerateMethodBridge()
|
||||
public static void CompileAndGenerateMethodBridge()
|
||||
{
|
||||
GenerateMethodBridge(true);
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
GenerateMethodBridge(target);
|
||||
}
|
||||
|
||||
public static void GenerateMethodBridge(bool compileDll)
|
||||
public static void GenerateMethodBridge(BuildTarget target)
|
||||
{
|
||||
// 此处理论会有点问题,打每个平台的时候,都得针对当前平台生成桥接函数
|
||||
// 但影响不大,先这样吧
|
||||
if (compileDll)
|
||||
{
|
||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
}
|
||||
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget), SettingsUtil.HotUpdateAssemblyNames))
|
||||
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNames;
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
|
||||
{
|
||||
var analyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
@@ -83,6 +78,7 @@ namespace HybridCLR.Editor.Commands
|
||||
Task.WaitAll(tasks.ToArray());
|
||||
}
|
||||
|
||||
CleanIl2CppBuildCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,20 @@ namespace HybridCLR.Editor.Commands
|
||||
[MenuItem("HybridCLR/Generate/All", priority = 200)]
|
||||
public static void GenerateAll()
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
|
||||
DifferentialHybridExecutionCommand.GenerateAssemblyList();
|
||||
DifferentialHybridExecutionCommand.GenerateAssemblyOptionDatas();
|
||||
// 顺序随意
|
||||
ReversePInvokeWrapperGeneratorCommand.GenerateReversePInvokeWrapper();
|
||||
|
||||
// AOTReferenceGeneratorCommand 涉及到代码生成,必须在MethodBridgeGeneratorCommand之前
|
||||
AOTReferenceGeneratorCommand.GenerateAOTGenericReference();
|
||||
MethodBridgeGeneratorCommand.GenerateMethodBridge();
|
||||
// 这几个生成依赖HotUpdateDlls
|
||||
LinkGeneratorCommand.GenerateLinkXml(target);
|
||||
|
||||
// 顺序随意,只要保证 GenerateLinkXml之前有调用过CompileDll即可
|
||||
LinkGeneratorCommand.GenerateLinkXml(false);
|
||||
// 生成裁剪后的aot dll
|
||||
StripAOTDllCommand.GenerateStripedAOTDlls(target, EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
|
||||
// 桥接函数生成依赖于AOT dll,必须保证已经build过,生成AOT dll
|
||||
MethodBridgeGeneratorCommand.GenerateMethodBridge(target);
|
||||
ReversePInvokeWrapperGeneratorCommand.GenerateReversePInvokeWrapper(target);
|
||||
AOTReferenceGeneratorCommand.GenerateAOTGenericReference(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,20 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
|
||||
[MenuItem("HybridCLR/Generate/ReversePInvokeWrapper", priority = 103)]
|
||||
public static void GenerateReversePInvokeWrapper()
|
||||
|
||||
public static void CompileAndGenerateReversePInvokeWrapper()
|
||||
{
|
||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
using (var cache = new AssemblyCache(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget)))
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
GenerateReversePInvokeWrapper(target);
|
||||
}
|
||||
|
||||
public static void GenerateReversePInvokeWrapper(BuildTarget target)
|
||||
{
|
||||
List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNames;
|
||||
using (var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls)))
|
||||
{
|
||||
var analyzer = new ReversePInvokeWrap.Analyzer(cache, SettingsUtil.HotUpdateAssemblyNames);
|
||||
var analyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls);
|
||||
analyzer.Run();
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
using HybridCLR.Editor.Installer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
public static class StripAOTDllCommand
|
||||
{
|
||||
[MenuItem("HybridCLR/Generate/AOTDlls", priority = 105)]
|
||||
public static void GenerateStripedAOTDlls()
|
||||
{
|
||||
GenerateStripedAOTDlls(EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
}
|
||||
|
||||
private static string GetLocationPathName(string buildDir, BuildTarget target)
|
||||
{
|
||||
switch(target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64: return $"{buildDir}/{target}";
|
||||
case BuildTarget.StandaloneOSX: return buildDir;
|
||||
case BuildTarget.iOS: return buildDir;
|
||||
case BuildTarget.Android: return buildDir;
|
||||
case BuildTarget.StandaloneLinux64: return buildDir;
|
||||
default: return buildDir;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateStripedAOTDlls(BuildTarget target, BuildTargetGroup group)
|
||||
{
|
||||
string outputPath = $"{SettingsUtil.HybridCLRDataDir}/StrippedAOTDllsTempProj/{target}";
|
||||
BashUtil.RemoveDir(outputPath);
|
||||
|
||||
var buildOptions = BuildOptions.BuildScriptsOnly;
|
||||
|
||||
bool oldExportAndroidProj = EditorUserBuildSettings.exportAsGoogleAndroidProject;
|
||||
#if UNITY_EDITOR_OSX
|
||||
bool oldCreateSolution = UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject;
|
||||
#elif UNITY_EDITOR_WIN
|
||||
bool oldCreateSolution = UnityEditor.WindowsStandalone.UserBuildSettings.createSolution;
|
||||
#endif
|
||||
bool oldBuildScriptsOnly = EditorUserBuildSettings.buildScriptsOnly;
|
||||
EditorUserBuildSettings.buildScriptsOnly = true;
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = true;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case BuildTarget.StandaloneOSX:
|
||||
{
|
||||
#if UNITY_EDITOR_OSX
|
||||
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = true;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case BuildTarget.Android:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions()
|
||||
{
|
||||
scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray(),
|
||||
locationPathName = GetLocationPathName(outputPath, target),
|
||||
options = buildOptions,
|
||||
target = target,
|
||||
targetGroup = group,
|
||||
};
|
||||
|
||||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
|
||||
EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly;
|
||||
switch (target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = oldCreateSolution;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case BuildTarget.StandaloneOSX:
|
||||
{
|
||||
#if UNITY_EDITOR_OSX
|
||||
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = oldCreateSolution;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case BuildTarget.Android:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = oldExportAndroidProj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||
{
|
||||
Debug.LogError("GenerateStripedAOTDlls 失败");
|
||||
return;
|
||||
}
|
||||
Debug.Log($"GenerateStripedAOTDlls target:{target} group:{group} path:{outputPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6be260bc9a8a40468a82b9ea49b89a1
|
||||
guid: 21fb0a02f23185141a4a3df67fe61789
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e6e11530acf7134796d0a439a6bbe61
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,44 +0,0 @@
|
||||
using HybridCLR.Editor.Template;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.DHE
|
||||
{
|
||||
public class AssemblyListGenerator
|
||||
{
|
||||
public class Options
|
||||
{
|
||||
public string OutputFile { get; set; }
|
||||
|
||||
public List<string> DifferentialHybridAssembyList { get; set; }
|
||||
}
|
||||
|
||||
private readonly Options _options;
|
||||
public AssemblyListGenerator(Options options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
{
|
||||
var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile));
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
foreach (var ass in _options.DifferentialHybridAssembyList)
|
||||
{
|
||||
lines.Add($"\t\t\"{ass}\",");
|
||||
}
|
||||
|
||||
frr.Replace("DHE", string.Join("\n", lines));
|
||||
|
||||
frr.Commit(_options.OutputFile);
|
||||
Debug.Log($"output:{_options.OutputFile}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Editor.Commands;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using HybridCLR.Runtime;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.DHE
|
||||
{
|
||||
public class AssemblyOptionDataGenerator
|
||||
{
|
||||
public class Options
|
||||
{
|
||||
public string OutputDir { get; set; }
|
||||
|
||||
public List<string> DifferentialHybridAssembyList { get; set; }
|
||||
}
|
||||
|
||||
private readonly Options _options;
|
||||
|
||||
public AssemblyOptionDataGenerator(Options options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
{
|
||||
foreach(string assName in _options.DifferentialHybridAssembyList)
|
||||
{
|
||||
using (var assCollector = new AssemblyCache(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget)))
|
||||
{
|
||||
var ass = assCollector.LoadModule(assName);
|
||||
|
||||
var dhaOptions = new DifferentialHybridAssemblyOptions()
|
||||
{
|
||||
notChangeMethodTokens = new List<uint>(),
|
||||
};
|
||||
|
||||
foreach (var type in ass.GetTypes())
|
||||
{
|
||||
foreach (var method in type.Methods)
|
||||
{
|
||||
var attr = method.CustomAttributes.Where(a => a.AttributeType.FullName == "HybridCLR.Runtime.UnchangedAttribute").FirstOrDefault();
|
||||
if (attr != null)
|
||||
{
|
||||
if ((bool)attr.ConstructorArguments[0].Value)
|
||||
{
|
||||
dhaOptions.notChangeMethodTokens.Add(method.MDToken.Raw);
|
||||
Debug.Log($"Unchanged method:{method.MDToken.Raw} {method}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
string outOptionFile = $"{_options.OutputDir}/{assName}.dhao.bytes";
|
||||
File.WriteAllBytes(outOptionFile, dhaOptions.Marshal());
|
||||
Debug.Log($"[AssemblyOptionDataGenerator] assembly:{ass} output:{outOptionFile}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a4eda50e51d72d499b439da236a8371
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -50,7 +50,7 @@ namespace HybridCLR.Editor.Il2CppDef
|
||||
}
|
||||
}
|
||||
|
||||
frr.Replace("UNITY_CONFIG", string.Join("\n", lines));
|
||||
frr.Replace("UNITY_VERSION", string.Join("\n", lines));
|
||||
|
||||
frr.Commit(_options.OutputFile);
|
||||
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile}");
|
||||
|
||||
@@ -18,59 +18,35 @@ namespace HybridCLR.Editor.Installer
|
||||
public enum InstallErrorCode
|
||||
{
|
||||
Ok,
|
||||
InvalidUnityInstallPath,
|
||||
Il2CppInstallPathNotMatchIl2CppBranch,
|
||||
Il2CppInstallPathNotExists,
|
||||
NotIl2CppPath,
|
||||
}
|
||||
|
||||
public partial class InstallerController
|
||||
{
|
||||
private const string hybridclr_repo_path = "hybridclr_repo";
|
||||
private const string hybridclr_url = "hybridclr";
|
||||
|
||||
private const string il2cpp_plus_repo_path = "il2cpp_plus_repo";
|
||||
private const string il2cpp_plus_url = "il2cpp_plus";
|
||||
|
||||
private string m_Il2CppInstallDirectory;
|
||||
|
||||
public string Il2CppInstallDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Il2CppInstallDirectory;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Il2CppInstallDirectory = value?.Replace('\\', '/');
|
||||
if (!string.IsNullOrEmpty(m_Il2CppInstallDirectory))
|
||||
{
|
||||
EditorPrefs.SetString("UnityInstallDirectory", m_Il2CppInstallDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetIl2CppPlusBranchByUnityVersion(string unityVersion)
|
||||
{
|
||||
if (unityVersion.Contains("2019."))
|
||||
{
|
||||
return "2019.4.40";
|
||||
}
|
||||
if (unityVersion.Contains("2020."))
|
||||
{
|
||||
return "2020.3.33";
|
||||
}
|
||||
if (unityVersion.Contains("2021."))
|
||||
{
|
||||
return "2021.3.1";
|
||||
}
|
||||
return "not support";
|
||||
}
|
||||
public int MajorVersion => _curVersion.major;
|
||||
|
||||
public string Il2CppBranch => GetIl2CppPlusBranchByUnityVersion(Application.unityVersion);
|
||||
private UnityVersion _curVersion;
|
||||
|
||||
public InstallerController()
|
||||
{
|
||||
PrepareIl2CppInstallPath();
|
||||
_curVersion = ParseUnityVersion(Application.unityVersion);
|
||||
}
|
||||
|
||||
public class UnityVersion
|
||||
{
|
||||
public int major;
|
||||
public int minor1;
|
||||
public int minor2;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{major}.{minor1}.{minor2}";
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Regex s_unityVersionPat = new Regex(@"(\d+)\.(\d+)\.(\d+)");
|
||||
@@ -79,145 +55,143 @@ namespace HybridCLR.Editor.Installer
|
||||
public const int min2020_3_CompatibleMinorVersion = 21;
|
||||
public const int min2021_3_CompatibleMinorVersion = 0;
|
||||
|
||||
private bool TryParseMinorVersion(string installDir, out (int Major, int Minor1, int Minor2) unityVersion)
|
||||
private UnityVersion ParseUnityVersion(string versionStr)
|
||||
{
|
||||
var matches = s_unityVersionPat.Matches(installDir);
|
||||
var matches = s_unityVersionPat.Matches(versionStr);
|
||||
if (matches.Count == 0)
|
||||
{
|
||||
unityVersion = default;
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
// 找最后一个匹配的,有的人居然会把Unity安装目录放到其他安装版本下。无语!
|
||||
// 找最后一个匹配的
|
||||
Match match = matches[matches.Count - 1];
|
||||
// Debug.Log($"capture count:{match.Groups.Count} {match.Groups[1].Value} {match.Groups[2].Value}");
|
||||
int major = int.Parse(match.Groups[1].Value);
|
||||
int minor1 = int.Parse(match.Groups[2].Value);
|
||||
int minor2 = int.Parse(match.Groups[3].Value);
|
||||
unityVersion = (major, minor1, minor2);
|
||||
return true;
|
||||
return new UnityVersion { major = major, minor1 = minor1, minor2 = minor2 };
|
||||
}
|
||||
|
||||
public string GetCurVersionStr(string installDir)
|
||||
public string GetCurrentUnityVersionMinCompatibleVersionStr()
|
||||
{
|
||||
if (TryParseMinorVersion(installDir, out var version))
|
||||
{
|
||||
return $"{version.Major}.{version.Minor1}.{version.Minor2}";
|
||||
}
|
||||
throw new Exception($"not support version:{installDir}");
|
||||
return GetMinCompatibleVersion(MajorVersion);
|
||||
}
|
||||
|
||||
public string GetMinCompatibleVersion(string branch)
|
||||
public string GetMinCompatibleVersion(int majorVersion)
|
||||
{
|
||||
switch(branch)
|
||||
switch(majorVersion)
|
||||
{
|
||||
case "2019.4.40": return $"2019.4.{min2019_4_CompatibleMinorVersion}";
|
||||
case "2020.3.33": return $"2020.3.{min2020_3_CompatibleMinorVersion}";
|
||||
case "2021.3.1": return $"2021.3.{min2021_3_CompatibleMinorVersion}";
|
||||
default: throw new Exception($"not support version:{branch}");
|
||||
case 2019: return $"2019.4.{min2019_4_CompatibleMinorVersion}";
|
||||
case 2020: return $"2020.3.{min2020_3_CompatibleMinorVersion}";
|
||||
case 2021: return $"2021.3.{min2021_3_CompatibleMinorVersion}";
|
||||
default: throw new Exception($"not support version:{majorVersion}");
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsComaptibleWithIl2CppPlusBranch(string branch, string installDir)
|
||||
public bool IsComaptibleVersion()
|
||||
{
|
||||
if (!TryParseMinorVersion(installDir, out var unityVersion))
|
||||
UnityVersion version = _curVersion;
|
||||
switch (version.major)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch(branch)
|
||||
{
|
||||
case "2019.4.40":
|
||||
case 2019:
|
||||
{
|
||||
if (unityVersion.Major != 2019 || unityVersion.Minor1 != 4)
|
||||
if (version.major != 2019 || version.minor1 != 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return unityVersion.Minor2 >= min2019_4_CompatibleMinorVersion;
|
||||
return version.minor2 >= min2019_4_CompatibleMinorVersion;
|
||||
}
|
||||
case "2020.3.33":
|
||||
case 2020:
|
||||
{
|
||||
if (unityVersion.Major != 2020 || unityVersion.Minor1 != 3)
|
||||
if (version.major != 2020 || version.minor1 != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return unityVersion.Minor2 >= min2020_3_CompatibleMinorVersion;
|
||||
return version.minor2 >= min2020_3_CompatibleMinorVersion;
|
||||
}
|
||||
case "2021.3.1":
|
||||
case 2021:
|
||||
{
|
||||
if (unityVersion.Major != 2021 || unityVersion.Minor1 != 3)
|
||||
if (version.major != 2021 || version.minor1 != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return unityVersion.Minor2 >= min2021_3_CompatibleMinorVersion;
|
||||
return version.minor2 >= min2021_3_CompatibleMinorVersion;
|
||||
}
|
||||
default: throw new Exception($"not support il2cpp_plus branch:{branch}");
|
||||
default: throw new Exception($"not support il2cpp_plus branch:{version.major}");
|
||||
}
|
||||
}
|
||||
|
||||
void PrepareIl2CppInstallPath()
|
||||
private string _hybridclrLocalVersion;
|
||||
|
||||
public string HybridclrLocalVersion => _hybridclrLocalVersion != null ? _hybridclrLocalVersion : _hybridclrLocalVersion = GetHybridCLRLocalVersion();
|
||||
|
||||
|
||||
public string HybridCLRRepoInstalledVersion
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
|
||||
m_Il2CppInstallDirectory = EditorPrefs.GetString("Il2CppInstallDirectory");
|
||||
if (CheckValidIl2CppInstallDirectory(Il2CppBranch, m_Il2CppInstallDirectory) == InstallErrorCode.Ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var il2cppBranch = Il2CppBranch;
|
||||
var curAppInstallPath = EditorApplication.applicationPath;
|
||||
if (IsComaptibleWithIl2CppPlusBranch(il2cppBranch, curAppInstallPath))
|
||||
{
|
||||
Il2CppInstallDirectory = $"{Directory.GetParent(curAppInstallPath)}/Data/il2cpp";
|
||||
return;
|
||||
}
|
||||
string unityHubRootDir = Directory.GetParent(curAppInstallPath).Parent.Parent.ToString();
|
||||
// Debug.Log("unity hub root dir:" + unityHubRootDir);
|
||||
foreach (var unityInstallDir in Directory.GetDirectories(unityHubRootDir, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
// Debug.Log("Unity install dir:" + unityInstallDir);
|
||||
if (IsComaptibleWithIl2CppPlusBranch(il2cppBranch, unityInstallDir))
|
||||
{
|
||||
Il2CppInstallDirectory = $"{unityInstallDir}/Editor/Data/il2cpp";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Il2CppInstallDirectory = $"{Directory.GetParent(curAppInstallPath)}/Data/il2cpp";
|
||||
#else
|
||||
m_Il2CppInstallDirectory = EditorPrefs.GetString("Il2CppInstallDirectory");
|
||||
if (CheckValidIl2CppInstallDirectory(Il2CppBranch, m_Il2CppInstallDirectory) == InstallErrorCode.Ok)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var il2cppBranch = Il2CppBranch;
|
||||
var curAppInstallPath = EditorApplication.applicationPath;
|
||||
if (IsComaptibleWithIl2CppPlusBranch(il2cppBranch, curAppInstallPath))
|
||||
{
|
||||
Il2CppInstallDirectory = $"{curAppInstallPath}/Contents/il2cpp";
|
||||
return;
|
||||
}
|
||||
string unityHubRootDir = Directory.GetParent(curAppInstallPath).Parent.Parent.ToString();
|
||||
foreach (var unityInstallDir in Directory.GetDirectories(unityHubRootDir, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
Debug.Log("nity install dir:" + unityInstallDir);
|
||||
if (IsComaptibleWithIl2CppPlusBranch(il2cppBranch, unityInstallDir))
|
||||
{
|
||||
Il2CppInstallDirectory = $"{unityInstallDir}/Unity.app/Contents/il2cpp";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Il2CppInstallDirectory = $"{curAppInstallPath}/Contents/il2cpp";
|
||||
#endif
|
||||
get { return EditorPrefs.GetString($"hybridclr_repo#{MajorVersion}"); }
|
||||
set { EditorPrefs.SetString($"hybridclr_repo#{MajorVersion}", value); }
|
||||
}
|
||||
|
||||
public void InitHybridCLR(string il2cppBranch, string il2cppInstallPath)
|
||||
public string Il2CppRepoInstalledVersion
|
||||
{
|
||||
if (CheckValidIl2CppInstallDirectory(il2cppBranch, il2cppInstallPath) != InstallErrorCode.Ok)
|
||||
get { return EditorPrefs.GetString($"il2cpp_plus_repo#{MajorVersion}"); }
|
||||
set { EditorPrefs.SetString($"il2cpp_plus_repo#{MajorVersion}", value); }
|
||||
}
|
||||
|
||||
|
||||
private string GetHybridCLRLocalVersion()
|
||||
{
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||
if (Directory.Exists(hybridclrRepoDir))
|
||||
{
|
||||
Debug.LogError($"请正确设置 il2cpp 安装目录");
|
||||
return;
|
||||
var ret = BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
||||
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
|
||||
false);
|
||||
if (ret.ExitCode == 0)
|
||||
{
|
||||
return ret.StdOut.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
RunInitLocalIl2CppData(il2cppBranch, il2cppInstallPath);
|
||||
return "";
|
||||
}
|
||||
|
||||
private string _il2cppPlusLocalVersion;
|
||||
|
||||
public string Il2cppPlusLocalVersion => _il2cppPlusLocalVersion != null ? _il2cppPlusLocalVersion : _il2cppPlusLocalVersion = GetIl2cppPlusLocalVersion();
|
||||
|
||||
private string GetIl2cppPlusLocalVersion()
|
||||
{
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||
if (Directory.Exists(il2cppPlusRepoDir))
|
||||
{
|
||||
var ret = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
|
||||
false);
|
||||
if (ret.ExitCode == 0)
|
||||
{
|
||||
return ret.StdOut.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private string GetIl2CppPathByContentPath(string contentPath)
|
||||
{
|
||||
return $"{contentPath}/il2cpp";
|
||||
}
|
||||
|
||||
public void InstallLocalHybridCLR(string hybridclrVer, string il2cppPlusVer)
|
||||
{
|
||||
RunInitLocalIl2CppData(GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath), _curVersion, hybridclrVer, il2cppPlusVer);
|
||||
}
|
||||
|
||||
public bool HasInstalledHybridCLR()
|
||||
@@ -225,34 +199,6 @@ namespace HybridCLR.Editor.Installer
|
||||
return Directory.Exists($"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr");
|
||||
}
|
||||
|
||||
public InstallErrorCode CheckValidIl2CppInstallDirectory(string il2cppBranch, string installDir)
|
||||
{
|
||||
installDir = installDir.Replace('\\', '/');
|
||||
if (!Directory.Exists(installDir))
|
||||
{
|
||||
return InstallErrorCode.Il2CppInstallPathNotExists;
|
||||
}
|
||||
|
||||
if (!IsComaptibleWithIl2CppPlusBranch(il2cppBranch, installDir))
|
||||
{
|
||||
return TryParseMinorVersion(installDir, out _) ?
|
||||
InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch
|
||||
: InstallErrorCode.InvalidUnityInstallPath;
|
||||
}
|
||||
|
||||
if (!installDir.EndsWith("/il2cpp"))
|
||||
{
|
||||
return InstallErrorCode.NotIl2CppPath;
|
||||
}
|
||||
|
||||
return InstallErrorCode.Ok;
|
||||
}
|
||||
|
||||
public bool IsUnity2019(string branch)
|
||||
{
|
||||
return branch.Contains("2019.");
|
||||
}
|
||||
|
||||
|
||||
private string GetUnityIl2CppDllInstallLocation()
|
||||
{
|
||||
@@ -272,13 +218,7 @@ namespace HybridCLR.Editor.Installer
|
||||
#endif
|
||||
}
|
||||
|
||||
private static string GetRepoUrl(string repoName)
|
||||
{
|
||||
string repoProvider = SettingsUtil.HybridCLRSettings.cloneHomeURL;
|
||||
return $"{repoProvider}/{repoName}";
|
||||
}
|
||||
|
||||
private void RunInitLocalIl2CppData(string il2cppBranch, string il2cppInstallPath)
|
||||
private void RunInitLocalIl2CppData(string editorIl2cppPath, UnityVersion version, string hybridclrVer, string il2cppPlusVer)
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
if (!BashUtil.ExistProgram("git"))
|
||||
@@ -296,16 +236,20 @@ namespace HybridCLR.Editor.Installer
|
||||
BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true);
|
||||
|
||||
// clone hybridclr
|
||||
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
|
||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||
{
|
||||
BashUtil.RemoveDir(hybridclrRepoDir);
|
||||
var ret = BashUtil.RunCommand(workDir, "git", new string[]
|
||||
string[] args = new string[]
|
||||
{
|
||||
"clone",
|
||||
"--depth=1",
|
||||
GetRepoUrl(hybridclr_url),
|
||||
"-b",
|
||||
hybridclrVer,
|
||||
hybridclrRepoURL,
|
||||
hybridclrRepoDir,
|
||||
});
|
||||
};
|
||||
var ret = BashUtil.RunCommand(workDir, "git", args);
|
||||
//if (ret != 0)
|
||||
//{
|
||||
// throw new Exception($"git clone 失败");
|
||||
@@ -313,18 +257,20 @@ namespace HybridCLR.Editor.Installer
|
||||
}
|
||||
|
||||
// clone il2cpp_plus
|
||||
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
|
||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||
{
|
||||
BashUtil.RemoveDir(il2cppPlusRepoDir);
|
||||
var ret = BashUtil.RunCommand(workDir, "git", new string[]
|
||||
string[] args = new string[]
|
||||
{
|
||||
"clone",
|
||||
"--depth=1",
|
||||
"-b",
|
||||
il2cppBranch,
|
||||
GetRepoUrl(il2cpp_plus_url),
|
||||
il2cppPlusVer,
|
||||
il2cppPlusRepoURL,
|
||||
il2cppPlusRepoDir,
|
||||
});
|
||||
};
|
||||
var ret = BashUtil.RunCommand(workDir, "git", args);
|
||||
//if (ret != 0)
|
||||
//{
|
||||
// throw new Exception($"git clone 失败");
|
||||
@@ -336,10 +282,10 @@ namespace HybridCLR.Editor.Installer
|
||||
BashUtil.RecreateDir(localUnityDataDir);
|
||||
|
||||
// copy MonoBleedingEdge
|
||||
BashUtil.CopyDir($"{Directory.GetParent(il2cppInstallPath)}/MonoBleedingEdge", $"{localUnityDataDir}/MonoBleedingEdge", true);
|
||||
BashUtil.CopyDir($"{Directory.GetParent(editorIl2cppPath)}/MonoBleedingEdge", $"{localUnityDataDir}/MonoBleedingEdge", true);
|
||||
|
||||
// copy il2cpp
|
||||
BashUtil.CopyDir(Il2CppInstallDirectory, SettingsUtil.LocalIl2CppDir, true);
|
||||
BashUtil.CopyDir(editorIl2cppPath, SettingsUtil.LocalIl2CppDir, true);
|
||||
|
||||
// replace libil2cpp
|
||||
string dstLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
@@ -349,9 +295,9 @@ namespace HybridCLR.Editor.Installer
|
||||
// clean Il2cppBuildCache
|
||||
BashUtil.RemoveDir($"{SettingsUtil.ProjectDir}/Library/Il2cppBuildCache", true);
|
||||
|
||||
if (IsUnity2019(il2cppBranch))
|
||||
if (version.major == 2019)
|
||||
{
|
||||
string curVersionStr = GetCurVersionStr(il2cppInstallPath);
|
||||
string curVersionStr = version.ToString();
|
||||
string srcIl2CppDll = GetUnityIl2CppDllModifiedPath(curVersionStr);
|
||||
if (File.Exists(srcIl2CppDll))
|
||||
{
|
||||
@@ -367,6 +313,10 @@ namespace HybridCLR.Editor.Installer
|
||||
if (HasInstalledHybridCLR())
|
||||
{
|
||||
Debug.Log("安装成功!");
|
||||
_hybridclrLocalVersion = null;
|
||||
_il2cppPlusLocalVersion = null;
|
||||
HybridCLRRepoInstalledVersion = hybridclrVer;
|
||||
Il2CppRepoInstalledVersion = il2cppPlusVer;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -8,11 +8,24 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
public class InstallerWindow : EditorWindow
|
||||
{
|
||||
private InstallerController m_Controller;
|
||||
private InstallerController _controller;
|
||||
|
||||
string _hybridclrVersion;
|
||||
string _il2cppPlusVersion;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Controller = new InstallerController();
|
||||
_controller = new InstallerController();
|
||||
_hybridclrVersion = _controller.HybridCLRRepoInstalledVersion;
|
||||
if (string.IsNullOrWhiteSpace(_hybridclrVersion))
|
||||
{
|
||||
_hybridclrVersion = "1.0";
|
||||
}
|
||||
_il2cppPlusVersion = _controller.Il2CppRepoInstalledVersion;
|
||||
if (string.IsNullOrWhiteSpace(_il2cppPlusVersion))
|
||||
{
|
||||
_il2cppPlusVersion = $"{_controller.MajorVersion}-1.0";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
@@ -30,124 +43,70 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
|
||||
}
|
||||
string minCompatibleVersion = m_Controller.GetMinCompatibleVersion(m_Controller.Il2CppBranch);
|
||||
GUI.enabled = true;
|
||||
GUILayout.Space(10f);
|
||||
EditorGUILayout.LabelField("=======================说明====================");
|
||||
EditorGUILayout.LabelField(
|
||||
$"你所在项目的Unity版本可以与il2cpp_plus版本:{m_Controller.Il2CppBranch} 不一样。\n"
|
||||
+ $"如果你的Unity的版本号 >= {minCompatibleVersion}, 可以直接安装。\n"
|
||||
+ $"如果你的Unity的版本号 < {minCompatibleVersion}, \n"
|
||||
+ $"由于安装HybridCLR时需要从il2cpp_plus兼容版本{m_Controller.Il2CppBranch}(而不是你项目版本)拷贝il2cpp目录,\n"
|
||||
+ $"你必须同时安装兼容版本 {m_Controller.Il2CppBranch} 才能完成安装", EditorStyles.wordWrappedLabel);
|
||||
EditorGUILayout.LabelField("==============================================");
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
|
||||
GUILayout.Space(5f);
|
||||
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
bool hasInstall = m_Controller.HasInstalledHybridCLR();
|
||||
bool hasInstall = _controller.HasInstalledHybridCLR();
|
||||
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel);
|
||||
|
||||
if (hasInstall)
|
||||
{
|
||||
EditorGUILayout.LabelField($"HybridCLR 版本: {m_Controller.GetHybridCLRLocalVersion()}");
|
||||
EditorGUILayout.LabelField($"HybridCLR 版本: {_controller.HybridclrLocalVersion}");
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"il2cpp_plus 版本: {m_Controller.GetIl2cppPlusLocalVersion(m_Controller.Il2CppBranch)}");
|
||||
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
|
||||
GUILayout.Space(5f);
|
||||
GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
|
||||
GUILayout.Space(40f);
|
||||
//GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
|
||||
//GUILayout.Space(40f);
|
||||
}
|
||||
|
||||
GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select");
|
||||
GUILayout.Space(10f);
|
||||
GUIInstallButton("安装最新HybridCLR插件代码到本项目", "安装", InitHybridCLR);
|
||||
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("待安装的 hybridclr 仓库版本号(或branch或tag)(默认取最新版本):", GUILayout.MaxWidth(400));
|
||||
_hybridclrVersion = EditorGUILayout.TextField(_hybridclrVersion);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField($"待安装的 il2cpp_plus 仓库版本号(或branch或tag)(默认取{_controller.MajorVersion}-main分支最新版本):", GUILayout.MaxWidth(400));
|
||||
_il2cppPlusVersion = EditorGUILayout.TextField(_il2cppPlusVersion);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
|
||||
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void GUIInstallButton(string content, string button, Action onClick)
|
||||
private void GUIInstallButton(string content, string button)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(content);
|
||||
GUI.enabled = m_Controller.CheckValidIl2CppInstallDirectory(m_Controller.Il2CppBranch, m_Controller.Il2CppInstallDirectory) == InstallErrorCode.Ok;
|
||||
if (GUILayout.Button(button, GUILayout.Width(100)))
|
||||
{
|
||||
onClick?.Invoke();
|
||||
InstallLocalHybridCLR();
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
GUI.enabled = true;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void GUISelectUnityDirectory(string content, string selectButton)
|
||||
private void InstallLocalHybridCLR()
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(content, GUILayout.MaxWidth(300));
|
||||
string il2cppInstallDirectory = m_Controller.Il2CppInstallDirectory = EditorGUILayout.TextField(m_Controller.Il2CppInstallDirectory);
|
||||
if (GUILayout.Button(selectButton, GUILayout.Width(100)))
|
||||
if (!_controller.IsComaptibleVersion())
|
||||
{
|
||||
string temp = EditorUtility.OpenFolderPanel(content, m_Controller.Il2CppInstallDirectory, string.Empty);
|
||||
if (!string.IsNullOrEmpty(temp))
|
||||
{
|
||||
il2cppInstallDirectory = m_Controller.Il2CppInstallDirectory = temp;
|
||||
}
|
||||
Debug.LogError($"il2cpp 版本不兼容,最小版本为 {_controller.GetCurrentUnityVersionMinCompatibleVersionStr()}");
|
||||
return;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
InstallErrorCode err = m_Controller.CheckValidIl2CppInstallDirectory(m_Controller.Il2CppBranch, il2cppInstallDirectory);
|
||||
switch (err)
|
||||
if (string.IsNullOrWhiteSpace(_hybridclrVersion))
|
||||
{
|
||||
case InstallErrorCode.Ok:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case InstallErrorCode.Il2CppInstallPathNotExists:
|
||||
{
|
||||
EditorGUILayout.HelpBox("li2cpp 路径不存在", MessageType.Error);
|
||||
break;
|
||||
}
|
||||
case InstallErrorCode.InvalidUnityInstallPath:
|
||||
{
|
||||
EditorGUILayout.HelpBox($"Unity安装目录必须包含版本号,否则无法识别版本", MessageType.Error);
|
||||
break;
|
||||
}
|
||||
case InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch:
|
||||
{
|
||||
EditorGUILayout.HelpBox($"il2cpp 版本不兼容,最小版本为 {m_Controller.GetMinCompatibleVersion(m_Controller.Il2CppBranch)}", MessageType.Error);
|
||||
break;
|
||||
}
|
||||
case InstallErrorCode.NotIl2CppPath:
|
||||
{
|
||||
EditorGUILayout.HelpBox($"当前选择的路径不是il2cpp目录(必须类似 xxx/il2cpp)", MessageType.Error);
|
||||
break;
|
||||
}
|
||||
default: throw new Exception($"not support {err}");
|
||||
_hybridclrVersion = "main";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitHybridCLR()
|
||||
{
|
||||
m_Controller.InitHybridCLR(m_Controller.Il2CppBranch, m_Controller.Il2CppInstallDirectory);
|
||||
}
|
||||
|
||||
private void UpdateHybridCLR()
|
||||
{
|
||||
bool hasUpdateIl2Cpp = m_Controller.HasUpdateIl2Cpp(m_Controller.Il2CppBranch);
|
||||
if (hasUpdateIl2Cpp)
|
||||
if (string.IsNullOrWhiteSpace(_il2cppPlusVersion))
|
||||
{
|
||||
bool ret = EditorUtility.DisplayDialog("检查更新", "版本不一致", "更新","取消");
|
||||
if (ret)
|
||||
{
|
||||
InitHybridCLR();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorUtility.DisplayDialog("检查更新", "暂无更新", "确定");
|
||||
_il2cppPlusVersion = $"{_controller.MajorVersion}-main";
|
||||
}
|
||||
_controller.InstallLocalHybridCLR(_hybridclrVersion, _il2cppPlusVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
public partial class InstallerController
|
||||
{
|
||||
public string GetHybridCLRLocalVersion()
|
||||
{
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||
if (Directory.Exists(hybridclrRepoDir))
|
||||
{
|
||||
var ret = BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
||||
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
|
||||
false);
|
||||
if (ret.ExitCode == 0)
|
||||
{
|
||||
return ret.StdOut.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public string GetIl2cppPlusLocalVersion(string il2cppBranch)
|
||||
{
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||
if (Directory.Exists(il2cppPlusRepoDir))
|
||||
{
|
||||
var ret = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", },
|
||||
false);
|
||||
if (ret.ExitCode == 0)
|
||||
{
|
||||
return ret.StdOut.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public bool HasUpdateIl2Cpp(string il2cppBranch)
|
||||
{
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
// last hash hybridclr
|
||||
{
|
||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||
var ret1 = BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
||||
BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "fetch", "--depth=1" }, false);
|
||||
var ret2 = BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
||||
new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", }
|
||||
, false);
|
||||
if (ret1.StdOut != ret2.StdOut)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// last hash il2cpp_plus
|
||||
{
|
||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||
var ret1 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
||||
BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "fetch", "--depth=1" }, false);
|
||||
var ret2 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
||||
if (ret1.StdOut != ret2.StdOut)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91454a4f0a354d11830642b4d4474d7e
|
||||
timeCreated: 1665546286
|
||||
+5
-12
@@ -22,26 +22,19 @@ namespace HybridCLR.Editor.Link
|
||||
_analyzeAssetType = analyzeAssetType;
|
||||
}
|
||||
|
||||
public HashSet<TypeRef> CollectRefs(List<Assembly> rootAssemblies)
|
||||
public HashSet<TypeRef> CollectRefs(List<string> rootAssemblies)
|
||||
{
|
||||
using (var assCollector = new AssemblyCache(_resolver))
|
||||
{
|
||||
var rootAssemblyName = new HashSet<string>();
|
||||
foreach (var ass in rootAssemblies)
|
||||
{
|
||||
if (!rootAssemblyName.Add(ass.GetName().Name))
|
||||
{
|
||||
throw new Exception($"assembly:{ass.GetName().Name} 重复");
|
||||
}
|
||||
}
|
||||
var rootAssemblyNames = new HashSet<string>(rootAssemblies);
|
||||
|
||||
var typeRefs = new HashSet<TypeRef>(TypeEqualityComparer.Instance);
|
||||
foreach (var rootAss in rootAssemblies)
|
||||
{
|
||||
var dnAss = assCollector.LoadModule(rootAss.GetName().Name);
|
||||
var dnAss = assCollector.LoadModule(rootAss, _analyzeAssetType);
|
||||
foreach (var type in dnAss.GetTypeRefs())
|
||||
{
|
||||
if (!rootAssemblyName.Contains(type.DefinitionAssembly.Name))
|
||||
if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString()))
|
||||
{
|
||||
typeRefs.Add(type);
|
||||
}
|
||||
@@ -51,7 +44,7 @@ namespace HybridCLR.Editor.Link
|
||||
if (_analyzeAssetType)
|
||||
{
|
||||
var modsExludeRoots = assCollector.LoadedModules
|
||||
.Where(e => !rootAssemblyName.Contains(e.Key))
|
||||
.Where(e => !rootAssemblyNames.Contains(e.Key))
|
||||
.ToDictionary(e => e.Key, e => e.Value);
|
||||
CollectObjectTypeInAssets(modsExludeRoots, typeRefs);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace HybridCLR.Editor.Meta
|
||||
_asmResolver.UseGAC = false;
|
||||
}
|
||||
|
||||
public ModuleDefMD LoadModule(string moduleName)
|
||||
public ModuleDefMD LoadModule(string moduleName, bool loadReferenceAssemblies = true)
|
||||
{
|
||||
// Debug.Log($"load module:{moduleName}");
|
||||
if (LoadedModules.TryGetValue(moduleName, out var mod))
|
||||
@@ -37,10 +37,14 @@ namespace HybridCLR.Editor.Meta
|
||||
mod = DoLoadModule(_assemblyPathResolver.ResolveAssembly(moduleName, true));
|
||||
LoadedModules.Add(moduleName, mod);
|
||||
|
||||
foreach (var refAsm in mod.GetAssemblyRefs())
|
||||
if (loadReferenceAssemblies)
|
||||
{
|
||||
LoadModule(refAsm.Name);
|
||||
foreach (var refAsm in mod.GetAssemblyRefs())
|
||||
{
|
||||
LoadModule(refAsm.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public abstract class AssemblyResolverBase : IAssemblyResolver
|
||||
{
|
||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||
{
|
||||
if (TryResolveAssembly(assemblyName, out string assemblyPath))
|
||||
{
|
||||
return assemblyPath;
|
||||
}
|
||||
if (throwExIfNotFind)
|
||||
{
|
||||
throw new Exception($"resolve assembly:{assemblyName} 失败! 如果是热更新dll找不到,请先运行`HybridCLR/CompileDll/ActiveBuildTarget`编译生成热更新dll。如果是AOT dll找不到,请先运行`HybridCLR/Generate/LinkXml`,接着在`Build Settings`中打包或者导出工程来生成AOT dll");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract bool TryResolveAssembly(string assemblyName, out string assemblyPath);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 998b5f512dc60924e953a558ed250e15
|
||||
guid: 5f8d48774b790364cbd36f1f68fd6614
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public class CombinedAssemblyResolver : IAssemblyResolver
|
||||
public class CombinedAssemblyResolver : AssemblyResolverBase
|
||||
{
|
||||
private readonly IAssemblyResolver[] _resolvers;
|
||||
|
||||
@@ -15,21 +15,19 @@ namespace HybridCLR.Editor.Meta
|
||||
_resolvers = resolvers;
|
||||
}
|
||||
|
||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||
protected override bool TryResolveAssembly(string assemblyName, out string assemblyPath)
|
||||
{
|
||||
foreach(var resolver in _resolvers)
|
||||
{
|
||||
var assembly = resolver.ResolveAssembly(assemblyName, false);
|
||||
if (assembly != null)
|
||||
{
|
||||
return assembly;
|
||||
assemblyPath = assembly;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (throwExIfNotFind)
|
||||
{
|
||||
throw new Exception($"resolve assembly:{assemblyName} fail");
|
||||
}
|
||||
return null;
|
||||
assemblyPath = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public class FixedSetAssemblyResolver : AssemblyResolverBase
|
||||
{
|
||||
private readonly string _rootDir;
|
||||
private readonly HashSet<string> _fileNames;
|
||||
|
||||
public FixedSetAssemblyResolver(string rootDir, IEnumerable<string> fileNameNotExts)
|
||||
{
|
||||
_rootDir = rootDir;
|
||||
_fileNames = new HashSet<string>(fileNameNotExts);
|
||||
}
|
||||
|
||||
protected override bool TryResolveAssembly(string assemblyName, out string assemblyPath)
|
||||
{
|
||||
if (_fileNames.Contains(assemblyName))
|
||||
{
|
||||
assemblyPath = $"{_rootDir}/{assemblyName}.dll";
|
||||
if (File.Exists(assemblyPath))
|
||||
{
|
||||
Debug.Log($"[FixedSetAssemblyResolver] resolve:{assemblyName} path:{assemblyPath}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
assemblyPath = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 029bc0368e1ada342aa29a18d4fae879
|
||||
guid: f135accd10f42c64b9735c3aa8cb1e77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+33
-6
@@ -6,6 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
@@ -119,13 +120,39 @@ namespace HybridCLR.Editor.Meta
|
||||
return typeSigs.Select(s => ToShareTypeSig(s)).ToList();
|
||||
}
|
||||
|
||||
public static IAssemblyResolver CreateBuildTargetAssemblyResolver(UnityEditor.BuildTarget target)
|
||||
public static IAssemblyResolver CreateHotUpdateAssemblyResolver(BuildTarget target, List<string> hotUpdateDlls)
|
||||
{
|
||||
return new CombinedAssemblyResolver(new PathAssemblyResolver(
|
||||
SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)),
|
||||
new UnityPluginAssemblyResolver(),
|
||||
new UnityAOTAssemblyResolver(),
|
||||
new UnityEditorAssemblyResolver());
|
||||
var externalDirs = HybridCLRSettings.Instance.externalHotUpdateAssembliyDirs;
|
||||
var defaultHotUpdateOutputDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target);
|
||||
IAssemblyResolver defaultHotUpdateResolver = new FixedSetAssemblyResolver(defaultHotUpdateOutputDir, hotUpdateDlls);
|
||||
if (externalDirs == null || externalDirs.Length == 0)
|
||||
{
|
||||
return defaultHotUpdateResolver;
|
||||
}
|
||||
else
|
||||
{
|
||||
var resolvers = new List<IAssemblyResolver>();
|
||||
foreach (var dir in externalDirs)
|
||||
{
|
||||
resolvers.Add(new FixedSetAssemblyResolver($"{dir}/{target}", hotUpdateDlls));
|
||||
resolvers.Add(new FixedSetAssemblyResolver(dir, hotUpdateDlls));
|
||||
}
|
||||
resolvers.Add(defaultHotUpdateResolver);
|
||||
return new CombinedAssemblyResolver(resolvers.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public static IAssemblyResolver CreateAOTAssemblyResolver(BuildTarget target)
|
||||
{
|
||||
return new PathAssemblyResolver(SettingsUtil.GetAssembliesPostIl2CppStripDir(target));
|
||||
}
|
||||
|
||||
public static IAssemblyResolver CreateHotUpdateAndAOTAssemblyResolver(BuildTarget target, List<string> hotUpdateDlls)
|
||||
{
|
||||
return new CombinedAssemblyResolver(
|
||||
CreateHotUpdateAssemblyResolver(target, hotUpdateDlls),
|
||||
CreateAOTAssemblyResolver(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public class PathAssemblyResolver : IAssemblyResolver
|
||||
public class PathAssemblyResolver : AssemblyResolverBase
|
||||
{
|
||||
private readonly string[] _searchPaths;
|
||||
public PathAssemblyResolver(params string[] searchPaths)
|
||||
@@ -16,7 +16,7 @@ namespace HybridCLR.Editor.Meta
|
||||
_searchPaths = searchPaths;
|
||||
}
|
||||
|
||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||
protected override bool TryResolveAssembly(string assemblyName, out string assemblyPath)
|
||||
{
|
||||
foreach(var path in _searchPaths)
|
||||
{
|
||||
@@ -24,14 +24,12 @@ namespace HybridCLR.Editor.Meta
|
||||
if (File.Exists(assPath))
|
||||
{
|
||||
Debug.Log($"resolve {assemblyName} at {assPath}");
|
||||
return assPath;
|
||||
assemblyPath = assPath;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (throwExIfNotFind)
|
||||
{
|
||||
throw new Exception($"resolve assembly:{assemblyName} fail");
|
||||
}
|
||||
return null;
|
||||
assemblyPath = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public class UnityAOTAssemblyResolver : IAssemblyResolver
|
||||
{
|
||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||
{
|
||||
//
|
||||
var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot/{assemblyName}.dll";
|
||||
if (File.Exists(assemblyFile))
|
||||
{
|
||||
Debug.Log($"UnityAOTAssemblyResolver.ResolveAssembly:{assemblyFile}");
|
||||
return assemblyFile;
|
||||
}
|
||||
if (throwExIfNotFind)
|
||||
{
|
||||
throw new Exception($"resolve assembly:{assemblyName} fail");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public class UnityEditorAssemblyResolver : IAssemblyResolver
|
||||
{
|
||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||
{
|
||||
var refAss = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == assemblyName);
|
||||
if (refAss != null)
|
||||
{
|
||||
return refAss.Location;
|
||||
}
|
||||
return Assembly.Load(assemblyName).Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78d06a3ad750c0b4b80b583188b02df3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public class UnityPluginAssemblyResolver : IAssemblyResolver
|
||||
{
|
||||
private static readonly HashSet<string> s_ignoreDirs = new HashSet<string>
|
||||
{
|
||||
"Editor",
|
||||
"StreamingAssets",
|
||||
"Resources",
|
||||
};
|
||||
|
||||
private bool IsPluginDll(string dllPath)
|
||||
{
|
||||
var fileOrDirs = new HashSet<string>(dllPath.Split('\\', '/'));
|
||||
return !fileOrDirs.Intersect(s_ignoreDirs).Any();
|
||||
}
|
||||
|
||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||
{
|
||||
foreach(var dll in Directory.GetFiles(UnityEngine.Application.dataPath, "*.dll", SearchOption.AllDirectories))
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(dll) == assemblyName && IsPluginDll(dll))
|
||||
{
|
||||
Debug.Log($"UnityPluginAssemblyResolver.ResolveAssembly:{dll}");
|
||||
return dll;
|
||||
}
|
||||
}
|
||||
if (throwExIfNotFind)
|
||||
{
|
||||
throw new Exception($"resolve assembly:{assemblyName} fail");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c235be11c219a74fa5eb55ed54e7662
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -36,7 +36,7 @@ Managed2NativeMethodInfo hybridclr::interpreter::g_managed2nativeStub[] =
|
||||
lines.Add($"\t{{\"{method.CreateInvokeSigName()}\", __M2N_{method.CreateInvokeSigName()}}},");
|
||||
}
|
||||
|
||||
lines.Add($"\t{{\"\", nullptr}},");
|
||||
lines.Add($"\t{{nullptr, nullptr}},");
|
||||
lines.Add("};");
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
codes.Add($@"
|
||||
{method.ReturnInfo.Type.GetTypeName()} __ReversePInvokeMethod_{methodIndex}({paramDeclaringListWithoutMethodInfoStr})
|
||||
{{
|
||||
const MethodInfo* method = MetadataModule::GetMethodInfoByReversePInvokeWrapperIndex({i});
|
||||
const MethodInfo* method = MetadataModule::GetMethodInfoByReversePInvokeWrapperIndex({methodIndex});
|
||||
{methodTypeDef};
|
||||
{(method.ReturnInfo.IsVoid ? "" : "return ")}((Callback)(method->methodPointerCallByInterp))({paramNameListWithoutMethodInfoStr});
|
||||
}}
|
||||
|
||||
@@ -11,15 +11,15 @@ namespace HybridCLR.Editor
|
||||
private SerializedObject _serializedObject;
|
||||
private SerializedProperty _enable;
|
||||
private SerializedProperty _useGlobalIl2cpp;
|
||||
private SerializedProperty _cloneHomeURL;
|
||||
private SerializedProperty _hybridclrRepoURL;
|
||||
private SerializedProperty _il2cppPlusRepoURL;
|
||||
private SerializedProperty _hotUpdateAssemblyDefinitions;
|
||||
private SerializedProperty _hotUpdateAssemblies;
|
||||
private SerializedProperty _preserveHotUpdateAssemblies;
|
||||
private SerializedProperty _hotUpdateDllCompileOutputRootDir;
|
||||
private SerializedProperty _externalHotUpdateAssembliyDirs;
|
||||
private SerializedProperty _strippedAOTDllOutputRootDir;
|
||||
private SerializedProperty _patchAOTAssemblies;
|
||||
private SerializedProperty _differentialHybridAssemblies;
|
||||
private SerializedProperty _differentialHybridOptionOutputDir;
|
||||
private SerializedProperty _collectAssetReferenceTypes;
|
||||
private SerializedProperty _outputLinkFile;
|
||||
private SerializedProperty _outputAOTGenericReferenceFile;
|
||||
@@ -39,15 +39,15 @@ namespace HybridCLR.Editor
|
||||
_serializedObject = new SerializedObject(setting);
|
||||
_enable = _serializedObject.FindProperty("enable");
|
||||
_useGlobalIl2cpp = _serializedObject.FindProperty("useGlobalIl2cpp");
|
||||
_cloneHomeURL = _serializedObject.FindProperty("cloneHomeURL");
|
||||
_hybridclrRepoURL = _serializedObject.FindProperty("hybridclrRepoURL");
|
||||
_il2cppPlusRepoURL = _serializedObject.FindProperty("il2cppPlusRepoURL");
|
||||
_hotUpdateAssemblyDefinitions = _serializedObject.FindProperty("hotUpdateAssemblyDefinitions");
|
||||
_hotUpdateAssemblies = _serializedObject.FindProperty("hotUpdateAssemblies");
|
||||
_preserveHotUpdateAssemblies = _serializedObject.FindProperty("preserveHotUpdateAssemblies");
|
||||
_hotUpdateDllCompileOutputRootDir = _serializedObject.FindProperty("hotUpdateDllCompileOutputRootDir");
|
||||
_externalHotUpdateAssembliyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs");
|
||||
_strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir");
|
||||
_patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies");
|
||||
_differentialHybridAssemblies = _serializedObject.FindProperty("differentialHybridAssemblies");
|
||||
_differentialHybridOptionOutputDir = _serializedObject.FindProperty("differentialHybridOptionOutputDir");
|
||||
_collectAssetReferenceTypes = _serializedObject.FindProperty("collectAssetReferenceTypes");
|
||||
_outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
|
||||
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
|
||||
@@ -127,16 +127,16 @@ namespace HybridCLR.Editor
|
||||
_serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(_enable);
|
||||
EditorGUILayout.PropertyField(_cloneHomeURL);
|
||||
EditorGUILayout.PropertyField(_hybridclrRepoURL);
|
||||
EditorGUILayout.PropertyField(_il2cppPlusRepoURL);
|
||||
EditorGUILayout.PropertyField(_useGlobalIl2cpp);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblies);
|
||||
EditorGUILayout.PropertyField(_preserveHotUpdateAssemblies);
|
||||
EditorGUILayout.PropertyField(_hotUpdateDllCompileOutputRootDir);
|
||||
EditorGUILayout.PropertyField(_externalHotUpdateAssembliyDirs);
|
||||
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
|
||||
EditorGUILayout.PropertyField(_patchAOTAssemblies);
|
||||
EditorGUILayout.PropertyField(_differentialHybridAssemblies);
|
||||
EditorGUILayout.PropertyField(_differentialHybridOptionOutputDir);
|
||||
EditorGUILayout.PropertyField(_collectAssetReferenceTypes);
|
||||
EditorGUILayout.PropertyField(_outputLinkFile);
|
||||
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
|
||||
|
||||
@@ -11,8 +11,11 @@ namespace HybridCLR.Editor
|
||||
[Header("使用全局安装的il2cpp")]
|
||||
public bool useGlobalIl2cpp;
|
||||
|
||||
[Header("基准 git clone URL")]
|
||||
public string cloneHomeURL = "https://gitee.com/focus-creative-games";
|
||||
[Header("hybridclr 仓库 URL")]
|
||||
public string hybridclrRepoURL = "https://gitee.com/focus-creative-games/hybridclr";
|
||||
|
||||
[Header("il2cpp_plus 仓库 URL")]
|
||||
public string il2cppPlusRepoURL = "https://gitee.com/focus-creative-games/il2cpp_plus";
|
||||
|
||||
[Header("热更新Assembly Definitions")]
|
||||
public AssemblyDefinitionAsset[] hotUpdateAssemblyDefinitions;
|
||||
@@ -26,18 +29,15 @@ namespace HybridCLR.Editor
|
||||
[Header("热更新dll编译输出根目录")]
|
||||
public string hotUpdateDllCompileOutputRootDir = "HybridCLRData/HotUpdateDlls";
|
||||
|
||||
[Header("外部热更新dll搜索路径")]
|
||||
public string[] externalHotUpdateAssembliyDirs;
|
||||
|
||||
[Header("裁减后AOT dll输出根目录")]
|
||||
public string strippedAOTDllOutputRootDir = "HybridCLRData/AssembliesPostIl2CppStrip";
|
||||
|
||||
[Header("补充元数据AOT dlls")]
|
||||
public string[] patchAOTAssemblies;
|
||||
|
||||
[Header("差分混合热更新 dlls")]
|
||||
public string[] differentialHybridAssemblies;
|
||||
|
||||
[Header("差分混合热更新配置数据输出目录")]
|
||||
public string differentialHybridOptionOutputDir = "Assets/StreamingAssets";
|
||||
|
||||
[Header("生成link.xml时扫描asset中引用的类型")]
|
||||
public bool collectAssetReferenceTypes;
|
||||
|
||||
@@ -50,9 +50,6 @@ namespace HybridCLR.Editor
|
||||
[Header("AOT泛型实例化搜索迭代次数")]
|
||||
public int maxGenericReferenceIteration = 10;
|
||||
|
||||
//[Header("预留MonoPInvokeCallbackAttribute函数个数")]
|
||||
//public int ReversePInvokeWrapperCount = 10;
|
||||
|
||||
[Header("MethodBridge泛型搜索迭代次数")]
|
||||
public int maxMethodBridgeGenericIteration = 10;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,15 @@ namespace HybridCLR.Editor
|
||||
{
|
||||
public static class SettingsUtil
|
||||
{
|
||||
public static bool Enable => HybridCLRSettings.Instance.enable;
|
||||
public static bool Enable
|
||||
{
|
||||
get => HybridCLRSettings.Instance.enable;
|
||||
set
|
||||
{
|
||||
HybridCLRSettings.Instance.enable = value;
|
||||
HybridCLRSettings.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static string PackageName { get; } = "com.focus-creative-games.hybridclr_unity";
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Runtime
|
||||
{
|
||||
public class DifferentialHybridAssemblyOptions
|
||||
{
|
||||
public const uint Signature = 0xABCDABCD;
|
||||
|
||||
public List<uint> notChangeMethodTokens;
|
||||
|
||||
|
||||
public byte[] Marshal()
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
var writer = new BinaryWriter(stream);
|
||||
writer.Write(Signature);
|
||||
writer.Write((uint)notChangeMethodTokens.Count);
|
||||
foreach (uint token in notChangeMethodTokens)
|
||||
{
|
||||
writer.Write(token);
|
||||
}
|
||||
writer.Flush();
|
||||
stream.Flush();
|
||||
byte[] result = new byte[stream.Length];
|
||||
stream.Position = 0;
|
||||
stream.Read(result, 0, result.Length);
|
||||
Debug.Log($"HotPatchAssemblyConfig. options bytes:{result.Length}");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3394055921ccce643b09466544ea3634
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -46,56 +46,6 @@ namespace HybridCLR
|
||||
public static extern unsafe int LoadMetadataForAOTAssembly(byte* dllBytes, int dllSize, int mode);
|
||||
|
||||
|
||||
//[DllImport(dllName, EntryPoint = "RuntimeApi_UseDifferentialHybridAOTAssembly")]
|
||||
//public static unsafe LoadImageErrorCode UseDifferentialHybridAOTAssembly(string assemblyName)
|
||||
//{
|
||||
// byte[] nameBytes = System.Text.Encoding.UTF8.GetBytes(assemblyName);
|
||||
// fixed(byte* namePtr = nameBytes)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 指示混合执行assembly使用原始的AOT代码。当assembly没有发生变化时必须调用此接口。
|
||||
/// </summary>
|
||||
/// <param name="assemblyName"></param>
|
||||
/// <returns></returns>
|
||||
#if UNITY_EDITOR
|
||||
public static LoadImageErrorCode UseDifferentialHybridAOTAssembly(string assemblyName)
|
||||
{
|
||||
return LoadImageErrorCode.OK;
|
||||
}
|
||||
#else
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_UseDifferentialHybridAOTAssembly")]
|
||||
public static extern LoadImageErrorCode UseDifferentialHybridAOTAssembly(string assemblyName);
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载差分混合执行 assembly
|
||||
/// </summary>
|
||||
/// <param name="dllBytes"></param>
|
||||
/// <param name="optionBytes"></param>
|
||||
/// <returns></returns>
|
||||
public static unsafe LoadImageErrorCode LoadDifferentialHybridAssembly(byte[] dllBytes, byte[] optionBytes)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return LoadImageErrorCode.OK;
|
||||
#else
|
||||
fixed(byte* dllBytesPtr = dllBytes)
|
||||
{
|
||||
fixed(byte* optionBytesPtr = optionBytes)
|
||||
{
|
||||
return (LoadImageErrorCode)LoadDifferentialHybridAssembly(dllBytesPtr, dllBytes.Length, optionBytesPtr, optionBytes.Length);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_LoadDifferentialHybridAssembly")]
|
||||
public static extern unsafe int LoadDifferentialHybridAssembly(byte* dllBytes, int dllSize, byte* optionBytesPtr, int optionBytesLength);
|
||||
|
||||
/// <summary>
|
||||
/// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Runtime
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class UnchangedAttribute : Attribute
|
||||
{
|
||||
public bool Unchanged { get; }
|
||||
|
||||
public UnchangedAttribute(bool unchanged = true)
|
||||
{
|
||||
Unchanged = unchanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 704603a2a0551f247a30e331ca476870
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.focus-creative-games.hybridclr_unity",
|
||||
"version": "0.10.4",
|
||||
"version": "1.0.12",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||
"category": "Runtime",
|
||||
|
||||
Reference in New Issue
Block a user