mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-20 07:22:39 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2020-3.2.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2021",
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2021-3.1.0"}
|
||||
"hybridclr" : { "branch":"v3.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2021-3.2.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022",
|
||||
"hybridclr" : { "branch":"v3.1.2"},
|
||||
"il2cpp_plus": { "branch":"v2022-3.1.0"}
|
||||
"hybridclr" : { "branch":"v3.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-3.2.0"}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,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 +53,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 +61,11 @@ namespace HybridCLR.Editor
|
||||
ModifyPBXProject(pathToBuiltProject, pbxprojFile, lumpFiles, extraSources, cflags);
|
||||
}
|
||||
|
||||
private static string GetRelativePathFromProj(string path)
|
||||
{
|
||||
return path.Substring(path.IndexOf("Libraries"));
|
||||
}
|
||||
|
||||
private static void ModifyPBXProject(string pathToBuiltProject, string pbxprojFile, List<LumpFile> lumpFiles, List<string> extraFiles, List<string> cflags)
|
||||
{
|
||||
var proj = new PBXProject();
|
||||
@@ -80,14 +84,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 +107,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 +188,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 +232,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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -122,13 +122,14 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
switch(majorVersion)
|
||||
{
|
||||
case 2020: return $"2020.3.{min2020_3_CompatibleMinorVersion}";
|
||||
case 2021: return $"2021.3.{min2021_3_CompatibleMinorVersion}";
|
||||
case 2022: return $"2022.3.{min2022_3_CompatibleMinorVersion}";
|
||||
default: throw new Exception($"not support version:{majorVersion}");
|
||||
default: return $"2020.3.{min2020_3_CompatibleMinorVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsComaptibleVersion()
|
||||
public bool IsCompatibleVersion()
|
||||
{
|
||||
UnityVersion version = _curVersion;
|
||||
if (version == null)
|
||||
@@ -157,9 +158,9 @@ namespace HybridCLR.Editor.Installer
|
||||
}
|
||||
}
|
||||
|
||||
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,7 +223,7 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
private void RunInitLocalIl2CppData(string editorIl2cppPath, string libil2cppWithHybridclrSourceDir, UnityVersion version)
|
||||
{
|
||||
if (!IsComaptibleVersion())
|
||||
if (!IsCompatibleVersion())
|
||||
{
|
||||
Debug.LogError($"il2cpp 版本不兼容,最小版本为 {GetCurrentUnityVersionMinCompatibleVersionStr()}");
|
||||
return;
|
||||
|
||||
@@ -47,20 +47,20 @@ namespace HybridCLR.Editor.Installer
|
||||
|
||||
EditorGUILayout.LabelField($"{SettingsUtil.PackageName} 版本: v{_controller.PackageVersion}");
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"bybridclr 版本: {_controller.HybridclrLocalVersion}");
|
||||
EditorGUILayout.LabelField($"hybridclr 版本: {_controller.HybridclrLocalVersion}");
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}");
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
if (_controller.IsComaptibleVersion())
|
||||
if (_controller.IsCompatibleVersion())
|
||||
{
|
||||
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装");
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("与当前版本不兼容", MessageType.Error);
|
||||
EditorGUILayout.HelpBox($"与当前版本不兼容,最小兼容版本:{_controller.GetCurrentUnityVersionMinCompatibleVersionStr()}", MessageType.Error);
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,4 @@
|
||||
|
||||
Unity Package for HybridCLR
|
||||
|
||||
## 改动日志
|
||||
|
||||
- v2.3.0 支持从本地目录直接复制hybridclr源码。轻微修复2019版本某些情况下路径过长导致安装失败的问题。
|
||||
- v2.2.0 支持2020.3.47及2021.3.23
|
||||
- v2.0.5 Installer使用tag而不是commit id,安装时不必拉取整个branch,大幅缩短安装时间
|
||||
|
||||
|
||||
发布日志请看 [RELEASELOG](./RELEASELOG.md)。
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
# 发布日志
|
||||
|
||||
## 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
|
||||
|
||||
- [new] Installer界面新增显示package版本
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.code-philosophy.hybridclr",
|
||||
"version": "3.2.1",
|
||||
"version": "3.3.0",
|
||||
"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