mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-20 07:22:39 +08:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f9faf49a3 | |||
| 3f1b34682d | |||
| c3f6325e4a | |||
| a9f5608ecf | |||
| 8a95fd57f5 | |||
| 679c21da43 | |||
| 52bab856ed | |||
| 844b2fb62f | |||
| 88404cbbfc | |||
| 9b4aa904ef | |||
| a71153d414 | |||
| bec8c84c56 | |||
| 79bab0459c | |||
| 1d09f72460 | |||
| 058270c658 | |||
| 210c781fad | |||
| 6757f6df5b | |||
| 41c73fe35b | |||
| 4d487fa4c4 | |||
| 2f71bb515d | |||
| 0d8b001dd2 | |||
| 3d68dc4db3 | |||
| 2988aef85a | |||
| 768512bcfa | |||
| 4492449b73 |
@@ -2,18 +2,18 @@
|
||||
"versions": [
|
||||
{
|
||||
"unity_version":"2020",
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2020-3.0.0"}
|
||||
"hybridclr" : { "branch":"v3.3.1"},
|
||||
"il2cpp_plus": { "branch":"v2020-3.3.1"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2021",
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2021-3.1.0"}
|
||||
"hybridclr" : { "branch":"v3.3.1"},
|
||||
"il2cpp_plus": { "branch":"v2021-3.3.2"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022",
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2022-3.1.0"}
|
||||
"hybridclr" : { "branch":"v3.3.1"},
|
||||
"il2cpp_plus": { "branch":"v2022-3.3.2"}
|
||||
}
|
||||
]
|
||||
}
|
||||
+7
-11
@@ -58,15 +58,15 @@ namespace HybridCLR.Editor.AOT
|
||||
return;
|
||||
}
|
||||
gc = gc.ToGenericShare();
|
||||
if (_genericTypes.Add(gc) && NeedWalk(gc.Type))
|
||||
if (_genericTypes.Add(gc) && NeedWalk(null, gc.Type))
|
||||
{
|
||||
WalkType(gc);
|
||||
}
|
||||
}
|
||||
|
||||
private bool NeedWalk(TypeDef type)
|
||||
private bool NeedWalk(MethodDef callFrom, TypeDef type)
|
||||
{
|
||||
return _hotUpdateAssemblyFiles.Contains(type.Module.Name);
|
||||
return _hotUpdateAssemblyFiles.Contains(type.Module.Name) || callFrom == null || callFrom.HasGenericParameters;
|
||||
}
|
||||
|
||||
private bool IsAotType(TypeDef type)
|
||||
@@ -85,7 +85,7 @@ namespace HybridCLR.Editor.AOT
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_genericMethods.Add(method) && NeedWalk(method.Method.DeclaringType))
|
||||
if (NeedWalk(methodDef, method.Method.DeclaringType) && _genericMethods.Add(method))
|
||||
{
|
||||
_newMethods.Add(method);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace HybridCLR.Editor.AOT
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_genericMethods.Add(method) && NeedWalk(method.Method.DeclaringType))
|
||||
if (NeedWalk(null, method.Method.DeclaringType) && _genericMethods.Add(method))
|
||||
{
|
||||
_newMethods.Add(method);
|
||||
}
|
||||
@@ -157,9 +157,9 @@ namespace HybridCLR.Editor.AOT
|
||||
for (uint rid = 1, n = ass.Metadata.TablesStream.TypeSpecTable.Rows; rid <= n; rid++)
|
||||
{
|
||||
var ts = ass.ResolveTypeSpec(rid);
|
||||
if (!ts.ContainsGenericParameter)
|
||||
var cs = GenericClass.ResolveClass(ts, null)?.ToGenericShare();
|
||||
if (cs != null)
|
||||
{
|
||||
var cs = GenericClass.ResolveClass(ts, null)?.ToGenericShare();
|
||||
TryAddAndWalkGenericType(cs);
|
||||
}
|
||||
}
|
||||
@@ -167,10 +167,6 @@ namespace HybridCLR.Editor.AOT
|
||||
for (uint rid = 1, n = ass.Metadata.TablesStream.MethodSpecTable.Rows; rid <= n; rid++)
|
||||
{
|
||||
var ms = ass.ResolveMethodSpec(rid);
|
||||
if (ms.DeclaringType.ContainsGenericParameter || ms.GenericInstMethodSig.ContainsGenericParameter)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var gm = GenericMethod.ResolveMethod(ms, null)?.ToGenericShare();
|
||||
TryAddMethodNotWalkType(gm);
|
||||
}
|
||||
|
||||
@@ -90,11 +90,12 @@ namespace HybridCLR.Editor.AOT
|
||||
|
||||
codes.Add("");
|
||||
codes.Add("\t// {{ AOT generic types");
|
||||
|
||||
types.Sort((a, b) => a.Type.FullName.CompareTo(b.Type.FullName));
|
||||
foreach(var type in types)
|
||||
|
||||
List<string> typeNames = types.Select(t => PrettifyTypeSig(t.ToTypeSig().ToString())).ToList();
|
||||
typeNames.Sort(string.CompareOrdinal);
|
||||
foreach(var typeName in typeNames)
|
||||
{
|
||||
codes.Add($"\t// {PrettifyTypeSig(type.ToTypeSig().ToString())}");
|
||||
codes.Add($"\t// {typeName}");
|
||||
}
|
||||
|
||||
codes.Add("\t// }}");
|
||||
@@ -102,27 +103,36 @@ namespace HybridCLR.Editor.AOT
|
||||
codes.Add("");
|
||||
codes.Add("\tpublic void RefMethods()");
|
||||
codes.Add("\t{");
|
||||
methods.Sort((a, b) =>
|
||||
|
||||
List<(string, string, string)> methodTypeAndNames = methods.Select(m =>
|
||||
(PrettifyTypeSig(m.Method.DeclaringType.ToString()), PrettifyMethodSig(m.Method.Name), PrettifyMethodSig(m.ToMethodSpec().ToString())))
|
||||
.ToList();
|
||||
methodTypeAndNames.Sort((a, b) =>
|
||||
{
|
||||
int c = a.Method.DeclaringType.FullName.CompareTo(b.Method.DeclaringType.FullName);
|
||||
int c = String.Compare(a.Item1, b.Item1, StringComparison.Ordinal);
|
||||
if (c != 0)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
c = a.Method.Name.CompareTo(b.Method.Name);
|
||||
return c;
|
||||
|
||||
c = String.Compare(a.Item2, b.Item2, StringComparison.Ordinal);
|
||||
if (c != 0)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
return String.Compare(a.Item3, b.Item3, StringComparison.Ordinal);
|
||||
});
|
||||
foreach(var method in methods)
|
||||
foreach(var method in methodTypeAndNames)
|
||||
{
|
||||
codes.Add($"\t\t// {PrettifyMethodSig(method.ToMethodSpec().ToString())}");
|
||||
codes.Add($"\t\t// {PrettifyMethodSig(method.Item3)}");
|
||||
}
|
||||
codes.Add("\t}");
|
||||
|
||||
codes.Add("}");
|
||||
|
||||
|
||||
var utf8WithoutBOM = new System.Text.UTF8Encoding(false);
|
||||
File.WriteAllText(outputFile, string.Join("\n", codes), utf8WithoutBOM);
|
||||
var utf8WithoutBom = new System.Text.UTF8Encoding(false);
|
||||
File.WriteAllText(outputFile, string.Join("\n", codes), utf8WithoutBom);
|
||||
Debug.Log($"[GenericReferenceWriter] write {outputFile}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using HybridCLR.Editor.Installer;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -29,9 +30,8 @@ namespace HybridCLR.Editor
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS)
|
||||
if (target != BuildTarget.iOS || !HybridCLRSettings.Instance.enable)
|
||||
return;
|
||||
|
||||
/*
|
||||
* 1. 生成lump,并且添加到工程
|
||||
3. 将libil2cpp目录复制到 Library/. 删除旧的. search paths里修改 libil2cpp/include为libil2cpp
|
||||
@@ -54,7 +54,7 @@ namespace HybridCLR.Editor
|
||||
CopyLibil2cppToXcodeProj(srcLibil2cppDir, dstLibil2cppDir);
|
||||
CopyExternalToXcodeProj(srcExternalDir, dstExternalDir);
|
||||
var lumpFiles = CreateLumps(dstLibil2cppDir, lumpDir);
|
||||
var extraSources = GetExtraSourceFiles(dstExternalDir);
|
||||
var extraSources = GetExtraSourceFiles(dstExternalDir, dstLibil2cppDir);
|
||||
var cflags = new List<string>()
|
||||
{
|
||||
"-DIL2CPP_MONO_DEBUGGER_DISABLED",
|
||||
@@ -62,6 +62,11 @@ namespace HybridCLR.Editor
|
||||
ModifyPBXProject(pathToBuiltProject, pbxprojFile, lumpFiles, extraSources, cflags);
|
||||
}
|
||||
|
||||
private static string GetRelativePathFromProj(string path)
|
||||
{
|
||||
return path.Substring(path.IndexOf("Libraries", StringComparison.Ordinal)).Replace('\\', '/');
|
||||
}
|
||||
|
||||
private static void ModifyPBXProject(string pathToBuiltProject, string pbxprojFile, List<LumpFile> lumpFiles, List<string> extraFiles, List<string> cflags)
|
||||
{
|
||||
var proj = new PBXProject();
|
||||
@@ -80,14 +85,16 @@ namespace HybridCLR.Editor
|
||||
|
||||
foreach (var lumpFile in lumpFiles)
|
||||
{
|
||||
string projPathOfFile = $"Classes/Lumps/{Path.GetFileName(lumpFile.lumpFile)}";
|
||||
string lumpFileName = Path.GetFileName(lumpFile.lumpFile);
|
||||
string projPathOfFile = $"Classes/Lumps/{lumpFileName}";
|
||||
string relativePathOfFile = GetRelativePathFromProj(lumpFile.lumpFile);
|
||||
string lumpGuid = proj.FindFileGuidByProjectPath(projPathOfFile);
|
||||
if (!string.IsNullOrEmpty(lumpGuid))
|
||||
{
|
||||
proj.RemoveFileFromBuild(targetGUID, lumpGuid);
|
||||
proj.RemoveFile(lumpGuid);
|
||||
}
|
||||
lumpGuid = proj.AddFile(lumpFile.lumpFile, projPathOfFile, PBXSourceTree.Source);
|
||||
lumpGuid = proj.AddFile(relativePathOfFile, projPathOfFile, PBXSourceTree.Source);
|
||||
proj.AddFileToBuild(targetGUID, lumpGuid);
|
||||
}
|
||||
|
||||
@@ -101,7 +108,7 @@ namespace HybridCLR.Editor
|
||||
proj.RemoveFile(extraFileGuid);
|
||||
//Debug.LogWarning($"remove exist extra file:{projPathOfFile} guid:{extraFileGuid}");
|
||||
}
|
||||
var lumpGuid = proj.AddFile(extraFile, projPathOfFile, PBXSourceTree.Source);
|
||||
var lumpGuid = proj.AddFile(GetRelativePathFromProj(extraFile), projPathOfFile, PBXSourceTree.Source);
|
||||
proj.AddFileToBuild(targetGUID, lumpGuid);
|
||||
}
|
||||
|
||||
@@ -182,7 +189,7 @@ namespace HybridCLR.Editor
|
||||
var lumpFileContent = new List<string>();
|
||||
foreach (var file in cppFiles)
|
||||
{
|
||||
lumpFileContent.Add($"#include \"{file}\"");
|
||||
lumpFileContent.Add($"#include \"{GetRelativePathFromProj(file)}\"");
|
||||
}
|
||||
File.WriteAllLines(lumpFile, lumpFileContent, Encoding.UTF8);
|
||||
Debug.Log($"create lump file:{lumpFile}");
|
||||
@@ -226,11 +233,22 @@ namespace HybridCLR.Editor
|
||||
return lumpFiles;
|
||||
}
|
||||
|
||||
private static List<string> GetExtraSourceFiles(string externalDir)
|
||||
private static List<string> GetExtraSourceFiles(string externalDir, string libil2cppDir)
|
||||
{
|
||||
var files = new List<string>();
|
||||
files.AddRange(Directory.GetFiles($"{externalDir}/zlib", "*.c"));
|
||||
files.Add($"{externalDir}/xxHash/xxhash.c");
|
||||
foreach (string extraDir in new string[]
|
||||
{
|
||||
$"{externalDir}/zlib",
|
||||
$"{externalDir}/xxHash",
|
||||
$"{libil2cppDir}/os/ClassLibraryPAL/brotli",
|
||||
})
|
||||
{
|
||||
if (!Directory.Exists(extraDir))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
files.AddRange(Directory.GetFiles(extraDir, "*.c", SearchOption.AllDirectories));
|
||||
}
|
||||
return files;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace HybridCLR.Editor
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS)
|
||||
if (target != BuildTarget.iOS || !HybridCLRSettings.Instance.enable)
|
||||
return;
|
||||
|
||||
string pbxprojFile = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -25,15 +26,18 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
return assemblies;
|
||||
}
|
||||
List<string> allHotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
List<string> allHotupdateDllFiles = SettingsUtil.HotUpdateAssemblyFilesExcludePreserved;
|
||||
|
||||
// 检查是否重复填写
|
||||
var hotUpdateDllSet = new HashSet<string>();
|
||||
foreach(var hotUpdateDll in allHotUpdateDllNames)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(hotUpdateDll))
|
||||
{
|
||||
throw new BuildFailedException($"热更新 assembly 名不能为空");
|
||||
}
|
||||
if (!hotUpdateDllSet.Add(hotUpdateDll))
|
||||
{
|
||||
throw new Exception($"热更新 assembly:{hotUpdateDll} 在列表中重复,请除去重复条目");
|
||||
throw new BuildFailedException($"热更新 assembly:{hotUpdateDll} 在列表中重复,请除去重复条目");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,16 +45,24 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
// 检查是否填写了正确的dll名称
|
||||
foreach (var hotUpdateDllName in allHotUpdateDllNames)
|
||||
{
|
||||
string hotUpdateDllFile = hotUpdateDllName + ".dll";
|
||||
if (assemblies.All(ass => !ass.EndsWith(hotUpdateDllFile)) && string.IsNullOrEmpty(assResolver.ResolveAssembly(hotUpdateDllName, false)))
|
||||
if (assemblies.Select(Path.GetFileNameWithoutExtension).All(ass => ass != hotUpdateDllName)
|
||||
&& string.IsNullOrEmpty(assResolver.ResolveAssembly(hotUpdateDllName, false)))
|
||||
{
|
||||
throw new Exception($"热更新 assembly:{hotUpdateDllFile} 不存在,请检查拼写错误");
|
||||
throw new BuildFailedException($"热更新 assembly:{hotUpdateDllName} 不存在,请检查拼写错误");
|
||||
}
|
||||
Debug.Log($"[FilterHotFixAssemblies] 过滤热更新assembly:{hotUpdateDllFile}");
|
||||
}
|
||||
|
||||
|
||||
// 将热更dll从打包列表中移除
|
||||
return assemblies.Where(ass => allHotupdateDllFiles.All(dll => !ass.EndsWith(dll, StringComparison.OrdinalIgnoreCase))).ToArray();
|
||||
return assemblies.Where(ass =>
|
||||
{
|
||||
string assName = Path.GetFileNameWithoutExtension(ass);
|
||||
bool reserved = allHotUpdateDllNames.All(dll => !assName.Equals(dll, StringComparison.Ordinal));
|
||||
if (!reserved)
|
||||
{
|
||||
Debug.Log($"[FilterHotFixAssemblies] 过滤热更新assembly:{assName}");
|
||||
}
|
||||
return reserved;
|
||||
}).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@ namespace HybridCLR.Editor.Commands
|
||||
ScriptCompilationSettings scriptCompilationSettings = new ScriptCompilationSettings();
|
||||
scriptCompilationSettings.group = group;
|
||||
scriptCompilationSettings.target = target;
|
||||
if (developmentBuild)
|
||||
{
|
||||
scriptCompilationSettings.options |= ScriptCompilationOptions.DevelopmentBuild;
|
||||
}
|
||||
scriptCompilationSettings.options = developmentBuild ? ScriptCompilationOptions.DevelopmentBuild : ScriptCompilationOptions.None;
|
||||
Directory.CreateDirectory(buildDir);
|
||||
ScriptCompilationResult scriptCompilationResult = PlayerBuildInterface.CompilePlayerScripts(scriptCompilationSettings, buildDir);
|
||||
#if UNITY_2022
|
||||
|
||||
@@ -93,10 +93,6 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
private static readonly Regex s_unityVersionPat = new Regex(@"(\d+)\.(\d+)\.(\d+)");
|
||||
|
||||
public const int min2020_3_CompatibleMinorVersion = 26;
|
||||
public const int min2021_3_CompatibleMinorVersion = 0;
|
||||
public const int min2022_3_CompatibleMinorVersion = 0;
|
||||
|
||||
private UnityVersion ParseUnityVersion(string versionStr)
|
||||
{
|
||||
var matches = s_unityVersionPat.Matches(versionStr);
|
||||
@@ -104,9 +100,7 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// 找最后一个匹配的
|
||||
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);
|
||||
@@ -122,13 +116,14 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
switch(majorVersion)
|
||||
{
|
||||
case 2021: return $"2021.3.{min2021_3_CompatibleMinorVersion}";
|
||||
case 2022: return $"2022.3.{min2022_3_CompatibleMinorVersion}";
|
||||
default: throw new Exception($"not support version:{majorVersion}");
|
||||
case 2020: return $"2020.3.0";
|
||||
case 2021: return $"2021.3.0";
|
||||
case 2022: return $"2022.3.0";
|
||||
default: return $"2020.3.0";
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsComaptibleVersion()
|
||||
public bool IsCompatibleVersion()
|
||||
{
|
||||
UnityVersion version = _curVersion;
|
||||
if (version == null)
|
||||
@@ -139,27 +134,12 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (version.major)
|
||||
{
|
||||
case 2020:
|
||||
{
|
||||
return version.minor2 >= min2021_3_CompatibleMinorVersion;
|
||||
}
|
||||
case 2021:
|
||||
{
|
||||
return version.minor2 >= min2021_3_CompatibleMinorVersion;
|
||||
}
|
||||
case 2022:
|
||||
{
|
||||
return version.minor2 >= min2022_3_CompatibleMinorVersion;
|
||||
}
|
||||
default: throw new Exception($"not support il2cpp_plus branch:{version.major}");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public string HybridclrLocalVersion => _curDefaultVersion.hybridclr.branch;
|
||||
public string HybridclrLocalVersion => _curDefaultVersion?.hybridclr?.branch;
|
||||
|
||||
public string Il2cppPlusLocalVersion => _curDefaultVersion.il2cpp_plus.branch;
|
||||
public string Il2cppPlusLocalVersion => _curDefaultVersion?.il2cpp_plus?.branch;
|
||||
|
||||
|
||||
private string GetIl2CppPathByContentPath(string contentPath)
|
||||
@@ -222,9 +202,9 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
private void RunInitLocalIl2CppData(string editorIl2cppPath, string libil2cppWithHybridclrSourceDir, UnityVersion version)
|
||||
{
|
||||
if (!IsComaptibleVersion())
|
||||
if (!IsCompatibleVersion())
|
||||
{
|
||||
Debug.LogError($"il2cpp 版本不兼容,最小版本为 {GetCurrentUnityVersionMinCompatibleVersionStr()}");
|
||||
Debug.LogError($"Incompatible with current version, minimum compatible version: {GetCurrentUnityVersionMinCompatibleVersionStr()}");
|
||||
return;
|
||||
}
|
||||
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||
@@ -249,11 +229,11 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
if (HasInstalledHybridCLR())
|
||||
{
|
||||
Debug.Log("安装成功");
|
||||
Debug.Log("Install Sucessfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("安装失败");
|
||||
Debug.LogError("Installation failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace HybridCLR.Editor.Installer
|
||||
height = 24
|
||||
};
|
||||
var content = EditorGUIUtility.IconContent("Settings");
|
||||
content.tooltip = "点击打开HybridCLR Settings";
|
||||
content.tooltip = "HybridCLR Settings";
|
||||
if (GUI.Button(rect, content, GUI.skin.GetStyle("IconButton")))
|
||||
{
|
||||
SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
|
||||
@@ -41,67 +41,57 @@ namespace HybridCLR.Editor.Installer
|
||||
GUILayout.Space(10f);
|
||||
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField($"Installed: {hasInstall}", EditorStyles.boldLabel);
|
||||
GUILayout.Space(10f);
|
||||
|
||||
|
||||
EditorGUILayout.LabelField($"{SettingsUtil.PackageName} 版本: v{_controller.PackageVersion}");
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"bybridclr 版本: {_controller.HybridclrLocalVersion}");
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
|
||||
EditorGUILayout.LabelField($"Package Version: v{_controller.PackageVersion}");
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
if (_controller.IsComaptibleVersion())
|
||||
if (_controller.IsCompatibleVersion())
|
||||
{
|
||||
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
_installFromDir = EditorGUILayout.Toggle("Copy libil2cpp from local", _installFromDir, GUILayout.MinWidth(100));
|
||||
EditorGUI.BeginDisabledGroup(!_installFromDir);
|
||||
EditorGUILayout.TextField(_installLibil2cppWithHybridclrSourceDir, GUILayout.Width(400));
|
||||
if (GUILayout.Button("Choose", GUILayout.Width(100)))
|
||||
{
|
||||
_installLibil2cppWithHybridclrSourceDir = EditorUtility.OpenFolderPanel("Select libil2cpp", Application.dataPath, "libil2cpp");
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(20f);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Install", GUILayout.Width(100)))
|
||||
{
|
||||
InstallLocalHybridCLR();
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("与当前版本不兼容", MessageType.Error);
|
||||
EditorGUILayout.HelpBox($"Incompatible with current version, minimum compatible version:{_controller.GetCurrentUnityVersionMinCompatibleVersionStr()}", MessageType.Error);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void GUIInstallButton(string content, string button)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
_installFromDir = EditorGUILayout.Toggle("从本地复制libil2cpp", _installFromDir);
|
||||
EditorGUI.BeginDisabledGroup(!_installFromDir);
|
||||
EditorGUILayout.TextField(_installLibil2cppWithHybridclrSourceDir, GUILayout.Width(400));
|
||||
if (GUILayout.Button("选择目录", GUILayout.Width(100)))
|
||||
{
|
||||
_installLibil2cppWithHybridclrSourceDir = EditorUtility.OpenFolderPanel("选择libil2cpp目录", Application.dataPath, "libil2cpp");
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField(content);
|
||||
if (GUILayout.Button(button, GUILayout.Width(100)))
|
||||
{
|
||||
InstallLocalHybridCLR();
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
}
|
||||
|
||||
private void InstallLocalHybridCLR()
|
||||
{
|
||||
if (_installFromDir)
|
||||
{
|
||||
if (!Directory.Exists(_installLibil2cppWithHybridclrSourceDir))
|
||||
{
|
||||
Debug.LogError($"本地libil2cpp复制目录不存在. '{_installLibil2cppWithHybridclrSourceDir}'");
|
||||
Debug.LogError($"Source libil2cpp:'{_installLibil2cppWithHybridclrSourceDir}' doesn't exist.");
|
||||
return;
|
||||
}
|
||||
if (!File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/il2cpp-config.h") || !File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/hybridclr/RuntimeApi.cpp"))
|
||||
{
|
||||
Debug.LogError($"本地libil2cpp不是合法有效的源码目录. '{_installLibil2cppWithHybridclrSourceDir}'");
|
||||
Debug.LogError($"Source libil2cpp:' {_installLibil2cppWithHybridclrSourceDir} ' is invalid");
|
||||
return;
|
||||
}
|
||||
_controller.InstallFromLocal(_installLibil2cppWithHybridclrSourceDir);
|
||||
|
||||
@@ -22,18 +22,18 @@ namespace HybridCLR.Editor.Link
|
||||
writer.WriteStartElement("linker");
|
||||
|
||||
var typesByAssembly = refTypes.GroupBy(t => t.DefinitionAssembly.Name.String).ToList();
|
||||
typesByAssembly.Sort((a, b) => a.Key.CompareTo(b.Key));
|
||||
typesByAssembly.Sort((a, b) => String.Compare(a.Key, b.Key, StringComparison.Ordinal));
|
||||
|
||||
foreach(var assembly in typesByAssembly)
|
||||
{
|
||||
writer.WriteStartElement("assembly");
|
||||
writer.WriteAttributeString("fullname", assembly.Key);
|
||||
List<TypeRef> assTypes = assembly.ToList();
|
||||
assTypes.Sort((a, b) => a.FullName.CompareTo(b.FullName));
|
||||
foreach(var type in assTypes)
|
||||
List<string> assTypeNames = assembly.Select(t => t.FullName).ToList();
|
||||
assTypeNames.Sort(string.CompareOrdinal);
|
||||
foreach(var typeName in assTypeNames)
|
||||
{
|
||||
writer.WriteStartElement("type");
|
||||
writer.WriteAttributeString("fullname", type.FullName);
|
||||
writer.WriteAttributeString("fullname", typeName);
|
||||
writer.WriteAttributeString("preserve", "all");
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
@@ -93,6 +93,8 @@ namespace HybridCLR.Editor.Meta
|
||||
case ElementType.SZArray: return corTypes.Object;
|
||||
case ElementType.Array: return corTypes.Object;
|
||||
case ElementType.ValueType: return typeSig;
|
||||
case ElementType.Var:
|
||||
case ElementType.MVar:
|
||||
case ElementType.Class: return corTypes.Object;
|
||||
case ElementType.GenericInst:
|
||||
{
|
||||
|
||||
@@ -22,15 +22,6 @@ namespace HybridCLR.Editor.Meta
|
||||
|
||||
public void WalkMethod(MethodDef method, List<TypeSig> klassGenericInst, List<TypeSig> methodGenericInst)
|
||||
{
|
||||
if (klassGenericInst != null || methodGenericInst != null)
|
||||
{
|
||||
//var typeSig = klassGenericInst != null ? new GenericInstSig(method.DeclaringType.ToTypeSig().ToClassOrValueTypeSig(), klassGenericInst) : method.DeclaringType?.ToTypeSig();
|
||||
//Debug.Log($"== walk generic method {typeSig}::{method.Name} {method.MethodSig}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log($"== walk not geneeric method:{method}");
|
||||
}
|
||||
var ctx = new GenericArgumentContext(klassGenericInst, methodGenericInst);
|
||||
|
||||
if (_methodEffectInsts.TryGetValue(method, out var effectInsts))
|
||||
|
||||
@@ -149,23 +149,16 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
for (uint rid = 1, n = ass.Metadata.TablesStream.TypeSpecTable.Rows; rid <= n; rid++)
|
||||
{
|
||||
var ts = ass.ResolveTypeSpec(rid);
|
||||
if (!ts.ContainsGenericParameter)
|
||||
var cs = GenericClass.ResolveClass(ts, null)?.ToGenericShare();
|
||||
if (cs != null)
|
||||
{
|
||||
var cs = GenericClass.ResolveClass(ts, null)?.ToGenericShare();
|
||||
if (cs != null)
|
||||
{
|
||||
TryAddAndWalkGenericType(cs);
|
||||
}
|
||||
TryAddAndWalkGenericType(cs);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint rid = 1, n = ass.Metadata.TablesStream.MethodSpecTable.Rows; rid <= n; rid++)
|
||||
{
|
||||
var ms = ass.ResolveMethodSpec(rid);
|
||||
if(ms.DeclaringType.ContainsGenericParameter || ms.GenericInstMethodSig.ContainsGenericParameter)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var gm = GenericMethod.ResolveMethod(ms, null)?.ToGenericShare();
|
||||
if (gm == null)
|
||||
{
|
||||
@@ -176,10 +169,6 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
_newMethods.Add(gm);
|
||||
}
|
||||
//if (gm.KlassInst != null)
|
||||
//{
|
||||
// TryAddAndWalkGenericType(new GenericClass(gm.Method.DeclaringType, gm.KlassInst));
|
||||
//}
|
||||
}
|
||||
}
|
||||
Debug.Log($"PostPrepare allMethods:{_notGenericMethods.Count} newMethods:{_newMethods.Count}");
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
private PlatformABI _platformABI;
|
||||
|
||||
private readonly IReadOnlyList<MethodDef> _notGenericMethods;
|
||||
private readonly List<MethodDef> _notGenericMethods;
|
||||
|
||||
private readonly IReadOnlyCollection<GenericMethod> _genericMethods;
|
||||
private readonly List<GenericMethod> _genericMethods;
|
||||
|
||||
private readonly HashSet<GenericMethod> _preservedMethods;
|
||||
|
||||
@@ -51,21 +51,22 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
private readonly HashSet<MethodDesc> _managed2nativeMethodSet = new HashSet<MethodDesc>();
|
||||
|
||||
private List<MethodDesc> _managed2nativeMethodList;
|
||||
|
||||
private readonly HashSet<MethodDesc> _native2managedMethodSet = new HashSet<MethodDesc>();
|
||||
|
||||
private List<MethodDesc> _native2managedMethodList;
|
||||
|
||||
private readonly HashSet<MethodDesc> _adjustThunkMethodSet = new HashSet<MethodDesc>();
|
||||
|
||||
private List<MethodDesc> _adjustThunkMethodList;
|
||||
|
||||
public Generator(Options options)
|
||||
{
|
||||
_platformABI = options.PlatformABI;
|
||||
_notGenericMethods = options.NotGenericMethods;
|
||||
_genericMethods = options.GenericMethods;
|
||||
|
||||
List<(MethodDef, string)> notGenericMethodInfo = options.NotGenericMethods.Select(m => (m, m.FullName)).ToList();
|
||||
notGenericMethodInfo.Sort((a, b) => string.Compare(a.Item2, b.Item2, StringComparison.Ordinal));
|
||||
_notGenericMethods = notGenericMethodInfo.Select(m => m.Item1).ToList();
|
||||
|
||||
List<(GenericMethod, string)> genericMethodInfo = options.GenericMethods.Select(m => (m, m.ToString())).ToList();
|
||||
genericMethodInfo.Sort((a, b) => string.CompareOrdinal(a.Item2, b.Item2));
|
||||
_genericMethods = genericMethodInfo.Select(m => m.Item1).ToList();
|
||||
|
||||
_preservedMethods = options.SpeicalPreserveMethods;
|
||||
_templateCode = options.TemplateCode;
|
||||
_outputFile = options.OutputFile;
|
||||
@@ -182,31 +183,6 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
ProcessMethod(method.Method, method.KlassInst, method.MethodInst);
|
||||
}
|
||||
|
||||
{
|
||||
var sortedMethods = new SortedDictionary<string, MethodDesc>();
|
||||
foreach (var method in _managed2nativeMethodSet)
|
||||
{
|
||||
sortedMethods.Add(method.CreateCallSigName(), method);
|
||||
}
|
||||
_managed2nativeMethodList = sortedMethods.Values.ToList();
|
||||
}
|
||||
{
|
||||
var sortedMethods = new SortedDictionary<string, MethodDesc>();
|
||||
foreach (var method in _native2managedMethodSet)
|
||||
{
|
||||
sortedMethods.Add(method.CreateCallSigName(), method);
|
||||
}
|
||||
_native2managedMethodList = sortedMethods.Values.ToList();
|
||||
}
|
||||
{
|
||||
var sortedMethods = new SortedDictionary<string, MethodDesc>();
|
||||
foreach (var method in _adjustThunkMethodSet)
|
||||
{
|
||||
sortedMethods.Add(method.CreateCallSigName(), method);
|
||||
}
|
||||
_adjustThunkMethodList = sortedMethods.Values.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
@@ -215,29 +191,38 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
List<string> lines = new List<string>(20_0000);
|
||||
|
||||
Debug.LogFormat("== managed2native:{0} native2managed:{1} adjustThunk:{2}",
|
||||
_managed2nativeMethodList.Count, _native2managedMethodList.Count, _adjustThunkMethodList.Count);
|
||||
List<MethodDesc> managed2NativeMethodList = _managed2nativeMethodSet.ToList();
|
||||
managed2NativeMethodList.Sort((a, b) => string.CompareOrdinal(a.Sig, b.Sig));
|
||||
|
||||
foreach(var method in _managed2nativeMethodList)
|
||||
List<MethodDesc> native2ManagedMethodList = _native2managedMethodSet.ToList();
|
||||
native2ManagedMethodList.Sort((a, b) => string.CompareOrdinal(a.Sig, b.Sig));
|
||||
|
||||
List<MethodDesc> adjustThunkMethodList = _adjustThunkMethodSet.ToList();
|
||||
adjustThunkMethodList.Sort((a, b) => string.CompareOrdinal(a.Sig, b.Sig));
|
||||
|
||||
Debug.LogFormat("== managed2native:{0} native2managed:{1} adjustThunk:{2}",
|
||||
managed2NativeMethodList.Count, native2ManagedMethodList.Count, adjustThunkMethodList.Count);
|
||||
|
||||
foreach(var method in managed2NativeMethodList)
|
||||
{
|
||||
_platformAdaptor.GenerateManaged2NativeMethod(method, lines);
|
||||
}
|
||||
|
||||
_platformAdaptor.GenerateManaged2NativeStub(_managed2nativeMethodList, lines);
|
||||
_platformAdaptor.GenerateManaged2NativeStub(managed2NativeMethodList, lines);
|
||||
|
||||
foreach (var method in _native2managedMethodList)
|
||||
foreach (var method in native2ManagedMethodList)
|
||||
{
|
||||
_platformAdaptor.GenerateNative2ManagedMethod(method, lines);
|
||||
}
|
||||
|
||||
_platformAdaptor.GenerateNative2ManagedStub(_native2managedMethodList, lines);
|
||||
_platformAdaptor.GenerateNative2ManagedStub(native2ManagedMethodList, lines);
|
||||
|
||||
foreach (var method in _adjustThunkMethodList)
|
||||
foreach (var method in adjustThunkMethodList)
|
||||
{
|
||||
_platformAdaptor.GenerateAdjustThunkMethod(method, lines);
|
||||
}
|
||||
|
||||
_platformAdaptor.GenerateAdjustThunkStub(_adjustThunkMethodList, lines);
|
||||
_platformAdaptor.GenerateAdjustThunkStub(adjustThunkMethodList, lines);
|
||||
|
||||
frr.Replace("CODE", string.Join("\n", lines));
|
||||
|
||||
|
||||
@@ -19,12 +19,10 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
public override void GenerateManaged2NativeMethod(MethodDesc method, List<string> lines)
|
||||
{
|
||||
int totalQuadWordNum = method.ParamInfos.Count + method.ReturnInfo.GetParamSlotNum(this.PlatformABI);
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => p.Managed2NativeParamValue(this.PlatformABI)).Concat(new string[] { "method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
|
||||
{{
|
||||
typedef {method.ReturnInfo.Type.GetTypeName()} (*NativeMethod)({paramListStr});
|
||||
@@ -39,7 +37,6 @@ static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => p.Native2ManagedParamValue(this.PlatformABI)))} }};
|
||||
@@ -57,7 +54,6 @@ static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_AdjustorThunk_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => (p.Index == 0 ? $"(uint64_t)(*(uint8_t**)&__arg{p.Index} + sizeof(Il2CppObject))" : p.Native2ManagedParamValue(this.PlatformABI))))} }};
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => p.Managed2NativeParamValue(this.PlatformABI)).Concat(new string[] { "method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
|
||||
{{
|
||||
typedef {method.ReturnInfo.Type.GetTypeName()} (*NativeMethod)({paramListStr});
|
||||
@@ -34,7 +33,6 @@ static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => p.Native2ManagedParamValue(this.PlatformABI)))} }};
|
||||
@@ -51,7 +49,6 @@ static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_AdjustorThunk_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => (p.Index == 0 ? $"(uint64_t)(*(uint8_t**)&__arg{p.Index} + sizeof(Il2CppObject))" : p.Native2ManagedParamValue(this.PlatformABI))))} }};
|
||||
|
||||
@@ -17,14 +17,11 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
public override void GenerateManaged2NativeMethod(MethodDesc method, List<string> lines)
|
||||
{
|
||||
int totalQuadWordNum = method.ParamInfos.Count + method.ReturnInfo.GetParamSlotNum(this.PlatformABI);
|
||||
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
string paramTypeListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()}").Concat(new string[] { "const MethodInfo*" })); ;
|
||||
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => p.Managed2NativeParamValue(this.PlatformABI)).Concat(new string[] { "method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
|
||||
{{
|
||||
typedef {method.ReturnInfo.Type.GetTypeName()} (*NativeMethod)({paramListStr});
|
||||
@@ -37,7 +34,6 @@ static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_
|
||||
int totalQuadWordNum = method.ParamInfos.Count + method.ReturnInfo.GetParamSlotNum(this.PlatformABI);
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => p.Native2ManagedParamValue(this.PlatformABI)))} }};
|
||||
@@ -53,7 +49,6 @@ static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}
|
||||
int totalQuadWordNum = method.ParamInfos.Count + method.ReturnInfo.GetParamSlotNum(this.PlatformABI);
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_AdjustorThunk_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => (p.Index == 0 ? $"(uint64_t)(*(uint8_t**)&__arg{p.Index} + sizeof(Il2CppObject))" : p.Native2ManagedParamValue(this.PlatformABI))))} }};
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => p.Managed2NativeParamValue(this.PlatformABI)).Concat(new string[] { "method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
|
||||
{{
|
||||
typedef {method.ReturnInfo.Type.GetTypeName()} (*NativeMethod)({paramListStr});
|
||||
@@ -35,7 +34,6 @@ static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => p.Native2ManagedParamValue(this.PlatformABI)))} }};
|
||||
@@ -52,7 +50,6 @@ static {method.ReturnInfo.Type.GetTypeName()} __N2M_{method.CreateCallSigName()}
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
|
||||
lines.Add($@"
|
||||
// {method.MethodDef}
|
||||
static {method.ReturnInfo.Type.GetTypeName()} __N2M_AdjustorThunk_{method.CreateCallSigName()}({paramListStr})
|
||||
{{
|
||||
StackObject args[{Math.Max(totalQuadWordNum, 1)}] = {{{string.Join(", ", method.ParamInfos.Select(p => (p.Index == 0 ? $"(uint64_t)(*(uint8_t**)&__arg{p.Index} + sizeof(Il2CppObject))" : p.Native2ManagedParamValue(this.PlatformABI))))} }};
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
arm.Count += preserveCount;
|
||||
}
|
||||
var methods = methodsBySig.Values.ToList();
|
||||
methods.Sort((a, b) => a.Method.Sig.CompareTo(b.Method.Sig));
|
||||
methods.Sort((a, b) => String.CompareOrdinal(a.Method.Sig, b.Method.Sig));
|
||||
return methods;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ namespace HybridCLR.Editor
|
||||
public string[] patchAOTAssemblies;
|
||||
|
||||
[Header("生成的link.xml路径")]
|
||||
public string outputLinkFile = "HybridCLRData/Generated/link.xml";
|
||||
public string outputLinkFile = "HybridCLRGenerate/link.xml";
|
||||
|
||||
[Header("自动扫描生成的AOTGenericReferences.cs路径")]
|
||||
public string outputAOTGenericReferenceFile = "HybridCLRData/Generated/AOTGenericReferences.cs";
|
||||
public string outputAOTGenericReferenceFile = "HybridCLRGenerate/AOTGenericReferences.cs";
|
||||
|
||||
[Header("AOT泛型实例化搜索迭代次数")]
|
||||
public int maxGenericReferenceIteration = 10;
|
||||
|
||||
@@ -1,11 +1,97 @@
|
||||
# hybridclr_unity
|
||||
|
||||
|
||||
- [README 中文](./README_zh.md)
|
||||
- [README English](./README.md)
|
||||
|
||||
# HybridCLR
|
||||
|
||||
Unity Package for HybridCLR
|
||||
|
||||
## 改动日志
|
||||
[](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE)
|
||||
|
||||
- v2.3.0 支持从本地目录直接复制hybridclr源码。轻微修复2019版本某些情况下路径过长导致安装失败的问题。
|
||||
- v2.2.0 支持2020.3.47及2021.3.23
|
||||
- v2.0.5 Installer使用tag而不是commit id,安装时不必拉取整个branch,大幅缩短安装时间
|
||||

|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
HybridCLR is the excellent work of **Code Philosophy** company. We hope to profoundly change the entire industry through our ingenuity and help game teams make better games.
|
||||
|
||||
HybridCLR is a **almost perfect** full-platform native c# hot update solution for Unity with complete features, zero cost, high performance, and low memory.
|
||||
|
||||
HybridCLR expands the ability of il2cpp, making it change from pure [AOT](https://en.wikipedia.org/wiki/Ahead-of-time_compilation) runtime to 'AOT+Interpreter' hybrid runtime, and then natively supports dynamic loading of assembly , so that the games packaged based on il2cpp backend can be executed not only on the Android platform, but also on IOS, Consoles and other platforms that limit JIT efficiently in **AOT+interpreter** hybrid mode, completely supporting hot updates from the bottom layer.
|
||||
|
||||
HybridCLR not only supports the traditional fully interpreted execution mode, but also pioneered [Differential Hybrid Execution](https://hybridclr.doc.code-philosophy.com/en/docs/business/ultimate/differentialhybridexecution) technique. That is, you can add, delete, or modify the AOT dll at will, and intelligently make the changed or newly added classes and functions run in interpreter mode, but the unchanged classes and functions run in AOT mode, so that the running performance of the hot-updated game logic basically reaches the original AOT level.
|
||||
|
||||
Welcome to embrace modern native C# hot update technology! ! !
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Official Documentation](https://hybridclr.doc.code-philosophy.com/en/docs/intro)
|
||||
- [Quickstart](https://hybridclr.doc.code-philosophy.com/en/docs/beginner/quickstart)
|
||||
- [Release Log](./RELEASELOG.md)
|
||||
|
||||
## Features
|
||||
|
||||
- Features complete. A nearly complete implementation of the [ECMA-335 specification](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/), with only a very small number of [unsupported features](https://hybridclr.doc.code-philosophy.com/en/docs/basic/notsupportedfeatures).
|
||||
- Zero learning and use costs. HybridCLR enhances the pure AOT runtime into a complete runtime, making hot update code work seamlessly with AOT code. The script class and the AOT class are in the same runtime, and you can freely write codes such as inheritance, reflection, and multi-threading (volatile, ThreadStatic, Task, async). No need to write any special code, no code generation, almost unlimited.
|
||||
- Efficient execution. Implemented an extremely efficient register interpreter, all indicators are significantly better than other hot update schemes. [Performance Test Report](https://hybridclr.doc.code-philosophy.com/en/docs/basic/performance)
|
||||
- Memory efficient. The classes defined in the hot update script occupy the same memory space as ordinary c# classes, which is far superior to other hot update solutions. [Memory and GC](https://hybridclr.doc.code-philosophy.com/en/docs/basic/memory)
|
||||
- Due to the perfect support for generics, libraries that are not compatible with il2cpp due to AOT generics issues can now run perfectly under il2cpp
|
||||
- Support some features not supported by il2cpp, such as __makeref, __reftype, __refvalue directives
|
||||
- [Differential Hybrid Execution](https://hybridclr.doc.code-philosophy.com/en/docs/business/ultimate/differentialhybridexecution)
|
||||
|
||||
## working principle
|
||||
|
||||
HybridCLR is inspired by mono's [mixed mode execution](https://www.mono-project.com/news/2017/11/13/mono-interpreter/) technology, and provides additional AOT runtimes such as unity's il2cpp The interpreter module is provided to transform them from pure AOT runtime to "AOT + Interpreter" hybrid operation mode.
|
||||
|
||||

|
||||
|
||||
More specifically, HybridCLR does the following:
|
||||
|
||||
- Implemented an efficient metadata (dll) parsing library
|
||||
- Modified the metadata management module to realize the dynamic registration of metadata
|
||||
- Implemented a compiler from IL instruction set to custom register instruction set
|
||||
- Implemented an efficient register interpreter
|
||||
- Provide a large number of instinct functions to improve the performance of the interpreter
|
||||
|
||||
## The difference from other popular c# hot update schemes
|
||||
|
||||
HybridCLR is a native c# hot update solution. In layman's terms, il2cpp is equivalent to the aot module of mono, and HybridCLR is equivalent to the interpreter module of mono, and the combination of the two becomes a complete mono. HybridCLR makes il2cpp a full-featured runtime, natively (that is, through System.Reflection.Assembly.Load) supports dynamic loading of dlls, thereby supporting hot updates of the ios platform.
|
||||
|
||||
Just because HybridCLR is implemented at the native runtime level, the types of the hot update part and the AOT part of the main project are completely equivalent and seamlessly unified. You can call, inherit, reflect, and multi-thread at will, without generating code or writing adapters.
|
||||
|
||||
Other hot update solutions are independent vm, and the relationship with il2cpp is essentially equivalent to the relationship of embedding lua in mono. Therefore, the type system is not uniform. In order to allow the hot update type to inherit some AOT types, an adapter needs to be written, and the type in the interpreter cannot be recognized by the type system of the main project. Incomplete features, troublesome development, and low operating efficiency.
|
||||
|
||||
## Compatibility
|
||||
|
||||
- Support 2019.4.x, 2020.3.x, 2021.3.x, 2022.3.x, 2023.2.x series LTS versions
|
||||
- Supports all platforms supported by il2cpp. At present, it has fully supported PC (Win32 and Win64), macOS (x86, x64, Arm64), Android (armv7, armv8), iOS (64bit), WebGL, **WeChat applet platform**, and the remaining platforms are yet to be tested.
|
||||
- Tested a large number of common game libraries, and did not find a library that is natively compatible with il2cpp but incompatible after using HybridCLR. As long as the library can work under the il2cpp backend, it can work normally under HybridCLR. Even those libraries that are incompatible with il2cpp due to AOT issues can now run normally because of HybridCLR's ability to expand il2cpp.
|
||||
|
||||
## Stability Status
|
||||
|
||||
At present, **extremely stable** official versions 1.x, 2.x, and 3.x have been released, which are sufficient to meet the stability requirements of large and medium-sized commercial projects. Since the first game was launched on June 7, 2022, only one small bug occurred in the online project, and it was quickly fixed within a few hours.
|
||||
|
||||
At present, at least thousands of commercial game projects have completed access, and hundreds of them have been launched on both ends. The online projects include games such as MMORPG, heavy card, and heavy tower defense.
|
||||
|
||||
Most leading companies such as Tencent, NetEase, Baidu, funplus, Perfect, Stacked Paper, and Byte have already connected to multiple projects and will soon (or already) go online.
|
||||
|
||||
## Support and Contact
|
||||
|
||||
- Official 1 group: 651188171 (full)
|
||||
- Novice group 1: 428404198 (full)
|
||||
- Novice group 2: **680274677 (recommended)**
|
||||
- QQ reward mutual aid group: 762953653. Offer a reward for asking questions and solving problems quickly.
|
||||
- discord channel [https://discord.gg/BATfNfJnm2](https://discord.gg/BATfNfJnm2)
|
||||
- Business cooperation email: business@code-philosophy.com
|
||||
- [Commercial support](https://hybridclr.doc.code-philosophy.com/en/docs/business/intro)
|
||||
|
||||
## About the author
|
||||
|
||||
**walon** : Founder of **Code Philosophy (code philosophy)**
|
||||
|
||||
Graduated from the Department of Physics of Tsinghua University, won the CMO gold medal in 2006, a member of the National Mathematical Olympiad Training Team, and was recommended to Tsinghua University for basic courses. Focus on game technology, good at developing architecture and basic technical facilities.
|
||||
|
||||
## license
|
||||
|
||||
HybridCLR is licensed under the [MIT](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE) license
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
- [README 中文](./README_zh.md)
|
||||
- [README English](./README.md)
|
||||
|
||||
# HybridCLR
|
||||
|
||||
[](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE)
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
HybridCLR是 **Code Philosophy(代码哲学)** 公司的代表作品,我们希望通过我们的聪明才智深刻地改变整个行业,帮助游戏团队制作出更优秀的游戏。
|
||||
|
||||
HybridCLR是一个**特性完整、零成本、高性能、低内存**的**近乎完美**的Unity全平台原生c#热更方案。
|
||||
|
||||
HybridCLR扩充了il2cpp的代码,使它由纯[AOT](https://en.wikipedia.org/wiki/Ahead-of-time_compilation) runtime变成‘AOT+Interpreter’ 混合runtime,进而原生支持动态加载assembly,使得基于il2cpp backend打包的游戏不仅能在Android平台,也能在IOS、Consoles等限制了JIT的平台上高效地以**AOT+interpreter**混合模式执行,从底层彻底支持了热更新。
|
||||
|
||||
HybridCLR不仅支持传统的全解释执行模式,还开创性地实现了 [Differential Hybrid Execution(差分混合执行技)](https://hybridclr.doc.code-philosophy.com/docs/business/ultimate/differentialhybridexecution) 差分混合执行技术。即可以对AOT dll任意增删改,会智能地让变化或者新增的类和函数以interpreter模式运行,但未改动的类和函数以AOT方式运行,让热更新的游戏逻辑的运行性能基本达到原生AOT的水平。
|
||||
|
||||
欢迎拥抱现代原生C#热更新技术 !!!
|
||||
|
||||
## 文档
|
||||
|
||||
- [官方文档](https://hybridclr.doc.code-philosophy.com/docs/intro)
|
||||
- [快速上手](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)
|
||||
- [发布日志](./RELEASELOG.md)
|
||||
|
||||
## 特性
|
||||
|
||||
- 特性完整。 近乎完整实现了[ECMA-335规范](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/),只有极少量的[不支持的特性](https://hybridclr.doc.code-philosophy.com/docs/basic/notsupportedfeatures)。
|
||||
- 零学习和使用成本。 HybridCLR将纯AOT runtime增强为完整的runtime,使得热更新代码与AOT代码无缝工作。脚本类与AOT类在同一个运行时内,可以随意写继承、反射、多线程(volatile、ThreadStatic、Task、async)之类的代码。不需要额外写任何特殊代码、没有代码生成,几乎没有限制。
|
||||
- 执行高效。实现了一个极其高效的寄存器解释器,所有指标都大幅优于其他热更新方案。[性能测试报告](https://hybridclr.doc.code-philosophy.com/docs/basic/performance)
|
||||
- 内存高效。 热更新脚本中定义的类跟普通c#类占用一样的内存空间,远优于其他热更新方案。[内存与GC](https://hybridclr.doc.code-philosophy.com/docs/basic/memory)
|
||||
- 由于对泛型的完美支持,使得因为AOT泛型问题跟il2cpp不兼容的库现在能够完美地在il2cpp下运行
|
||||
- 支持一些il2cpp不支持的特性,如__makeref、 __reftype、__refvalue指令
|
||||
- [Differential Hybrid Execution(差分混合执行技)](https://hybridclr.doc.code-philosophy.com/docs/business/ultimate/differentialhybridexecution)
|
||||
|
||||
## 工作原理
|
||||
|
||||
HybridCLR从mono的 [mixed mode execution](https://www.mono-project.com/news/2017/11/13/mono-interpreter/) 技术中得到启发,为unity的il2cpp之类的AOT runtime额外提供了interpreter模块,将它们由纯AOT运行时改造为"AOT + Interpreter"混合运行方式。
|
||||
|
||||

|
||||
|
||||
更具体地说,HybridCLR做了以下几点工作:
|
||||
|
||||
- 实现了一个高效的元数据(dll)解析库
|
||||
- 改造了元数据管理模块,实现了元数据的动态注册
|
||||
- 实现了一个IL指令集到自定义的寄存器指令集的compiler
|
||||
- 实现了一个高效的寄存器解释器
|
||||
- 额外提供大量的instinct函数,提升解释器性能
|
||||
|
||||
## 与其他流行的c#热更新方案的区别
|
||||
|
||||
HybridCLR是原生的c#热更新方案。通俗地说,il2cpp相当于mono的aot模块,HybridCLR相当于mono的interpreter模块,两者合一成为完整mono。HybridCLR使得il2cpp变成一个全功能的runtime,原生(即通过System.Reflection.Assembly.Load)支持动态加载dll,从而支持ios平台的热更新。
|
||||
|
||||
正因为HybridCLR是原生runtime级别实现,热更新部分的类型与主工程AOT部分类型是完全等价并且无缝统一的。可以随意调用、继承、反射、多线程,不需要生成代码或者写适配器。
|
||||
|
||||
其他热更新方案则是独立vm,与il2cpp的关系本质上相当于mono中嵌入lua的关系。因此类型系统不统一,为了让热更新类型能够继承AOT部分类型,需要写适配器,并且解释器中的类型不能为主工程的类型系统所识别。特性不完整、开发麻烦、运行效率低下。
|
||||
|
||||
## 兼容性
|
||||
|
||||
- 支持2019.4.x、2020.3.x、2021.3.x、2022.3.x、2022.2.x 系列LTS版本
|
||||
- 支持所有il2cpp支持的平台。目前已完善支持 PC(Win32和Win64)、macOS(x86、x64、Arm64)、Android(armv7、armv8)、iOS(64bit)、WebGL、**微信小程序平台**,剩余平台有待测试。
|
||||
- 测试过大量游戏常见库,未发现跟il2cpp原生兼容但使用HybridCLR后不兼容性的库。只要能在il2cpp backend下工作的库都可以在HybridCLR下正常工作。甚至那些与il2cpp因为AOT问题不兼容的库,现在因为HybridCLR对il2cpp的能力扩充,反而可以正常运行了。
|
||||
|
||||
## 稳定性状况
|
||||
|
||||
当前已经发布了**极其稳定**的1.x、2.x、3.x正式版本,足以满足大中型商业项目的稳定性要求。自2022.6.7上线第一个游戏起,线上项目中只发生过一起小bug,并且迅速地在几个小时内被修复。
|
||||
|
||||
目前至少有上千个商业游戏项目完成接入,其中有几百款已经双端上线,上线的项目中包括MMORPG、重度卡牌、重度塔防之类的游戏。
|
||||
|
||||
大多数头部公司如腾讯、网易、百度、funplus、完美、叠纸、字节都已经接入多个项目并且很快要(或者已经)上线。
|
||||
|
||||
## 支持与联系
|
||||
|
||||
- 官方1群:651188171(满)
|
||||
- 新手1群:428404198(满)
|
||||
- 新手2群:**680274677(推荐)**
|
||||
- QQ悬赏互助群:762953653。悬赏提问,快速解决问题。
|
||||
- discord频道 https://discord.gg/BATfNfJnm2
|
||||
- 商业合作邮箱: business@code-philosophy.com
|
||||
- [商业化支持](https://hybridclr.doc.code-philosophy.com/docs/business/intro)
|
||||
|
||||
## 关于作者
|
||||
|
||||
**walon** :**Code Philosophy(代码哲学)** 创始人
|
||||
|
||||
毕业于清华大学物理系,2006年CMO金牌,奥数国家集训队成员,保送清华基科班。专注于游戏技术,擅长开发架构和基础技术设施。
|
||||
|
||||
## license
|
||||
|
||||
HybridCLR is licensed under the [MIT](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE) license
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52688f4469ff9454e8c3d8aaf045d9f4
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+132
-45
@@ -1,120 +1,207 @@
|
||||
# 发布日志
|
||||
|
||||
## 3.4.2
|
||||
|
||||
发布日期 2023.08.14。
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复RawImage::LoadTables读取_4byteGUIDIndex的bug
|
||||
- [version] 支持2022.3.7版本
|
||||
- [version] 支持2021.3.29版本
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复计算AOTGenericReference未考虑到泛型调用泛型的情况,导致少计算了泛型及补充元数据
|
||||
|
||||
## 3.4.1
|
||||
|
||||
发布日期 2023.07.31。
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复 InitializeRuntimeMetadata的内存可见性问题
|
||||
- [fix] 修复CustomAttribute未正确处理父类NamedArg导致崩溃的bug
|
||||
- [opt] 优化Transfrom Instinct指令的代码,从HashMap中快速查找而不是挨个匹配
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复FilterHotFixAssemblies只对比程序集名尾部,导致有AOT的尾部与某个热更新程序集匹配时意外被过滤的bug
|
||||
- [change] 检查Settings中热更新程序集列表配置中程序集名不能为空
|
||||
|
||||
## 3.4.0
|
||||
|
||||
发布日期 2023.07.17。
|
||||
|
||||
### Runtime
|
||||
|
||||
- [version] 支持2021.3.28和2022.3.4版本
|
||||
- [opt] 删除MachineState::InitEvalStack分配_StackBase后不必要的memset
|
||||
- [fix] 修复Exception机制的bug
|
||||
- [fix] 修复CustomAttribute不支持Type[]类型参数的bug
|
||||
- [fix] 修复不支持new string(xxx)用法的问题
|
||||
- [refactor] 重构VTableSetup实现
|
||||
- [fix] 修复未计算子interface中显式实现父interface的函数的bug
|
||||
- [opt] Lazy初始化CustomAttributeData,而不是加载时全部初始化,明显减少Assembly.Load时间
|
||||
- [fix] 修复2022 当new byte\[]{a,b,c...}方式初始化较长的byte[]数据时,返回错误数据的bug
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复计算桥接函数未考虑到泛型类的成员函数中可能包含的Native2Managed调用
|
||||
- [change] link.xml及AOTGenericReferences.cs默认输出路径改为HybridCLRGenerate,避免与顶层HybridCLRData混淆
|
||||
- [fix] 修复Win下生成的Lump文件中include路径以\为目录分隔符导致同步到Mac后找不到路径的bug
|
||||
- [refactor] 重构Installer
|
||||
|
||||
|
||||
## 3.3.0
|
||||
|
||||
发布日期 2023.07.03。
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复localloc分配的内存未释放的bug
|
||||
- [change] MachineState改用RegisterRoot的方式注册执行栈,避免GC时扫描整个堆栈
|
||||
- [opt] 优化Managed2NativeCallByReflectionInvoke性能,提前计算好传参方式
|
||||
- [refactor] 重构ConvertInvokeArgs
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复2020-2021编译libil2cpp.a未包含brotli相关代码文件导致出现编译错误的bug
|
||||
- [fix] 修复从导出xcode项目包含绝对路径导致传送到其他机器上编译时找不到路径的bug
|
||||
- [fix] 解决Generate LinkXml、 MethodBridge、AOTGenericReference、ReversePInvokeWrap 生成不稳定的问题
|
||||
- [fix] 修复使用不兼容版本打开Installer时出现异常的bug
|
||||
- [change] 禁用hybridclr后打包ios时不再修改导出的xcode工程
|
||||
|
||||
## 3.2.1
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复il2cpp TypeNameParser未将类型名中转义字符'\'去掉,导致找不到嵌套子类型的bug
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] Installer界面新增显示package版本
|
||||
- [new] CompileDll新增MacOS、Linux、WebGL目标
|
||||
- [fix] 修复il2cpp TypeNameParser未将类型名中转义字符'\'去掉,导致找不到嵌套子类型的bug
|
||||
- [fix] 修复完全泛型共享生成的代码与2021.3.x中低版本代码不兼容,有编译错误的bug
|
||||
- [fix] 修复重构文档站后的帮助文档的链接错误
|
||||
- [change] 为Anaylizer加上using 限定,解决某些情况下与项目的类型同名而产生编译冲突的问题
|
||||
|
||||
## 3.2.0
|
||||
|
||||
- [new] 支持直接从源码打包iOS,不再需要单独编译libil2cpp.a
|
||||
- [opt] 优化版本不兼容时错误提示,不再抛出异常,而是显示"与当前版本不兼容"
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复未在PlaceHolder中的Assembly加载时,如果由于不在Assembly列表,也没有任何解释器栈,导致Class::resolve_parse_info_internal查找不到类型的bug
|
||||
- [fix] 修复读取CustomAttribute System.Type类型数据崩溃的bug
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] 支持直接从源码打包iOS,不再需要单独编译libil2cpp.a
|
||||
- [opt] 优化版本不兼容时错误提示,不再抛出异常,而是显示"与当前版本不兼容"
|
||||
|
||||
|
||||
## 3.1.1
|
||||
|
||||
- [fix] 修复 Win32、Android32、WebGL平台的编译错误
|
||||
- [fix] 修复计算桥接函数时未考虑到补充元数据泛型实例化会导致访问到一些非公开的函数的情况,导致少生成一些必要的桥接函数
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复2021及更高版本,InterpreterModule::Managed2NativeCallByReflectionInvoke调用值类型成员函数时,对this指针多余this=this-1操作。
|
||||
- [fix] 修复解析CustomAttribute中Enum[]类型字段的bug
|
||||
- [fix] 修复2021及更高版本反射调用值类型 close Delegate的Invoke函数时未修复target指针的bug
|
||||
- [opt] 生成AOTGenericReferences时,补充元数据assembly列表由注释改成List<string>列表,方便在代码中直接使用。
|
||||
- [new] 新增对增量式GC宏的检查,避免build.gradle中意外开启增量式GC引发的极其隐蔽的问题
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复 Win32、Android32、WebGL平台的编译错误
|
||||
- [fix] 修复计算桥接函数时未考虑到补充元数据泛型实例化会导致访问到一些非公开的函数的情况,导致少生成一些必要的桥接函数
|
||||
- [opt] 生成AOTGenericReferences时,补充元数据assembly列表由注释改成List<string>列表,方便在代码中直接使用。
|
||||
- [change] CheckSettings中不再自动设置Api Compatible Level
|
||||
|
||||
## 3.1.0
|
||||
|
||||
### 改动
|
||||
### Runtime
|
||||
|
||||
- 还原对Unity 2020.3.x支持
|
||||
- [rollback] 还原对Unity 2020.3.x支持
|
||||
- [fix] 修复 WebGL平台ABI的bug
|
||||
|
||||
### 修复
|
||||
### Editor
|
||||
|
||||
- 修复 WebGL平台ABI的bug
|
||||
- [rollback] 还原对Unity 2020.3.x支持
|
||||
|
||||
## 3.0.3
|
||||
|
||||
### 修复
|
||||
### Runtime
|
||||
|
||||
- 修复Enum::GetValues返回值不正确的bug
|
||||
- [fix] 修复Enum::GetValues返回值不正确的bug
|
||||
|
||||
## 3.0.2
|
||||
|
||||
### 改动
|
||||
### Runtime
|
||||
|
||||
- 移除 `HybridCLR/CreateAOTDllSnapshot`菜单
|
||||
- [fix] 修复Memory Profiler中创建内存快照时崩溃的bug
|
||||
|
||||
### 修复
|
||||
### Editor
|
||||
|
||||
- [remove] 移除 `HybridCLR/CreateAOTDllSnapshot`菜单
|
||||
|
||||
- 修复Memory Profiler中创建内存快照时崩溃的bug
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### 改动
|
||||
### Runtime
|
||||
|
||||
- 支持2022.3.0
|
||||
- [new] 支持2022.3.0
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### 修复
|
||||
### Runtime
|
||||
|
||||
- 修复不支持访问CustomData字段及值的bug
|
||||
- [fix] 修复不支持访问CustomData字段及值的bug
|
||||
- [remove] 移除对2019及2020版本支持
|
||||
|
||||
### 改动
|
||||
### Editor
|
||||
|
||||
- 包名更改为com.code-philosophy.hybridclr
|
||||
- 移除对2019及2020版本支持
|
||||
- 移除UnityFS插件
|
||||
- 移除Zip插件
|
||||
- HybridCLR菜单位置调整
|
||||
|
||||
## 2.4.2
|
||||
|
||||
### 改动
|
||||
### Runtime
|
||||
|
||||
- 支持 2020.3.48,最后一个2020LTS版本
|
||||
- 支持 2021.3.25
|
||||
- hybridclr 升级到 v2.3.1
|
||||
- il2cpp_plus 升级到 v2020-2.2.1 、v2021-2.2.1
|
||||
- [version] 支持 2020.3.48,最后一个2020LTS版本
|
||||
- [version] 支持 2021.3.25
|
||||
|
||||
## 2.4.1
|
||||
|
||||
### 修复
|
||||
### Runtime
|
||||
|
||||
- 修复遗漏 RELEASELOG.md.meta 文件的问题
|
||||
### Editor
|
||||
|
||||
- [fix] 修复遗漏 RELEASELOG.md.meta 文件的问题
|
||||
|
||||
## 2.4.0
|
||||
|
||||
### 改动
|
||||
### Runtime
|
||||
|
||||
- CheckSettings中检查ScriptingBackend及ApiCompatibleLevel,切换为正确的值
|
||||
- hybridclr 升级到v2.3.0版本
|
||||
- il2cpp_plus 升级到v2019-2.2.0、v2020-2.2.0、v2021-2.2.0版本
|
||||
### Editor
|
||||
|
||||
### 修复
|
||||
|
||||
- 新增 MsvcStdextWorkaround.cs 解决2020 vs下stdext编译错误的问题
|
||||
- 修复当struct只包含一个float或double字段时,在arm64上计算桥接函数签名错误的bug
|
||||
- [new] CheckSettings中检查ScriptingBackend及ApiCompatibleLevel,切换为正确的值
|
||||
- [new] 新增 MsvcStdextWorkaround.cs 解决2020 vs下stdext编译错误的问题
|
||||
- [fix] 修复当struct只包含一个float或double字段时,在arm64上计算桥接函数签名错误的bug
|
||||
|
||||
## 2.3.1
|
||||
|
||||
### 修复
|
||||
- 修复本地复制libil2cpp却仍然从仓库下载安装的bug
|
||||
### Runtime
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复本地复制libil2cpp却仍然从仓库下载安装的bug
|
||||
|
||||
## 2.3.0
|
||||
|
||||
### 改动
|
||||
### Runtime
|
||||
|
||||
- Installer支持从本地目录复制改造后的libil2cpp
|
||||
### Editor
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复2019版本MonoBleedingEdge的子目录中包含了过长路径的文件导致Installer复制文件出错的问题
|
||||
- [new] Installer支持从本地目录复制改造后的libil2cpp
|
||||
- [fix] 修复2019版本MonoBleedingEdge的子目录中包含了过长路径的文件导致Installer复制文件出错的问题
|
||||
|
||||
|
||||
|
||||
+37
-3
@@ -42,36 +42,70 @@ namespace HybridCLR
|
||||
/// <param name="dllBytes"></param>
|
||||
/// <param name="dllSize"></param>
|
||||
/// <returns></returns>
|
||||
#if UNITY_EDITOR
|
||||
public static unsafe int LoadMetadataForAOTAssembly(byte* dllBytes, int dllSize, int mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_LoadMetadataForAOTAssembly")]
|
||||
public static extern unsafe int LoadMetadataForAOTAssembly(byte* dllBytes, int dllSize, int mode);
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
#if UNITY_EDITOR
|
||||
public static int GetInterpreterThreadObjectStackSize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_GetInterpreterThreadObjectStackSize")]
|
||||
public static extern int GetInterpreterThreadObjectStackSize();
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 设置解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
#if UNITY_EDITOR
|
||||
public static void SetInterpreterThreadObjectStackSize(int size)
|
||||
{
|
||||
|
||||
}
|
||||
#else
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_SetInterpreterThreadObjectStackSize")]
|
||||
public static extern void SetInterpreterThreadObjectStackSize(int size);
|
||||
|
||||
#endif
|
||||
/// <summary>
|
||||
/// 获取解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
#if UNITY_EDITOR
|
||||
public static int GetInterpreterThreadFrameStackSize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_GetInterpreterThreadFrameStackSize")]
|
||||
public static extern int GetInterpreterThreadFrameStackSize();
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 设置解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
#if UNITY_EDITOR
|
||||
public static void SetInterpreterThreadFrameStackSize(int size)
|
||||
{
|
||||
|
||||
}
|
||||
#else
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_SetInterpreterThreadFrameStackSize")]
|
||||
public static extern void SetInterpreterThreadFrameStackSize(int size);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.code-philosophy.hybridclr",
|
||||
"version": "3.2.1",
|
||||
"version": "3.4.2",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "HybridCLR is a fully featured, zero-cost, high-performance, low-memory solution for Unity's all-platform native c# hotupdate.",
|
||||
"category": "Runtime",
|
||||
|
||||
Reference in New Issue
Block a user