mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-20 07:22:39 +08:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d0fef095b | |||
| 642d2cd644 | |||
| e54ce36b0e | |||
| ac8b649d50 | |||
| 9ca9cd5aa7 | |||
| 37dafd7b3c | |||
| f58d12c2cb | |||
| d5eaa350c5 | |||
| 1f0053a3c9 | |||
| 15dccc7427 | |||
| 7d287a2293 | |||
| f19ba3eb30 | |||
| 4e172129d8 | |||
| 2414e77fef | |||
| 77517a9814 | |||
| 162f21f6a5 | |||
| bd7c3293bc | |||
| e25be945c7 | |||
| 925921c27c | |||
| 64a6d26fa3 | |||
| c24617d864 | |||
| 59bc259cc8 | |||
| c413cd6143 | |||
| c614cdcf4e | |||
| 08f493ab3e | |||
| 3705ca6e1f | |||
| 34df279943 | |||
| b85ed1aa92 | |||
| faf4a328af | |||
| 53f4f33bf0 | |||
| 48c91f497b | |||
| 9afbe3bd84 | |||
| 2d5f71f6b7 | |||
| 5747458bf2 | |||
| 0b455eb882 | |||
| e086228d90 | |||
| 909e96ca7c | |||
| 75b24345f6 | |||
| 88e20505f8 | |||
| b4b486944c | |||
| 360ba38805 | |||
| e5a6952777 | |||
| 9330cf682c | |||
| 16a7d5d529 | |||
| 303c6c7b35 | |||
| e4cf9e9086 | |||
| b977a85b23 | |||
| 0fcb51a369 | |||
| d61511924d | |||
| aca7dd0a67 | |||
| fc685a99ca | |||
| d431aeb019 | |||
| 63d0aaa6e6 | |||
| d45974c6b4 | |||
| 3de931a3af | |||
| b96d6fc10d | |||
| ef1b78caae | |||
| 47622bf49c | |||
| 846d7103a3 | |||
| 170f13082e | |||
| 60016d7481 | |||
| 97dae7fed2 | |||
| f935127cd3 | |||
| ec5f2ef05e | |||
| 6d0ceaa4f5 | |||
| 95922aec1e | |||
| 3259c11828 | |||
| 74bab1d935 | |||
| fd81edb495 | |||
| 12bafb897f | |||
| a6befb1312 | |||
| a36e3fe72d | |||
| d9776d1793 | |||
| 2697eb5a90 | |||
| 4879bb7f44 | |||
| 24f85780a2 |
@@ -2,28 +2,38 @@
|
||||
"versions": [
|
||||
{
|
||||
"unity_version":"2019",
|
||||
"hybridclr" : { "branch":"v5.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2019-5.0.0"}
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2019-7.0.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2020",
|
||||
"hybridclr" : { "branch":"v5.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2020-5.1.0"}
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2020-7.0.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2021",
|
||||
"hybridclr" : { "branch":"v5.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2021-5.1.0"}
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2021-7.0.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022",
|
||||
"hybridclr" : { "branch":"v5.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-5.2.0"}
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-7.2.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022-tuanjie",
|
||||
"hybridclr" : { "branch":"v5.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-tuanjie-5.2.0"}
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-tuanjie-7.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2023",
|
||||
"hybridclr" : { "branch":"v6.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2023-6.0.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"6000",
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v6000-7.2.0"}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -116,8 +116,8 @@ namespace MonoHook
|
||||
|
||||
static void SetupFlushICacheFunc()
|
||||
{
|
||||
string processorType = SystemInfo.processorType;
|
||||
if (processorType.Contains("Intel") || processorType.Contains("AMD"))
|
||||
string processorType = SystemInfo.processorType.ToLowerInvariant();
|
||||
if (processorType.Contains("intel") || processorType.Contains("amd"))
|
||||
return;
|
||||
|
||||
if (IntPtr.Size == 4)
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.IO;
|
||||
|
||||
namespace HybridCLR.MonoHook
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
#if UNITY_2021_1_OR_NEWER && !UNITY_2023_1_OR_NEWER
|
||||
[InitializeOnLoad]
|
||||
public class CopyStrippedAOTAssembliesHook
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.IO;
|
||||
|
||||
namespace HybridCLR.MonoHook
|
||||
{
|
||||
#if UNITY_2022
|
||||
#if UNITY_2022 || UNITY_2023_1_OR_NEWER
|
||||
[InitializeOnLoad]
|
||||
public class GetIl2CppFolderHook
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.IO;
|
||||
|
||||
namespace HybridCLR.MonoHook
|
||||
{
|
||||
#if (UNITY_2021_1_OR_NEWER && UNITY_WEBGL) || TUANJIE_2022
|
||||
#if UNITY_2021_1_OR_NEWER && (UNITY_WEBGL || UNITY_WEIXINMINIGAME)
|
||||
[InitializeOnLoad]
|
||||
public class PatchScriptingAssembliesJsonHook
|
||||
{
|
||||
@@ -35,18 +35,29 @@ namespace HybridCLR.MonoHook
|
||||
|
||||
private static string BuildMainWindowTitle()
|
||||
{
|
||||
string tempJsonPath = $"{Application.dataPath}/../Library/PlayerDataCache/WebGL/Data/ScriptingAssemblies.json";
|
||||
#if TUANJIE_2022
|
||||
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.WeixinMiniGame)
|
||||
var cacheDir = $"{Application.dataPath}/../Library/PlayerDataCache";
|
||||
if (Directory.Exists(cacheDir))
|
||||
{
|
||||
tempJsonPath = $"{Application.dataPath}/../Library/PlayerDataCache/WeixinMiniGame/Data/ScriptingAssemblies.json";
|
||||
}
|
||||
foreach (var tempJsonPath in Directory.GetDirectories(cacheDir, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
string dirName = Path.GetFileName(tempJsonPath);
|
||||
#if UNITY_WEIXINMINIGAME
|
||||
if (!dirName.Contains("WeixinMiniGame"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
if (!dirName.Contains("WebGL"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (File.Exists(tempJsonPath))
|
||||
{
|
||||
var patcher = new PatchScriptingAssemblyList();
|
||||
patcher.PathScriptingAssembilesFile(Path.GetDirectoryName(tempJsonPath));
|
||||
|
||||
var patcher = new PatchScriptingAssemblyList();
|
||||
patcher.PathScriptingAssembilesFile(tempJsonPath);
|
||||
}
|
||||
}
|
||||
|
||||
string newTitle = BuildMainWindowTitleProxy();
|
||||
return newTitle;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,16 @@ namespace HybridCLR.Editor.AOT
|
||||
public AssemblyReferenceDeepCollector Collector { get; set; }
|
||||
|
||||
public int MaxIterationCount { get; set; }
|
||||
|
||||
public bool ComputeAotAssembly { get; set; }
|
||||
}
|
||||
|
||||
private readonly int _maxInterationCount;
|
||||
|
||||
private readonly AssemblyReferenceDeepCollector _assemblyCollector;
|
||||
|
||||
private readonly bool _computeAotAssembly;
|
||||
|
||||
private readonly HashSet<GenericClass> _genericTypes = new HashSet<GenericClass>();
|
||||
private readonly HashSet<GenericMethod> _genericMethods = new HashSet<GenericMethod>();
|
||||
|
||||
@@ -47,6 +51,7 @@ namespace HybridCLR.Editor.AOT
|
||||
{
|
||||
_assemblyCollector = options.Collector;
|
||||
_maxInterationCount = options.MaxIterationCount;
|
||||
_computeAotAssembly = options.ComputeAotAssembly;
|
||||
_methodReferenceAnalyzer = new MethodReferenceAnalyzer(this.OnNewMethod);
|
||||
_hotUpdateAssemblyFiles = new HashSet<string>(options.Collector.GetRootAssemblyNames().Select(assName => assName + ".dll"));
|
||||
}
|
||||
@@ -71,7 +76,7 @@ namespace HybridCLR.Editor.AOT
|
||||
|
||||
private bool IsAotType(TypeDef type)
|
||||
{
|
||||
return !_hotUpdateAssemblyFiles.Contains(type.Module.Name);
|
||||
return _computeAotAssembly || !_hotUpdateAssemblyFiles.Contains(type.Module.Name);
|
||||
}
|
||||
|
||||
private bool IsAotGenericMethod(MethodDef method)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace HybridCLR.Editor.AOT
|
||||
{
|
||||
_typeSimpleNameMapping.Add(e.Key.FullName, e.Value);
|
||||
}
|
||||
_systemTypePattern = new Regex(string.Join("|", _typeSimpleNameMapping.Keys.Select (k => $@"\b{k}\b")));
|
||||
_systemTypePattern = new Regex(string.Join("|", _typeSimpleNameMapping.Keys.Select (k => $@"\b{Regex.Escape(k)}\b")));
|
||||
}
|
||||
|
||||
public string PrettifyTypeSig(string typeSig)
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
using HybridCLR.Editor.Settings;
|
||||
#if UNITY_2019 && UNITY_IOS
|
||||
#if UNITY_2019 && (UNITY_IOS || UNITY_TVOS)
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
@@ -17,22 +17,10 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2019
|
||||
{
|
||||
//[MenuItem("Test/GenProj")]
|
||||
//public static void Modify()
|
||||
//{
|
||||
// OnPostProcessBuild(BuildTarget.iOS, $"{SettingsUtil.ProjectDir}/Build-iOS");
|
||||
//}
|
||||
|
||||
//[MenuItem("Test/CreateLumps")]
|
||||
//public static void CreateLumpsCmd()
|
||||
//{
|
||||
// CreateLumps($"{SettingsUtil.LocalIl2CppDir}/libil2cpp", $"{SettingsUtil.HybridCLRDataDir}/lumps");
|
||||
//}
|
||||
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS || !HybridCLRSettings.Instance.enable)
|
||||
if (!HybridCLRSettings.Instance.enable)
|
||||
return;
|
||||
/*
|
||||
* 1. 生成lump,并且添加到工程
|
||||
@@ -46,8 +34,8 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
9. add external/xxHash
|
||||
10. add "#include <stdio.h>" to Classes/Prefix.pch
|
||||
*/
|
||||
|
||||
string pbxprojFile = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
|
||||
string pbxprojFile = BuildProcessorUtil.GetXcodeProjectFile(pathToBuiltProject);
|
||||
string srcLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
string dstLibil2cppDir = $"{pathToBuiltProject}/Libraries/libil2cpp";
|
||||
string lumpDir = $"{pathToBuiltProject}/Libraries/lumps";
|
||||
@@ -147,6 +135,7 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
newPro += " $(SRCROOT)/Libraries/external/xxHash";
|
||||
}
|
||||
newPro += " $(SRCR00T)/Libraries/external/mono";
|
||||
//Debug.Log($"config:{bcn} new prop:{newPro}");
|
||||
proj.SetBuildPropertyForConfig(configGuid, headerSearchPaths, newPro);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
using HybridCLR.Editor.Settings;
|
||||
#if (UNITY_2020 || UNITY_2021) && UNITY_IOS
|
||||
#if (UNITY_2020 || UNITY_2021) && (UNITY_IOS || UNITY_TVOS)
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
@@ -17,22 +17,11 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2020Or2021
|
||||
{
|
||||
//[MenuItem("Test/GenProj")]
|
||||
//public static void Modify()
|
||||
//{
|
||||
// OnPostProcessBuild(BuildTarget.iOS, $"{SettingsUtil.ProjectDir}/Build-iOS");
|
||||
//}
|
||||
|
||||
//[MenuItem("Test/CreateLumps")]
|
||||
//public static void CreateLumpsCmd()
|
||||
//{
|
||||
// CreateLumps($"{SettingsUtil.LocalIl2CppDir}/libil2cpp", $"{SettingsUtil.HybridCLRDataDir}/lumps");
|
||||
//}
|
||||
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS || !HybridCLRSettings.Instance.enable)
|
||||
if (!HybridCLRSettings.Instance.enable)
|
||||
return;
|
||||
/*
|
||||
* 1. 生成lump,并且添加到工程
|
||||
@@ -46,7 +35,7 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
9. add external/xxHash
|
||||
*/
|
||||
|
||||
string pbxprojFile = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
string pbxprojFile = BuildProcessorUtil.GetXcodeProjectFile(pathToBuiltProject);
|
||||
string srcLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
string dstLibil2cppDir = $"{pathToBuiltProject}/Libraries/libil2cpp";
|
||||
string lumpDir = $"{pathToBuiltProject}/Libraries/lumps";
|
||||
@@ -132,6 +121,7 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
newPro += " $(SRCROOT)/Libraries/external/xxHash";
|
||||
}
|
||||
newPro += " $(SRCR00T)/Libraries/external/mono";
|
||||
//Debug.Log($"config:{bcn} new prop:{newPro}");
|
||||
proj.SetBuildPropertyForConfig(configGuid, headerSearchPaths, newPro);
|
||||
|
||||
|
||||
@@ -2,47 +2,72 @@ using HybridCLR.Editor.Installer;
|
||||
using HybridCLR.Editor.Settings;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2022_2_OR_NEWER && UNITY_IOS
|
||||
#if UNITY_2022 && (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS)
|
||||
|
||||
namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2022OrNewer
|
||||
{
|
||||
//[MenuItem("HybridCLR/Modfiyxcode")]
|
||||
//public static void Modify()
|
||||
//{
|
||||
// OnPostProcessBuild(BuildTarget.iOS, $"{SettingsUtil.ProjectDir}/Build-iOS");
|
||||
//}
|
||||
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target != BuildTarget.iOS || !HybridCLRSettings.Instance.enable)
|
||||
if (!HybridCLRSettings.Instance.enable)
|
||||
return;
|
||||
|
||||
string pbxprojFile = $"{pathToBuiltProject}/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
string pbxprojFile = BuildProcessorUtil.GetXcodeProjectFile(pathToBuiltProject);
|
||||
RemoveExternalLibil2cppOption(pbxprojFile);
|
||||
CopyLibil2cppToXcodeProj(pathToBuiltProject);
|
||||
}
|
||||
|
||||
private static string TryRemoveDunplicateShellScriptSegment(string pbxprojFile, string pbxprojContent)
|
||||
{
|
||||
// will appear duplicated Shell Script segment when append to existed xcode project.
|
||||
// This is unity bug.
|
||||
// we remove duplicated Shell Script to avoid build error.
|
||||
string copyFileComment = @"/\* CopyFiles \*/,\s+([A-Z0-9]{24}) /\* ShellScript \*/,\s+([A-Z0-9]{24}) /\* ShellScript \*/,";
|
||||
var m = Regex.Match(pbxprojContent, copyFileComment, RegexOptions.Multiline);
|
||||
if (!m.Success)
|
||||
{
|
||||
return pbxprojContent;
|
||||
}
|
||||
|
||||
if (m.Groups[1].Value != m.Groups[2].Value)
|
||||
{
|
||||
throw new BuildFailedException($"find invalid /* ShellScript */ segment");
|
||||
}
|
||||
|
||||
int startIndexOfDupShellScript = m.Groups[2].Index;
|
||||
int endIndexOfDupShellScript = pbxprojContent.IndexOf(",", startIndexOfDupShellScript);
|
||||
|
||||
pbxprojContent = pbxprojContent.Remove(startIndexOfDupShellScript, endIndexOfDupShellScript + 1 - startIndexOfDupShellScript);
|
||||
Debug.LogWarning($"[AddLil2cppSourceCodeToXcodeproj] remove duplicated '/* ShellScript */' from file '{pbxprojFile}'");
|
||||
return pbxprojContent;
|
||||
}
|
||||
|
||||
private static void RemoveExternalLibil2cppOption(string pbxprojFile)
|
||||
{
|
||||
string pbxprojContent = File.ReadAllText(pbxprojFile, Encoding.UTF8);
|
||||
string removeBuildOption = @"--external-lib-il2-cpp=\""$PROJECT_DIR/Libraries/libil2cpp.a\""";
|
||||
if (!pbxprojContent.Contains(removeBuildOption))
|
||||
if (pbxprojContent.Contains(removeBuildOption))
|
||||
{
|
||||
//throw new BuildFailedException("modified project.pbxproj fail");
|
||||
Debug.LogError("[AddLil2cppSourceCodeToXcodeproj] modified project.pbxproj fail");
|
||||
return;
|
||||
pbxprojContent = pbxprojContent.Replace(removeBuildOption, "");
|
||||
Debug.Log($"[AddLil2cppSourceCodeToXcodeproj] remove il2cpp build option '{removeBuildOption}' from file '{pbxprojFile}'");
|
||||
}
|
||||
pbxprojContent = pbxprojContent.Replace(removeBuildOption, "");
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[AddLil2cppSourceCodeToXcodeproj] project.pbxproj remove building option:'{removeBuildOption}' fail. This may occur when 'Append' to existing xcode project in building");
|
||||
}
|
||||
|
||||
pbxprojContent = TryRemoveDunplicateShellScriptSegment(pbxprojFile, pbxprojContent);
|
||||
|
||||
|
||||
File.WriteAllText(pbxprojFile, pbxprojContent, Encoding.UTF8);
|
||||
Debug.Log($"[AddLil2cppSourceCodeToXcodeproj] remove il2cpp build option '{removeBuildOption}' from file '{pbxprojFile}'");
|
||||
}
|
||||
|
||||
private static void CopyLibil2cppToXcodeProj(string pathToBuiltProject)
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using HybridCLR.Editor.Installer;
|
||||
using HybridCLR.Editor.Settings;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2023_1_OR_NEWER && (UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS)
|
||||
|
||||
namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
public static class AddLil2cppSourceCodeToXcodeproj2022OrNewer
|
||||
{
|
||||
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (!HybridCLRSettings.Instance.enable)
|
||||
return;
|
||||
CopyLibil2cppToXcodeProj(pathToBuiltProject);
|
||||
}
|
||||
|
||||
private static void CopyLibil2cppToXcodeProj(string pathToBuiltProject)
|
||||
{
|
||||
string srcLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||
string destLibil2cppDir = $"{pathToBuiltProject}/Il2CppOutputProject/IL2CPP/libil2cpp";
|
||||
BashUtil.RemoveDir(destLibil2cppDir);
|
||||
BashUtil.CopyDir(srcLibil2cppDir, destLibil2cppDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fa46135129b046a28014d58fdfd18ca
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor.Build;
|
||||
|
||||
namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
|
||||
public static class BuildProcessorUtil
|
||||
{
|
||||
|
||||
public static string GetXcodeProjectFile(string pathToBuiltProject)
|
||||
{
|
||||
foreach (string dir in Directory.GetDirectories(pathToBuiltProject, "*.xcodeproj", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
string pbxprojFile = $"{dir}/project.pbxproj";
|
||||
if (File.Exists(pbxprojFile))
|
||||
{
|
||||
return pbxprojFile;
|
||||
}
|
||||
}
|
||||
throw new BuildFailedException($"can't find xxxx.xcodeproj/project.pbxproj in {pathToBuiltProject}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7db18e1736f593c4089c85d764cf8620
|
||||
guid: c680e56f90f2745298a90803c04f6efc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,8 +1,10 @@
|
||||
using HybridCLR.Editor.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
@@ -16,6 +18,8 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
public int callbackOrder => 0;
|
||||
|
||||
public static bool DisableMethodBridgeDevelopmentFlagChecking { get; set; }
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
HybridCLRSettings globalSettings = SettingsUtil.HybridCLRSettings;
|
||||
@@ -67,6 +71,24 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
Debug.LogWarning("[CheckSettings] No hot update modules configured in HybridCLRSettings");
|
||||
}
|
||||
|
||||
if (!DisableMethodBridgeDevelopmentFlagChecking)
|
||||
{
|
||||
string methodBridgeFile = $"{SettingsUtil.GeneratedCppDir}/MethodBridge.cpp";
|
||||
var match = Regex.Match(File.ReadAllText(methodBridgeFile), @"// DEVELOPMENT=(\d)");
|
||||
if (match.Success)
|
||||
{
|
||||
int developmentFlagInMethodBridge = int.Parse(match.Groups[1].Value);
|
||||
int developmentFlagInEditorSettings = EditorUserBuildSettings.development ? 1 : 0;
|
||||
if (developmentFlagInMethodBridge != developmentFlagInEditorSettings)
|
||||
{
|
||||
Debug.LogError($"[CheckSettings] MethodBridge.cpp DEVELOPMENT flag:{developmentFlagInMethodBridge} is inconsistent with EditorUserBuildSettings.development:{developmentFlagInEditorSettings}. Please run 'HybridCLR/Generate/All' before building.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("[CheckSettings] MethodBridge.cpp DEVELOPMENT flag not found. Please run 'HybridCLR/Generate/All' before building.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEditor.Il2Cpp;
|
||||
using UnityEditor.UnityLinker;
|
||||
using UnityEngine;
|
||||
#if !UNITY_2021_1_OR_NEWER
|
||||
using UnityEditor.Il2Cpp;
|
||||
#endif
|
||||
|
||||
namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
@@ -33,11 +35,23 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
return $"{projectDir}/Library/Bee/artifacts/WinPlayerBuildProgram/ManagedStripped";
|
||||
case BuildTarget.StandaloneLinux64:
|
||||
return $"{projectDir}/Library/Bee/artifacts/LinuxPlayerBuildProgram/ManagedStripped";
|
||||
case BuildTarget.WSAPlayer:
|
||||
return $"{projectDir}/Library/Bee/artifacts/UWPPlayerBuildProgram/ManagedStripped";
|
||||
case BuildTarget.Android:
|
||||
return $"{projectDir}/Library/Bee/artifacts/Android/ManagedStripped";
|
||||
#if TUANJIE_2022_3_OR_NEWER
|
||||
case BuildTarget.HMIAndroid:
|
||||
return $"{projectDir}/Library/Bee/artifacts/HMIAndroid/ManagedStripped";
|
||||
#endif
|
||||
case BuildTarget.iOS:
|
||||
#if UNITY_TVOS
|
||||
case BuildTarget.tvOS:
|
||||
#endif
|
||||
#if UNITY_VISIONOS
|
||||
case BuildTarget.VisionOS:
|
||||
#endif
|
||||
return $"{projectDir}/Library/Bee/artifacts/iOS/ManagedStripped";
|
||||
case BuildTarget.WebGL:
|
||||
case BuildTarget.WebGL:
|
||||
return $"{projectDir}/Library/Bee/artifacts/WebGL/ManagedStripped";
|
||||
case BuildTarget.StandaloneOSX:
|
||||
return $"{projectDir}/Library/Bee/artifacts/MacStandalonePlayerBuildProgram/ManagedStripped";
|
||||
@@ -45,9 +59,11 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
return $"{projectDir}/Library/Bee/artifacts/PS4PlayerBuildProgram/ManagedStripped";
|
||||
case BuildTarget.PS5:
|
||||
return $"{projectDir}/Library/Bee/artifacts/PS5PlayerBuildProgram/ManagedStripped";
|
||||
#if TUANJIE_2022
|
||||
#if UNITY_WEIXINMINIGAME
|
||||
case BuildTarget.WeixinMiniGame:
|
||||
return $"{projectDir}/Library/Bee/artifacts/WeixinMiniGame/ManagedStripped";
|
||||
#endif
|
||||
#if UNITY_OPENHARMONY
|
||||
case BuildTarget.OpenHarmony:
|
||||
return $"{projectDir}/Library/Bee/artifacts/OpenHarmonyPlayerBuildProgram/ManagedStripped";
|
||||
#endif
|
||||
@@ -64,9 +80,9 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
}
|
||||
|
||||
public void OnBeforeConvertRun(BuildReport report, Il2CppBuildPipelineData data)
|
||||
{
|
||||
// 此回调只在 2020中调用
|
||||
CopyStripDlls(GetStripAssembliesDir2020(data.target), data.target);
|
||||
{
|
||||
BuildTarget target = report.summary.platform;
|
||||
CopyStripDlls(GetStripAssembliesDir2020(target), target);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -94,7 +110,7 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
public void OnPostprocessBuild(BuildReport report)
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
BuildTarget target = report.summary.platform;
|
||||
string srcStripDllPath = GetStripAssembliesDir2021(target);
|
||||
if (!string.IsNullOrEmpty(srcStripDllPath) && Directory.Exists(srcStripDllPath))
|
||||
{
|
||||
@@ -105,7 +121,7 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
BuildTarget target = report.summary.platform;
|
||||
var dstPath = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
BashUtil.RecreateDir(dstPath);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@ using UnityEditor;
|
||||
using UnityEditor.Android;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEditor.Il2Cpp;
|
||||
using UnityEditor.UnityLinker;
|
||||
using UnityEngine;
|
||||
using UnityFS;
|
||||
#if !UNITY_2023_1_OR_NEWER
|
||||
using UnityEditor.Il2Cpp;
|
||||
#endif
|
||||
|
||||
namespace HybridCLR.Editor.BuildProcessors
|
||||
{
|
||||
@@ -177,7 +179,7 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
return true;
|
||||
}
|
||||
|
||||
#if UNITY_WEBGL
|
||||
#if UNITY_WEBGL && !UNITY_2022_3_OR_NEWER
|
||||
public void OnBeforeConvertRun(BuildReport report, Il2CppBuildPipelineData data)
|
||||
{
|
||||
PathScriptingAssembilesFile($"{SettingsUtil.ProjectDir}/Temp/StagingArea/Data");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -22,25 +23,110 @@ namespace HybridCLR.Editor.Commands
|
||||
GenerateAOTGenericReference(target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算热更代码中的泛型引用
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
public static void GenerateAOTGenericReference(BuildTarget target)
|
||||
{
|
||||
var gs = SettingsUtil.HybridCLRSettings;
|
||||
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
|
||||
AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames);
|
||||
var analyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
var analyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
MaxIterationCount = Math.Min(20, gs.maxGenericReferenceIteration),
|
||||
Collector = collector,
|
||||
});
|
||||
MaxIterationCount = Math.Min(20, gs.maxGenericReferenceIteration),
|
||||
Collector = collector,
|
||||
});
|
||||
|
||||
analyzer.Run();
|
||||
analyzer.Run();
|
||||
|
||||
var writer = new GenericReferenceWriter();
|
||||
writer.Write(analyzer.AotGenericTypes.ToList(), analyzer.AotGenericMethods.ToList(), $"{Application.dataPath}/{gs.outputAOTGenericReferenceFile}");
|
||||
AssetDatabase.Refresh();
|
||||
var writer = new GenericReferenceWriter();
|
||||
writer.Write(analyzer.AotGenericTypes.ToList(), analyzer.AotGenericMethods.ToList(), $"{Application.dataPath}/{gs.outputAOTGenericReferenceFile}");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//[MenuItem("HybridCLR/Generate/AOTGenericReference2", priority = 103)]
|
||||
//public static void GeneratedAOTGenericReferenceExcludeExists()
|
||||
//{
|
||||
// GeneratedAOTGenericReferenceExcludeExists(EditorUserBuildSettings.activeBuildTarget);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 计算热更新代码中的泛型引用,但排除AOT已经存在的泛型引用
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
///
|
||||
public static void GeneratedAOTGenericReferenceExcludeExistsAOTClassAndMethods(BuildTarget target)
|
||||
{
|
||||
|
||||
var gs = SettingsUtil.HybridCLRSettings;
|
||||
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
|
||||
AssemblyReferenceDeepCollector hotUpdateCollector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames);
|
||||
var hotUpdateAnalyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
MaxIterationCount = Math.Min(10, gs.maxGenericReferenceIteration),
|
||||
Collector = hotUpdateCollector,
|
||||
});
|
||||
|
||||
hotUpdateAnalyzer.Run();
|
||||
|
||||
|
||||
string aotDllDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
List<string> aotAssemblyNames = Directory.Exists(aotDllDir) ?
|
||||
Directory.GetFiles(aotDllDir, "*.dll", SearchOption.TopDirectoryOnly).Select(Path.GetFileNameWithoutExtension).ToList()
|
||||
: new List<string>();
|
||||
if (aotAssemblyNames.Count == 0)
|
||||
{
|
||||
throw new Exception($"no aot assembly found. please run `HybridCLR/Generate/All` or `HybridCLR/Generate/AotDlls` to generate aot dlls before runing `HybridCLR/Generate/AOTGenericReference`");
|
||||
}
|
||||
AssemblyReferenceDeepCollector aotCollector = new AssemblyReferenceDeepCollector(MetaUtil.CreateAOTAssemblyResolver(target), aotAssemblyNames);
|
||||
var aotAnalyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
MaxIterationCount = Math.Min(10, gs.maxGenericReferenceIteration),
|
||||
Collector = aotCollector,
|
||||
ComputeAotAssembly = true,
|
||||
});
|
||||
|
||||
aotAnalyzer.Run();
|
||||
|
||||
var (resultTypes, resultMethods) = ExcludeExistAOTGenericTypeAndMethodss(hotUpdateAnalyzer.AotGenericTypes.ToList(), hotUpdateAnalyzer.AotGenericMethods.ToList(), aotAnalyzer.AotGenericTypes.ToList(), aotAnalyzer.AotGenericMethods.ToList());
|
||||
var writer = new GenericReferenceWriter();
|
||||
writer.Write(resultTypes, resultMethods, $"{Application.dataPath}/{gs.outputAOTGenericReferenceFile}");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
|
||||
private static (List<GenericClass>, List<GenericMethod>) ExcludeExistAOTGenericTypeAndMethodss(List<GenericClass> hotUpdateTypes, List<GenericMethod> hotUpdateMethods, List<GenericClass> aotTypes, List<GenericMethod> aotMethods)
|
||||
{
|
||||
var types = new List<GenericClass>();
|
||||
|
||||
var typeSig2Type = hotUpdateTypes.ToDictionary(t => t.Type.DefinitionAssembly.Name + ":" + t.ToTypeSig(), t => t);
|
||||
foreach (var t in aotTypes)
|
||||
{
|
||||
string key = t.Type.DefinitionAssembly.Name + ":" + t.ToTypeSig();
|
||||
if (typeSig2Type.TryGetValue(key, out var removedType))
|
||||
{
|
||||
typeSig2Type.Remove(key);
|
||||
Debug.Log($"remove AOT type:{removedType.ToTypeSig()} ");
|
||||
}
|
||||
}
|
||||
|
||||
var methodSig2Method = hotUpdateMethods.ToDictionary(m => m.Method.DeclaringType.DefinitionAssembly.Name + ":" + m.ToMethodSpec().ToString(), m => m);
|
||||
foreach (var m in aotMethods)
|
||||
{
|
||||
string key = m.Method.DeclaringType.DefinitionAssembly.Name + ":" + m.ToMethodSpec().ToString();
|
||||
if (methodSig2Method.TryGetValue(key, out var removedMethod))
|
||||
{
|
||||
methodSig2Method.Remove(key);
|
||||
Debug.Log($"remove AOT method:{removedMethod.ToMethodSpec()} ");
|
||||
}
|
||||
}
|
||||
|
||||
return (typeSig2Type.Values.ToList(), methodSig2Method.Values.ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using HybridCLR.Editor.Link;
|
||||
using HybridCLR.Editor.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -21,6 +22,8 @@ namespace HybridCLR.Editor.Commands
|
||||
HotUpdateAssemblies = SettingsUtil.HotUpdateAssemblyNamesIncludePreserved,
|
||||
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/UnityVersion.h",
|
||||
OutputFile2 = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/AssemblyManifest.cpp",
|
||||
EnableProfilerInReleaseBuild = HybridCLRSettings.Instance.enableProfilerInReleaseBuild,
|
||||
EnableStraceTraceInWebGLReleaseBuild = HybridCLRSettings.Instance.enableStraceTraceInWebGLReleaseBuild,
|
||||
};
|
||||
|
||||
var g = new Il2CppDef.Il2CppDefGenerator(options);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using HybridCLR.Editor.ABI;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using HybridCLR.Editor.MethodBridge;
|
||||
using HybridCLR.Editor.ReversePInvokeWrap;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -30,29 +31,30 @@ namespace HybridCLR.Editor.Commands
|
||||
Directory.Delete(il2cppBuildCachePath, true);
|
||||
}
|
||||
|
||||
private static void GenerateMethodBridgeCppFile(Analyzer analyzer, string outputFile)
|
||||
private static void GenerateMethodBridgeCppFile(IReadOnlyCollection<GenericMethod> genericMethods, List<RawReversePInvokeMethodInfo> reversePInvokeMethods, string outputFile)
|
||||
{
|
||||
string templateCode = File.ReadAllText(outputFile, Encoding.UTF8);
|
||||
var g = new Generator(new Generator.Options()
|
||||
{
|
||||
TemplateCode = templateCode,
|
||||
OutputFile = outputFile,
|
||||
GenericMethods = analyzer.GenericMethods,
|
||||
GenericMethods = genericMethods,
|
||||
ReversePInvokeMethods = reversePInvokeMethods,
|
||||
Development = EditorUserBuildSettings.development,
|
||||
});
|
||||
|
||||
g.PrepareMethods();
|
||||
g.Generate();
|
||||
Debug.LogFormat("[MethodBridgeGeneratorCommand] output:{0}", outputFile);
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/Generate/MethodBridge", priority = 101)]
|
||||
public static void CompileAndGenerateMethodBridge()
|
||||
[MenuItem("HybridCLR/Generate/MethodBridgeAndReversePInvokeWrapper", priority = 101)]
|
||||
public static void GenerateMethodBridgeAndReversePInvokeWrapper()
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
GenerateMethodBridge(target);
|
||||
GenerateMethodBridgeAndReversePInvokeWrapper(target);
|
||||
}
|
||||
|
||||
public static void GenerateMethodBridge(BuildTarget target)
|
||||
public static void GenerateMethodBridgeAndReversePInvokeWrapper(BuildTarget target)
|
||||
{
|
||||
string aotDllDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
List<string> aotAssemblyNames = Directory.Exists(aotDllDir) ?
|
||||
@@ -62,18 +64,25 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
throw new Exception($"no aot assembly found. please run `HybridCLR/Generate/All` or `HybridCLR/Generate/AotDlls` to generate aot dlls before runing `HybridCLR/Generate/MethodBridge`");
|
||||
}
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateAOTAssemblyResolver(target), aotAssemblyNames))
|
||||
{
|
||||
var analyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
MaxIterationCount = Math.Min(20, SettingsUtil.HybridCLRSettings.maxMethodBridgeGenericIteration),
|
||||
Collector = collector,
|
||||
});
|
||||
AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateAOTAssemblyResolver(target), aotAssemblyNames);
|
||||
|
||||
analyzer.Run();
|
||||
string outputFile = $"{SettingsUtil.GeneratedCppDir}/MethodBridge.cpp";
|
||||
GenerateMethodBridgeCppFile(analyzer, outputFile);
|
||||
}
|
||||
var methodBridgeAnalyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
MaxIterationCount = Math.Min(20, SettingsUtil.HybridCLRSettings.maxMethodBridgeGenericIteration),
|
||||
Collector = collector,
|
||||
});
|
||||
|
||||
methodBridgeAnalyzer.Run();
|
||||
|
||||
List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls));
|
||||
|
||||
var reversePInvokeAnalyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls);
|
||||
reversePInvokeAnalyzer.Run();
|
||||
|
||||
string outputFile = $"{SettingsUtil.GeneratedCppDir}/MethodBridge.cpp";
|
||||
|
||||
GenerateMethodBridgeCppFile(methodBridgeAnalyzer.GenericMethods, reversePInvokeAnalyzer.ReversePInvokeMethods, outputFile);
|
||||
|
||||
CleanIl2CppBuildCache();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
|
||||
namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
@@ -15,6 +16,11 @@ namespace HybridCLR.Editor.Commands
|
||||
[MenuItem("HybridCLR/Generate/All", priority = 200)]
|
||||
public static void GenerateAll()
|
||||
{
|
||||
var installer = new Installer.InstallerController();
|
||||
if (!installer.HasInstalledHybridCLR())
|
||||
{
|
||||
throw new BuildFailedException($"You have not initialized HybridCLR, please install it via menu 'HybridCLR/Installer'");
|
||||
}
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
|
||||
@@ -26,8 +32,7 @@ namespace HybridCLR.Editor.Commands
|
||||
StripAOTDllCommand.GenerateStripedAOTDlls(target);
|
||||
|
||||
// 桥接函数生成依赖于AOT dll,必须保证已经build过,生成AOT dll
|
||||
MethodBridgeGeneratorCommand.GenerateMethodBridge(target);
|
||||
ReversePInvokeWrapperGeneratorCommand.GenerateReversePInvokeWrapper(target);
|
||||
MethodBridgeGeneratorCommand.GenerateMethodBridgeAndReversePInvokeWrapper(target);
|
||||
AOTReferenceGeneratorCommand.GenerateAOTGenericReference(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
using HybridCLR.Editor.ABI;
|
||||
using HybridCLR.Editor.Link;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using HybridCLR.Editor.ReversePInvokeWrap;
|
||||
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.Commands
|
||||
{
|
||||
|
||||
public static class ReversePInvokeWrapperGeneratorCommand
|
||||
{
|
||||
|
||||
[MenuItem("HybridCLR/Generate/ReversePInvokeWrapper", priority = 103)]
|
||||
|
||||
public static void CompileAndGenerateReversePInvokeWrapper()
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
GenerateReversePInvokeWrapper(target);
|
||||
}
|
||||
|
||||
public static void GenerateReversePInvokeWrapper(BuildTarget target)
|
||||
{
|
||||
List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
using (var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls)))
|
||||
{
|
||||
var analyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls);
|
||||
analyzer.Run();
|
||||
|
||||
string outputFile = $"{SettingsUtil.GeneratedCppDir}/ReversePInvokeMethodStub.cpp";
|
||||
|
||||
List<ABIReversePInvokeMethodInfo> methods = analyzer.BuildABIMethods();
|
||||
Debug.Log($"GenerateReversePInvokeWrapper. wraperCount:{methods.Sum(m => m.Count)} output:{outputFile}");
|
||||
var generator = new Generator();
|
||||
generator.Generate(methods, outputFile);
|
||||
Debug.LogFormat("[ReversePInvokeWrapperGeneratorCommand] output:{0}", outputFile);
|
||||
}
|
||||
MethodBridgeGeneratorCommand.CleanIl2CppBuildCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using HybridCLR.Editor.Installer;
|
||||
using HybridCLR.Editor.BuildProcessors;
|
||||
using HybridCLR.Editor.Installer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -56,11 +57,11 @@ namespace HybridCLR.Editor.Commands
|
||||
switch(target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64: return $"{buildDir}/{target}";
|
||||
case BuildTarget.StandaloneWindows64: return $"{buildDir}/{PlayerSettings.productName}.exe";
|
||||
case BuildTarget.StandaloneOSX: return buildDir;
|
||||
case BuildTarget.iOS: return buildDir;
|
||||
case BuildTarget.Android: return buildDir;
|
||||
case BuildTarget.StandaloneLinux64: return buildDir;
|
||||
case BuildTarget.StandaloneLinux64: return $"{buildDir}/{PlayerSettings.productName}";
|
||||
default: return buildDir;
|
||||
}
|
||||
}
|
||||
@@ -81,103 +82,113 @@ namespace HybridCLR.Editor.Commands
|
||||
#elif UNITY_EDITOR_WIN
|
||||
bool oldCreateSolution = UnityEditor.WindowsStandalone.UserBuildSettings.createSolution;
|
||||
#endif
|
||||
#if TUANJIE_2022
|
||||
#if TUANJIE_2022_3_OR_NEWER
|
||||
bool oldOpenHarmonyProj = EditorUserBuildSettings.exportAsOpenHarmonyProject;
|
||||
#endif
|
||||
bool oldBuildScriptsOnly = EditorUserBuildSettings.buildScriptsOnly;
|
||||
EditorUserBuildSettings.buildScriptsOnly = true;
|
||||
|
||||
string location = GetLocationPathName(outputPath, target);
|
||||
string oldBuildLocation = EditorUserBuildSettings.GetBuildLocation(target);
|
||||
EditorUserBuildSettings.SetBuildLocation(target, location);
|
||||
|
||||
switch (target)
|
||||
try
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
CheckSettings.DisableMethodBridgeDevelopmentFlagChecking = true;
|
||||
EditorUserBuildSettings.buildScriptsOnly = true;
|
||||
|
||||
string location = GetLocationPathName(outputPath, target);
|
||||
EditorUserBuildSettings.SetBuildLocation(target, location);
|
||||
|
||||
switch (target)
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = true;
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
#if TUANJIE_2022_3_OR_NEWER
|
||||
case BuildTarget.HMIAndroid:
|
||||
#endif
|
||||
case BuildTarget.Android:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
|
||||
break;
|
||||
}
|
||||
#if TUANJIE_2022_3_OR_NEWER
|
||||
case BuildTarget.OpenHarmony:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsOpenHarmonyProject = true;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
case BuildTarget.StandaloneOSX:
|
||||
|
||||
Debug.Log($"GenerateStripedAOTDlls build option:{buildOptions}");
|
||||
|
||||
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions()
|
||||
{
|
||||
#if UNITY_EDITOR_OSX
|
||||
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = true;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#if TUANJIE_2022
|
||||
case BuildTarget.HMIAndroid:
|
||||
#endif
|
||||
case BuildTarget.Android:
|
||||
scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray(),
|
||||
locationPathName = location,
|
||||
options = buildOptions,
|
||||
target = target,
|
||||
targetGroup = BuildPipeline.GetBuildTargetGroup(target),
|
||||
};
|
||||
|
||||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
|
||||
|
||||
|
||||
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
|
||||
break;
|
||||
throw new Exception("GenerateStripedAOTDlls failed");
|
||||
}
|
||||
#if TUANJIE_2022
|
||||
case BuildTarget.OpenHarmony:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsOpenHarmonyProject = true;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Debug.Log($"GenerateStripedAOTDlls build option:{buildOptions}");
|
||||
|
||||
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions()
|
||||
finally
|
||||
{
|
||||
scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray(),
|
||||
locationPathName = location,
|
||||
options = buildOptions,
|
||||
target = target,
|
||||
targetGroup = BuildPipeline.GetBuildTargetGroup(target),
|
||||
};
|
||||
CheckSettings.DisableMethodBridgeDevelopmentFlagChecking = false;
|
||||
EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly;
|
||||
EditorUserBuildSettings.SetBuildLocation(target, oldBuildLocation);
|
||||
|
||||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
|
||||
EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly;
|
||||
EditorUserBuildSettings.SetBuildLocation(target, oldBuildLocation);
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
switch (target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = oldCreateSolution;
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = oldCreateSolution;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case BuildTarget.StandaloneOSX:
|
||||
case BuildTarget.StandaloneOSX:
|
||||
{
|
||||
#if UNITY_EDITOR_OSX
|
||||
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = oldCreateSolution;
|
||||
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = oldCreateSolution;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#if TUANJIE_2022
|
||||
case BuildTarget.HMIAndroid:
|
||||
#if TUANJIE_2022_3_OR_NEWER
|
||||
case BuildTarget.HMIAndroid:
|
||||
#endif
|
||||
case BuildTarget.Android:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = oldExportAndroidProj;
|
||||
break;
|
||||
}
|
||||
#if TUANJIE_2022
|
||||
case BuildTarget.OpenHarmony:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsOpenHarmonyProject = oldOpenHarmonyProj;
|
||||
break;
|
||||
}
|
||||
case BuildTarget.Android:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = oldExportAndroidProj;
|
||||
break;
|
||||
}
|
||||
#if TUANJIE_2022_3_OR_NEWER
|
||||
case BuildTarget.OpenHarmony:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsOpenHarmonyProject = oldOpenHarmonyProj;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||
{
|
||||
throw new Exception("GenerateStripedAOTDlls failed");
|
||||
}
|
||||
}
|
||||
Debug.Log($"GenerateStripedAOTDlls target:{target} path:{outputPath}");
|
||||
}
|
||||
|
||||
@@ -61,31 +61,36 @@ namespace HybridCLR.Editor.HotUpdate
|
||||
}
|
||||
}
|
||||
|
||||
foreach (IMethodDefOrRef methodRef in mod.GetMemberRefs())
|
||||
foreach (IMethodDefOrRef memberRef in mod.GetMemberRefs())
|
||||
{
|
||||
if (methodRef.DeclaringType.DefinitionAssembly == null)
|
||||
if (memberRef.DeclaringType.DefinitionAssembly == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string defAssName = methodRef.DeclaringType.DefinitionAssembly.Name;
|
||||
string defAssName = memberRef.DeclaringType.DefinitionAssembly.Name;
|
||||
if (!_aotAssNames.Contains(defAssName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (methodRef.IsField)
|
||||
if (memberRef.IsField)
|
||||
{
|
||||
|
||||
IField field = (IField)memberRef;
|
||||
if (field.ResolveFieldDef() == null)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Missing Field: {memberRef.FullName}");
|
||||
anyMissing = true;
|
||||
}
|
||||
}
|
||||
else if (methodRef.IsMethod)
|
||||
else if (memberRef.IsMethod)
|
||||
{
|
||||
TypeSig declaringTypeSig = methodRef.DeclaringType.ToTypeSig();
|
||||
if (methodRef.ResolveMethodDef() == null)
|
||||
TypeSig declaringTypeSig = memberRef.DeclaringType.ToTypeSig();
|
||||
if (memberRef.ResolveMethodDef() == null)
|
||||
{
|
||||
if (declaringTypeSig.ElementType == ElementType.Array || declaringTypeSig.ElementType == ElementType.SZArray)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
UnityEngine.Debug.LogError($"Missing Method: {methodRef.FullName}");
|
||||
UnityEngine.Debug.LogError($"Missing Method: {memberRef.FullName}");
|
||||
anyMissing = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,10 @@ namespace HybridCLR.Editor.Il2CppDef
|
||||
public string OutputFile2 { get; set; }
|
||||
|
||||
public string UnityVersion { get; set; }
|
||||
|
||||
public bool EnableProfilerInReleaseBuild { get; set; }
|
||||
|
||||
public bool EnableStraceTraceInWebGLReleaseBuild { get; set; }
|
||||
}
|
||||
|
||||
private readonly Options _options;
|
||||
@@ -52,13 +56,40 @@ namespace HybridCLR.Editor.Il2CppDef
|
||||
|
||||
lines.Add($"#define HYBRIDCLR_UNITY_VERSION {majorVer}{minorVer1.ToString("D2")}{minorVer2.ToString("D2")}");
|
||||
lines.Add($"#define HYBRIDCLR_UNITY_{majorVer} 1");
|
||||
for (int ver = 2019; ver <= 2024; ver++)
|
||||
for (int ver = 2019; ver <= 2023; ver++)
|
||||
{
|
||||
if (majorVer >= ver)
|
||||
{
|
||||
lines.Add($"#define HYBRIDCLR_UNITY_{ver}_OR_NEW 1");
|
||||
}
|
||||
}
|
||||
for (int ver = 6000; ver <= 6100; ver++)
|
||||
{
|
||||
if (majorVer >= ver)
|
||||
{
|
||||
lines.Add($"#define HYBRIDCLR_UNITY_{ver}_OR_NEW 1");
|
||||
}
|
||||
}
|
||||
|
||||
#if TUANJIE_1_1_OR_NEWER
|
||||
var tuanjieMatch = Regex.Matches(Application.tuanjieVersion, @"(\d+)\.(\d+)\.(\d+)");
|
||||
int tuanjieMajorVer = int.Parse(tuanjieMatch[0].Groups[1].Value);
|
||||
int tuanjieMinorVer1 = int.Parse(tuanjieMatch[0].Groups[2].Value);
|
||||
int tuanjieMinorVer2 = int.Parse(tuanjieMatch[0].Groups[3].Value);
|
||||
lines.Add($"#define HYBRIDCLR_TUANJIE_VERSION {tuanjieMajorVer}{tuanjieMinorVer1.ToString("D2")}{tuanjieMinorVer2.ToString("D2")}");
|
||||
#elif TUANJIE_2022_3_OR_NEWER
|
||||
lines.Add($"#define HYBRIDCLR_TUANJIE_VERSION 10000");
|
||||
#endif
|
||||
|
||||
if (_options.EnableProfilerInReleaseBuild)
|
||||
{
|
||||
lines.Add("#define HYBRIDCLR_ENABLE_PROFILER_IN_RELEASE_BUILD 1");
|
||||
}
|
||||
|
||||
if (_options.EnableStraceTraceInWebGLReleaseBuild)
|
||||
{
|
||||
lines.Add("#define HYBRIDCLR_ENABLE_STRACE_TRACE_IN_WEBGL_RELEASE_BUILD 1");
|
||||
}
|
||||
|
||||
frr.Replace("UNITY_VERSION", string.Join("\n", lines));
|
||||
|
||||
|
||||
@@ -122,10 +122,12 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
switch(majorVersion)
|
||||
{
|
||||
case 2019: return $"2019.4.0";
|
||||
case 2020: return $"2020.3.0";
|
||||
case 2021: return $"2021.3.0";
|
||||
case 2022: return $"2022.3.0";
|
||||
case 2019: return "2019.4.0";
|
||||
case 2020: return "2020.3.0";
|
||||
case 2021: return "2021.3.0";
|
||||
case 2022: return "2022.3.0";
|
||||
case 2023: return "2023.2.0";
|
||||
case 6000: return "6000.0.0";
|
||||
default: return $"2020.3.0";
|
||||
}
|
||||
}
|
||||
@@ -144,7 +146,8 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
return CompatibleType.Incompatible;
|
||||
}
|
||||
if ((version.major == 2019 && version.minor1 < 4) || (version.major >= 2020 && version.minor1 < 3))
|
||||
if ((version.major == 2019 && version.minor1 < 4)
|
||||
|| (version.major >= 2020 && version.major <= 2022 && version.minor1 < 3))
|
||||
{
|
||||
return CompatibleType.MaybeIncompatible;
|
||||
}
|
||||
|
||||
+16
-14
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using IAssemblyResolver = HybridCLR.Editor.Meta.IAssemblyResolver;
|
||||
|
||||
namespace HybridCLR.Editor.Link
|
||||
@@ -22,26 +23,27 @@ namespace HybridCLR.Editor.Link
|
||||
|
||||
public HashSet<TypeRef> CollectRefs(List<string> rootAssemblies)
|
||||
{
|
||||
using (var assCollector = new AssemblyCache(_resolver))
|
||||
{
|
||||
var rootAssemblyNames = new HashSet<string>(rootAssemblies);
|
||||
var assCollector = new AssemblyCache(_resolver);
|
||||
var rootAssemblyNames = new HashSet<string>(rootAssemblies);
|
||||
|
||||
var typeRefs = new HashSet<TypeRef>(TypeEqualityComparer.Instance);
|
||||
foreach (var rootAss in rootAssemblies)
|
||||
var typeRefs = new HashSet<TypeRef>(TypeEqualityComparer.Instance);
|
||||
foreach (var rootAss in rootAssemblies)
|
||||
{
|
||||
var dnAss = assCollector.LoadModule(rootAss, false);
|
||||
foreach (var type in dnAss.GetTypeRefs())
|
||||
{
|
||||
var dnAss = assCollector.LoadModule(rootAss, false);
|
||||
foreach (var type in dnAss.GetTypeRefs())
|
||||
if (type.DefinitionAssembly == null)
|
||||
{
|
||||
if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString()))
|
||||
{
|
||||
typeRefs.Add(type);
|
||||
}
|
||||
Debug.LogWarning($"assembly:{dnAss.Name} TypeRef {type.FullName} has no DefinitionAssembly");
|
||||
continue;
|
||||
}
|
||||
if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString()))
|
||||
{
|
||||
typeRefs.Add(type);
|
||||
}
|
||||
}
|
||||
|
||||
assCollector.Dispose();
|
||||
return typeRefs;
|
||||
}
|
||||
return typeRefs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ namespace HybridCLR.Editor.Link
|
||||
assTypeNames.Sort(string.CompareOrdinal);
|
||||
foreach(var typeName in assTypeNames)
|
||||
{
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
if (typeName == "UnityEngine.Debug")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
writer.WriteStartElement("type");
|
||||
writer.WriteAttributeString("fullname", typeName);
|
||||
writer.WriteAttributeString("preserve", "all");
|
||||
|
||||
@@ -8,12 +8,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
public abstract class AssemblyCacheBase : IDisposable
|
||||
public abstract class AssemblyCacheBase
|
||||
{
|
||||
private readonly IAssemblyResolver _assemblyPathResolver;
|
||||
private readonly ModuleContext _modCtx;
|
||||
private readonly AssemblyResolver _asmResolver;
|
||||
private bool disposedValue;
|
||||
private bool _loadedNetstandard;
|
||||
|
||||
|
||||
@@ -91,32 +90,10 @@ namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
//Debug.Log($"do load module:{dllPath}");
|
||||
ModuleDefMD mod = ModuleDefMD.Load(File.ReadAllBytes(dllPath), _modCtx);
|
||||
mod.EnableTypeDefFindCache = true;
|
||||
_asmResolver.AddToCache(mod);
|
||||
_loadedModulesIncludeNetstandard.Add(mod);
|
||||
return mod;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
foreach (var mod in _loadedModulesIncludeNetstandard)
|
||||
{
|
||||
mod.Dispose();
|
||||
}
|
||||
_loadedModulesIncludeNetstandard.Clear();
|
||||
LoadedModules.Clear();
|
||||
}
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Editor.ABI;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Editor.ABI;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using HybridCLR.Editor.ReversePInvokeWrap;
|
||||
using HybridCLR.Editor.Template;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,6 +14,9 @@ using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using TypeInfo = HybridCLR.Editor.ABI.TypeInfo;
|
||||
using CallingConvention = System.Runtime.InteropServices.CallingConvention;
|
||||
using System.Security.Cryptography;
|
||||
using TypeAttributes = dnlib.DotNet.TypeAttributes;
|
||||
|
||||
namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
@@ -25,14 +29,22 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
public string OutputFile { get; set; }
|
||||
|
||||
public IReadOnlyCollection<GenericMethod> GenericMethods { get; set; }
|
||||
|
||||
public List<RawReversePInvokeMethodInfo> ReversePInvokeMethods { get; set; }
|
||||
|
||||
public bool Development { get; set; }
|
||||
}
|
||||
|
||||
private readonly List<GenericMethod> _genericMethods;
|
||||
|
||||
private readonly List<RawReversePInvokeMethodInfo> _originalReversePInvokeMethods;
|
||||
|
||||
private readonly string _templateCode;
|
||||
|
||||
private readonly string _outputFile;
|
||||
|
||||
private readonly bool _development;
|
||||
|
||||
private readonly TypeCreator _typeCreator;
|
||||
|
||||
private readonly HashSet<MethodDesc> _managed2nativeMethodSet = new HashSet<MethodDesc>();
|
||||
@@ -41,15 +53,19 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
private readonly HashSet<MethodDesc> _adjustThunkMethodSet = new HashSet<MethodDesc>();
|
||||
|
||||
private List<ABIReversePInvokeMethodInfo> _reversePInvokeMethods;
|
||||
|
||||
public Generator(Options options)
|
||||
{
|
||||
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();
|
||||
_originalReversePInvokeMethods = options.ReversePInvokeMethods;
|
||||
|
||||
_templateCode = options.TemplateCode;
|
||||
_outputFile = options.OutputFile;
|
||||
_typeCreator = new TypeCreator();
|
||||
_development = options.Development;
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, TypeInfo> _sig2Types = new Dictionary<string, TypeInfo>();
|
||||
@@ -167,12 +183,23 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
}
|
||||
}
|
||||
|
||||
public void PrepareMethods()
|
||||
private void PrepareMethodBridges()
|
||||
{
|
||||
foreach(var method in _genericMethods)
|
||||
foreach (var method in _genericMethods)
|
||||
{
|
||||
ProcessMethod(method.Method, method.KlassInst, method.MethodInst);
|
||||
}
|
||||
foreach (var reversePInvokeMethod in _originalReversePInvokeMethods)
|
||||
{
|
||||
MethodDef method = reversePInvokeMethod.Method;
|
||||
ICorLibTypes corLibTypes = method.Module.CorLibTypes;
|
||||
|
||||
var returnType = MetaUtil.ToShareTypeSig(corLibTypes, method.ReturnType);
|
||||
var parameters = method.Parameters.Select(p => MetaUtil.ToShareTypeSig(corLibTypes, p.Type)).ToList();
|
||||
var sharedMethod = CreateMethodDesc(method, true, returnType, parameters);
|
||||
sharedMethod.Init();
|
||||
AddNative2ManagedMethod(sharedMethod);
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckUnique(IEnumerable<string> names)
|
||||
@@ -220,11 +247,20 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
_managed2NativeMethodList0.Count, _native2ManagedMethodList0.Count, _adjustThunkMethodList0.Count, _structTypes0.Count);
|
||||
}
|
||||
|
||||
private class AnalyzeFieldInfo
|
||||
{
|
||||
public FieldDef field;
|
||||
|
||||
public TypeInfo type;
|
||||
}
|
||||
|
||||
private class AnalyzeTypeInfo
|
||||
{
|
||||
public TypeInfo toSharedType;
|
||||
public List<TypeInfo> fields;
|
||||
public List<AnalyzeFieldInfo> fields;
|
||||
public string signature;
|
||||
public ClassLayout classLayout;
|
||||
public TypeAttributes layout;
|
||||
}
|
||||
|
||||
private readonly Dictionary<TypeInfo, AnalyzeTypeInfo> _analyzeTypeInfos = new Dictionary<TypeInfo, AnalyzeTypeInfo>();
|
||||
@@ -240,7 +276,11 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
|
||||
ClassLayout sa = typeDef.ClassLayout;
|
||||
var analyzeTypeInfo = new AnalyzeTypeInfo();
|
||||
var analyzeTypeInfo = new AnalyzeTypeInfo()
|
||||
{
|
||||
classLayout = sa,
|
||||
layout = typeDef.Layout,
|
||||
};
|
||||
|
||||
// don't share type with explicit layout
|
||||
if (sa != null)
|
||||
@@ -251,7 +291,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
return analyzeTypeInfo;
|
||||
}
|
||||
|
||||
var fields = analyzeTypeInfo.fields = new List<TypeInfo>();
|
||||
var fields = analyzeTypeInfo.fields = new List<AnalyzeFieldInfo>();
|
||||
|
||||
foreach (FieldDef field in typeDef.Fields)
|
||||
{
|
||||
@@ -260,7 +300,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
continue;
|
||||
}
|
||||
TypeSig fieldType = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
fields.Add(GetSharedTypeInfo(fieldType));
|
||||
fields.Add(new AnalyzeFieldInfo { field = field, type = GetSharedTypeInfo(fieldType) });
|
||||
}
|
||||
return analyzeTypeInfo;
|
||||
}
|
||||
@@ -286,9 +326,19 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
}
|
||||
|
||||
var sigBuf = new StringBuilder();
|
||||
if (ati.classLayout != null)
|
||||
{
|
||||
sigBuf.Append($"[{ati.classLayout.ClassSize}|{ati.classLayout.PackingSize}|{ati.classLayout}]");
|
||||
}
|
||||
if (ati.layout != 0)
|
||||
{
|
||||
sigBuf.Append($"[{(int)ati.layout}]");
|
||||
}
|
||||
|
||||
foreach (var field in ati.fields)
|
||||
{
|
||||
sigBuf.Append(GetOrCalculateTypeInfoSignature(ToIsomorphicType(field)));
|
||||
string fieldOffset = field.field.FieldOffset != null ? field.field.FieldOffset.ToString() + "|" : "";
|
||||
sigBuf.Append("{" + fieldOffset + GetOrCalculateTypeInfoSignature(ToIsomorphicType(field.type)) + "}");
|
||||
}
|
||||
return ati.signature = sigBuf.ToString();
|
||||
}
|
||||
@@ -370,11 +420,92 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
return methodMap.Values.ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static string MakeSignature(MethodDesc desc, CallingConvention CallingConventionention)
|
||||
{
|
||||
string convStr = ((char)('A' + (int)CallingConventionention - 1)).ToString();
|
||||
return $"{convStr}{desc.Sig}";
|
||||
}
|
||||
|
||||
private static CallingConvention GetCallingConvention(MethodDef method)
|
||||
{
|
||||
var monoPInvokeCallbackAttr = method.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.Name == "MonoPInvokeCallbackAttribute");
|
||||
if (monoPInvokeCallbackAttr == null)
|
||||
{
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
object delegateTypeSig = monoPInvokeCallbackAttr.ConstructorArguments[0].Value;
|
||||
|
||||
TypeDef delegateTypeDef;
|
||||
if (delegateTypeSig is ClassSig classSig)
|
||||
{
|
||||
delegateTypeDef = classSig.TypeDefOrRef.ResolveTypeDefThrow();
|
||||
}
|
||||
else if (delegateTypeSig is GenericInstSig genericInstSig)
|
||||
{
|
||||
delegateTypeDef = genericInstSig.GenericType.TypeDefOrRef.ResolveTypeDefThrow();
|
||||
}
|
||||
else
|
||||
{
|
||||
delegateTypeDef = null;
|
||||
}
|
||||
|
||||
if (delegateTypeDef == null)
|
||||
{
|
||||
throw new NotSupportedException($"Unsupported delegate type: {delegateTypeSig}");
|
||||
}
|
||||
var attr = delegateTypeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute");
|
||||
if (attr == null)
|
||||
{
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
var conv = attr.ConstructorArguments[0].Value;
|
||||
return (CallingConvention)conv;
|
||||
}
|
||||
|
||||
private List<ABIReversePInvokeMethodInfo> BuildABIMethods(List<RawReversePInvokeMethodInfo> rawMethods)
|
||||
{
|
||||
var methodsBySig = new Dictionary<string, ABIReversePInvokeMethodInfo>();
|
||||
foreach (var method in rawMethods)
|
||||
{
|
||||
var sharedMethod = new MethodDesc
|
||||
{
|
||||
MethodDef = method.Method,
|
||||
ReturnInfo = new ReturnInfo { Type = _typeCreator.CreateTypeInfo(method.Method.ReturnType) },
|
||||
ParamInfos = method.Method.Parameters.Select(p => new ParamInfo { Type = _typeCreator.CreateTypeInfo(p.Type) }).ToList(),
|
||||
};
|
||||
sharedMethod.Init();
|
||||
sharedMethod = ToIsomorphicMethod(sharedMethod);
|
||||
|
||||
CallingConvention callingConv = GetCallingConvention(method.Method);
|
||||
string signature = MakeSignature(sharedMethod, callingConv);
|
||||
|
||||
if (!methodsBySig.TryGetValue(signature, out var arm))
|
||||
{
|
||||
arm = new ABIReversePInvokeMethodInfo()
|
||||
{
|
||||
Method = sharedMethod,
|
||||
Signature = signature,
|
||||
Count = 0,
|
||||
Callvention = callingConv,
|
||||
};
|
||||
methodsBySig.Add(signature, arm);
|
||||
}
|
||||
int preserveCount = method.GenerationAttribute != null ? (int)method.GenerationAttribute.ConstructorArguments[0].Value : 1;
|
||||
arm.Count += preserveCount;
|
||||
}
|
||||
var newMethods = methodsBySig.Values.ToList();
|
||||
newMethods.Sort((a, b) => string.CompareOrdinal(a.Signature, b.Signature));
|
||||
return newMethods;
|
||||
}
|
||||
|
||||
private void BuildOptimizedMethods()
|
||||
{
|
||||
_managed2NativeMethodList = ToUniqueOrderedList(_managed2NativeMethodList0);
|
||||
_native2ManagedMethodList = ToUniqueOrderedList(_native2ManagedMethodList0);
|
||||
_adjustThunkMethodList = ToUniqueOrderedList(_adjustThunkMethodList0);
|
||||
_reversePInvokeMethods = BuildABIMethods(_originalReversePInvokeMethods);
|
||||
}
|
||||
|
||||
private void OptimizationTypesAndMethods()
|
||||
@@ -389,7 +520,12 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
var frr = new FileRegionReplace(_templateCode);
|
||||
|
||||
List<string> lines = new List<string>(20_0000);
|
||||
List<string> lines = new List<string>(20_0000)
|
||||
{
|
||||
"\n",
|
||||
$"// DEVELOPMENT={(_development ? 1 : 0)}",
|
||||
"\n"
|
||||
};
|
||||
|
||||
var classInfos = new List<ClassInfo>();
|
||||
var classTypeSet = new HashSet<TypeInfo>();
|
||||
@@ -424,6 +560,8 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
GenerateAdjustThunkStub(_adjustThunkMethodList, lines);
|
||||
|
||||
GenerateReversePInvokeWrappers(_reversePInvokeMethods, lines);
|
||||
|
||||
frr.Replace("CODE", string.Join("\n", lines));
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_outputFile));
|
||||
@@ -431,8 +569,69 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
frr.Commit(_outputFile);
|
||||
}
|
||||
|
||||
private static string GetIl2cppCallConventionName(CallingConvention conv)
|
||||
{
|
||||
switch (conv)
|
||||
{
|
||||
case 0:
|
||||
case CallingConvention.Winapi:
|
||||
return "DEFAULT_CALL";
|
||||
case CallingConvention.Cdecl:
|
||||
return "CDECL";
|
||||
case CallingConvention.StdCall:
|
||||
return "STDCALL";
|
||||
case CallingConvention.ThisCall:
|
||||
return "THISCALL";
|
||||
case CallingConvention.FastCall:
|
||||
return "FASTCALL";
|
||||
default:
|
||||
throw new NotSupportedException($"Unsupported CallingConvention {conv}");
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateReversePInvokeWrappers(List<ABIReversePInvokeMethodInfo> methods, List<string> lines)
|
||||
{
|
||||
int methodIndex = 0;
|
||||
var stubCodes = new List<string>();
|
||||
foreach (var methodInfo in methods)
|
||||
{
|
||||
MethodDesc method = methodInfo.Method;
|
||||
string il2cppCallConventionName = GetIl2cppCallConventionName(methodInfo.Callvention);
|
||||
string paramDeclaringListWithoutMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}"));
|
||||
string paramNameListWithoutMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"__arg{p.Index}").Concat(new string[] { "method" }));
|
||||
string paramTypeListWithMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()}").Concat(new string[] { "const MethodInfo*" }));
|
||||
string methodTypeDef = $"typedef {method.ReturnInfo.Type.GetTypeName()} (*Callback)({paramTypeListWithMethodInfoStr})";
|
||||
for (int i = 0; i < methodInfo.Count; i++, methodIndex++)
|
||||
{
|
||||
lines.Add($@"
|
||||
{method.ReturnInfo.Type.GetTypeName()} {il2cppCallConventionName} __ReversePInvokeMethod_{methodIndex}({paramDeclaringListWithoutMethodInfoStr})
|
||||
{{
|
||||
il2cpp::vm::ScopedThreadAttacher _vmThreadHelper;
|
||||
const MethodInfo* method = InterpreterModule::GetMethodInfoByReversePInvokeWrapperIndex({methodIndex});
|
||||
{methodTypeDef};
|
||||
{(method.ReturnInfo.IsVoid ? "" : "return ")}((Callback)(method->methodPointerCallByInterp))({paramNameListWithoutMethodInfoStr});
|
||||
}}
|
||||
");
|
||||
stubCodes.Add($"\t{{\"{methodInfo.Signature}\", (Il2CppMethodPointer)__ReversePInvokeMethod_{methodIndex}}},");
|
||||
}
|
||||
Debug.Log($"[ReversePInvokeWrap.Generator] method:{method.MethodDef} wrapperCount:{methodInfo.Count}");
|
||||
}
|
||||
|
||||
lines.Add(@"
|
||||
const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStub[]
|
||||
{
|
||||
");
|
||||
lines.AddRange(stubCodes);
|
||||
|
||||
lines.Add(@"
|
||||
{nullptr, nullptr},
|
||||
};
|
||||
");
|
||||
}
|
||||
|
||||
public void Generate()
|
||||
{
|
||||
PrepareMethodBridges();
|
||||
CollectTypesAndMethods();
|
||||
OptimizationTypesAndMethods();
|
||||
GenerateCode();
|
||||
@@ -678,7 +877,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
public void GenerateStructureSignatureStub(List<TypeInfo> types, List<string> lines)
|
||||
{
|
||||
lines.Add("FullName2Signature hybridclr::interpreter::g_fullName2SignatureStub[] = {");
|
||||
lines.Add("const FullName2Signature hybridclr::interpreter::g_fullName2SignatureStub[] = {");
|
||||
foreach (var type in types)
|
||||
{
|
||||
TypeInfo isoType = ToIsomorphicType(type);
|
||||
@@ -691,7 +890,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
public void GenerateManaged2NativeStub(List<MethodDesc> methods, List<string> lines)
|
||||
{
|
||||
lines.Add($@"
|
||||
Managed2NativeMethodInfo hybridclr::interpreter::g_managed2nativeStub[] =
|
||||
const Managed2NativeMethodInfo hybridclr::interpreter::g_managed2nativeStub[] =
|
||||
{{
|
||||
");
|
||||
|
||||
@@ -707,7 +906,7 @@ Managed2NativeMethodInfo hybridclr::interpreter::g_managed2nativeStub[] =
|
||||
public void GenerateNative2ManagedStub(List<MethodDesc> methods, List<string> lines)
|
||||
{
|
||||
lines.Add($@"
|
||||
Native2ManagedMethodInfo hybridclr::interpreter::g_native2managedStub[] =
|
||||
const Native2ManagedMethodInfo hybridclr::interpreter::g_native2managedStub[] =
|
||||
{{
|
||||
");
|
||||
|
||||
@@ -723,7 +922,7 @@ Native2ManagedMethodInfo hybridclr::interpreter::g_native2managedStub[] =
|
||||
public void GenerateAdjustThunkStub(List<MethodDesc> methods, List<string> lines)
|
||||
{
|
||||
lines.Add($@"
|
||||
NativeAdjustThunkMethodInfo hybridclr::interpreter::g_adjustThunkStub[] =
|
||||
const NativeAdjustThunkMethodInfo hybridclr::interpreter::g_adjustThunkStub[] =
|
||||
{{
|
||||
");
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CallingConvention = System.Runtime.InteropServices.CallingConvention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
@@ -21,7 +22,11 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
{
|
||||
public MethodDesc Method { get; set; }
|
||||
|
||||
public CallingConvention Callvention { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
public string Signature { get; set; }
|
||||
}
|
||||
|
||||
public class Analyzer
|
||||
@@ -31,6 +36,8 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
|
||||
private readonly List<RawReversePInvokeMethodInfo> _reversePInvokeMethods = new List<RawReversePInvokeMethodInfo>();
|
||||
|
||||
public List<RawReversePInvokeMethodInfo> ReversePInvokeMethods => _reversePInvokeMethods;
|
||||
|
||||
public Analyzer(AssemblyCache cache, List<string> assemblyNames)
|
||||
{
|
||||
foreach (var assemblyName in assemblyNames)
|
||||
@@ -70,36 +77,6 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
}
|
||||
}
|
||||
|
||||
public List<ABIReversePInvokeMethodInfo> BuildABIMethods()
|
||||
{
|
||||
var methodsBySig = new Dictionary<string, ABIReversePInvokeMethodInfo>();
|
||||
var typeCreator = new TypeCreator();
|
||||
foreach(var method in _reversePInvokeMethods)
|
||||
{
|
||||
MethodDesc desc = new MethodDesc
|
||||
{
|
||||
MethodDef = method.Method,
|
||||
ReturnInfo = new ReturnInfo { Type = typeCreator.CreateTypeInfo(method.Method.ReturnType)},
|
||||
ParamInfos = method.Method.Parameters.Select(p => new ParamInfo { Type = typeCreator.CreateTypeInfo(p.Type)}).ToList(),
|
||||
};
|
||||
desc.Init();
|
||||
if (!methodsBySig.TryGetValue(desc.Sig, out var arm))
|
||||
{
|
||||
arm = new ABIReversePInvokeMethodInfo()
|
||||
{
|
||||
Method = desc,
|
||||
Count = 0,
|
||||
};
|
||||
methodsBySig.Add(desc.Sig, arm);
|
||||
}
|
||||
int preserveCount = method.GenerationAttribute != null ? (int)method.GenerationAttribute.ConstructorArguments[0].Value : 1;
|
||||
arm.Count += preserveCount;
|
||||
}
|
||||
var methods = methodsBySig.Values.ToList();
|
||||
methods.Sort((a, b) => String.CompareOrdinal(a.Method.Sig, b.Method.Sig));
|
||||
return methods;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
CollectReversePInvokeMethods();
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
using HybridCLR.Editor.ABI;
|
||||
using HybridCLR.Editor.Template;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
{
|
||||
public class Generator
|
||||
{
|
||||
public void Generate(List<ABIReversePInvokeMethodInfo> methods, string outputFile)
|
||||
{
|
||||
string template = File.ReadAllText(outputFile, Encoding.UTF8);
|
||||
var frr = new FileRegionReplace(template);
|
||||
var codes = new List<string>();
|
||||
|
||||
int methodIndex = 0;
|
||||
var stubCodes = new List<string>();
|
||||
foreach(var methodInfo in methods)
|
||||
{
|
||||
MethodDesc method = methodInfo.Method;
|
||||
string paramDeclaringListWithoutMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}"));
|
||||
string paramNameListWithoutMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"__arg{p.Index}").Concat(new string[] { "method" }));
|
||||
string paramTypeListWithMethodInfoStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()}").Concat(new string[] { "const MethodInfo*" }));
|
||||
string methodTypeDef = $"typedef {method.ReturnInfo.Type.GetTypeName()} (*Callback)({paramTypeListWithMethodInfoStr})";
|
||||
for (int i = 0; i < methodInfo.Count; i++, methodIndex++)
|
||||
{
|
||||
codes.Add($@"
|
||||
{method.ReturnInfo.Type.GetTypeName()} __ReversePInvokeMethod_{methodIndex}({paramDeclaringListWithoutMethodInfoStr})
|
||||
{{
|
||||
const MethodInfo* method = MetadataModule::GetMethodInfoByReversePInvokeWrapperIndex({methodIndex});
|
||||
{methodTypeDef};
|
||||
{(method.ReturnInfo.IsVoid ? "" : "return ")}((Callback)(method->methodPointerCallByInterp))({paramNameListWithoutMethodInfoStr});
|
||||
}}
|
||||
");
|
||||
stubCodes.Add($"\t\t{{\"{method.Sig}\", (Il2CppMethodPointer)__ReversePInvokeMethod_{methodIndex}}},\n");
|
||||
}
|
||||
Debug.Log($"[ReversePInvokeWrap.Generator] method:{method.MethodDef} wrapperCount:{methodInfo.Count}");
|
||||
}
|
||||
|
||||
codes.Add(@"
|
||||
ReversePInvokeMethodData g_reversePInvokeMethodStub[]
|
||||
{
|
||||
");
|
||||
codes.AddRange(stubCodes);
|
||||
|
||||
codes.Add(@"
|
||||
{nullptr, nullptr},
|
||||
};
|
||||
");
|
||||
|
||||
frr.Replace("CODE", string.Join("", codes));
|
||||
frr.Commit(outputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d883f182f206fa4db31f4085ce0ecdc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,9 +6,6 @@ using UnityEditorInternal;
|
||||
namespace HybridCLR.Editor.Settings
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 监听编辑器状态,当编辑器重新 focus 时,重新加载实例,避免某些情景下 svn 、git 等外部修改了数据却无法同步的异常。
|
||||
/// </summary>
|
||||
[InitializeOnLoad]
|
||||
public static class EditorStatusWatcher
|
||||
{
|
||||
|
||||
@@ -25,6 +25,9 @@ namespace HybridCLR.Editor.Settings
|
||||
private SerializedProperty _outputAOTGenericReferenceFile;
|
||||
private SerializedProperty _maxGenericReferenceIteration;
|
||||
private SerializedProperty _maxMethodBridgeGenericIteration;
|
||||
private SerializedProperty _enableProfilerInReleaseBuild;
|
||||
private SerializedProperty enableStraceTraceInWebGLReleaseBuild;
|
||||
|
||||
private GUIStyle buttonStyle;
|
||||
public HybridCLRSettingsProvider() : base("Project/HybridCLR Settings", SettingsScope.Project) { }
|
||||
public override void OnActivate(string searchContext, VisualElement rootElement)
|
||||
@@ -52,6 +55,8 @@ namespace HybridCLR.Editor.Settings
|
||||
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
|
||||
_maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration");
|
||||
_maxMethodBridgeGenericIteration = _serializedObject.FindProperty("maxMethodBridgeGenericIteration");
|
||||
_enableProfilerInReleaseBuild = _serializedObject.FindProperty("enableProfilerInReleaseBuild");
|
||||
enableStraceTraceInWebGLReleaseBuild = _serializedObject.FindProperty("enableStraceTraceInWebGLReleaseBuild");
|
||||
}
|
||||
private void OnEditorFocused()
|
||||
{
|
||||
@@ -73,7 +78,7 @@ namespace HybridCLR.Editor.Settings
|
||||
content.tooltip = "点击访问 HybridCLR 官方文档";
|
||||
if (GUI.Button(rect, content, buttonStyle))
|
||||
{
|
||||
Application.OpenURL("https://focus-creative-games.github.io/hybridclr/");
|
||||
Application.OpenURL("https://hybridclr.doc.code-philosophy.com/");
|
||||
}
|
||||
#endregion
|
||||
#region 绘制 Preset
|
||||
@@ -118,7 +123,6 @@ namespace HybridCLR.Editor.Settings
|
||||
{
|
||||
using (CreateSettingsWindowGUIScope())
|
||||
{
|
||||
//解决编辑器打包时出现的 _serializedObject.targetObject 意外销毁的情况
|
||||
if (_serializedObject == null||!_serializedObject.targetObject)
|
||||
{
|
||||
InitGUI();
|
||||
@@ -140,6 +144,8 @@ namespace HybridCLR.Editor.Settings
|
||||
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
|
||||
EditorGUILayout.PropertyField(_maxGenericReferenceIteration);
|
||||
EditorGUILayout.PropertyField(_maxMethodBridgeGenericIteration);
|
||||
EditorGUILayout.PropertyField(_enableProfilerInReleaseBuild);
|
||||
EditorGUILayout.PropertyField(enableStraceTraceInWebGLReleaseBuild);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
_serializedObject.ApplyModifiedProperties();
|
||||
|
||||
@@ -6,49 +6,55 @@ namespace HybridCLR.Editor.Settings
|
||||
[FilePath("ProjectSettings/HybridCLRSettings.asset")]
|
||||
public class HybridCLRSettings : ScriptableSingleton<HybridCLRSettings>
|
||||
{
|
||||
[Header("开启HybridCLR插件")]
|
||||
[Tooltip("enable HybridCLR")]
|
||||
public bool enable = true;
|
||||
|
||||
[Header("使用全局安装的il2cpp")]
|
||||
[Tooltip("use il2cpp in unity editor installation location")]
|
||||
public bool useGlobalIl2cpp;
|
||||
|
||||
[Header("hybridclr 仓库 URL")]
|
||||
[Tooltip("hybridclr repo URL")]
|
||||
public string hybridclrRepoURL = "https://gitee.com/focus-creative-games/hybridclr";
|
||||
|
||||
[Header("il2cpp_plus 仓库 URL")]
|
||||
[Tooltip("il2cpp_plus repo URL")]
|
||||
public string il2cppPlusRepoURL = "https://gitee.com/focus-creative-games/il2cpp_plus";
|
||||
|
||||
[Header("热更新Assembly Definitions")]
|
||||
[Tooltip("hot update assembly definitions(asd)")]
|
||||
public AssemblyDefinitionAsset[] hotUpdateAssemblyDefinitions;
|
||||
|
||||
[Header("热更新dlls")]
|
||||
[Tooltip("hot update assembly names(without .dll suffix)")]
|
||||
public string[] hotUpdateAssemblies;
|
||||
|
||||
[Header("预留的热更新dlls")]
|
||||
[Tooltip("preserved hot update assembly names(without .dll suffix)")]
|
||||
public string[] preserveHotUpdateAssemblies;
|
||||
|
||||
[Header("热更新dll编译输出根目录")]
|
||||
[Tooltip("output directory of compiling hot update assemblies")]
|
||||
public string hotUpdateDllCompileOutputRootDir = "HybridCLRData/HotUpdateDlls";
|
||||
|
||||
[Header("外部热更新dll搜索路径")]
|
||||
[Tooltip("searching paths of external hot update assemblies")]
|
||||
public string[] externalHotUpdateAssembliyDirs;
|
||||
|
||||
[Header("裁减后AOT dll输出根目录")]
|
||||
[Tooltip("output directory of stripped AOT assemblies")]
|
||||
public string strippedAOTDllOutputRootDir = "HybridCLRData/AssembliesPostIl2CppStrip";
|
||||
|
||||
[Header("补充元数据AOT dlls")]
|
||||
[Tooltip("supplementary metadata assembly names(without .dll suffix)")]
|
||||
public string[] patchAOTAssemblies;
|
||||
|
||||
[Header("生成的link.xml路径")]
|
||||
[Tooltip("output file of automatic generated link.xml by scanning hot update assemblies")]
|
||||
public string outputLinkFile = "HybridCLRGenerate/link.xml";
|
||||
|
||||
[Header("自动扫描生成的AOTGenericReferences.cs路径")]
|
||||
[Tooltip("output file of automatic generated AOTGenericReferences.cs")]
|
||||
public string outputAOTGenericReferenceFile = "HybridCLRGenerate/AOTGenericReferences.cs";
|
||||
|
||||
[Header("AOT泛型实例化搜索迭代次数")]
|
||||
[Tooltip("max iteration count of searching generic methods in hot update assemblies")]
|
||||
public int maxGenericReferenceIteration = 10;
|
||||
|
||||
[Header("MethodBridge泛型搜索迭代次数")]
|
||||
[Tooltip("max iteration count of searching method bridge generic methods in AOT assemblies")]
|
||||
public int maxMethodBridgeGenericIteration = 10;
|
||||
|
||||
[Tooltip("enable profiler support when publishing in release mode")]
|
||||
public bool enableProfilerInReleaseBuild = false;
|
||||
|
||||
[Tooltip("enable StraceTrace support when publishing to the WebGL platform in release mode")]
|
||||
public bool enableStraceTraceInWebGLReleaseBuild = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,6 @@ namespace HybridCLR.Editor
|
||||
public string name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 热更新dll列表。不包含 preserveHotUpdateAssemblies。
|
||||
/// </summary>
|
||||
public static List<string> HotUpdateAssemblyNamesExcludePreserved
|
||||
{
|
||||
get
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
|
||||
- [README 中文](./README_zh.md)
|
||||
- [README English](./README.md)
|
||||
- [README 中文](./README.md)
|
||||
- [README English](./README_EN.md)
|
||||
|
||||
# HybridCLR
|
||||
|
||||
@@ -11,81 +10,78 @@
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
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是一个**特性完整、零成本、高性能、低内存**的**近乎完美**的Unity全平台原生c#热更新解决方案。
|
||||
|
||||
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扩充了il2cpp运行时代码,使它由纯[AOT](https://en.wikipedia.org/wiki/Ahead-of-time_compilation) runtime变成AOT+Interpreter 混合runtime,进而原生支持动态加载assembly,从底层彻底支持了热更新。使用HybridCLR技术的游戏不仅能在Android平台,也能在IOS、Consoles、WebGL等所有il2cpp支持的平台上高效运行。
|
||||
|
||||
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/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.
|
||||
由于HybridCLR对ECMA-335规范 的良好支持以及对Unity开发工作流的高度兼容,Unity项目在接入HybridCLR后,可以几乎无缝地获得C#代码热更新的能力,开发者不需要改变日常开发习惯和要求。HybridCLR首次实现了将Unity平台的全平台代码热更新方案的工程难度降到几乎为零的水平。
|
||||
|
||||
Welcome to embrace modern native C# hot update technology! ! !
|
||||
欢迎拥抱现代原生C#热更新技术 !!!
|
||||
|
||||
## 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)
|
||||
- [官方文档](https://hybridclr.doc.code-philosophy.com/docs/intro)
|
||||
- [快速上手](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)
|
||||
- [商业项目案例](https://hybridclr.doc.code-philosophy.com/docs/other/businesscase)
|
||||
|
||||
## 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/differentialhybridexecution)
|
||||
## 特性
|
||||
|
||||
## Working Principle
|
||||
- 近乎完整实现了[ECMA-335规范](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/),只有极少量的[不支持的特性](https://hybridclr.doc.code-philosophy.com/docs/basic/notsupportedfeatures)。
|
||||
- 零学习和使用成本。对绝大多数开发者来说写代码近乎没有限制。 热更新代码与AOT代码无缝工作,可以随意写继承、**泛型**、**反射**之类的代码。不需要额外写任何特殊代码、没有代码生成
|
||||
- 完全支持多线程,包含但不限于 volatile、ThreadStatic、async Task等相关功能和特性。这是其他所有热更新方案都不支持的
|
||||
- 几乎完全兼容Unity的工作流。包括且不限于支持热更新**MonoBehaviour**、ScriptableObject、**DOTS**技术,资源上挂载的热更新脚本可以正确实例化,这是其他所有热更新方案都不支持的
|
||||
- 执行高效。实现了一个极其高效的寄存器解释器,所有指标都大幅优于其他热更新方案。[性能测试报告](https://hybridclr.doc.code-philosophy.com/docs/basic/performance)
|
||||
- 内存高效。 热更新脚本中定义的类跟普通c#类占用一样的内存空间,远优于其他热更新方案。[内存占用报告](https://hybridclr.doc.code-philosophy.com/docs/basic/memory)
|
||||
- 支持MonoPInvokeCallback,可以与native代码或者其他语言如lua、javascript、python良好交互
|
||||
- 支持一些il2cpp不支持的特性,如__makeref、 __reftype、__refvalue指令
|
||||
- 支持独创的 **Differential Hybrid Execution(DHE)** 差分混合执行技术,即可以对AOT dll任意增删改,会智能地让未改动的函数以AOT方式运行,变化或者新增的函数以interpreter模式运行,让热更新的游戏逻辑的运行性能基本达到原生AOT的水平
|
||||
- 支持 **热重载** 技术,可以100%卸载程序集
|
||||
- 支持现代的dll加密技术,有效保障代码安全
|
||||
|
||||
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.
|
||||
## 支持的版本与平台
|
||||
|
||||
- 支持2019.4.x、2020.3.x、2021.3.x、2022.3.x、2023.2.x、6000.0.x全系列LTS版本
|
||||
- 支持所有il2cpp支持的平台
|
||||
- 支持团结引擎和鸿蒙平台
|
||||
|
||||
## 工作原理
|
||||
|
||||
HybridCLR从mono的 [mixed mode execution](https://www.mono-project.com/news/2017/11/13/mono-interpreter/) 技术中得到启发,为unity的il2cpp之类的AOT runtime额外提供了interpreter模块,将它们由纯AOT运行时改造为"AOT + Interpreter"混合运行方式。
|
||||
|
||||

|
||||
|
||||
More specifically, HybridCLR does the following:
|
||||
更具体地说,HybridCLR做了以下几点工作:
|
||||
|
||||
- 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
|
||||
- 实现了一个高效的元数据(dll)解析库
|
||||
- 改造了元数据管理模块,实现了元数据的动态注册
|
||||
- 实现了一个IL指令集到自定义的寄存器指令集的compiler
|
||||
- 实现了一个高效的寄存器解释器
|
||||
- 额外提供大量的instinct函数,提升解释器性能
|
||||
|
||||
## The Difference From Other C# Hot-Update Solution
|
||||
## 稳定性状况
|
||||
|
||||
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.
|
||||
HybridCLR已经被广泛验证是非常高效、稳定的Unity热更新解决方案,良好满足大中型商业项目的稳定和性能要求。
|
||||
|
||||
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.
|
||||
目前已经有数千个商业游戏项目接入了HybridCLR,其中有超过千个已经在App Store和Google Player上线,仅仅iOS免费榜前500名中就有近百款使用了HybridCLR。上线的项目中包括MMORPG、重度卡牌、重度塔防之类的游戏。国内绝大多数**Top游戏公司**都已经在使用HybridCLR。
|
||||
|
||||
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.
|
||||
可查看我们已知的头部公司中使用HybridCLR并且已经上线的[项目列表](https://hybridclr.doc.code-philosophy.com/docs/other/businesscase)。
|
||||
|
||||
## Supported Versions And Platforms
|
||||
## 支持与联系
|
||||
|
||||
- Support 2019.4.x, 2020.3.x, 2021.3.x, 2022.3.x full series of LTS versions. The `2023.2.0ax` version is also supported, but not released to the public.
|
||||
- Supports all il2cpp supported platforms
|
||||
- 官方1群:651188171(满)
|
||||
- 新手1群:428404198(满)
|
||||
- 新手2群:**680274677(推荐)**
|
||||
- discord频道 https://discord.gg/BATfNfJnm2
|
||||
- 商业合作邮箱: business#code-philosophy.com
|
||||
- [商业化支持](https://hybridclr.doc.code-philosophy.com/docs/business/intro)
|
||||
|
||||
## Stability Status
|
||||
## 关于作者
|
||||
|
||||
HybridCLR has been widely verified as a very efficient and stable solution for hot update of Unity.
|
||||
**walon** :**Code Philosophy(代码哲学)** 创始人
|
||||
|
||||
The official versions of **extremely stable** 1.x, 2.x, and 3.x are currently released, which are sufficient to meet the stability requirements of large and medium-sized commercial projects.
|
||||
At present, at least thousands of commercial game projects have been integrated, and hundreds of them have been launched on both ends. The online projects include MMORPG, heavy card, heavy tower defense and other games. **Most top game companies** (such as Tencent and NetEase) are already using HybridCLR.
|
||||
毕业于清华大学物理系,2006年CMO金牌,奥数国家集训队成员,保送清华基科班。专注于游戏技术,擅长开发架构和基础技术设施。
|
||||
|
||||
You can read the [game projects in top game companies](https://hybridclr.doc.code-philosophy.com/en/docs/other/businesscase) those are using HybridCLR and has been launched.
|
||||
|
||||
## Support And Contact
|
||||
|
||||
- Official 1 group: 651188171 (full)
|
||||
- Novice QQ group 1: 428404198 (full)
|
||||
- Novice QQ group 2: **680274677 (recommended)**
|
||||
- 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
|
||||
## license
|
||||
|
||||
HybridCLR is licensed under the [MIT](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE) license
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
|
||||
- [README Chinese](./README.md)
|
||||
- [README English](./README_EN.md)
|
||||
|
||||
# HybridCLR
|
||||
|
||||
[](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE)
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
HybridCLR is a **feature-complete, zero-cost, high-performance, low-memory** **near-perfect** Unity cross-platform native C# hot update solution.
|
||||
|
||||
HybridCLR extends the il2cpp runtime code, transforming it from a pure [AOT](https://en.wikipedia.org/wiki/Ahead-of-time_compilation) runtime to an AOT+Interpreter hybrid runtime, thereby natively supporting the dynamic loading of assemblies and fundamentally supporting hot updates from the bottom layer. Games using HybridCLR technology can not only run efficiently on the Android platform but also on all platforms supported by il2cpp, including iOS, Consoles, WebGL, etc.
|
||||
|
||||
Thanks to HybridCLR's good support for the ECMA-335 specification and its high compatibility with the Unity development workflow, Unity projects can almost seamlessly gain the ability to hot update C# code after integrating HybridCLR. Developers do not need to change their daily development habits and requirements. HybridCLR is the first to achieve the engineering difficulty of a full-platform code hot update solution for the Unity platform to almost zero.
|
||||
|
||||
Welcome to embrace modern native C# hot update technology!
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Official Documentation](https://hybridclr.doc.code-philosophy.com/en/docs/intro)
|
||||
- [Quick Start](https://hybridclr.doc.code-philosophy.com/en/docs/beginner/quickstart)
|
||||
- [Business Project Cases](https://hybridclr.doc.code-philosophy.com/en/docs/other/businesscase)
|
||||
|
||||
## Features
|
||||
|
||||
- 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 usage costs. For most developers, writing code is almost unrestricted. Hot update code works seamlessly with AOT code, allowing for inheritance, **generics**, **reflection**, and other code without additional special code or code generation.
|
||||
- Full support for multithreading, including but not limited to volatile, ThreadStatic, async Task, and related features and characteristics. This is not supported by any other hot update solution.
|
||||
- Almost complete compatibility with Unity's workflow. This includes support for hot updating **MonoBehaviour**, ScriptableObject, **DOTS** technology, and correctly instantiating hot update scripts mounted on resources, which is not supported by any other hot update solution.
|
||||
- Efficient execution. A highly efficient register interpreter has been implemented, with all indicators significantly better than other hot update solutions. [Performance Test Report](https://hybridclr.doc.code-philosophy.com/en/docs/basic/performance)
|
||||
- Efficient memory usage. Classes defined in hot update scripts occupy the same memory space as ordinary C# classes, far superior to other hot update solutions. [Memory Usage Report](https://hybridclr.doc.code-philosophy.com/en/docs/basic/memory)
|
||||
- Supports MonoPInvokeCallback, enabling good interaction with native code or other languages such as Lua, JavaScript, Python.
|
||||
- Supports some features not supported by il2cpp, such as __makeref, __reftype, __refvalue instructions.
|
||||
- Supports the unique **Differential Hybrid Execution (DHE)** technology, which allows for arbitrary additions, deletions, and modifications to AOT DLLs. It intelligently runs unchanged functions in AOT mode and changed or newly added functions in interpreter mode, bringing the performance of hot-updated game logic close to that of native AOT.
|
||||
- Supports **hot reload** technology, allowing 100% unloading of assemblies.
|
||||
- Supports modern DLL encryption technology to effectively protect code security.
|
||||
|
||||
## Supported Versions and Platforms
|
||||
|
||||
- Supports all LTS versions including 2019.4.x, 2020.3.x, 2021.3.x, 2022.3.x, 2023.2.x, 6000.0.x.
|
||||
- Supports all platforms supported by il2cpp.
|
||||
- Supports Tuanjie(China) Engine and HarmonyOS platform.
|
||||
|
||||
## Working Principle
|
||||
|
||||
HybridCLR draws inspiration from Mono's [mixed mode execution](https://www.mono-project.com/news/2017/11/13/mono-interpreter/) technology, providing an interpreter module for AOT runtimes like Unity's il2cpp, transforming them from pure AOT runtimes to "AOT + Interpreter" hybrid operation modes.
|
||||
|
||||

|
||||
|
||||
More specifically, HybridCLR has done the following:
|
||||
|
||||
- Implemented an efficient metadata (dll) parsing library.
|
||||
- Modified the metadata management module to achieve dynamic registration of metadata.
|
||||
- Implemented a compiler that converts IL instructions to a custom register instruction set.
|
||||
- Implemented an efficient register interpreter.
|
||||
- Provided a large number of instinct functions to enhance interpreter performance.
|
||||
|
||||
## Stability Status
|
||||
|
||||
HybridCLR has been widely verified as an efficient and stable Unity hot update solution, meeting the stability and performance requirements of medium and large commercial projects.
|
||||
|
||||
Currently, thousands of commercial game projects have integrated HybridCLR, with over a thousand already launched on the App Store and Google Play. Nearly a hundred of the top 500 free iOS games use HybridCLR, including MMORPGs, heavy card games, and heavy tower defense games. Most of the **Top Game Companies** in China are already using HybridCLR.
|
||||
|
||||
You can view the [list of known top companies using HybridCLR and their launched projects](https://hybridclr.doc.code-philosophy.com/en/docs/other/businesscase).
|
||||
|
||||
## Support and Contact
|
||||
|
||||
- Official Group 1: 651188171 (Full)
|
||||
- Beginner Group 1: 428404198 (Full)
|
||||
- Beginner Group 2: **680274677 (Recommended)**
|
||||
- Discord channel 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 (代码哲学)**
|
||||
|
||||
Graduated from the Department of Physics at Tsinghua University, gold medalist of the 2006 CMO, member of the National Mathematical Olympiad Training Team, and sent to the Basic Science Class of Tsinghua. Focused on game technology, proficient in development architecture and basic technical infrastructure.
|
||||
|
||||
## License
|
||||
|
||||
HybridCLR is licensed under the [MIT](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE) license.
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52688f4469ff9454e8c3d8aaf045d9f4
|
||||
guid: c9e34f237251ef44193538977db6b15f
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -1,91 +0,0 @@
|
||||
- [README 中文](./README_zh.md)
|
||||
- [README English](./README.md)
|
||||
|
||||
# HybridCLR
|
||||
|
||||
[](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE)
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
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/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/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全系列LTS版本。`2023.2.0ax`版本也已支持,但未对外发布。
|
||||
- 支持所有il2cpp支持的平台
|
||||
|
||||
## 稳定性状况
|
||||
|
||||
HybridCLR已经被广泛验证是非常高效、稳定的Unity热更新解决方案。
|
||||
|
||||
当前发布了**极其稳定**的1.x、2.x、3.x正式版本,足以满足大中型商业项目的稳定性要求。
|
||||
目前至少有上千个商业游戏项目完成接入,其中有几百款已经双端上线,上线的项目中包括MMORPG、重度卡牌、重度塔防之类的游戏。**绝大多数头部游戏公司**(如腾讯、网易)都已经在使用HybridCLR。
|
||||
|
||||
可查看我们已知的头部公司中使用HybridCLR并且已经上线的[项目列表](https://hybridclr.doc.code-philosophy.com/docs/other/businesscase)。
|
||||
|
||||
|
||||
## 支持与联系
|
||||
|
||||
- 官方1群:651188171(满)
|
||||
- 新手1群:428404198(满)
|
||||
- 新手2群:**680274677(推荐)**
|
||||
- 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
|
||||
+502
-209
@@ -1,451 +1,742 @@
|
||||
# 发布日志
|
||||
# ReleaseLog
|
||||
|
||||
## 7.2.0
|
||||
|
||||
Release Date: 2024-12-9.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] fix a critical bug in Image::ReadArrayType, where it incorrectly uses alloca to allocate Il2CppArray's sizes and lobounds data.
|
||||
- [merge] merge il2cpp changes from 2022.3.51f1 to 2022.3.54f1
|
||||
- [merge] merge il2cpp changes from 6000.0.21 to 6000.0.30
|
||||
|
||||
## 7.1.0
|
||||
|
||||
Release Date: 2024-12-4.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] support prejit interpreter class and method
|
||||
- [new] add RuntimeOptionId::MaxInlineableMethodBodySize
|
||||
- [merge] merge il2cpp changes from tuanjie v1.3.1 to v1.3.4
|
||||
- [fix] fix memory leak of TransformContext::irbbs and ir2offsetMap
|
||||
- [opt] does not insert CheckThrowIfNull check when inlining constructors
|
||||
- [opt] remove unnecessary typeSize calculation from the NewValueTypeInterpVar instruction.
|
||||
- [change] change default maxInlineableMethodBodySize from 16 to 32
|
||||
- [change] remove the unnecessary Inflate operation on arg.type when initializing ArgVarInfo in TransformContext::TransformBodyImpl.
|
||||
- [change] remove unnecessary fields genericContext, klassContainer, methodContainer from the TransformContext
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] support prejit interpreter class and method
|
||||
- [new] add RuntimeOptionId::MaxInlineableMethodBodySize
|
||||
- [fix] fix the bug that CopyStrippedAOTAssemblies didn't work on UWP platform of 6000.0.x
|
||||
- [fix] fix the issue that CopyStrippedAOTAssemblies didn't support HMIAndroid in tuanjie engine
|
||||
- [change] change the attributes on fields of HybridCLRSettings from `[Header]` to `[ToolTip]`
|
||||
- [refactor] refactor code comments and translate them to English
|
||||
|
||||
## 7.0.0
|
||||
|
||||
Release Date: 2024-11-15.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] support method inlining
|
||||
- [refactor] refactor Transform codes
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] add option RuntimeOptionId::MaxMethodBodyCacheSize and RuntimeOptionId::MaxMethodInlineDepth
|
||||
- [fix] fix the bug in GenericReferenceWriter where _systemTypePattern did not properly escape the '.' in type names. This caused issues when compiler-generated anonymous types and functions contained string sequences like 'System-Int', incorrectly matching them to 'System.Int', resulting in runtime exceptions.
|
||||
- [fix] fix the bug in `MissingMetadataChecker` where it did not check for missing fields.
|
||||
|
||||
## 6.11.0
|
||||
|
||||
Release Date: 2024-10-31.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [merge] Merges changes from Tuanjie versions 1.3.0 to 1.3.1
|
||||
- [merge] Merges il2cpp code changes from version 2022.3.48f1 to 2022.3.51f1
|
||||
|
||||
## 6.10.1
|
||||
|
||||
Release Date: 2024-10-24.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] Fixs HookUtils compile errors in Unity 2019 and 2020
|
||||
- [change] remove README_zh.md.meta, add README_EN.md.meta
|
||||
|
||||
## 6.10.0
|
||||
|
||||
Release Date: 2024-10-23.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] Officially supports 6000.0.23f LTS version
|
||||
- [merge] Merges changes from Tuanjie versions 1.2.6 to 1.3.0
|
||||
- [fix] Fixed an issue in MonoHook where processorType was not handled correctly on some CPUs when the processorType was returned in all uppercase (e.g., some machines return 'INTEL' instead of 'Intel').
|
||||
|
||||
## 6.9.0
|
||||
|
||||
Release Date: 2024-9-30.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] Fixes the bug where thrown exceptions did not call `il2cpp::vm::Exception::PrepareExceptionForThrow`, resulting in an empty stack trace.
|
||||
- [merge] Merges changes from versions 2021.3.42f1 to 2021.3.44f1, fixing compilation errors introduced by il2cpp changes in version 2021.3.44.
|
||||
- [merge] Merges changes from versions 2022.3.41f1 to 2022.3.48f1, fixing compilation errors introduced by il2cpp changes in version 2022.3.48.
|
||||
- [merge] Merges code from 6000.0.19f1 to 6000.0.21f1, fixing compilation errors introduced by il2cpp changes in version 6000.0.20.
|
||||
- [merge] Merges changes from Tuanjie versions 1.1.0 to 1.2.6
|
||||
|
||||
## 6.8.0
|
||||
|
||||
Release Date: 2024-9-14.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] Fixes the bug where exception stacks did not include line numbers.
|
||||
- [fix] Fixes the bug where `Il2CppGenericContextCompare` simply compared class_inst and method_inst pointers for equality, which is not the case for all GenericInst (e.g., `s_Il2CppMetadataRegistration->genericInsts`) that do not come from GenericInstPool, hence identical GenericInst are not pointer equal.
|
||||
- [merge] Merges il2cpp code changes from version 6000.0.10 to 6000.0.19
|
||||
|
||||
## 6.7.1
|
||||
|
||||
Release Date: 2024-8-26.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] Fixes the bug where there were compilation errors when publishing to the iOS platform with Unity 2019.
|
||||
|
||||
## 6.7.0
|
||||
|
||||
Release Date: 2024-8-26.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [opt] No longer enables PROFILER in Release compilation mode, this optimization reduces the overhead of function calls by 10-15%, and overall performance is improved by approximately 2-4%.
|
||||
- [opt] When publishing for WebGL targets, StackTrace is no longer maintained in Release compilation mode, which improves performance by about 1-2%.
|
||||
- [fix] Fixes the bug where `Transform Enum::GetHashCode` did not change the variable type from `uintptr_t` to `int32_t` on the stack, leading to incorrect calculations when participating in subsequent numerical computations due to the parameter type being extended to 64 bits.
|
||||
- [fix] Fixes the bug where a stack overflow was triggered by calling delegates extensively within interpreter functions.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] HybridCLRSettings adds two new options: `enableProfilerInReleaseBuild` and `enableStackTraceInWebGLReleaseBuild`.
|
||||
- [change] Fixes the issue where an assertion failure occurred when switching from the WebGL platform to other platforms (no substantial impact).
|
||||
|
||||
## 6.6.0
|
||||
|
||||
Release Date: 2024-8-12.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] Fixes the bug where `CustomAttribute` construction or namedArg includes a `typeof(T[])` parameter, causing a crash.
|
||||
- [fix] Fixes the bug where `T[index].CallMethod()` throws an `ArrayTypeMismatchException` when `CallMethod` is an interface function of generic type T, and the array element is a subclass of T.
|
||||
- [fix] Fixes the bug where `MethodBase.GetCurrentMethod` does not return the correct result. A new instinct instruction `MethodBaseGetCurrentMethod` is added.
|
||||
- [fix] Fixes the bug where loading pdb on platforms like WebGL still does not display stack code line numbers.
|
||||
- [fix] Fixes the bug where, after calling a sub-interpreter function and returning, logging prints the code line number of the called function due to `frame->ip` not being reset to `&ip`.
|
||||
- [fix] Fixes the bug where calling a sub-interpreter function displays the line number of the next statement in the parent function's code line number due to `frame->ip` pointing to the next instruction.
|
||||
- [merge] Merges il2cpp code from 2021.3.42f1 and 2022.3.41f1, fixing compilation errors caused by the new `il2cpp_codegen_memcpy_with_write_barrier` function in versions 2021.3.42f1 and 2022.3.40f1.
|
||||
|
||||
## 6.5.0
|
||||
|
||||
Release Date: 2024-8-5.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] Hot update function stacks for versions 2019-2020 can now correctly display code files and line numbers.
|
||||
- [merge] Merges il2cpp changes from Unity versions 6000.0.1 to 6000.0.10
|
||||
|
||||
## 6.4.0
|
||||
|
||||
Release Date: 2024-7-25.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] Supports loading dll and pdb symbol files with `Assembly.Load(byte[] assData, byte[] pdbData)`, displaying the correct code files and line numbers in function stacks when printing on versions 2021+.
|
||||
- [fix] Fixes the bug where `InterpreterImage::GetEventInfo` and `GetPropertyInfo` might not initialize `method`, resulting in empty getter functions.
|
||||
- [opt] Optimizes the order of function stacks printed by `StackTrace` and `UnityEngine.Debug`, displaying interpreter functions at the correct stack positions in most cases.
|
||||
- [opt] Optimizes metadata memory.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] Fixes the bug where `GenerateMethodBridge` did not consider `ClassLayout`, `Layout`, and `FieldOffset` factors when calculating equivalent classes.
|
||||
- [fix] Fixes the bug where `PatchScriptingAssembliesJsonHook` throws an异常 when the `Library/PlayerDataCache` directory does not exist.
|
||||
|
||||
## 6.3.0
|
||||
|
||||
Release Date: 2024-7-15.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [opt] Significantly optimizes metadata memory, reducing memory usage by 15-40% compared to version 6.2.0.
|
||||
- [fix] Fixes the bug where memory was not released for `insts` in `IRBasicBlock` during transformation, causing a memory leak approximately 0.7-1.6 times the size of the dll.
|
||||
- [fix] Fixes the bug where `ClassFieldLayoutCalculator` caused a memory leak.
|
||||
- [fix] Fixes the bug where `MetadataAllocT` incorrectly used `HYBRIDCLR_MALLOC` instead of `HYBRIDCLR_METADATA_MALLOC`.
|
||||
- [opt] Optimizes the native stack size occupied by `Interpreter::Execute` to avoid stack overflow errors when nesting is too deep.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] Fixes the bug where exporting an xcode project for Unity 2022 includes multiple ShellScript fragments, incorrectly deleting non-repeated fragments.
|
||||
- [fix] Fixes the bug where the temporary directory name is `WinxinMiniGame{xxx}` when `TextureCompression` is not the default value on the WeChat Mini Games platform, causing the `scriptingassemblies.json` file to not be successfully modified.
|
||||
- [fix] Fixes the bug where the WeChat Mini Games platform on the Unity Engine, due to the definition of both `UNITY_WEIXINMINIGAME` and `UNITY_WEBGL` macros, fails to find the `scriptingassemblies.json` file from the wrong path, resulting in a script missing bug at runtime.
|
||||
|
||||
## 6.2.0
|
||||
|
||||
Release Date: 2024-7-1.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [merge] Merges changes from versions 2021.3.27f1 to 2021.3.40f1.
|
||||
- [opt] Optimizes metadata memory, reducing memory usage by 20-25%.
|
||||
- [opt] Optimizes the implementation of `GetHashCode` for enum types, no longer generating GC.
|
||||
|
||||
## 6.1.0
|
||||
|
||||
Release Date: 2024-6-17.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [merge] Merges changes from versions 2022.3.23f1 to 2022.3.33f1, fixing incompatibility issues with version 2022.3.33.
|
||||
- [new] Supports the new function return value Attribute added in version 2022.3.33.
|
||||
- [fix] Fixes the bug where `FieldInfo` calling `GetFieldMarshaledSizeForField` crashes.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] Upgrades the dnlib version, fixing the serious bug where `ModuleMD` saves dlls without setting the assembly-qualified `mscorlib` assembly types to the current assembly.
|
||||
- [fix] Fixes the issue where `Generate/LinkXml` generates a `link.xml` that preserves all `UnityEngine.Debug`, causing compilation errors on iOS and visionOS platforms with Unity 2023 and higher versions. This bug is caused by Unity, and we temporarily solve this problem by ignoring the `UnityEngine.Debug` class when generating `link.xml`.
|
||||
|
||||
## 6.0.0
|
||||
|
||||
Release Date: 2024-6-11.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] Supports Unity 6000.x.y and Unity 2023.2.x versions.
|
||||
- [refactor] Merges `ReversePInvokeMethodStub` into `MethodBridge`, and moves ReversePInvoke-related code from `MetadataModule` to `InterpreterModule`.
|
||||
- [new] Supports MonoPInvokeCallback functions with parameters or return types as struct types.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] Supports Unity 6000.x.y and Unity 2023.2.x versions.
|
||||
- [new] Supports MonoPInvokeCallback functions with parameters or return types as struct types.
|
||||
- [new] Adds `GeneratedAOTGenericReferenceExcludeExistsAOTClassAndMethods`, which calculates hot update references to AOT generic types and functions, excluding those already existing in AOT, ultimately generating a more accurate list of supplementary metadata assembly programs.
|
||||
- [fix] Fixes the bug where `CopyStrippedAOTAssemblies` class has compilation errors on some Unity versions that do not support visionOS.
|
||||
- [fix] Fixes the bug where calculating the `CallingConvention` of `MonoPInvokeCallback` is incorrectly treated as Winapi if the delegate is defined in another assembly, resulting in an incorrect wrapper signature calculation.
|
||||
- [fix] PatchScriptingAssemblyList.cs has compilation errors on Unity 2023+ WebGL platforms.
|
||||
- [fix] Fixes the bug where calculating Native2Manager bridge functions does not consider MonoPInvokeCallback functions, leading to `UnsupportedNative2ManagedMethod` when calling C# hot update functions from Lua or other languages.
|
||||
- [refactor] Merges `ReversePInvokeMethodStub` into `MethodBridge`, and moves ReversePInvoke-related code from `MetadataModule` to `InterpreterModule`.
|
||||
- [opt] Checks if the development option during packaging is consistent with the current development option. Switching the development option after `Generate/All` and then packaging will cause serious crashes.
|
||||
- [opt] `Generate/All` checks if HybridCLR is installed before generating.
|
||||
|
||||
## 5.4.1
|
||||
|
||||
Release Date: 2024-5-30.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] Supports the visionOS platform.
|
||||
- [fix]**[Serious]** Fixes the bug where calculating `MonoPInvokeCallback`'s `CallingConvention` incorrectly treats it as Winapi if the delegate is defined in another assembly, resulting in an incorrect wrapper signature calculation.
|
||||
- [fix] Fixes the bug where the wrong Unity-iPhone.xcodeproj path is used on tvOS platforms, causing the project.pbxproj to not be found.
|
||||
|
||||
## 5.4.0
|
||||
|
||||
Release Date: 2024-5-20.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] ReversePInvoke supports CallingConvention.
|
||||
- [fix] Fixes the bug where `calli`'s `argBasePtr=argIdx[0]` when the number of arguments is 0, due to `argIdxs` not being assigned, causing the function stack frame to point to the wrong location.
|
||||
- [fix] Fixes the bug where `MetadataModule::GetReversePInvokeWrappe`'s `ComputeSignature` might deadlock.
|
||||
- [fix] Fixes the bug where AOT base class virtual functions implementing hot update interface functions use `CallInterpVirtual`, causing runtime exceptions.
|
||||
- [fix] Fixes the issue where some sub-instructions of the `PREFIX1` prefix instruction are missing and not sorted by instruction number in the Transform.
|
||||
- [fix] Fixes the bug where the `no.{x}` prefix instruction is 3 bytes long but incorrectly treated as 2 bytes in the Transform.
|
||||
- [fix] Fixes the bug where the `unaligned.{x}` prefix instruction is 3 bytes long but incorrectly treated as 2 bytes in the Transform.
|
||||
- [opt] Removes unnecessary `INIT_CLASS` operations in `Interpreter_Execute`, as `PREPARE_NEW_FRAME_FROM_NATIVE` will always check.
|
||||
- [opt] No longer caches MethodBody of non-generic functions, optimizing memory.
|
||||
- [opt] **Optimizes supplementary metadata memory**, saving approximately 2.8 times the size of metadata dll memory.
|
||||
- [refactor] Changes the type of the `_rawImage` field in `Image` from `RawImage` to `RawImage*`.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] ReversePInvoke supports CallingConvention.
|
||||
- [fix] Fixes the bug where calculating the equivalence of structs by flattening and expanding them does not apply on some platforms. For example, struct A { uint8_t x; A2 y; } struct A2 { uint8_t x; int32_t y;}; and struct B { uint8_t x; uint8_t y; int32_t z; } are not equivalent under the x86_64 ABI.
|
||||
- [fix] Fixes the bug where appending to an existing xcode project causes the 'Run Script' command to be duplicated the first time and subsequently fails to find --external-lib-il2-cpp, printing an error log.
|
||||
|
||||
## 5.3.0
|
||||
|
||||
Release Date: 2024-4-22.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] Fixes the bug where MachineState::CollectFramesWithoutDuplicates incorrectly uses `hybridclr::metadata::IsInterpreterMethod` to remove hot update functions, leading to an increasingly long StackFrames list and an infinite loop when printing the stack. The implementation is adjusted to uniformly use `il2cpp::vm::StackTrace::PushFrame` and `PopFrame` for perfect interpreter stack printing. The downside is the increased overhead of maintaining the stack when calling interpreter functions.
|
||||
- [fix] Fixes the serious bug where `StringUtils::Utf16ToUtf8` does not correctly handle `maxinumSize==0`, causing a significant overflow when converting strings of length 0 in `InterpreterImage::ConvertConstValue`.
|
||||
- [fix] Fixes the bug where `_ReversePInvokeMethod_XXX` functions do not set `Il2CppThreadContext`, causing a crash when obtaining thread variables from native threads.
|
||||
- [merge] Merges il2cpp changes from versions 2021.3.34 to 2021.3.37f1.
|
||||
- [merge] Merges il2cpp changes from versions 2022.3.19 to 2022.3.23f1.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] Fixes the bug where exporting a tvOS project does not modify xcode project settings, causing packaging to fail.
|
||||
- [fix] Fixes the bug where building for tvOS targets does not copy the pruned AOT dll, causing bridge function generation to fail.
|
||||
- [fix] Solves the issue where the locationPathName generated by `StripAOTDllCommand` is not standardized, causing incompatibility with some plugins like the Embedded Browser.
|
||||
- [fix] Fixes the bug where deleting the `TUANJIE_2022` macro in Unity Engine 1.1.0 does not copy the pruned AOT assembly.
|
||||
- [fix] Fixes the bug where `_ReversePInvokeMethod_XXX` functions do not set `Il2CppThreadContext`, causing a crash when obtaining thread variables from native threads.
|
||||
- [fix] Fixes the bug where iOS platform mono-related header files are not found when the development build option is enabled.
|
||||
|
||||
## 5.2.1
|
||||
|
||||
Release Date: 2024-4-7.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] Fixes the bug where stack logs are not printed on the WebGL platform.
|
||||
- [fix] Fixes the bug where `RuntimeConfig::GetRuntimeOption` incorrectly returns `s_threadFrameStackSize` for `InterpreterThreadExceptionFlowSize`.
|
||||
|
||||
### Editor
|
||||
|
||||
- [opt] Sets `mod.EnableTypeDefFindCache = true` in `LoadModule`, reducing the time to calculate bridge functions to one-third of the original.
|
||||
- [fix] Fixes the bug where renaming the xcode project file to `Tuanjie-iPhone.xcodeproj` when exporting for the Unity Engine platform causes xcode project construction to fail.
|
||||
|
||||
## 5.2.0
|
||||
|
||||
发布日期 2024.3.25.
|
||||
Release Date: 2024-3-25.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] 支持团结引擎
|
||||
- [new] 支持函数指针,支持IL2CPP_TYPE_FNPTR类型
|
||||
- [fix] 修复SetMdArrElementVarVar_ref指令未SetWriteBarrier的bug
|
||||
- [fix] InvokeSingleDelegate当调用一个未补充元数据的泛型函数时,发生崩溃的bug
|
||||
- [fix] 修复InterpreterDelegateInvoke调用delegate时,如果delegate指向未补充元数据的泛型函数,发生崩溃的bug
|
||||
- [fix] 修复当BlobStream为空时, RawImage::GetBlobFromRawIndex断言index < _streamBlobHeap.size失败的bug
|
||||
- [change] 重构metadata index设计,允许分配最多3个64M dll,16个16M dll,64个4M dll,255个1M dll
|
||||
- [new] Supports the Unity Engine.
|
||||
- [new] Supports function pointers, supporting IL2CPP_TYPE_FNPTR type.
|
||||
- [fix] Fixes the bug where the `SetMdArrElementVarVar_ref` instruction does not SetWriteBarrier.
|
||||
- [fix] Fixes the bug where `InvokeSingleDelegate` crashes when calling a generic function without supplementary metadata.
|
||||
- [fix] Fixes the bug where `InterpreterDelegateInvoke` crashes when calling a delegate pointing to a generic function without supplementary metadata.
|
||||
- [fix] Fixes the bug where `RawImage::GetBlobFromRawIndex` fails when the BlobStream is empty.
|
||||
- [change] Refactorizes the metadata index design, allowing up to 3 64M dlls, 16 16M dlls, 64 4M dlls, and 255 1M dlls to be allocated.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] 支持团结引擎
|
||||
- [fix] 修复GenericArgumentContext不支持ElementType.FnPtr的bug
|
||||
- [change] 为RuntimeApi添加[Preserve]特性,避免被裁剪
|
||||
- [new] Supports the Unity Engine.
|
||||
- [fix] Fixes the bug where `GenericArgumentContext` does not support `ElementType.FnPtr`.
|
||||
- [change] Adds the `[Preserve]` attribute to RuntimeApi to prevent it from being pruned.
|
||||
|
||||
## 5.1.0
|
||||
|
||||
发布日期 2024.2.26.
|
||||
Release Date: 2024-2-26.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复2021未实现System.ByReference`1的.ctor及get_Value函数引发的运行错误的问题,il2cpp通过特殊的instrinct函数实现了正常运行
|
||||
- [opt] 优化元数据加载,将部分元数据改为延迟加载,大约减少30%的Assembly::Load的执行时间
|
||||
- [change] tempRet由Interpreter::Execute的局部变量改为CallDelegateInvoke_xxx的局部变量,减少嵌套过深时栈溢出的可能性
|
||||
- [fix] Fixes the runtime error caused by not implementing `System.ByReference`1's .ctor and get_Value functions in 2021, where il2cpp runs normally through special instinct functions.
|
||||
- [opt] Optimizes metadata loading by delaying the loading of some metadata, reducing the execution time of `Assembly::Load` by approximately 30%.
|
||||
- [change] Changes `tempRet` from a local variable in `Interpreter::Execute` to a local variable in `CallDelegateInvoke_xxx`, reducing the possibility of stack overflow when nesting is too deep.
|
||||
|
||||
## 5.0.0
|
||||
|
||||
发布日期 2024.1.26.
|
||||
Release Date: 2024-1-26.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] 恢复对2019支持
|
||||
- [fix] 修复未按依赖顺序加载dll,由于在创建Image时缓存了当时的程序集列表,如果被依赖的程序集在本程序集后加载,延迟访问时由于不在缓存程序集列表而出现TypeLoadedException的bug
|
||||
|
||||
- [new] Restores support for 2019.
|
||||
- [fix] Fixes the bug where dlls are not loaded in dependency order, and since the assembly list at the time of image creation is cached, if dependent assemblies are loaded after this assembly, delayed access may result in `TypeLoadedException` due to not being in the cached assembly list.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] 恢复对2019支持
|
||||
- [new] 支持2019版本在iOS平台以源码形式构建
|
||||
- [new] 新增 AOTAssemblyMetadataStripper用于剔除AOT dll中非泛型函数元数据
|
||||
- [new] 新增 MissingMetadataChecker检查裁剪类型或者函数丢失的问题
|
||||
- [opt] 优化 AOTReference计算,如果泛型的所有泛型参数都是class约束,则不加入到需要补充元数据的集合
|
||||
- [change] 为了支持团结引擎而作了一些调整(注意,支持团结引擎的il2cpp_plus分支并未公开)
|
||||
- [new] Restores support for 2019.
|
||||
- [new] Supports building 2019 on the iOS platform in source form.
|
||||
- [new] Adds AOTAssemblyMetadataStripper to remove non-generic function metadata from AOT dlls.
|
||||
- [new] Adds MissingMetadataChecker to check for missing types or function metadata.
|
||||
- [opt] Optimizes AOTReference calculations; if all generic parameters of a generic are class-constrained, they are not added to the set of metadata that needs to be supplemented.
|
||||
- [change] Makes some adjustments to support the Unity Engine (note that the il2cpp_plus branch supporting the Unity Engine has not been made public).
|
||||
|
||||
## 4.0.15
|
||||
|
||||
发布日期 2024.1.2.
|
||||
Release Date: 2024-1-2.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复计算未完全实例化的泛型类时将VAR和MVAR类型参数大小计算成sizeof(void*),导致计算出无效且过大的instance,在执行LayoutFieldsLocked过程中调用UpdateInstanceSizeForGenericClass错误地使用泛型基类instance覆盖设置了实例类型的instance值的严重bug
|
||||
- [change] 支持打印热更新栈,虽然顺序不太正确
|
||||
- [change] 使用HYBRIDCLR_MALLOC之类分配函数替换IL2CPP_MALLOC
|
||||
- [refactor] 重构Config接口,统一通过GetRuntimeOption和SetRuntimeOption获取和设置选项
|
||||
- [opt] 删除NewValueTypeVar和NewValueTypeInterpVar指令不必要的对结构memset操作
|
||||
- [fix] Fixes the serious bug where the size of the instance of a not fully instantiated generic class is calculated as `sizeof(void*)`, resulting in an invalid and excessively large instance. This causes an error when using the generic base class instance to overwrite the instance type value set during `LayoutFieldsLocked` in `UpdateInstanceSizeForGenericClass`.
|
||||
- [change] Supports printing hot update stacks, although the order is not quite correct.
|
||||
- [change] Replaces IL2CPP_MALLOC with HYBRIDCLR_MALLOC and similar allocation functions.
|
||||
- [refactor] Refactorizes the Config interface to统一ly retrieve and set options through `GetRuntimeOption` and `SetRuntimeOption`.
|
||||
- [opt] Removes unnecessary memset operations on structures for `NewValueTypeVar` and `NewValueTypeInterpVar` instructions.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复Additional Compiler Arguments中输入 -nullable:enable 之后,Editor抛出InvalidCastException的bug。来自报告 https://github.com/focus-creative-games/hybridclr/issues/116
|
||||
- [fix] 修复某些情况下报错:BuildFailedException: Build path contains a project previously built without the "Create Visual Studio Solution"
|
||||
- [opt] 优化桥接函数生成,将同构的struct映射到同一个结构,减少了30-35%的桥接函数数量
|
||||
- [change] StripAOTDllCommand导出时不再设置BuildScriptsOnly选项
|
||||
- [change] 调整Installer窗口的显示内容
|
||||
- [refactor] RuntimeApi中设置hybridclr参数的功能统一通过GetRuntimeOption和SetRuntimeOption函数
|
||||
- [fix] Fixes the bug where entering `-nullable:enable` in Additional Compiler Arguments throws an `InvalidCastException` in the Editor. Reported at https://github.com/focus-creative-games/hybridclr/issues/116
|
||||
- [fix] Fixes the error: `BuildFailedException: Build path contains a project previously built without the "Create Visual Studio Solution"`
|
||||
- [opt] Optimizes bridge function generation by mapping isomorphic structs to the same structure, reducing the number of bridge functions by 30-35%.
|
||||
- [change] `StripAOTDllCommand` no longer sets the `BuildScriptsOnly` option when exporting.
|
||||
- [change] Adjusts the display content of the Installer window.
|
||||
- [refactor] Centralizes the functionality of setting hybridclr parameters in RuntimeApi through `GetRuntimeOption` and `SetRuntimeOption` functions.
|
||||
|
||||
## 4.0.14
|
||||
|
||||
发布日期 2023.12.11.
|
||||
Release Date: 2023-12-11.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复优化 box; brtrue|brfalse序列时,当类型为class或nullable类型时,无条件转换为无条件branch语句的bug
|
||||
- [fix] 修复 ClassFieldLayoutCalculator未释放 _classMap的每个key-value对中value对象,造成内存泄露的bug
|
||||
- [fix] 修复计算 ExplicitLayout的struct的native_size的bug
|
||||
- [fix] 修复当出现签名完全相同的虚函数与虚泛型函数时,计算override未考虑泛型签名,错误地返回了不匹配的函数,导致虚表错误的bug
|
||||
- [fix][2021] 修复开启faster(smaller) build选项后某些情况下完全泛型共享AOT函数未使用补充元数据来设置函数指针,导致调用时出错的bug
|
||||
- [fix] Fixes the bug where optimizing the `box; brtrue|brfalse` sequence unconditionally converts to an unconditional branch statement when the type is a class or nullable type.
|
||||
- [fix] Fixes the bug where `ClassFieldLayoutCalculator` does not release value objects in each key-value pair of `_classMap`, causing a memory leak.
|
||||
- [fix] Fixes the bug where calculating the native_size of a struct with `ExplicitLayout` is incorrect.
|
||||
- [fix] Fixes the bug where when there are virtual functions with identical signatures and virtual generic functions, the override calculation does not consider the generic signature, incorrectly returning a non-matching function, resulting in an incorrect vtable.
|
||||
- [fix][2021] Fixes the bug where when the faster (smaller) build option is enabled, some fully generic shared AOT functions do not use supplementary metadata to set function pointers, causing errors when called.
|
||||
|
||||
## 4.0.13
|
||||
|
||||
发布日期 2023.11.27.
|
||||
Release Date: 2023-11-27.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复ConvertInvokeArgs有可能传递了非对齐args,导致CopyStackObject在armv7这种要求内存对齐的平台发生崩溃的bug
|
||||
- [fix] 修复通过StructLayout指定size时,计算ClassFieldLayout的严重bug
|
||||
- [fix] 修复bgt之类指令未取双重取反进行判断,导致当浮点数与Nan比较时由于不满足对称性执行了错误的分支的bug
|
||||
- [fix] 修复Class::FromGenericParameter错误地设置了thread_static_fields_size=-1,导致为其分配ThreadStatic内存的严重bug
|
||||
- [opt] Il2CppGenericInst分配统一使用MetadataCache::GetGenericInst分配唯一池对象,优化内存分配
|
||||
- [opt] 由于Interpreter部分Il2CppGenericInst统一使用MetadataCache::GetGenericInst,比较 Il2CppGenericContext时直接比较 class_inst和method_inst指针
|
||||
- [fix] Fixes the bug where `ConvertInvokeArgs` might pass non-aligned args, causing `CopyStackObject` to crash on platforms like armv7 that require memory alignment.
|
||||
- [fix] Fixes the serious bug where calculating `ClassFieldLayout` when the size is specified by `StructLayout`.
|
||||
- [fix] Fixes the bug where instructions like `bgt` do not double-negate the judgment, causing incorrect branch execution when comparing floating-point numbers with NaN due to不对称性.
|
||||
- [fix] Fixes the serious bug where `Class::FromGenericParameter` incorrectly sets `thread_static_fields_size=-1`, causing ThreadStatic memory allocation for it.
|
||||
- [opt] Allocates `Il2CppGenericInst`统一ly using `MetadataCache::GetGenericInst` to allocate unique pool objects, optimizing memory allocation.
|
||||
- [opt] Since some Il2CppGenericInst in the Interpreter uses `MetadataCache::GetGenericInst` uniformly, compare `Il2CppGenericContext` by directly comparing class_inst and method_inst pointers.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复裁剪aot dll中出现netstandard时,生成桥接函数异常的bug
|
||||
- [fix] 修复当出现非常规字段名时生成的桥接函数代码文件有编译错误的bug
|
||||
- [change] 删除不必要的Datas~/Templates目录,直接以原始文件为模板
|
||||
- [refactor] 重构 AssemblyCache和 AssemblyReferenceDeepCollector,消除冗余代码
|
||||
- [fix] Fixes the bug where pruning aot dll results in an exception when generating bridge functions if netstandard is referenced.
|
||||
- [fix] Fixes the bug where unusual field names result in compilation errors in the generated bridge function code files.
|
||||
- [change] Removes the unnecessaryDatas~/Templates directory, using the original files as templates directly.
|
||||
- [refactor] Refactorizes `AssemblyCache` and `AssemblyReferenceDeepCollector` to eliminate redundant code.
|
||||
|
||||
## 4.0.12
|
||||
|
||||
发布日期 2023.11.02.
|
||||
Release Date: 2023-11-02.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复BashUtil.RemoveDir的bug导致Installer安装失败的bug
|
||||
- [fix] Fixes the bug in `BashUtil.RemoveDir` causing Installer installation to fail.
|
||||
|
||||
## 4.0.11
|
||||
|
||||
发布日期 2023.11.02.
|
||||
Release Date: 2023-11-02.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复开启完全泛型共享后, 对于某些MethodInfo,由于methodPointer与virtualMethodPointer使用补充元数据后的解释器函数,而invoker_method仍然为支持完全泛型共享的调用形式,导致invoker_method与methodPointer及virtualMethodPointer不匹配的bug
|
||||
- [fix] 修复Il2CppGenericContextCompare比较时仅仅对比inst指针的bug,造成热更新模块大量泛型函数重复
|
||||
- [fix] 修复完全泛型共享时未正确设置MethodInfo的bug
|
||||
- [fix] Fixes the bug where when full generic sharing is enabled, for some `MethodInfo`, since `methodPointer` and `virtualMethodPointer` use the interpreter function with supplementary metadata, while `invoker_method` remains in the call form supporting full generic sharing, causing `invoker_method` to mismatch with `methodPointer` and `virtualMethodPointer`.
|
||||
- [fix] Fixes the bug where `Il2CppGenericContextCompare` only compares inst pointers, causing a large number of duplicate generic functions in the hot update module.
|
||||
- [fix] Fixes the bug where `MethodInfo` is not correctly set when full generic sharing is enabled.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] 检查当前安装的libil2cpp版本是否与package版本匹配,避免升级package后未重新install的问题
|
||||
- [new] Generate支持 netstandard
|
||||
- [fix] 修复 ReversePInvokeWrap生成不必要地解析referenced dll,导致如果有aot dll引用了netstandard会出现解析错误的bug
|
||||
- [fix] 修复BashUtil.RemoveDir在偶然情况下出现删除目录失败的问题。新增多次重试
|
||||
- [fix] 修复桥接函数计算时未归结函数参数类型,导致出现多个同名签名的bug
|
||||
|
||||
- [new] Checks if the currently installed libil2cpp version matches the package version to avoid issues when upgrading the package without reinstalling.
|
||||
- [new] `Generate` supports netstandard.
|
||||
- [fix] Fixes the bug where `ReversePInvokeWrap` generates unnecessarily, parsing referenced dlls, causing parsing errors if aot dll references netstandard.
|
||||
- [fix] Fixes the bug where `BashUtil.RemoveDir` occasionally fails to delete directories. Adds multiple retries.
|
||||
- [fix] Fixes the bug where bridge function calculation does not reduce function parameter types, resulting in multiple functions with the same signature.
|
||||
|
||||
## 4.0.10
|
||||
|
||||
发布日期 2023.10.12.
|
||||
Release Date: 2023-10-12.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [merge][il2cpp] 合并2022.3.10-2022.3.11f1的il2cpp改动,修复2022.3.11版本不兼容的问题
|
||||
- [merge][il2cpp] Merges il2cpp changes from versions 2022.3.10 to 2022.3.11f1, fixing incompatibility issues with version 2022.3.11.
|
||||
|
||||
## 4.0.9
|
||||
|
||||
发布日期 2023.10.11.
|
||||
Release Date: 2023-10-11.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [merge][il2cpp][fix] 合并2021.3.29-2021.3.31f1的il2cpp改动,修复在2021.3.31版本的不兼容问题
|
||||
- [merge][il2cpp] 合并2022.3.7-2022.3.10f1的il2cpp改动
|
||||
- [merge][il2cpp][fix] Merges il2cpp changes from versions 2021.3.29 to 2021.3.31f1, fixing incompatibility issues with version 2021.3.31.
|
||||
- [merge][il2cpp] Merges il2cpp changes from versions 2022.3.7 to 2022.3.10f1.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复2022版本iOS平台AddLil2cppSourceCodeToXcodeproj2022OrNewer的编译错误
|
||||
- [fix] Fixes the compilation error with `AddLil2cppSourceCodeToXcodeproj2022OrNewer` on the iOS platform for Unity 2022 versions.
|
||||
|
||||
## 4.0.8
|
||||
|
||||
发布日期 2023.10.10.
|
||||
Release Date: 2023-10-10.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复计算值类型泛型桥接函数签名时,错误地将值类型泛型参数类型也换成签名,导致与Editor计算的签名不一致的bug
|
||||
- [fix][refactor] RuntimeApi相关函数由PInvoke改为InternalCall,解决Android平台调用RuntimeApi时触发重新加载libil2cpp.a的问题
|
||||
- [fix] Fixes the bug where calculating the bridge function signature for value type generic bridge functions incorrectly replaces the value type generic parameter type with the signature, resulting in an inconsistent signature with the Editor calculation.
|
||||
- [fix][refactor] Changes RuntimeApi related functions from PInvoke to InternalCall, solving the issue of reloading libil2cpp.a when calling RuntimeApi on Android platforms.
|
||||
|
||||
### Editor
|
||||
|
||||
- [refactor] RuntimeApi相关函数由PInvoke改为InternalCall
|
||||
- [refactor] 调整HybridCLR.Editor模块一些不规范的命名空间
|
||||
- [refactor] Changes RuntimeApi related functions from PInvoke to InternalCall .
|
||||
- [refactor] Adjusts some non-standard namespace names in the HybridCLR.Editor module.
|
||||
|
||||
## 4.0.7
|
||||
|
||||
发布日期 2023.10.09.
|
||||
Release Date: 2023-10-09.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复initobj调用了CopyN,但CopyN未考虑对象的内存对齐的情况,在32位这种的平台可能发生未对齐访问异常的bug
|
||||
- [fix] 修复计算未完全实例化的泛型函数的桥接函数签名时崩溃的bug
|
||||
- [fix] 修复Il2cpp代码生成选项为faster(smaller)时,2021和2022版本GenericMethod::CreateMethodLocked的bug
|
||||
- [remove] 移除所有array相关指令中index为int64_t的指令,简化代码
|
||||
- [remove] 移除ldfld_xxx_ref系列指令
|
||||
- [fix] Fixes the bug where `initobj` calls `CopyN`, but `CopyN` does not consider object memory alignment, which may cause unaligned access exceptions on platforms like 32-bit.
|
||||
- [fix] Fixes the bug where calculating the bridge function signature for not fully instantiated generic functions crashes.
|
||||
- [fix] Fixes the bug where `GenericMethod::CreateMethodLocked` has issues when the Il2cpp code generation option is faster (smaller) for versions 2021 and 2022.
|
||||
- [remove] Removes all array-related instructions with int64_t indices to simplify the code.
|
||||
- [remove] Removes the `ldfld_xxx_ref` series of instructions.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复生成桥接函数时,如果热更新程序集未包含任何代码直接引用了某个aot程序集,则没有为该aot程序集生成桥接函数,导致出现NotSupportNative2Managed异常的bug
|
||||
- [fix] 修复mac下面路径过长导致拷贝文件失败的bug
|
||||
- [fix] 修复发布PS5目标时未处理ScriptingAssemblies.json的bug
|
||||
- [change] 打包时清空裁减aot dll目录
|
||||
- [fix] Fixes the bug where generating bridge functions does not generate bridge functions for an aot assembly if the hot update assembly does not directly reference any code, resulting in a `NotSupportNative2Managed` exception.
|
||||
- [fix] Fixes the bug where copying files fails on Mac due to excessively long paths.
|
||||
- [fix] Fixes the bug where publishing for PS5 targets does not process `ScriptingAssemblies.json`.
|
||||
- [change] Clears the pruned aot dll directory when packaging.
|
||||
|
||||
## 4.0.6
|
||||
|
||||
发布日期 2023.09.26.
|
||||
Release Date: 2023-09-26.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复2021和2022版本开启完全泛型共享后的bug
|
||||
- [fix] 修复加载PlaceHolder Assembly后未增加assemblyVersion导致Assembly::GetAssemblies()错误地获得了旧程序集列表的bug
|
||||
- [fix] Fixes the bug with versions 2021 and 2022 when full generic sharing is enabled.
|
||||
- [fix] Fixes the bug where loading a PlaceHolder Assembly does not increase `assemblyVersion`, causing `Assembly::GetAssemblies()` to incorrectly obtain an old assembly list.
|
||||
|
||||
## 4.0.5
|
||||
|
||||
发布日期 2023.09.25.
|
||||
Release Date: 2023-09-25.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复Transform中未析构pendingFlows造成内存泄露的bug
|
||||
- [fix] 修复多维数组SetMdArrElement未区分带ref与不带ref结构的bug
|
||||
- [fix] 修复CpobjVarVAr_WriteBarrier_n_4未设置size的bug
|
||||
- [fix] 修复计算interface成员函数slot时未考虑到static之类函数的bug
|
||||
- [fix] 修复2022版本ExplicitLayout未设置layout.alignment,导致计算出size==0的bug
|
||||
- [fix] 修复InterpreterInvoke在完全泛型共享时,class类型的methodPointer与virtualMethodPointer有可能不一致,导致失误对this指针+1的bug
|
||||
- [fix] ldobj当T为byte之类size<4的类型时,未将数据展开为int的bug
|
||||
- [fix] 修复CopySize未考虑到内存对齐的问题
|
||||
- [opt] 优化stelem当元素为size较大的struct时统一当作含ref结构的问题
|
||||
- [opt] TemporaryMemoryArena默认内存块大小由1M调整8K
|
||||
- [opt] 将Image::Image中Assembly::GetAllAssemblies()换成Assembly::GetAllAssemblies(AssemblyVector&),避免创建assembly快照而造成不必要的内存泄露
|
||||
- [fix] Fixes the bug where `Transform` does not destruct `pendingFlows`, causing a memory leak.
|
||||
- [fix] Fixes the bug where `SetMdArrElement` does not distinguish between structures with and without ref.
|
||||
- [fix] Fixes the bug where `CpobjVarVAr_WriteBarrier_n_4` does not set the size.
|
||||
- [fix] Fixes the bug where calculating interface member function slots does not consider static and similar functions.
|
||||
- [fix] Fixes the bug where `ExplicitLayout` is not set for layout.alignment in version 2022, resulting in a size of 0.
|
||||
- [fix] Fixes the bug where `InterpreterInvoke` in full generic sharing may have inconsistent `methodPointer` and `virtualMethodPointer` for class types, causing an error in incrementing the this pointer by 1.
|
||||
- [fix] Fixes the bug where `ldobj` does not expand data into an int when T is a type like byte with a size less than 4.
|
||||
- [fix] Fixes the bug where `CopySize` does not consider memory alignment issues.
|
||||
- [opt] Optimizes `stelem` when the element is a larger struct, unifying it as a structure containing ref.
|
||||
- [opt] Adjusts the default memory block size of `TemporaryMemoryArena` from 1M to 8K.
|
||||
- [opt] Changes `Assembly::GetAllAssemblies()` in `Image::Image` to `Assembly::GetAllAssemblies(AssemblyVector&)`, avoiding the creation of an assembly snapshot and preventing unnecessary memory leaks.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复StandaloneLinux平台DllImport的dllName和裁剪dll路径的错误
|
||||
- [change] 对于小版本不兼容的Unity版本,不再禁止安装,而是提示警告
|
||||
- [fix] 修复桥接函数计算中MetaUtil.ToShareTypeSig将Ptr和ByRef计算成IntPtr的bug,正确应该是UIntPtr
|
||||
- [fix] Fixes the bug where `DllImport` for the StandaloneLinux platform has incorrect dllName and pruned dll path errors.
|
||||
- [change] For Unity versions with minor incompatibility, installation is no longer prohibited, but a warning is displayed instead.
|
||||
- [fix] Fixes the bug where `MetaUtil.ToShareTypeSig` calculates `Ptr` and `ByRef` as `IntPtr` in bridge function calculations, which should correctly be `UIntPtr`.
|
||||
|
||||
## 4.0.4
|
||||
|
||||
发布日期 2023.09.11。
|
||||
Release Date: 2023-09-11.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new][platform] 彻底支持所有平台,包括UWP和PS5
|
||||
- [fix][严重] 修复计算interpreter部分enum类型的桥接函数签名的bug
|
||||
- [fix] 修复在某些平台下有编译错误的问题
|
||||
- [fix] 修复转换STOBJ指令未正确处理增量式GC的bug
|
||||
- [fix] [fix] 修复 StindVarVar_ref指令未正确设置WriteBarrier的bug
|
||||
- [fix] 修复2020 GenericMethod::CreateMethodLocked调用vm::MetadataAllocGenericMethod()未持有s_GenericMethodMutex锁的线程安全问题
|
||||
- [new][platform] Fully supports all platforms, including UWP and PS5.
|
||||
- [fix][serious] Fixes the bug where calculating the bridge function signature for interpreter parts of enum types is incorrect.
|
||||
- [fix] Fixes compilation errors on some platforms.
|
||||
- [fix] Fixes the bug where converting STOBJ instructions does not correctly handle incremental GC.
|
||||
- [fix] Fixes the bug where the `StindVarVar_ref` instruction does not correctly set WriteBarrier.
|
||||
- [fix] Fixes the thread safety issue where `GenericMethod::CreateMethodLocked` calls `vm::MetadataAllocGenericMethod()` without holding the `s_GenericMethodMutex` lock in version 2020.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复AddLil2cppSourceCodeToXcodeproj2021OrOlder在Unity 2020下偶然同时包含了不同目录的两个ThreadPool.cpp文件导致出现编译错误的问题
|
||||
- [fix] 修复不正确地从EditorUserBuildSettings.selectedBuildTargetGroup获得BuildGroupTarget的bug
|
||||
- [fix] StripAOTDllCommand生成AOT dll时的BuildOption采用当前Player的设置,避免当打包开启development时,StripAOTDllCommand生成Release aot dll,而打包生成debug aot dll,产生补充元数据及桥接函数生成不匹配的严重错误
|
||||
- [change] 为了更好地支持全平台,调整了RuntimeApi.cs中dllName的实现,默认取 __Internal
|
||||
- [change] 为了更好地支持全平台,自2021起裁剪AOT dll全都通过MonoHook复制
|
||||
- [fix] Fixes the bug where `AddLil2cppSourceCodeToXcodeproj2021OrOlder` includes two ThreadPool.cpp files in different directories, causing compilation errors in Unity 2020.
|
||||
- [fix] Fixes the bug where obtaining `BuildGroupTarget` from `EditorUserBuildSettings.selectedBuildTargetGroup` is incorrect.
|
||||
- [fix] `StripAOTDllCommand` generates AOT dlls with the current Player settings to avoid serious mismatches between supplementary metadata and bridge function generation when packaging with development enabled.
|
||||
- [change] To better support all platforms, adjusts the implementation of dllName in RuntimeApi.cs to default to `__Internal`.
|
||||
- [change] To better support all platforms, all AOT dll pruning since 2021 is done through MonoHook copying.
|
||||
|
||||
## 4.0.3
|
||||
|
||||
发布日期 2023.08.31。
|
||||
Release Date: 2023-08-31.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复桥接函数计算的bug
|
||||
- [fix] Fixes the bug in bridge function calculation.
|
||||
|
||||
## 4.0.2
|
||||
|
||||
发布日期 2023.08.29。
|
||||
Release Date: 2023-08-29.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix][严重] 修复LdobjVarVar_ref指令的bug。此bug由增量式GC代码引入
|
||||
- [fix] 修复未处理ResolveField获得的Field为nullptr时情形导致崩溃的bug
|
||||
- [fix] 修复未正确处理AOT及interpreter interface中显式实现父接口函数的bug
|
||||
- [fix][serious] Fixes the bug in `LdobjVarVar_ref` instruction. This bug was introduced by incremental GC code.
|
||||
- [fix] Fixes the bug where `ResolveField` obtaining a Field as nullptr is not handled, causing a crash.
|
||||
- [fix] Fixes the bug where AOT and interpreter interface explicitly implement parent interface functions are not correctly handled.
|
||||
|
||||
## 4.0.1
|
||||
|
||||
发布日期 2023.08.28。
|
||||
Release Date: 2023-08-28.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复2020版本开启增量式GC后出现编译错误的问题
|
||||
- [fix] Fixes the compilation error when incremental GC is enabled in version 2020.
|
||||
|
||||
## 4.0.0
|
||||
|
||||
发布日期 2023.08.28。
|
||||
Release Date: 2023-08-28.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] 支持增量式GC
|
||||
- [refactor] 重构桥接函数,彻底支持所有il2cpp支持的平台
|
||||
- [opt] 大幅优化Native2Managed方向的传参
|
||||
- [new] Supports incremental GC.
|
||||
- [refactor] Refactorizes bridge functions to fully support all platforms supported by il2cpp.
|
||||
- [opt] Significantly optimizes Native2Managed direction parameter passing.
|
||||
|
||||
### Editor
|
||||
|
||||
- [change] 删除增量式GC选项检查
|
||||
- [refactor] 重构桥接函数生成
|
||||
- [change] Removes incremental GC option checks.
|
||||
- [refactor] Refactorizes bridge function generation.
|
||||
|
||||
## 3.4.2
|
||||
|
||||
发布日期 2023.08.14。
|
||||
Release Date: 2023-08-14.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复RawImage::LoadTables读取_4byteGUIDIndex的bug
|
||||
- [version] 支持2022.3.7版本
|
||||
- [version] 支持2021.3.29版本
|
||||
- [fix] Fixes the bug in `RawImage::LoadTables` reading `_4byteGUIDIndex`.
|
||||
- [version] Supports version 2022.3.7.
|
||||
- [version] Supports version 2021.3.29.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复计算AOTGenericReference未考虑到泛型调用泛型的情况,导致少计算了泛型及补充元数据
|
||||
- [fix] Fixes the bug where calculating AOTGenericReference does not consider generic calls on generics, resulting in fewer calculated generics and supplementary metadata.
|
||||
|
||||
## 3.4.1
|
||||
|
||||
发布日期 2023.07.31。
|
||||
Release Date: 2023-07-31.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复 InitializeRuntimeMetadata的内存可见性问题
|
||||
- [fix] 修复CustomAttribute未正确处理父类NamedArg导致崩溃的bug
|
||||
- [opt] 优化Transfrom Instinct指令的代码,从HashMap中快速查找而不是挨个匹配
|
||||
- [fix] Fixes the memory visibility issue in `InitializeRuntimeMetadata`.
|
||||
- [fix] Fixes the bug where `CustomAttribute` does not correctly handle parent NamedArg, causing a crash.
|
||||
- [opt] Optimizes the code for Transform Instinct instructions, quickly looking up in the HashMap instead of matching one by one.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复FilterHotFixAssemblies只对比程序集名尾部,导致有AOT的尾部与某个热更新程序集匹配时意外被过滤的bug
|
||||
- [change] 检查Settings中热更新程序集列表配置中程序集名不能为空
|
||||
- [fix] Fixes the bug where `FilterHotFixAssemblies` only compares the tail of the assembly name, causing an assembly to be unexpectedly filtered if it matches the tail of an AOT assembly.
|
||||
- [change] Checks that the assembly name in the hot update assembly list configuration in Settings is not empty.
|
||||
|
||||
## 3.4.0
|
||||
|
||||
发布日期 2023.07.17。
|
||||
Release Date: 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
|
||||
- [version] Supports versions 2021.3.28 and 2022.3.4.
|
||||
- [opt] Removes unnecessary memset after allocating `_StackBase` in `MachineState::InitEvalStack`.
|
||||
- [fix] Fixes the exception mechanism bug.
|
||||
- [fix] Fixes the bug where `CustomAttribute` does not support Type[] type parameters.
|
||||
- [fix] Fixes the issue where the new string(xxx) syntax is not supported.
|
||||
- [refactor] Refactorizes VTableSetup implementation.
|
||||
- [fix] Fixes the bug where functions explicitly implementing parent interfaces in subinterfaces are not calculated.
|
||||
- [opt] Lazily initializes `CustomAttributeData` instead of initializing all at load time, significantly reducing `Assembly.Load` time.
|
||||
- [fix] Fixes the bug where new byte[]{a,b,c...} initialization of longer byte[] data returns incorrect data in version 2022.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复计算桥接函数未考虑到泛型类的成员函数中可能包含的Native2Managed调用
|
||||
- [change] link.xml及AOTGenericReferences.cs默认输出路径改为HybridCLRGenerate,避免与顶层HybridCLRData混淆
|
||||
- [fix] 修复Win下生成的Lump文件中include路径以\为目录分隔符导致同步到Mac后找不到路径的bug
|
||||
- [refactor] 重构Installer
|
||||
|
||||
- [fix] Fixes the bug where calculating bridge functions does not consider Native2Managed calls that may be included in generic class member functions.
|
||||
- [change] The default output paths for link.xml and AOTGenericReferences.cs are changed to HybridCLRGenerate to avoid confusion with the top-level HybridCLRData.
|
||||
- [fix] Fixes the bug where the include path in the lump file generated on Windows uses \ as the directory separator, causing path not found errors when synchronized to Mac.
|
||||
- [refactor] Refactorizes the Installer.
|
||||
|
||||
## 3.3.0
|
||||
|
||||
发布日期 2023.07.03。
|
||||
Release Date: 2023-07-03.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复localloc分配的内存未释放的bug
|
||||
- [change] MachineState改用RegisterRoot的方式注册执行栈,避免GC时扫描整个堆栈
|
||||
- [opt] 优化Managed2NativeCallByReflectionInvoke性能,提前计算好传参方式
|
||||
- [refactor] 重构ConvertInvokeArgs
|
||||
- [fix] Fixes the bug where memory allocated by localloc is not released.
|
||||
- [change] `MachineState` uses RegisterRoot to register the execution stack, avoiding GC scanning of the entire stack.
|
||||
- [opt] Optimizes the performance of Managed2NativeCallByReflectionInvoke by calculating the parameter passing method in advance.
|
||||
- [refactor] Refactorizes 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工程
|
||||
- [fix] Fixes the bug where compiling libil2cpp.a for 2020-2021 does not include brotli-related code files, resulting in compilation errors.
|
||||
- [fix] Fixes the bug where exporting an xcode project includes absolute paths, causing path not found errors when compiled on other machines.
|
||||
- [fix] Solves the instability issues in generating LinkXml, MethodBridge, AOTGenericReference, and ReversePInvokeWrap.
|
||||
- [fix] Fixes the exception when opening the Installer with an incompatible version.
|
||||
- [change] When hybridclr is disabled, packaging iOS no longer modifies the exported xcode project.
|
||||
|
||||
## 3.2.1
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复il2cpp TypeNameParser未将类型名中转义字符'\'去掉,导致找不到嵌套子类型的bug
|
||||
- [fix] Fixes the bug where il2cpp TypeNameParser does not remove escape characters '\' from type names, causing nested child types to not be found.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] Installer界面新增显示package版本
|
||||
- [new] CompileDll新增MacOS、Linux、WebGL目标
|
||||
- [fix] 修复重构文档站后的帮助文档的链接错误
|
||||
- [change] 为Anaylizer加上using 限定,解决某些情况下与项目的类型同名而产生编译冲突的问题
|
||||
- [new] The Installer interface adds display of package version.
|
||||
- [new] CompileDll adds MacOS, Linux, and WebGL targets.
|
||||
- [fix] Fixes the help documentation link errors after refactoring the documentation site.
|
||||
- [change] Adds using qualifiers to Analyzer to resolve compilation conflicts with project types that have the same name.
|
||||
|
||||
## 3.2.0
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复未在PlaceHolder中的Assembly加载时,如果由于不在Assembly列表,也没有任何解释器栈,导致Class::resolve_parse_info_internal查找不到类型的bug
|
||||
- [fix] 修复读取CustomAttribute System.Type类型数据崩溃的bug
|
||||
- [fix] Fixes the bug where if an Assembly is not in the PlaceHolder, and there is no interpreter stack, `Class::resolve_parse_info_internal` cannot find the type due to not being in the Assembly list.
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] 支持直接从源码打包iOS,不再需要单独编译libil2cpp.a
|
||||
- [opt] 优化版本不兼容时错误提示,不再抛出异常,而是显示"与当前版本不兼容"
|
||||
|
||||
- [new] Supports packaging iOS directly from source code, no longer needing to compile libil2cpp.a separately.
|
||||
- [opt] Optimizes error prompts for incompatible versions, no longer throwing exceptions, but displaying "incompatible with the current version".
|
||||
|
||||
## 3.1.1
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复2021及更高版本,InterpreterModule::Managed2NativeCallByReflectionInvoke调用值类型成员函数时,对this指针多余this=this-1操作。
|
||||
- [fix] 修复解析CustomAttribute中Enum[]类型字段的bug
|
||||
- [fix] 修复2021及更高版本反射调用值类型 close Delegate的Invoke函数时未修复target指针的bug
|
||||
- [new] 新增对增量式GC宏的检查,避免build.gradle中意外开启增量式GC引发的极其隐蔽的问题
|
||||
- [fix] Fixes the bug where InterpreterModule::Managed2NativeCallByReflectionInvoke calls value type member functions in 2021 and higher versions, with an extra this=this-1 operation.
|
||||
- [fix] Fixes the bug where parsing CustomAttribute Enum[] type fields.
|
||||
- [fix] Fixes the bug where invoking the Invoke function of a closed Delegate via reflection in 2021 and higher versions does not repair the target pointer.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复 Win32、Android32、WebGL平台的编译错误
|
||||
- [fix] 修复计算桥接函数时未考虑到补充元数据泛型实例化会导致访问到一些非公开的函数的情况,导致少生成一些必要的桥接函数
|
||||
- [opt] 生成AOTGenericReferences时,补充元数据assembly列表由注释改成List<string>列表,方便在代码中直接使用。
|
||||
- [change] CheckSettings中不再自动设置Api Compatible Level
|
||||
- [fix] Fixes compilation errors for Win32, Android32, and WebGL platforms.
|
||||
- [fix] Fixes the bug where calculating bridge functions does not consider supplementary metadata generic instantiation, which may access some non-public functions, resulting in fewer necessary bridge functions being generated.
|
||||
- [opt] When generating AOTGenericReferences, the supplementary metadata assembly list is changed from comments to List<string> lists for easy direct use in code.
|
||||
- [change] CheckSettings no longer automatically sets Api Compatible Level.
|
||||
|
||||
## 3.1.0
|
||||
|
||||
### Runtime
|
||||
|
||||
- [rollback] 还原对Unity 2020.3.x支持
|
||||
- [fix] 修复 WebGL平台ABI的bug
|
||||
- [rollback] Reverts support for Unity 2020.3.x.
|
||||
- [fix] Fixes the WebGL platform ABI bug.
|
||||
|
||||
### Editor
|
||||
|
||||
- [rollback] 还原对Unity 2020.3.x支持
|
||||
- [rollback] Reverts support for Unity 2020.3.x.
|
||||
|
||||
## 3.0.3
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复Enum::GetValues返回值不正确的bug
|
||||
- [fix] Fixes the bug where Enum::GetValues returns incorrect values.
|
||||
|
||||
## 3.0.2
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复Memory Profiler中创建内存快照时崩溃的bug
|
||||
- [fix] Fixes the bug where creating a memory snapshot in Memory Profiler crashes.
|
||||
|
||||
### Editor
|
||||
|
||||
- [remove] 移除 `HybridCLR/CreateAOTDllSnapshot`菜单
|
||||
|
||||
- [remove] Removes the `HybridCLR/CreateAOTDllSnapshot` menu.
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] 支持2022.3.0
|
||||
- [new] Supports version 2022.3.0.
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] 修复不支持访问CustomData字段及值的bug
|
||||
- [remove] 移除对2019及2020版本支持
|
||||
- [fix] Fixes the bug where accessing CustomData fields and values is not supported.
|
||||
- [remove] Removes support for 2019 and 2020 versions.
|
||||
|
||||
### Editor
|
||||
|
||||
- 包名更改为com.code-philosophy.hybridclr
|
||||
- 移除UnityFS插件
|
||||
- 移除Zip插件
|
||||
- HybridCLR菜单位置调整
|
||||
- Changes the package name to com.code-philosophy.hybridclr.
|
||||
- Removes the UnityFS plugin.
|
||||
- Removes the Zip plugin.
|
||||
- Adjusts the HybridCLR menu location.
|
||||
|
||||
## 2.4.2
|
||||
|
||||
### Runtime
|
||||
|
||||
- [version] 支持 2020.3.48,最后一个2020LTS版本
|
||||
- [version] 支持 2021.3.25
|
||||
- [version] Supports 2020.3.48, the last 2020 LTS version.
|
||||
- [version] Supports 2021.3.25.
|
||||
|
||||
## 2.4.1
|
||||
|
||||
@@ -453,7 +744,7 @@
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复遗漏 RELEASELOG.md.meta 文件的问题
|
||||
- [fix] Fixes the遗漏 RELEASELOG.md.meta file issue.
|
||||
|
||||
## 2.4.0
|
||||
|
||||
@@ -461,9 +752,9 @@
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] CheckSettings中检查ScriptingBackend及ApiCompatibleLevel,切换为正确的值
|
||||
- [new] 新增 MsvcStdextWorkaround.cs 解决2020 vs下stdext编译错误的问题
|
||||
- [fix] 修复当struct只包含一个float或double字段时,在arm64上计算桥接函数签名错误的bug
|
||||
- [new] CheckSettings checks ScriptingBackend and ApiCompatibleLevel, switching to the correct values.
|
||||
- [new] Adds MsvcStdextWorkaround.cs to solve stdext compilation errors in 2020 vs.
|
||||
- [fix] Fixes the bug where calculating bridge function signatures for structs containing only one float or double field is incorrect on arm64.
|
||||
|
||||
## 2.3.1
|
||||
|
||||
@@ -471,7 +762,7 @@
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] 修复本地复制libil2cpp却仍然从仓库下载安装的bug
|
||||
- [fix] Fixes the bug where copying libil2cpp locally still downloads and installs from the repository.
|
||||
|
||||
## 2.3.0
|
||||
|
||||
@@ -479,7 +770,9 @@
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] Installer支持从本地目录复制改造后的libil2cpp
|
||||
- [fix] 修复2019版本MonoBleedingEdge的子目录中包含了过长路径的文件导致Installer复制文件出错的问题
|
||||
- [new] The Installer supports copying modified libil2cpp from a local directory.
|
||||
- [fix] Fixes the bug where the MonoBleedingEdge subdirectory in version 2019 includes files with excessively long paths, causing the Installer to fail when copying files.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ namespace HybridCLR
|
||||
{
|
||||
public enum HomologousImageMode
|
||||
{
|
||||
Consistent, // AOT dll需要跟主工程精确一致,即为裁剪后的AO dll
|
||||
SuperSet, // AOT dll不需要跟主工程精确一致,但必须包含裁剪后的AOT dll的所有元数据,即为裁剪后dll的超集。推荐使用原始aot dll
|
||||
Consistent,
|
||||
SuperSet,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@ namespace HybridCLR
|
||||
public enum LoadImageErrorCode
|
||||
{
|
||||
OK = 0,
|
||||
BAD_IMAGE, // dll 不合法
|
||||
NOT_IMPLEMENT, // 不支持的元数据特性
|
||||
AOT_ASSEMBLY_NOT_FIND, // 对应的AOT assembly未找到
|
||||
HOMOLOGOUS_ONLY_SUPPORT_AOT_ASSEMBLY, // 不能给解释器assembly补充元数据
|
||||
HOMOLOGOUS_ASSEMBLY_HAS_LOADED, // 已经补充过了,不能再次补充
|
||||
INVALID_HOMOLOGOUS_MODE, // 非法HomologousImageMode
|
||||
};
|
||||
BAD_IMAGE, // invalid dll file
|
||||
NOT_IMPLEMENT, // not implement feature
|
||||
AOT_ASSEMBLY_NOT_FIND, // AOT assembly not found
|
||||
HOMOLOGOUS_ONLY_SUPPORT_AOT_ASSEMBLY, // can not load supplementary metadata assembly for non-AOT assembly
|
||||
HOMOLOGOUS_ASSEMBLY_HAS_LOADED, // can not load supplementary metadata assembly for the same assembly
|
||||
INVALID_HOMOLOGOUS_MODE, // invalid homologous image mode
|
||||
PDB_BAD_FILE, // invalid pdb file
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+48
-6
@@ -6,6 +6,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
namespace HybridCLR
|
||||
@@ -14,7 +15,7 @@ namespace HybridCLR
|
||||
public static class RuntimeApi
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载补充元数据assembly
|
||||
/// load supplementary metadata assembly
|
||||
/// </summary>
|
||||
/// <param name="dllBytes"></param>
|
||||
/// <returns></returns>
|
||||
@@ -30,7 +31,38 @@ namespace HybridCLR
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
|
||||
/// prejit method to avoid the jit cost of first time running
|
||||
/// </summary>
|
||||
/// <param name="method"></param>
|
||||
/// <returns>return true if method is jited, return false if method can't be jited </returns>
|
||||
///
|
||||
#if UNITY_EDITOR
|
||||
public static bool PreJitMethod(MethodInfo method)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
public static extern bool PreJitMethod(MethodInfo method);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// prejit all methods of class to avoid the jit cost of first time running
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns>return true if class is jited, return false if class can't be jited </returns>
|
||||
#if UNITY_EDITOR
|
||||
public static bool PreJitClass(Type type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
public static extern bool PreJitClass(Type type);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// get the maximum number of StackObjects in the interpreter thread stack (size*8 represents the final memory size occupied
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetInterpreterThreadObjectStackSize()
|
||||
@@ -39,17 +71,17 @@ namespace HybridCLR
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
|
||||
/// set the maximum number of StackObjects for the interpreter thread stack (size*8 represents the final memory size occupied)
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
public static void SetInterpreterThreadObjectStackSize(int size)
|
||||
{
|
||||
SetRuntimeOption(RuntimeOptionId.InterpreterThreadObjectStackSize, size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
|
||||
/// get the number of interpreter thread function frames (sizeof(InterpreterFrame)*size represents the final memory size occupied)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetInterpreterThreadFrameStackSize()
|
||||
@@ -58,7 +90,7 @@ namespace HybridCLR
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
|
||||
/// set the number of interpreter thread function frames (sizeof(InterpreterFrame)*size represents the final memory size occupied)
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
public static void SetInterpreterThreadFrameStackSize(int size)
|
||||
@@ -71,6 +103,11 @@ namespace HybridCLR
|
||||
|
||||
private static readonly Dictionary<RuntimeOptionId, int> s_runtimeOptions = new Dictionary<RuntimeOptionId, int>();
|
||||
|
||||
/// <summary>
|
||||
/// set runtime option value
|
||||
/// </summary>
|
||||
/// <param name="optionId"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void SetRuntimeOption(RuntimeOptionId optionId, int value)
|
||||
{
|
||||
s_runtimeOptions[optionId] = value;
|
||||
@@ -80,6 +117,11 @@ namespace HybridCLR
|
||||
public static extern void SetRuntimeOption(RuntimeOptionId optionId, int value);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// get runtime option value
|
||||
/// </summary>
|
||||
/// <param name="optionId"></param>
|
||||
/// <returns></returns>
|
||||
#if UNITY_EDITOR
|
||||
public static int GetRuntimeOption(RuntimeOptionId optionId)
|
||||
{
|
||||
|
||||
@@ -5,5 +5,8 @@
|
||||
InterpreterThreadObjectStackSize = 1,
|
||||
InterpreterThreadFrameStackSize = 2,
|
||||
ThreadExceptionFlowSize = 3,
|
||||
MaxMethodBodyCacheSize = 4,
|
||||
MaxMethodInlineDepth = 5,
|
||||
MaxInlineableMethodBodySize = 6,
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.code-philosophy.hybridclr",
|
||||
"version": "5.2.0",
|
||||
"version": "7.2.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