mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-20 07:22:39 +08:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59a3c3974a | |||
| c9ff293dfe | |||
| 56486b8a76 | |||
| 8e27e8d41b | |||
| fca130bbfa | |||
| c21dbcc60a | |||
| 7f2fa52f37 | |||
| da46e71534 | |||
| 804418fddb | |||
| 7a0032934b | |||
| b301b44cd3 | |||
| ddc3332958 | |||
| 52f25bdb2a | |||
| 31be818bb6 | |||
| 213a11ff25 | |||
| 585be97be9 | |||
| 361873803f | |||
| 46f308ed5e | |||
| 34406b1c13 | |||
| e5b52922f7 | |||
| e44fa663db | |||
| 903cf9faa2 | |||
| 3fe41a8cba | |||
| 603b0ccb24 | |||
| 9429a4d24d | |||
| ea592ba20c | |||
| 8d1280a1bd | |||
| 528240b52b | |||
| 4768c039d2 | |||
| 10dc749d7a | |||
| 0c5ef00c12 | |||
| 1553582ec1 | |||
| 756b906a21 | |||
| 355e24fbe8 | |||
| 9e4946aa45 | |||
| 8e571d594d | |||
| b8dd2be1e4 | |||
| de7b60695a | |||
| a11ebecf93 | |||
| 019412fa81 | |||
| 84bf6d59db | |||
| 82163d2e50 | |||
| 208372e6af | |||
| dd8d812641 | |||
| c19b34542e | |||
| e30306d7e1 | |||
| 20f34c9b14 | |||
| 45749ffb5c | |||
| b176d63d93 | |||
| 0c99afd58e | |||
| 2458c9a9ba |
@@ -0,0 +1,12 @@
|
||||
#include "../Il2CppCompatibleDef.h"
|
||||
|
||||
namespace hybridclr
|
||||
{
|
||||
const char* g_placeHolderAssemblies[] =
|
||||
{
|
||||
//!!!{{PLACE_HOLDER
|
||||
|
||||
//!!!}}PLACE_HOLDER
|
||||
nullptr,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <codegen/il2cpp-codegen-metadata.h>
|
||||
#if HYBRIDCLR_UNITY_2023_OR_NEW
|
||||
#include <codegen/il2cpp-codegen.h>
|
||||
#elif HYBRIDCLR_UNITY_2022
|
||||
#include <codegen/il2cpp-codegen-il2cpp.h>
|
||||
#elif HYBRIDCLR_UNITY_2020 || HYBRIDCLR_UNITY_2021
|
||||
#include <codegen/il2cpp-codegen-common-big.h>
|
||||
#else
|
||||
#include <codegen/il2cpp-codegen-common.h>
|
||||
#endif
|
||||
|
||||
#include "vm/ClassInlines.h"
|
||||
#include "vm/Object.h"
|
||||
#include "vm/Class.h"
|
||||
#include "vm/ScopedThreadAttacher.h"
|
||||
|
||||
#include "../metadata/MetadataUtil.h"
|
||||
|
||||
|
||||
#include "../interpreter/InterpreterModule.h"
|
||||
#include "../interpreter/MethodBridge.h"
|
||||
#include "../interpreter/Interpreter.h"
|
||||
#include "../interpreter/MemoryUtil.h"
|
||||
#include "../interpreter/InstrinctDef.h"
|
||||
|
||||
using namespace hybridclr::interpreter;
|
||||
using namespace hybridclr::metadata;
|
||||
|
||||
//!!!{{CODE
|
||||
|
||||
|
||||
//!!!}}CODE
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
//!!!{{UNITY_VERSION
|
||||
|
||||
|
||||
//!!!}}UNITY_VERSION
|
||||
@@ -2,38 +2,38 @@
|
||||
"versions": [
|
||||
{
|
||||
"unity_version":"2019",
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2019-7.0.0"}
|
||||
"hybridclr" : { "branch":"v8.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2019-8.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2020",
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2020-7.0.0"}
|
||||
"hybridclr" : { "branch":"v8.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2020-8.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2021",
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2021-7.0.0"}
|
||||
"hybridclr" : { "branch":"v8.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2021-8.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022",
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-7.2.0"}
|
||||
"hybridclr" : { "branch":"v8.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-8.2.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2022-tuanjie",
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-tuanjie-7.1.0"}
|
||||
"hybridclr" : { "branch":"v8.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2022-tuanjie-8.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"2023",
|
||||
"hybridclr" : { "branch":"v6.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2023-6.0.0"}
|
||||
"hybridclr" : { "branch":"v8.2.0"},
|
||||
"il2cpp_plus": { "branch":"v2023-8.1.0"}
|
||||
},
|
||||
{
|
||||
"unity_version":"6000",
|
||||
"hybridclr" : { "branch":"v7.2.0"},
|
||||
"il2cpp_plus": { "branch":"v6000-7.2.0"}
|
||||
"hybridclr" : { "branch":"v8.2.0"},
|
||||
"il2cpp_plus": { "branch":"v6000-8.1.0"}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -16,7 +16,11 @@ namespace MonoHook
|
||||
|
||||
static HookUtils()
|
||||
{
|
||||
jit_write_protect_supported = pthread_jit_write_protect_supported_np() != 0;
|
||||
try
|
||||
{
|
||||
jit_write_protect_supported = pthread_jit_write_protect_supported_np() != 0;
|
||||
}
|
||||
catch { }
|
||||
|
||||
PropertyInfo p_SystemPageSize = typeof(Environment).GetProperty("SystemPageSize");
|
||||
if (p_SystemPageSize == null)
|
||||
@@ -35,6 +39,16 @@ namespace MonoHook
|
||||
|
||||
public static void MemCpy_Jit(void* pDst, byte[] src)
|
||||
{
|
||||
if (!jit_write_protect_supported)
|
||||
{
|
||||
fixed(void * pSrc = &src[0])
|
||||
{
|
||||
MemCpy(pDst, pSrc, src.Length);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fixed(void * p = &src[0])
|
||||
{
|
||||
memcpy_jit(new IntPtr(pDst), new IntPtr(p), src.Length);
|
||||
|
||||
@@ -13,7 +13,14 @@ namespace HybridCLR.Editor.AOT
|
||||
{
|
||||
public static byte[] Strip(byte[] assemblyBytes)
|
||||
{
|
||||
var mod = ModuleDefMD.Load(assemblyBytes);
|
||||
var context = ModuleDef.CreateModuleContext();
|
||||
var readerOption = new ModuleCreationOptions(context)
|
||||
{
|
||||
Runtime = CLRRuntimeReaderKind.Mono
|
||||
};
|
||||
var mod = ModuleDefMD.Load(assemblyBytes, readerOption);
|
||||
// remove all resources
|
||||
mod.Resources.Clear();
|
||||
foreach (var type in mod.GetTypes())
|
||||
{
|
||||
if (type.HasGenericParameters)
|
||||
@@ -31,8 +38,8 @@ namespace HybridCLR.Editor.AOT
|
||||
}
|
||||
var writer = new System.IO.MemoryStream();
|
||||
var options = new ModuleWriterOptions(mod);
|
||||
options.MetadataOptions.Flags |= MetadataFlags.PreserveAll;
|
||||
mod.Write(writer);
|
||||
options.MetadataOptions.Flags |= MetadataFlags.PreserveRids;
|
||||
mod.Write(writer, options);
|
||||
writer.Flush();
|
||||
return writer.ToArray();
|
||||
}
|
||||
|
||||
@@ -47,10 +47,15 @@ namespace HybridCLR.Editor.BuildProcessors
|
||||
#if UNITY_TVOS
|
||||
case BuildTarget.tvOS:
|
||||
#endif
|
||||
return $"{projectDir}/Library/Bee/artifacts/iOS/ManagedStripped";
|
||||
#if UNITY_VISIONOS
|
||||
case BuildTarget.VisionOS:
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
return $"{projectDir}/Library/Bee/artifacts/VisionOS/ManagedStripped";
|
||||
#else
|
||||
return $"{projectDir}/Library/Bee/artifacts/iOS/ManagedStripped";
|
||||
#endif
|
||||
#endif
|
||||
return $"{projectDir}/Library/Bee/artifacts/iOS/ManagedStripped";
|
||||
case BuildTarget.WebGL:
|
||||
return $"{projectDir}/Library/Bee/artifacts/WebGL/ManagedStripped";
|
||||
case BuildTarget.StandaloneOSX:
|
||||
|
||||
@@ -25,10 +25,15 @@ namespace HybridCLR.Editor.Commands
|
||||
#if UNITY_2022
|
||||
UnityEditor.EditorUtility.ClearProgressBar();
|
||||
#endif
|
||||
Debug.Log("compile finish!!!");
|
||||
Debug.Log($"compile finish!!! buildDir:{buildDir} target:{target} development:{developmentBuild}");
|
||||
}
|
||||
|
||||
public static void CompileDll(BuildTarget target, bool developmentBuild = false)
|
||||
public static void CompileDll(BuildTarget target)
|
||||
{
|
||||
CompileDll(target, EditorUserBuildSettings.development);
|
||||
}
|
||||
|
||||
public static void CompileDll(BuildTarget target, bool developmentBuild)
|
||||
{
|
||||
CompileDll(SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target), target, developmentBuild);
|
||||
}
|
||||
@@ -36,10 +41,16 @@ namespace HybridCLR.Editor.Commands
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget", priority = 100)]
|
||||
public static void CompileDllActiveBuildTarget()
|
||||
{
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget);
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.development);
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Development", priority = 101)]
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Release", priority = 102)]
|
||||
public static void CompileDllActiveBuildTargetRelease()
|
||||
{
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget, false);
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Development", priority = 104)]
|
||||
public static void CompileDllActiveBuildTargetDevelopment()
|
||||
{
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget, true);
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
UnityVersion = Application.unityVersion,
|
||||
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,
|
||||
UnityVersionTemplateFile = $"{SettingsUtil.TemplatePathInPackage}/UnityVersion.h.tpl",
|
||||
UnityVersionOutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/UnityVersion.h",
|
||||
AssemblyManifestTemplateFile = $"{SettingsUtil.TemplatePathInPackage}/AssemblyManifest.cpp.tpl",
|
||||
AssemblyManifestOutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/AssemblyManifest.cpp",
|
||||
};
|
||||
|
||||
var g = new Il2CppDef.Il2CppDefGenerator(options);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
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;
|
||||
@@ -31,15 +30,16 @@ namespace HybridCLR.Editor.Commands
|
||||
Directory.Delete(il2cppBuildCachePath, true);
|
||||
}
|
||||
|
||||
private static void GenerateMethodBridgeCppFile(IReadOnlyCollection<GenericMethod> genericMethods, List<RawReversePInvokeMethodInfo> reversePInvokeMethods, string outputFile)
|
||||
private static void GenerateMethodBridgeCppFile(IReadOnlyCollection<GenericMethod> genericMethods, List<RawMonoPInvokeCallbackMethodInfo> reversePInvokeMethods, IReadOnlyCollection<CallNativeMethodSignatureInfo> calliMethodSignatures, string tempFile, string outputFile)
|
||||
{
|
||||
string templateCode = File.ReadAllText(outputFile, Encoding.UTF8);
|
||||
string templateCode = File.ReadAllText(tempFile, Encoding.UTF8);
|
||||
var g = new Generator(new Generator.Options()
|
||||
{
|
||||
TemplateCode = templateCode,
|
||||
OutputFile = outputFile,
|
||||
GenericMethods = genericMethods,
|
||||
ReversePInvokeMethods = reversePInvokeMethods,
|
||||
CalliMethodSignatures = calliMethodSignatures,
|
||||
Development = EditorUserBuildSettings.development,
|
||||
});
|
||||
|
||||
@@ -77,12 +77,20 @@ namespace HybridCLR.Editor.Commands
|
||||
List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls));
|
||||
|
||||
var reversePInvokeAnalyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls);
|
||||
var reversePInvokeAnalyzer = new MonoPInvokeCallbackAnalyzer(cache, hotUpdateDlls);
|
||||
reversePInvokeAnalyzer.Run();
|
||||
|
||||
var calliAnalyzer = new CalliAnalyzer(cache, hotUpdateDlls);
|
||||
calliAnalyzer.Run();
|
||||
var pinvokeAnalyzer = new PInvokeAnalyzer(cache, hotUpdateDlls);
|
||||
pinvokeAnalyzer.Run();
|
||||
var callPInvokeMethodSignatures = pinvokeAnalyzer.PInvokeMethodSignatures;
|
||||
|
||||
string templateFile = $"{SettingsUtil.TemplatePathInPackage}/MethodBridge.cpp.tpl";
|
||||
string outputFile = $"{SettingsUtil.GeneratedCppDir}/MethodBridge.cpp";
|
||||
|
||||
GenerateMethodBridgeCppFile(methodBridgeAnalyzer.GenericMethods, reversePInvokeAnalyzer.ReversePInvokeMethods, outputFile);
|
||||
var callNativeMethodSignatures = calliAnalyzer.CalliMethodSignatures.Concat(pinvokeAnalyzer.PInvokeMethodSignatures).ToList();
|
||||
GenerateMethodBridgeCppFile(methodBridgeAnalyzer.GenericMethods, reversePInvokeAnalyzer.ReversePInvokeMethods, callNativeMethodSignatures, templateFile, outputFile);
|
||||
|
||||
CleanIl2CppBuildCache();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace HybridCLR.Editor.Commands
|
||||
throw new BuildFailedException($"You have not initialized HybridCLR, please install it via menu 'HybridCLR/Installer'");
|
||||
}
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
CompileDllCommand.CompileDll(target, EditorUserBuildSettings.development);
|
||||
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
|
||||
|
||||
// 这几个生成依赖HotUpdateDlls
|
||||
|
||||
@@ -72,9 +72,6 @@ namespace HybridCLR.Editor.Commands
|
||||
BashUtil.RemoveDir(outputPath);
|
||||
|
||||
var buildOptions = GetBuildPlayerOptions(target);
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
buildOptions |= BuildOptions.CleanBuildCache;
|
||||
#endif
|
||||
|
||||
bool oldExportAndroidProj = EditorUserBuildSettings.exportAsGoogleAndroidProject;
|
||||
#if UNITY_EDITOR_OSX
|
||||
@@ -139,6 +136,9 @@ namespace HybridCLR.Editor.Commands
|
||||
options = buildOptions,
|
||||
target = target,
|
||||
targetGroup = BuildPipeline.GetBuildTargetGroup(target),
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
subtarget = (int)EditorUserBuildSettings.standaloneBuildSubtarget,
|
||||
#endif
|
||||
};
|
||||
|
||||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
|
||||
@@ -13,17 +13,19 @@ namespace HybridCLR.Editor.HotUpdate
|
||||
{
|
||||
private readonly HashSet<string> _aotAssNames;
|
||||
|
||||
private readonly HashSet<string> _hotUpdateAssNames;
|
||||
|
||||
private readonly AssemblyCache _assCache;
|
||||
|
||||
public MissingMetadataChecker(string aotDllDir, IEnumerable<string> excludeDllNames)
|
||||
public MissingMetadataChecker(string aotDllDir, IEnumerable<string> hotUpdateAssNames)
|
||||
{
|
||||
|
||||
var excludeDllNameSet = new HashSet<string>(excludeDllNames ?? new List<string>());
|
||||
_hotUpdateAssNames = new HashSet<string>(hotUpdateAssNames ?? new List<string>());
|
||||
_aotAssNames = new HashSet<string>();
|
||||
foreach (var aotFile in Directory.GetFiles(aotDllDir, "*.dll"))
|
||||
{
|
||||
string aotAssName = Path.GetFileNameWithoutExtension(aotFile);
|
||||
if (excludeDllNameSet.Contains(aotAssName))
|
||||
if (_hotUpdateAssNames.Contains(aotAssName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -34,6 +36,8 @@ namespace HybridCLR.Editor.HotUpdate
|
||||
|
||||
public bool Check(string hotUpdateDllPath)
|
||||
{
|
||||
bool anyMissing = false;
|
||||
|
||||
ModuleDef mod = ModuleDefMD.Load(File.ReadAllBytes(hotUpdateDllPath), _assCache.ModCtx);
|
||||
|
||||
foreach (var refass in mod.GetAssemblyRefs())
|
||||
@@ -43,9 +47,13 @@ namespace HybridCLR.Editor.HotUpdate
|
||||
{
|
||||
_assCache.LoadModule(refass.Name, true);
|
||||
}
|
||||
else if (!_hotUpdateAssNames.Contains(refAssName))
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Missing AOT Assembly: {refAssName}");
|
||||
anyMissing = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool anyMissing = false;
|
||||
|
||||
foreach (TypeRef typeRef in mod.GetTypeRefs())
|
||||
{
|
||||
|
||||
@@ -17,15 +17,15 @@ namespace HybridCLR.Editor.Il2CppDef
|
||||
{
|
||||
public List<string> HotUpdateAssemblies { get; set; }
|
||||
|
||||
public string OutputFile { get; set; }
|
||||
public string UnityVersionTemplateFile { get; set; }
|
||||
|
||||
public string OutputFile2 { get; set; }
|
||||
public string UnityVersionOutputFile { get; set; }
|
||||
|
||||
public string AssemblyManifestTemplateFile { get; set; }
|
||||
|
||||
public string AssemblyManifestOutputFile { get; set; }
|
||||
|
||||
public string UnityVersion { get; set; }
|
||||
|
||||
public bool EnableProfilerInReleaseBuild { get; set; }
|
||||
|
||||
public bool EnableStraceTraceInWebGLReleaseBuild { get; set; }
|
||||
}
|
||||
|
||||
private readonly Options _options;
|
||||
@@ -45,7 +45,7 @@ namespace HybridCLR.Editor.Il2CppDef
|
||||
|
||||
private void GenerateIl2CppConfig()
|
||||
{
|
||||
var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile));
|
||||
var frr = new FileRegionReplace(File.ReadAllText(_options.UnityVersionTemplateFile));
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
|
||||
@@ -81,25 +81,15 @@ namespace HybridCLR.Editor.Il2CppDef
|
||||
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));
|
||||
|
||||
frr.Commit(_options.OutputFile);
|
||||
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile}");
|
||||
frr.Commit(_options.UnityVersionOutputFile);
|
||||
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.UnityVersionOutputFile}");
|
||||
}
|
||||
|
||||
private void GeneratePlaceHolderAssemblies()
|
||||
{
|
||||
var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile2));
|
||||
var frr = new FileRegionReplace(File.ReadAllText(_options.AssemblyManifestTemplateFile));
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
|
||||
@@ -110,8 +100,8 @@ namespace HybridCLR.Editor.Il2CppDef
|
||||
|
||||
frr.Replace("PLACE_HOLDER", string.Join("\n", lines));
|
||||
|
||||
frr.Commit(_options.OutputFile2);
|
||||
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile2}");
|
||||
frr.Commit(_options.AssemblyManifestOutputFile);
|
||||
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.AssemblyManifestOutputFile}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
RemoveDir(subDir);
|
||||
}
|
||||
Directory.Delete(dir);
|
||||
Directory.Delete(dir, true);
|
||||
break;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -111,12 +111,12 @@ namespace HybridCLR.Editor.Installer
|
||||
#endif
|
||||
if (srcFile.Length > maxPathLength)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"srcFile:{srcFile} path is too long. copy ignore!");
|
||||
UnityEngine.Debug.LogError($"srcFile:{srcFile} path is too long. skip copy!");
|
||||
return;
|
||||
}
|
||||
if (dstFile.Length > maxPathLength)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"dstFile:{dstFile} path is too long. copy ignore!");
|
||||
UnityEngine.Debug.LogError($"dstFile:{dstFile} path is too long. skip copy!");
|
||||
return;
|
||||
}
|
||||
File.Copy(srcFile, dstFile);
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Link
|
||||
{
|
||||
internal class LinkXmlWriter
|
||||
public class LinkXmlWriter
|
||||
{
|
||||
public void Write(string outputLinkXmlFile, HashSet<TypeRef> refTypes)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
|
||||
public class AssemblySorter
|
||||
{
|
||||
class Node
|
||||
{
|
||||
public string Name;
|
||||
public List<Node> Dependencies = new List<Node>();
|
||||
|
||||
public Node(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
class TopologicalSorter
|
||||
{
|
||||
|
||||
public static List<Node> Sort(List<Node> nodes)
|
||||
{
|
||||
List<Node> sorted = new List<Node>();
|
||||
HashSet<Node> visited = new HashSet<Node>();
|
||||
HashSet<Node> tempMarks = new HashSet<Node>();
|
||||
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (!visited.Contains(node))
|
||||
{
|
||||
Visit(node, visited, tempMarks, sorted);
|
||||
}
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
private static void Visit(Node node, HashSet<Node> visited, HashSet<Node> tempMarks, List<Node> sorted)
|
||||
{
|
||||
if (tempMarks.Contains(node))
|
||||
{
|
||||
throw new Exception("Detected cyclic dependency!");
|
||||
}
|
||||
|
||||
if (!visited.Contains(node))
|
||||
{
|
||||
tempMarks.Add(node);
|
||||
foreach (var dependency in node.Dependencies)
|
||||
{
|
||||
Visit(dependency, visited, tempMarks, sorted);
|
||||
}
|
||||
tempMarks.Remove(node);
|
||||
visited.Add(node);
|
||||
sorted.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> SortAssemblyByReferenceOrder(IEnumerable<string> assemblies, Dictionary<string, HashSet<string>> refs)
|
||||
{
|
||||
var nodes = new List<Node>();
|
||||
var nodeMap = new Dictionary<string, Node>();
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
var node = new Node(assembly);
|
||||
nodes.Add(node);
|
||||
nodeMap.Add(assembly, node);
|
||||
}
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
var node = nodeMap[assembly];
|
||||
foreach (var refAssembly in refs[assembly])
|
||||
{
|
||||
node.Dependencies.Add(nodeMap[refAssembly]);
|
||||
}
|
||||
}
|
||||
var sortedNodes = TopologicalSorter.Sort(nodes);
|
||||
return sortedNodes.Select(node => node.Name).ToList();
|
||||
}
|
||||
|
||||
public static List<string> SortAssemblyByReferenceOrder(IEnumerable<string> assemblies, IAssemblyResolver assemblyResolver)
|
||||
{
|
||||
var assCache = new AssemblyCache(assemblyResolver);
|
||||
var assRefAssemblies = new Dictionary<string, HashSet<string>>();
|
||||
foreach (var assName in assemblies)
|
||||
{
|
||||
var refAssemblies = new HashSet<string>();
|
||||
var mod = assCache.LoadModule(assName, false);
|
||||
foreach (var refAss in mod.GetAssemblyRefs())
|
||||
{
|
||||
if (assemblies.Contains(refAss.Name.ToString()))
|
||||
{
|
||||
refAssemblies.Add(refAss.Name.ToString());
|
||||
}
|
||||
}
|
||||
assRefAssemblies.Add(assName, refAssemblies);
|
||||
}
|
||||
return SortAssemblyByReferenceOrder(assemblies, assRefAssemblies);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 851c44a8da67a9742a7ea68815383f27
|
||||
guid: b9b8eb45398fa344daa8c6e9b9fbf291
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -29,6 +29,12 @@ namespace HybridCLR.Editor.Meta
|
||||
Debug.Log($"[FixedSetAssemblyResolver] resolve:{assemblyName} path:{assemblyPath}");
|
||||
return true;
|
||||
}
|
||||
assemblyPath = $"{_rootDir}/{assemblyName}.dll.bytes";
|
||||
if (File.Exists(assemblyPath))
|
||||
{
|
||||
Debug.Log($"[FixedSetAssemblyResolver] resolve:{assemblyName} path:{assemblyPath}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
assemblyPath = null;
|
||||
return false;
|
||||
|
||||
@@ -7,13 +7,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
/// <summary>
|
||||
/// Replaces generic type/method var with its generic argument
|
||||
/// </summary>
|
||||
public sealed class GenericArgumentContext
|
||||
|
||||
public class GenericArgumentContext
|
||||
{
|
||||
List<TypeSig> typeArgsStack = new List<TypeSig>();
|
||||
List<TypeSig> methodArgsStack = new List<TypeSig>();
|
||||
private readonly List<TypeSig> typeArgsStack;
|
||||
private readonly List<TypeSig> methodArgsStack;
|
||||
|
||||
public GenericArgumentContext(List<TypeSig> typeArgsStack, List<TypeSig> methodArgsStack)
|
||||
{
|
||||
@@ -21,16 +19,6 @@ namespace HybridCLR.Editor.Meta
|
||||
this.methodArgsStack = methodArgsStack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Replaces a generic type/method var with its generic argument (if any). If
|
||||
/// <paramref name="typeSig"/> isn't a generic type/method var or if it can't
|
||||
/// be resolved, it itself is returned. Else the resolved type is returned.
|
||||
/// </summary>
|
||||
/// <param name="typeSig">Type signature</param>
|
||||
/// <returns>New <see cref="TypeSig"/> which is never <c>null</c> unless
|
||||
/// <paramref name="typeSig"/> is <c>null</c></returns>
|
||||
public TypeSig Resolve(TypeSig typeSig)
|
||||
{
|
||||
if (!typeSig.ContainsGenericParameter)
|
||||
@@ -41,9 +29,9 @@ namespace HybridCLR.Editor.Meta
|
||||
switch (typeSig.ElementType)
|
||||
{
|
||||
case ElementType.Ptr: return new PtrSig(Resolve(typeSig.Next));
|
||||
case ElementType.ByRef: return new PtrSig(Resolve(typeSig.Next));
|
||||
case ElementType.ByRef: return new ByRefSig(Resolve(typeSig.Next));
|
||||
|
||||
case ElementType.SZArray: return new PtrSig(Resolve(typeSig.Next));
|
||||
case ElementType.SZArray: return new SZArraySig(Resolve(typeSig.Next));
|
||||
case ElementType.Array:
|
||||
{
|
||||
var ara = (ArraySig)typeSig;
|
||||
@@ -53,7 +41,7 @@ namespace HybridCLR.Editor.Meta
|
||||
case ElementType.Var:
|
||||
{
|
||||
GenericVar genericVar = (GenericVar)typeSig;
|
||||
var newSig = Resolve(typeArgsStack, genericVar.Number, true);
|
||||
var newSig = Resolve(typeArgsStack, genericVar.Number);
|
||||
if (newSig == null)
|
||||
{
|
||||
throw new Exception();
|
||||
@@ -64,7 +52,7 @@ namespace HybridCLR.Editor.Meta
|
||||
case ElementType.MVar:
|
||||
{
|
||||
GenericMVar genericVar = (GenericMVar)typeSig;
|
||||
var newSig = Resolve(methodArgsStack, genericVar.Number, true);
|
||||
var newSig = Resolve(methodArgsStack, genericVar.Number);
|
||||
if (newSig == null)
|
||||
{
|
||||
throw new Exception();
|
||||
@@ -113,13 +101,9 @@ namespace HybridCLR.Editor.Meta
|
||||
}
|
||||
}
|
||||
|
||||
private TypeSig Resolve(List<TypeSig> args, uint number, bool isTypeVar)
|
||||
private TypeSig Resolve(List<TypeSig> args, uint number)
|
||||
{
|
||||
var typeSig = args[(int)number];
|
||||
var gvar = typeSig as GenericSig;
|
||||
if (gvar is null || gvar.IsTypeVar != isTypeVar)
|
||||
return typeSig;
|
||||
return gvar;
|
||||
return args[(int)number];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace HybridCLR.Editor.Meta
|
||||
methodDef = method.ResolveMethodDef();
|
||||
if (methodDef == null)
|
||||
{
|
||||
Debug.LogWarning($"method:{method} ResolveMethodDef() == null");
|
||||
//Debug.LogWarning($"method:{method} ResolveMethodDef() == null");
|
||||
return null;
|
||||
}
|
||||
if (method is MethodSpec methodSpec)
|
||||
|
||||
+25
-1
@@ -122,7 +122,7 @@ namespace HybridCLR.Editor.Meta
|
||||
}
|
||||
return new GenericInstSig(gia.GenericType, gia.GenericArguments.Select(ga => ToShareTypeSig(corTypes, ga)).ToList());
|
||||
}
|
||||
case ElementType.FnPtr: return corTypes.IntPtr;
|
||||
case ElementType.FnPtr: return corTypes.UIntPtr;
|
||||
case ElementType.ValueArray: return typeSig;
|
||||
case ElementType.Module: return typeSig;
|
||||
default:
|
||||
@@ -189,5 +189,29 @@ namespace HybridCLR.Editor.Meta
|
||||
}
|
||||
return methodGenericParams;
|
||||
}
|
||||
|
||||
public static bool IsSupportedPInvokeTypeSig(TypeSig typeSig)
|
||||
{
|
||||
typeSig = typeSig.RemovePinnedAndModifiers();
|
||||
if (typeSig.IsByRef)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
switch (typeSig.ElementType)
|
||||
{
|
||||
case ElementType.SZArray:
|
||||
case ElementType.Array:
|
||||
//case ElementType.Class:
|
||||
case ElementType.String:
|
||||
//case ElementType.Object:
|
||||
return false;
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsSupportedPInvokeMethodSignature(MethodSig methodSig)
|
||||
{
|
||||
return IsSupportedPInvokeTypeSig(methodSig.RetType) && methodSig.Params.All(p => IsSupportedPInvokeTypeSig(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,16 @@ namespace HybridCLR.Editor.Meta
|
||||
{
|
||||
foreach(var path in _searchPaths)
|
||||
{
|
||||
string assPath = Path.Combine(path, assemblyName + ".dll");
|
||||
if (File.Exists(assPath))
|
||||
assemblyPath = Path.Combine(path, $"{assemblyName}.dll");
|
||||
if (File.Exists(assemblyPath))
|
||||
{
|
||||
Debug.Log($"resolve {assemblyName} at {assPath}");
|
||||
assemblyPath = assPath;
|
||||
Debug.Log($"resolve {assemblyName} at {assemblyPath}");
|
||||
return true;
|
||||
}
|
||||
assemblyPath = Path.Combine(path, $"{assemblyName}.dll.bytes");
|
||||
if (File.Exists(assemblyPath))
|
||||
{
|
||||
Debug.Log($"resolve {assemblyName} at {assemblyPath}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using dnlib.DotNet;
|
||||
|
||||
namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
public class CallNativeMethodSignatureInfo
|
||||
{
|
||||
public MethodSig MethodSig { get; set; }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8373e0cb30c4894db7cd4d0b77a7a48
|
||||
guid: d2e4ca0a49975a84a8a72dbc70ec7795
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,65 @@
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
|
||||
public class CalliAnalyzer
|
||||
{
|
||||
private readonly List<ModuleDefMD> _rootModules = new List<ModuleDefMD>();
|
||||
|
||||
private readonly List<CallNativeMethodSignatureInfo> _calliMethodSignatures = new List<CallNativeMethodSignatureInfo>();
|
||||
|
||||
public List<CallNativeMethodSignatureInfo> CalliMethodSignatures => _calliMethodSignatures;
|
||||
|
||||
public CalliAnalyzer(AssemblyCache cache, List<string> assemblyNames)
|
||||
{
|
||||
foreach (var assemblyName in assemblyNames)
|
||||
{
|
||||
_rootModules.Add(cache.LoadModule(assemblyName));
|
||||
}
|
||||
}
|
||||
|
||||
private void CollectCalli()
|
||||
{
|
||||
foreach (var mod in _rootModules)
|
||||
{
|
||||
Debug.Log($"ass:{mod.FullName} methodcount:{mod.Metadata.TablesStream.MethodTable.Rows}");
|
||||
for (uint rid = 1, n = mod.Metadata.TablesStream.MethodTable.Rows; rid <= n; rid++)
|
||||
{
|
||||
var method = mod.ResolveMethod(rid);
|
||||
//Debug.Log($"method:{method}");
|
||||
if (!method.HasBody)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var il in method.Body.Instructions)
|
||||
{
|
||||
if (il.OpCode.Code == dnlib.DotNet.Emit.Code.Calli)
|
||||
{
|
||||
MethodSig methodSig = (MethodSig)il.Operand;
|
||||
|
||||
_calliMethodSignatures.Add(new CallNativeMethodSignatureInfo()
|
||||
{
|
||||
MethodSig = methodSig,
|
||||
});
|
||||
Debug.Log($"method:{method} calli method signature:{methodSig}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
CollectCalli();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 093a9e6c1e7399244bbcd8983fdbfdee
|
||||
guid: 6ce33c8e48da5a649b261ba3a60fd3b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+343
-115
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -15,8 +14,8 @@ 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;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
@@ -30,14 +29,38 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
public IReadOnlyCollection<GenericMethod> GenericMethods { get; set; }
|
||||
|
||||
public List<RawReversePInvokeMethodInfo> ReversePInvokeMethods { get; set; }
|
||||
public List<RawMonoPInvokeCallbackMethodInfo> ReversePInvokeMethods { get; set; }
|
||||
|
||||
public IReadOnlyCollection<CallNativeMethodSignatureInfo> CalliMethodSignatures { get; set; }
|
||||
|
||||
public bool Development { get; set; }
|
||||
}
|
||||
|
||||
private class ABIReversePInvokeMethodInfo
|
||||
{
|
||||
public MethodDesc Method { get; set; }
|
||||
|
||||
public CallingConvention Callvention { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
public string Signature { get; set; }
|
||||
}
|
||||
|
||||
private class CalliMethodInfo
|
||||
{
|
||||
public MethodDesc Method { get; set; }
|
||||
|
||||
public CallingConvention Callvention { get; set; }
|
||||
|
||||
public string Signature { get; set; }
|
||||
}
|
||||
|
||||
private readonly List<GenericMethod> _genericMethods;
|
||||
|
||||
private readonly List<RawReversePInvokeMethodInfo> _originalReversePInvokeMethods;
|
||||
private readonly List<RawMonoPInvokeCallbackMethodInfo> _originalReversePInvokeMethods;
|
||||
|
||||
private readonly List<CallNativeMethodSignatureInfo> _originalCalliMethodSignatures;
|
||||
|
||||
private readonly string _templateCode;
|
||||
|
||||
@@ -55,13 +78,16 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
private List<ABIReversePInvokeMethodInfo> _reversePInvokeMethods;
|
||||
|
||||
private List<CalliMethodInfo> _callidMethods;
|
||||
|
||||
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;
|
||||
|
||||
_originalCalliMethodSignatures = options.CalliMethodSignatures.ToList();
|
||||
|
||||
_templateCode = options.TemplateCode;
|
||||
_outputFile = options.OutputFile;
|
||||
_typeCreator = new TypeCreator();
|
||||
@@ -114,6 +140,30 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
return mbs;
|
||||
}
|
||||
|
||||
private MethodDesc CreateMethodDesc(TypeSig returnType, List<TypeSig> parameters)
|
||||
{
|
||||
var paramInfos = new List<ParamInfo>();
|
||||
if (returnType.ContainsGenericParameter)
|
||||
{
|
||||
throw new Exception($"[PreservedMethod] method has generic parameters");
|
||||
}
|
||||
foreach (var paramInfo in parameters)
|
||||
{
|
||||
if (paramInfo.ContainsGenericParameter)
|
||||
{
|
||||
throw new Exception($"[PreservedMethod] method has generic parameters");
|
||||
}
|
||||
paramInfos.Add(new ParamInfo() { Type = GetSharedTypeInfo(paramInfo) });
|
||||
}
|
||||
var mbs = new MethodDesc()
|
||||
{
|
||||
MethodDef = null,
|
||||
ReturnInfo = new ReturnInfo() { Type = returnType != null ? GetSharedTypeInfo(returnType) : TypeInfo.s_void },
|
||||
ParamInfos = paramInfos,
|
||||
};
|
||||
return mbs;
|
||||
}
|
||||
|
||||
private void AddManaged2NativeMethod(MethodDesc method)
|
||||
{
|
||||
method.Init();
|
||||
@@ -256,43 +306,105 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
private class AnalyzeTypeInfo
|
||||
{
|
||||
public TypeInfo toSharedType;
|
||||
public TypeInfo isoType;
|
||||
public List<AnalyzeFieldInfo> fields;
|
||||
public string signature;
|
||||
public ClassLayout classLayout;
|
||||
public TypeAttributes layout;
|
||||
public uint originalPackingSize;
|
||||
public uint packingSize;
|
||||
public uint classSize;
|
||||
public LayoutKind layout;
|
||||
public bool blittable;
|
||||
}
|
||||
|
||||
private readonly Dictionary<TypeInfo, AnalyzeTypeInfo> _analyzeTypeInfos = new Dictionary<TypeInfo, AnalyzeTypeInfo>();
|
||||
|
||||
private readonly Dictionary<string, TypeInfo> _signature2Type = new Dictionary<string, TypeInfo>();
|
||||
|
||||
|
||||
|
||||
private bool IsBlittable(TypeSig typeSig)
|
||||
{
|
||||
typeSig = typeSig.RemovePinnedAndModifiers();
|
||||
if (typeSig.IsByRef)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
switch (typeSig.ElementType)
|
||||
{
|
||||
case ElementType.Void: return false;
|
||||
case ElementType.Boolean:
|
||||
case ElementType.I1:
|
||||
case ElementType.U1:
|
||||
case ElementType.I2:
|
||||
case ElementType.Char:
|
||||
case ElementType.U2:
|
||||
case ElementType.I4:
|
||||
case ElementType.U4:
|
||||
case ElementType.I8:
|
||||
case ElementType.U8:
|
||||
case ElementType.R4:
|
||||
case ElementType.R8:
|
||||
case ElementType.I:
|
||||
case ElementType.U:
|
||||
case ElementType.Ptr:
|
||||
case ElementType.ByRef:
|
||||
case ElementType.FnPtr:
|
||||
case ElementType.TypedByRef: return true;
|
||||
case ElementType.String:
|
||||
case ElementType.Class:
|
||||
case ElementType.Array:
|
||||
case ElementType.SZArray:
|
||||
case ElementType.Object:
|
||||
case ElementType.Module:
|
||||
case ElementType.Var:
|
||||
case ElementType.MVar: return false;
|
||||
case ElementType.ValueType:
|
||||
{
|
||||
TypeDef typeDef = typeSig.ToTypeDefOrRef().ResolveTypeDef();
|
||||
if (typeDef == null)
|
||||
{
|
||||
throw new Exception($"type:{typeSig} definition could not be found. Please try `HybridCLR/Genergate/LinkXml`, then Build once to generate the AOT dll, and then regenerate the bridge function");
|
||||
}
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return CalculateAnalyzeTypeInfoBasic(GetSharedTypeInfo(typeSig)).blittable;
|
||||
}
|
||||
case ElementType.GenericInst:
|
||||
{
|
||||
GenericInstSig gis = (GenericInstSig)typeSig;
|
||||
if (!gis.GenericType.IsValueType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TypeDef typeDef = gis.GenericType.ToTypeDefOrRef().ResolveTypeDef();
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return CalculateAnalyzeTypeInfoBasic(GetSharedTypeInfo(typeSig)).blittable;
|
||||
}
|
||||
default: throw new NotSupportedException($"{typeSig.ElementType}");
|
||||
}
|
||||
}
|
||||
|
||||
private AnalyzeTypeInfo CalculateAnalyzeTypeInfoBasic(TypeInfo typeInfo)
|
||||
{
|
||||
Debug.Assert(typeInfo.IsStruct);
|
||||
if (_analyzeTypeInfos.TryGetValue(typeInfo, out var ati))
|
||||
{
|
||||
return ati;
|
||||
}
|
||||
TypeSig type = typeInfo.Klass;
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
|
||||
List<TypeSig> klassInst = type.ToGenericInstSig()?.GenericArguments?.ToList();
|
||||
GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
|
||||
ClassLayout sa = typeDef.ClassLayout;
|
||||
var analyzeTypeInfo = new AnalyzeTypeInfo()
|
||||
{
|
||||
classLayout = sa,
|
||||
layout = typeDef.Layout,
|
||||
};
|
||||
|
||||
// don't share type with explicit layout
|
||||
if (sa != null)
|
||||
{
|
||||
analyzeTypeInfo.toSharedType = typeInfo;
|
||||
analyzeTypeInfo.signature = typeInfo.CreateSigName();
|
||||
_signature2Type.Add(analyzeTypeInfo.signature, typeInfo);
|
||||
return analyzeTypeInfo;
|
||||
}
|
||||
|
||||
var fields = analyzeTypeInfo.fields = new List<AnalyzeFieldInfo>();
|
||||
var fields = new List<AnalyzeFieldInfo>();
|
||||
|
||||
bool blittable = true;
|
||||
foreach (FieldDef field in typeDef.Fields)
|
||||
{
|
||||
if (field.IsStatic)
|
||||
@@ -300,8 +412,39 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
continue;
|
||||
}
|
||||
TypeSig fieldType = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
fields.Add(new AnalyzeFieldInfo { field = field, type = GetSharedTypeInfo(fieldType) });
|
||||
blittable &= IsBlittable(fieldType);
|
||||
TypeInfo sharedFieldTypeInfo = GetSharedTypeInfo(fieldType);
|
||||
TypeInfo isoType = ToIsomorphicType(sharedFieldTypeInfo);
|
||||
fields.Add(new AnalyzeFieldInfo { field = field, type = isoType });
|
||||
}
|
||||
//analyzeTypeInfo.blittable = blittable;
|
||||
//analyzeTypeInfo.packingSize = blittable ? analyzeTypeInfo.originalPackingSize : 0;
|
||||
|
||||
ClassLayout sa = typeDef.ClassLayout;
|
||||
uint originalPackingSize = sa?.PackingSize ?? 0;
|
||||
var analyzeTypeInfo = new AnalyzeTypeInfo()
|
||||
{
|
||||
originalPackingSize = originalPackingSize,
|
||||
packingSize = blittable && !typeDef.IsAutoLayout ? originalPackingSize : 0,
|
||||
classSize = sa?.ClassSize ?? 0,
|
||||
layout = typeDef.IsAutoLayout ? LayoutKind.Auto : (typeDef.IsExplicitLayout ? LayoutKind.Explicit : LayoutKind.Sequential),
|
||||
fields = fields,
|
||||
blittable = blittable,
|
||||
};
|
||||
_analyzeTypeInfos.Add(typeInfo, analyzeTypeInfo);
|
||||
analyzeTypeInfo.signature = GetOrCalculateTypeInfoSignature(typeInfo);
|
||||
|
||||
if (_signature2Type.TryGetValue(analyzeTypeInfo.signature, out var sharedType))
|
||||
{
|
||||
// Debug.Log($"[ToIsomorphicType] type:{type.Klass} ==> sharedType:{sharedType.Klass} signature:{signature} ");
|
||||
analyzeTypeInfo.isoType = sharedType;
|
||||
}
|
||||
else
|
||||
{
|
||||
analyzeTypeInfo.isoType = typeInfo;
|
||||
_signature2Type.Add(analyzeTypeInfo.signature, typeInfo);
|
||||
}
|
||||
|
||||
return analyzeTypeInfo;
|
||||
}
|
||||
|
||||
@@ -324,17 +467,12 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
return ati.signature;
|
||||
}
|
||||
|
||||
|
||||
var sigBuf = new StringBuilder();
|
||||
if (ati.classLayout != null)
|
||||
if (ati.packingSize != 0 || ati.classSize != 0 || ati.layout != LayoutKind.Sequential || !ati.blittable)
|
||||
{
|
||||
sigBuf.Append($"[{ati.classLayout.ClassSize}|{ati.classLayout.PackingSize}|{ati.classLayout}]");
|
||||
sigBuf.Append($"[{ati.classSize}|{ati.packingSize}|{ati.layout}|{(ati.blittable ? 0 : 1)}]");
|
||||
}
|
||||
if (ati.layout != 0)
|
||||
{
|
||||
sigBuf.Append($"[{(int)ati.layout}]");
|
||||
}
|
||||
|
||||
foreach (var field in ati.fields)
|
||||
{
|
||||
string fieldOffset = field.field.FieldOffset != null ? field.field.FieldOffset.ToString() + "|" : "";
|
||||
@@ -349,27 +487,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
return type;
|
||||
}
|
||||
if (!_analyzeTypeInfos.TryGetValue(type, out var ati))
|
||||
{
|
||||
ati = CalculateAnalyzeTypeInfoBasic(type);
|
||||
_analyzeTypeInfos.Add(type, ati);
|
||||
}
|
||||
if (ati.toSharedType == null)
|
||||
{
|
||||
string signature = GetOrCalculateTypeInfoSignature(type);
|
||||
Debug.Assert(signature == ati.signature);
|
||||
if (_signature2Type.TryGetValue(signature, out var sharedType))
|
||||
{
|
||||
// Debug.Log($"[ToIsomorphicType] type:{type.Klass} ==> sharedType:{sharedType.Klass} signature:{signature} ");
|
||||
ati.toSharedType = sharedType;
|
||||
}
|
||||
else
|
||||
{
|
||||
ati.toSharedType = type;
|
||||
_signature2Type.Add(signature, type);
|
||||
}
|
||||
}
|
||||
return ati.toSharedType;
|
||||
return CalculateAnalyzeTypeInfoBasic(type).isoType;
|
||||
}
|
||||
|
||||
private MethodDesc ToIsomorphicMethod(MethodDesc method)
|
||||
@@ -422,11 +540,16 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
|
||||
|
||||
private static string MakeSignature(MethodDesc desc, CallingConvention CallingConventionention)
|
||||
private static string MakeReversePInvokeSignature(MethodDesc desc, CallingConvention CallingConventionention)
|
||||
{
|
||||
string convStr = ((char)('A' + (int)CallingConventionention - 1)).ToString();
|
||||
return $"{convStr}{desc.Sig}";
|
||||
}
|
||||
private static string MakeCalliSignature(MethodDesc desc, CallingConvention CallingConventionention)
|
||||
{
|
||||
string convStr = ((char)('A' + Math.Max((int)CallingConventionention - 1, 0))).ToString();
|
||||
return $"{convStr}{desc.Sig}";
|
||||
}
|
||||
|
||||
private static CallingConvention GetCallingConvention(MethodDef method)
|
||||
{
|
||||
@@ -464,7 +587,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
return (CallingConvention)conv;
|
||||
}
|
||||
|
||||
private List<ABIReversePInvokeMethodInfo> BuildABIMethods(List<RawReversePInvokeMethodInfo> rawMethods)
|
||||
private List<ABIReversePInvokeMethodInfo> BuildABIMethods(List<RawMonoPInvokeCallbackMethodInfo> rawMethods)
|
||||
{
|
||||
var methodsBySig = new Dictionary<string, ABIReversePInvokeMethodInfo>();
|
||||
foreach (var method in rawMethods)
|
||||
@@ -472,14 +595,14 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
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(),
|
||||
ReturnInfo = new ReturnInfo { Type = GetSharedTypeInfo(method.Method.ReturnType) },
|
||||
ParamInfos = method.Method.Parameters.Select(p => new ParamInfo { Type = GetSharedTypeInfo(p.Type) }).ToList(),
|
||||
};
|
||||
sharedMethod.Init();
|
||||
sharedMethod = ToIsomorphicMethod(sharedMethod);
|
||||
|
||||
CallingConvention callingConv = GetCallingConvention(method.Method);
|
||||
string signature = MakeSignature(sharedMethod, callingConv);
|
||||
string signature = MakeReversePInvokeSignature(sharedMethod, callingConv);
|
||||
|
||||
if (!methodsBySig.TryGetValue(signature, out var arm))
|
||||
{
|
||||
@@ -500,12 +623,46 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
return newMethods;
|
||||
}
|
||||
|
||||
private List<CalliMethodInfo> BuildCalliMethods(List<CallNativeMethodSignatureInfo> rawMethods)
|
||||
{
|
||||
var methodsBySig = new Dictionary<string, CalliMethodInfo>();
|
||||
foreach (var method in rawMethods)
|
||||
{
|
||||
var sharedMethod = new MethodDesc
|
||||
{
|
||||
MethodDef = null,
|
||||
ReturnInfo = new ReturnInfo { Type = GetSharedTypeInfo(method.MethodSig.RetType) },
|
||||
ParamInfos = method.MethodSig.Params.Select(p => new ParamInfo { Type = GetSharedTypeInfo(p) }).ToList(),
|
||||
};
|
||||
sharedMethod.Init();
|
||||
sharedMethod = ToIsomorphicMethod(sharedMethod);
|
||||
|
||||
CallingConvention callingConv = (CallingConvention)((int)(method.MethodSig.CallingConvention & dnlib.DotNet.CallingConvention.Mask) + 1);
|
||||
string signature = MakeCalliSignature(sharedMethod, callingConv);
|
||||
|
||||
if (!methodsBySig.TryGetValue(signature, out var arm))
|
||||
{
|
||||
arm = new CalliMethodInfo()
|
||||
{
|
||||
Method = sharedMethod,
|
||||
Signature = signature,
|
||||
Callvention = callingConv,
|
||||
};
|
||||
methodsBySig.Add(signature, arm);
|
||||
}
|
||||
}
|
||||
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);
|
||||
_callidMethods = BuildCalliMethods(_originalCalliMethodSignatures);
|
||||
}
|
||||
|
||||
private void OptimizationTypesAndMethods()
|
||||
@@ -528,7 +685,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
};
|
||||
|
||||
var classInfos = new List<ClassInfo>();
|
||||
var classTypeSet = new HashSet<TypeInfo>();
|
||||
var classTypeSet = new Dictionary<TypeInfo, ClassInfo>();
|
||||
foreach (var type in structTypes)
|
||||
{
|
||||
GenerateClassInfo(type, classTypeSet, classInfos);
|
||||
@@ -562,6 +719,13 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
|
||||
GenerateReversePInvokeWrappers(_reversePInvokeMethods, lines);
|
||||
|
||||
foreach (var method in _callidMethods)
|
||||
{
|
||||
GenerateManaged2NativeFunctionPointerMethod(method, lines);
|
||||
}
|
||||
GenerateManaged2NativeFunctionPointerMethodStub(_callidMethods, lines);
|
||||
|
||||
|
||||
frr.Replace("CODE", string.Join("\n", lines));
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(_outputFile));
|
||||
@@ -674,47 +838,68 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
|
||||
class ClassInfo
|
||||
{
|
||||
public TypeInfo type;
|
||||
|
||||
public TypeDef typeDef;
|
||||
|
||||
public List<FieldInfo> fields = new List<FieldInfo>();
|
||||
|
||||
public ClassLayout layout;
|
||||
public List<AnalyzeFieldInfo> fields;
|
||||
public uint packingSize;
|
||||
public uint classSize;
|
||||
public LayoutKind layout;
|
||||
public bool blittable;
|
||||
}
|
||||
|
||||
private void GenerateClassInfo(TypeInfo type, HashSet<TypeInfo> typeSet, List<ClassInfo> classInfos)
|
||||
private void GenerateClassInfo(TypeInfo type, Dictionary<TypeInfo, ClassInfo> typeSet, List<ClassInfo> classInfos)
|
||||
{
|
||||
if (!typeSet.Add(type))
|
||||
if (typeSet.ContainsKey(type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
TypeSig typeSig = type.Klass;
|
||||
var fields = new List<FieldInfo>();
|
||||
|
||||
TypeDef typeDef = typeSig.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
AnalyzeTypeInfo ati = CalculateAnalyzeTypeInfoBasic(type);
|
||||
//TypeSig typeSig = type.Klass;
|
||||
//var fields = new List<FieldInfo>();
|
||||
|
||||
List<TypeSig> klassInst = typeSig.ToGenericInstSig()?.GenericArguments?.ToList();
|
||||
GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
//TypeDef typeDef = typeSig.ToTypeDefOrRef().ResolveTypeDefThrow();
|
||||
|
||||
ClassLayout sa = typeDef.ClassLayout;
|
||||
|
||||
ICorLibTypes corLibTypes = typeDef.Module.CorLibTypes;
|
||||
foreach (FieldDef field in typeDef.Fields)
|
||||
//List<TypeSig> klassInst = typeSig.ToGenericInstSig()?.GenericArguments?.ToList();
|
||||
//GenericArgumentContext ctx = klassInst != null ? new GenericArgumentContext(klassInst, null) : null;
|
||||
|
||||
//ClassLayout sa = typeDef.ClassLayout;
|
||||
|
||||
//ICorLibTypes corLibTypes = typeDef.Module.CorLibTypes;
|
||||
//bool blittable = true;
|
||||
//foreach (FieldDef field in typeDef.Fields)
|
||||
//{
|
||||
// if (field.IsStatic)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// TypeSig fieldType = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
// fieldType = MetaUtil.ToShareTypeSig(corLibTypes, fieldType);
|
||||
// var fieldTypeInfo = ToIsomorphicType(GetSharedTypeInfo(fieldType));
|
||||
// if (fieldTypeInfo.IsStruct)
|
||||
// {
|
||||
// GenerateClassInfo(fieldTypeInfo, typeSet, classInfos);
|
||||
// }
|
||||
// blittable &= IsBlittable(fieldType, fieldTypeInfo, typeSet);
|
||||
// fields.Add(new FieldInfo { field = field, type = fieldTypeInfo });
|
||||
//}
|
||||
|
||||
foreach (var field in ati.fields)
|
||||
{
|
||||
if (field.IsStatic)
|
||||
if (field.type.IsStruct)
|
||||
{
|
||||
continue;
|
||||
GenerateClassInfo(field.type, typeSet, classInfos);
|
||||
}
|
||||
TypeSig fieldType = ctx != null ? MetaUtil.Inflate(field.FieldType, ctx) : field.FieldType;
|
||||
fieldType = MetaUtil.ToShareTypeSig(corLibTypes, fieldType);
|
||||
var fieldTypeInfo = ToIsomorphicType(_typeCreator.CreateTypeInfo(fieldType));
|
||||
if (fieldTypeInfo.IsStruct)
|
||||
{
|
||||
GenerateClassInfo(fieldTypeInfo, typeSet, classInfos);
|
||||
}
|
||||
fields.Add(new FieldInfo { field = field, type = fieldTypeInfo });
|
||||
}
|
||||
classInfos.Add(new ClassInfo() { type = type, typeDef = typeDef, fields = fields, layout = sa });
|
||||
var classInfo = new ClassInfo()
|
||||
{
|
||||
type = type,
|
||||
fields = ati.fields,
|
||||
packingSize = ati.packingSize,
|
||||
classSize = ati.classSize,
|
||||
layout = ati.layout,
|
||||
blittable = ati.blittable,
|
||||
};
|
||||
typeSet.Add(type, classInfo);
|
||||
classInfos.Add(classInfo);
|
||||
}
|
||||
|
||||
private void GenerateStructDefines(List<ClassInfo> classInfos, List<string> lines)
|
||||
@@ -722,16 +907,13 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
|
||||
foreach (var ci in classInfos)
|
||||
{
|
||||
lines.Add($"// {ci.type.Klass}");
|
||||
uint packingSize = ci.layout?.PackingSize ?? 0;
|
||||
if (packingSize != 0)
|
||||
{
|
||||
lines.Add($"#pragma pack(push, {packingSize})");
|
||||
}
|
||||
uint classSize = ci.layout?.ClassSize ?? 0;
|
||||
uint packingSize = ci.packingSize;
|
||||
uint classSize = ci.classSize;
|
||||
|
||||
if (ci.typeDef.IsExplicitLayout)
|
||||
if (ci.layout == LayoutKind.Explicit)
|
||||
{
|
||||
lines.Add($"union {ci.type.GetTypeName()} {{");
|
||||
lines.Add($"struct {ci.type.GetTypeName()} {{");
|
||||
lines.Add("\tunion {");
|
||||
if (classSize > 0)
|
||||
{
|
||||
lines.Add($"\tstruct {{ char __fieldSize_offsetPadding[{classSize}];}};");
|
||||
@@ -743,14 +925,28 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
|
||||
string fieldName = $"__{index}";
|
||||
string commentFieldName = $"{field.field.Name}";
|
||||
lines.Add("\t#pragma pack(push, 1)");
|
||||
lines.Add($"\tstruct {{ {(offset > 0 ? $"char {fieldName}_offsetPadding[{offset}];" : "")} {field.type.GetTypeName()} {fieldName};}}; // {commentFieldName}");
|
||||
lines.Add($"\tstruct {{ {(offset > 0 ? $"char {fieldName}_offsetPadding[{offset}]; " : "")}{field.type.GetTypeName()} {fieldName};}}; // {commentFieldName}");
|
||||
lines.Add($"\t#pragma pack(pop)");
|
||||
lines.Add($"\tstruct {{ {field.type.GetTypeName()} {fieldName}_forAlignmentOnly;}}; // {commentFieldName}");
|
||||
if (packingSize > 0)
|
||||
{
|
||||
lines.Add($"\t#pragma pack(push, {packingSize})");
|
||||
}
|
||||
lines.Add($"\tstruct {{ {(offset > 0 ? $"char {fieldName}_offsetPadding_forAlignmentOnly[{offset}]; " : "")}{field.type.GetTypeName()} {fieldName}_forAlignmentOnly;}}; // {commentFieldName}");
|
||||
if (packingSize > 0)
|
||||
{
|
||||
lines.Add($"\t#pragma pack(pop)");
|
||||
}
|
||||
++index;
|
||||
}
|
||||
lines.Add("\t};");
|
||||
lines.Add("};");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packingSize != 0)
|
||||
{
|
||||
lines.Add($"#pragma pack(push, {packingSize})");
|
||||
}
|
||||
lines.Add($"{(classSize > 0 ? "union" : "struct")} {ci.type.GetTypeName()} {{");
|
||||
if (classSize > 0)
|
||||
{
|
||||
@@ -769,18 +965,18 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
|
||||
{
|
||||
lines.Add("\t};");
|
||||
}
|
||||
}
|
||||
lines.Add("};");
|
||||
if (packingSize != 0)
|
||||
{
|
||||
lines.Add($"#pragma pack(pop)");
|
||||
lines.Add("};");
|
||||
if (packingSize != 0)
|
||||
{
|
||||
lines.Add($"#pragma pack(pop)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public const string SigOfObj = "u";
|
||||
private const string SigOfObj = "u";
|
||||
|
||||
public static string ToFullName(TypeSig type)
|
||||
private static string ToFullName(TypeSig type)
|
||||
{
|
||||
type = type.RemovePinnedAndModifiers();
|
||||
switch (type.ElementType)
|
||||
@@ -875,7 +1071,7 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
|
||||
return $"{Path.GetFileNameWithoutExtension(typeDef.Module.Name)}:{typeDef.FullName}";
|
||||
}
|
||||
|
||||
public void GenerateStructureSignatureStub(List<TypeInfo> types, List<string> lines)
|
||||
private void GenerateStructureSignatureStub(List<TypeInfo> types, List<string> lines)
|
||||
{
|
||||
lines.Add("const FullName2Signature hybridclr::interpreter::g_fullName2SignatureStub[] = {");
|
||||
foreach (var type in types)
|
||||
@@ -887,7 +1083,7 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu
|
||||
lines.Add("};");
|
||||
}
|
||||
|
||||
public void GenerateManaged2NativeStub(List<MethodDesc> methods, List<string> lines)
|
||||
private void GenerateManaged2NativeStub(List<MethodDesc> methods, List<string> lines)
|
||||
{
|
||||
lines.Add($@"
|
||||
const Managed2NativeMethodInfo hybridclr::interpreter::g_managed2nativeStub[] =
|
||||
@@ -903,7 +1099,7 @@ const Managed2NativeMethodInfo hybridclr::interpreter::g_managed2nativeStub[] =
|
||||
lines.Add("};");
|
||||
}
|
||||
|
||||
public void GenerateNative2ManagedStub(List<MethodDesc> methods, List<string> lines)
|
||||
private void GenerateNative2ManagedStub(List<MethodDesc> methods, List<string> lines)
|
||||
{
|
||||
lines.Add($@"
|
||||
const Native2ManagedMethodInfo hybridclr::interpreter::g_native2managedStub[] =
|
||||
@@ -919,7 +1115,7 @@ const Native2ManagedMethodInfo hybridclr::interpreter::g_native2managedStub[] =
|
||||
lines.Add("};");
|
||||
}
|
||||
|
||||
public void GenerateAdjustThunkStub(List<MethodDesc> methods, List<string> lines)
|
||||
private void GenerateAdjustThunkStub(List<MethodDesc> methods, List<string> lines)
|
||||
{
|
||||
lines.Add($@"
|
||||
const NativeAdjustThunkMethodInfo hybridclr::interpreter::g_adjustThunkStub[] =
|
||||
@@ -945,7 +1141,7 @@ const NativeAdjustThunkMethodInfo hybridclr::interpreter::g_adjustThunkStub[] =
|
||||
return type.NeedExpandValue() ? $"(uint64_t)({varName})" : $"N2MAsUint64ValueOrAddress<{type.GetTypeName()}>({varName})";
|
||||
}
|
||||
|
||||
public void GenerateManaged2NativeMethod(MethodDesc method, List<string> lines)
|
||||
private void GenerateManaged2NativeMethod(MethodDesc method, List<string> lines)
|
||||
{
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}").Concat(new string[] { "const MethodInfo* method" }));
|
||||
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => GetManaged2NativePassParam(p.Type, $"localVarBase+argVarIndexs[{p.Index}]")).Concat(new string[] { "method" }));
|
||||
@@ -959,7 +1155,7 @@ static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_
|
||||
");
|
||||
}
|
||||
|
||||
public string GenerateArgumentSizeAndOffset(List<ParamInfo> paramInfos)
|
||||
private string GenerateArgumentSizeAndOffset(List<ParamInfo> paramInfos)
|
||||
{
|
||||
StringBuilder s = new StringBuilder();
|
||||
int index = 0;
|
||||
@@ -973,7 +1169,7 @@ static void __M2N_{method.CreateCallSigName()}(const MethodInfo* method, uint16_
|
||||
return s.ToString();
|
||||
}
|
||||
|
||||
public string GenerateCopyArgumentToInterpreterStack(List<ParamInfo> paramInfos)
|
||||
private string GenerateCopyArgumentToInterpreterStack(List<ParamInfo> paramInfos)
|
||||
{
|
||||
StringBuilder s = new StringBuilder();
|
||||
int index = 0;
|
||||
@@ -1014,14 +1210,46 @@ static {method.ReturnInfo.Type.GetTypeName()} __N2M_{(adjustorThunk ? "AdjustorT
|
||||
");
|
||||
}
|
||||
|
||||
public void GenerateNative2ManagedMethod(MethodDesc method, List<string> lines)
|
||||
private void GenerateNative2ManagedMethod(MethodDesc method, List<string> lines)
|
||||
{
|
||||
GenerateNative2ManagedMethod0(method, false, lines);
|
||||
}
|
||||
|
||||
public void GenerateAdjustThunkMethod(MethodDesc method, List<string> lines)
|
||||
private void GenerateAdjustThunkMethod(MethodDesc method, List<string> lines)
|
||||
{
|
||||
GenerateNative2ManagedMethod0(method, true, lines);
|
||||
}
|
||||
|
||||
private void GenerateManaged2NativeFunctionPointerMethod(CalliMethodInfo methodInfo, List<string> lines)
|
||||
{
|
||||
MethodDesc method = methodInfo.Method;
|
||||
string paramListStr = string.Join(", ", method.ParamInfos.Select(p => $"{p.Type.GetTypeName()} __arg{p.Index}"));
|
||||
string paramNameListStr = string.Join(", ", method.ParamInfos.Select(p => GetManaged2NativePassParam(p.Type, $"localVarBase+argVarIndexs[{p.Index}]")));
|
||||
string il2cppCallConventionName = GetIl2cppCallConventionName(methodInfo.Callvention);
|
||||
lines.Add($@"
|
||||
static void __M2NF_{methodInfo.Signature}(Il2CppMethodPointer methodPointer, uint16_t* argVarIndexs, StackObject* localVarBase, void* ret)
|
||||
{{
|
||||
typedef {method.ReturnInfo.Type.GetTypeName()} ({il2cppCallConventionName} *NativeMethod)({paramListStr});
|
||||
{(!method.ReturnInfo.IsVoid ? $"*({method.ReturnInfo.Type.GetTypeName()}*)ret = " : "")}((NativeMethod)(methodPointer))({paramNameListStr});
|
||||
}}
|
||||
");
|
||||
}
|
||||
|
||||
private void GenerateManaged2NativeFunctionPointerMethodStub(List<CalliMethodInfo> calliMethodSignatures, List<string> lines)
|
||||
{
|
||||
lines.Add(@"
|
||||
const Managed2NativeFunctionPointerCallData hybridclr::interpreter::g_managed2NativeFunctionPointerCallStub[]
|
||||
{
|
||||
");
|
||||
foreach (var method in calliMethodSignatures)
|
||||
{
|
||||
lines.Add($"\t{{\"{method.Signature}\", __M2NF_{method.Signature}}},");
|
||||
}
|
||||
|
||||
lines.Add(@"
|
||||
{nullptr, nullptr},
|
||||
};
|
||||
");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-19
@@ -9,36 +9,25 @@ using System.Threading.Tasks;
|
||||
using CallingConvention = System.Runtime.InteropServices.CallingConvention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
public class RawReversePInvokeMethodInfo
|
||||
public class RawMonoPInvokeCallbackMethodInfo
|
||||
{
|
||||
public MethodDef Method { get; set; }
|
||||
|
||||
public CustomAttribute GenerationAttribute { get; set; }
|
||||
}
|
||||
|
||||
public class ABIReversePInvokeMethodInfo
|
||||
{
|
||||
public MethodDesc Method { get; set; }
|
||||
|
||||
public CallingConvention Callvention { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
public string Signature { get; set; }
|
||||
}
|
||||
|
||||
public class Analyzer
|
||||
public class MonoPInvokeCallbackAnalyzer
|
||||
{
|
||||
|
||||
private readonly List<ModuleDefMD> _rootModules = new List<ModuleDefMD>();
|
||||
|
||||
private readonly List<RawReversePInvokeMethodInfo> _reversePInvokeMethods = new List<RawReversePInvokeMethodInfo>();
|
||||
private readonly List<RawMonoPInvokeCallbackMethodInfo> _reversePInvokeMethods = new List<RawMonoPInvokeCallbackMethodInfo>();
|
||||
|
||||
public List<RawReversePInvokeMethodInfo> ReversePInvokeMethods => _reversePInvokeMethods;
|
||||
public List<RawMonoPInvokeCallbackMethodInfo> ReversePInvokeMethods => _reversePInvokeMethods;
|
||||
|
||||
public Analyzer(AssemblyCache cache, List<string> assemblyNames)
|
||||
public MonoPInvokeCallbackAnalyzer(AssemblyCache cache, List<string> assemblyNames)
|
||||
{
|
||||
foreach (var assemblyName in assemblyNames)
|
||||
{
|
||||
@@ -50,7 +39,7 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
{
|
||||
foreach (var mod in _rootModules)
|
||||
{
|
||||
Debug.Log($"ass:{mod.FullName} methodcount:{mod.Metadata.TablesStream.MethodTable.Rows}");
|
||||
Debug.Log($"ass:{mod.FullName} method count:{mod.Metadata.TablesStream.MethodTable.Rows}");
|
||||
for (uint rid = 1, n = mod.Metadata.TablesStream.MethodTable.Rows; rid <= n; rid++)
|
||||
{
|
||||
var method = mod.ResolveMethod(rid);
|
||||
@@ -64,11 +53,15 @@ namespace HybridCLR.Editor.ReversePInvokeWrap
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!MetaUtil.IsSupportedPInvokeMethodSignature(method.MethodSig))
|
||||
{
|
||||
Debug.LogError($"MonoPInvokeCallback method {method.FullName} has unsupported parameter or return type. Please check the method signature.");
|
||||
}
|
||||
//foreach (var ca in method.CustomAttributes)
|
||||
//{
|
||||
// Debug.Log($"{ca.AttributeType.FullName} {ca.TypeFullName}");
|
||||
//}
|
||||
_reversePInvokeMethods.Add(new RawReversePInvokeMethodInfo()
|
||||
_reversePInvokeMethods.Add(new RawMonoPInvokeCallbackMethodInfo()
|
||||
{
|
||||
Method = method,
|
||||
GenerationAttribute = method.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "HybridCLR.ReversePInvokeWrapperGenerationAttribute"),
|
||||
@@ -0,0 +1,50 @@
|
||||
using dnlib.DotNet;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
|
||||
public class PInvokeAnalyzer
|
||||
{
|
||||
private readonly List<ModuleDefMD> _rootModules = new List<ModuleDefMD>();
|
||||
|
||||
private readonly List<CallNativeMethodSignatureInfo> _pinvokeMethodSignatures = new List<CallNativeMethodSignatureInfo>();
|
||||
|
||||
public List<CallNativeMethodSignatureInfo> PInvokeMethodSignatures => _pinvokeMethodSignatures;
|
||||
|
||||
public PInvokeAnalyzer(AssemblyCache cache, List<string> assemblyNames)
|
||||
{
|
||||
foreach (var assemblyName in assemblyNames)
|
||||
{
|
||||
_rootModules.Add(cache.LoadModule(assemblyName));
|
||||
}
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
foreach (var mod in _rootModules)
|
||||
{
|
||||
foreach (TypeDef type in mod.GetTypes())
|
||||
{
|
||||
foreach (MethodDef method in type.Methods)
|
||||
{
|
||||
if (method.IsPinvokeImpl)
|
||||
{
|
||||
if (!MetaUtil.IsSupportedPInvokeMethodSignature(method.MethodSig))
|
||||
{
|
||||
Debug.LogError($"PInvoke method {method.FullName} has unsupported parameter or return type. Please check the method signature.");
|
||||
}
|
||||
_pinvokeMethodSignatures.Add(new CallNativeMethodSignatureInfo { MethodSig = method.MethodSig });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9923175c961b78849aeaf99708e294ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,29 +0,0 @@
|
||||
using HybridCLR.Editor;
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace HybridCLR.Editor.Settings
|
||||
{
|
||||
|
||||
[InitializeOnLoad]
|
||||
public static class EditorStatusWatcher
|
||||
{
|
||||
public static Action OnEditorFocused;
|
||||
static bool isFocused;
|
||||
static EditorStatusWatcher() => EditorApplication.update += Update;
|
||||
static void Update()
|
||||
{
|
||||
if (isFocused != InternalEditorUtility.isApplicationActive)
|
||||
{
|
||||
isFocused = InternalEditorUtility.isApplicationActive;
|
||||
if (isFocused)
|
||||
{
|
||||
HybridCLRSettings.LoadOrCreate();
|
||||
OnEditorFocused?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,23 +18,21 @@ namespace HybridCLR.Editor.Settings
|
||||
private SerializedProperty _hotUpdateAssemblies;
|
||||
private SerializedProperty _preserveHotUpdateAssemblies;
|
||||
private SerializedProperty _hotUpdateDllCompileOutputRootDir;
|
||||
private SerializedProperty _externalHotUpdateAssembliyDirs;
|
||||
private SerializedProperty _externalHotUpdateAssemblyDirs;
|
||||
private SerializedProperty _strippedAOTDllOutputRootDir;
|
||||
private SerializedProperty _patchAOTAssemblies;
|
||||
private SerializedProperty _outputLinkFile;
|
||||
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)
|
||||
{
|
||||
EditorStatusWatcher.OnEditorFocused += OnEditorFocused;
|
||||
InitGUI();
|
||||
}
|
||||
|
||||
private void InitGUI()
|
||||
{
|
||||
var setting = HybridCLRSettings.LoadOrCreate();
|
||||
@@ -48,137 +46,61 @@ namespace HybridCLR.Editor.Settings
|
||||
_hotUpdateAssemblies = _serializedObject.FindProperty("hotUpdateAssemblies");
|
||||
_preserveHotUpdateAssemblies = _serializedObject.FindProperty("preserveHotUpdateAssemblies");
|
||||
_hotUpdateDllCompileOutputRootDir = _serializedObject.FindProperty("hotUpdateDllCompileOutputRootDir");
|
||||
_externalHotUpdateAssembliyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs");
|
||||
_externalHotUpdateAssemblyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs");
|
||||
_strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir");
|
||||
_patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies");
|
||||
_outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
|
||||
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
|
||||
_maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration");
|
||||
_maxMethodBridgeGenericIteration = _serializedObject.FindProperty("maxMethodBridgeGenericIteration");
|
||||
_enableProfilerInReleaseBuild = _serializedObject.FindProperty("enableProfilerInReleaseBuild");
|
||||
enableStraceTraceInWebGLReleaseBuild = _serializedObject.FindProperty("enableStraceTraceInWebGLReleaseBuild");
|
||||
}
|
||||
private void OnEditorFocused()
|
||||
{
|
||||
InitGUI();
|
||||
Repaint();
|
||||
}
|
||||
public override void OnTitleBarGUI()
|
||||
{
|
||||
base.OnTitleBarGUI();
|
||||
var rect = GUILayoutUtility.GetLastRect();
|
||||
buttonStyle = buttonStyle ?? GUI.skin.GetStyle("IconButton");
|
||||
|
||||
#region 绘制官方网站跳转按钮
|
||||
var w = rect.x + rect.width;
|
||||
rect.x = w - 57;
|
||||
rect.y += 6;
|
||||
rect.width = rect.height = 18;
|
||||
var content = EditorGUIUtility.IconContent("_Help");
|
||||
content.tooltip = "点击访问 HybridCLR 官方文档";
|
||||
if (GUI.Button(rect, content, buttonStyle))
|
||||
{
|
||||
Application.OpenURL("https://hybridclr.doc.code-philosophy.com/");
|
||||
}
|
||||
#endregion
|
||||
#region 绘制 Preset
|
||||
rect.x += 19;
|
||||
content = EditorGUIUtility.IconContent("Preset.Context");
|
||||
content.tooltip = "点击存储或加载 Preset .";
|
||||
if (GUI.Button(rect, content, buttonStyle))
|
||||
{
|
||||
var target = HybridCLRSettings.Instance;
|
||||
var receiver = ScriptableObject.CreateInstance<SettingsPresetReceiver>();
|
||||
receiver.Init(target, this);
|
||||
PresetSelector.ShowSelector(target, null, true, receiver);
|
||||
}
|
||||
#endregion
|
||||
#region 绘制 Reset
|
||||
rect.x += 19;
|
||||
content = EditorGUIUtility.IconContent(
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
"pane options"
|
||||
#else
|
||||
"_Popup"
|
||||
#endif
|
||||
);
|
||||
content.tooltip = "Reset";
|
||||
if (GUI.Button(rect, content, buttonStyle))
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddItem(new GUIContent("Reset"), false, () =>
|
||||
{
|
||||
Undo.RecordObject(HybridCLRSettings.Instance, "Capture Value for Reset");
|
||||
var dv = ScriptableObject.CreateInstance<HybridCLRSettings>();
|
||||
var json = EditorJsonUtility.ToJson(dv);
|
||||
UnityEngine.Object.DestroyImmediate(dv);
|
||||
EditorJsonUtility.FromJsonOverwrite(json, HybridCLRSettings.Instance);
|
||||
HybridCLRSettings.Save();
|
||||
});
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public override void OnGUI(string searchContext)
|
||||
{
|
||||
using (CreateSettingsWindowGUIScope())
|
||||
if (_serializedObject == null || !_serializedObject.targetObject)
|
||||
{
|
||||
if (_serializedObject == null||!_serializedObject.targetObject)
|
||||
{
|
||||
InitGUI();
|
||||
}
|
||||
_serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(_enable);
|
||||
EditorGUILayout.PropertyField(_hybridclrRepoURL);
|
||||
EditorGUILayout.PropertyField(_il2cppPlusRepoURL);
|
||||
EditorGUILayout.PropertyField(_useGlobalIl2cpp);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblies);
|
||||
EditorGUILayout.PropertyField(_preserveHotUpdateAssemblies);
|
||||
EditorGUILayout.PropertyField(_hotUpdateDllCompileOutputRootDir);
|
||||
EditorGUILayout.PropertyField(_externalHotUpdateAssembliyDirs);
|
||||
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
|
||||
EditorGUILayout.PropertyField(_patchAOTAssemblies);
|
||||
EditorGUILayout.PropertyField(_outputLinkFile);
|
||||
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
|
||||
EditorGUILayout.PropertyField(_maxGenericReferenceIteration);
|
||||
EditorGUILayout.PropertyField(_maxMethodBridgeGenericIteration);
|
||||
EditorGUILayout.PropertyField(_enableProfilerInReleaseBuild);
|
||||
EditorGUILayout.PropertyField(enableStraceTraceInWebGLReleaseBuild);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
_serializedObject.ApplyModifiedProperties();
|
||||
HybridCLRSettings.Save();
|
||||
}
|
||||
InitGUI();
|
||||
}
|
||||
_serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(_enable);
|
||||
EditorGUILayout.PropertyField(_hybridclrRepoURL);
|
||||
EditorGUILayout.PropertyField(_il2cppPlusRepoURL);
|
||||
EditorGUILayout.PropertyField(_useGlobalIl2cpp);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblies);
|
||||
EditorGUILayout.PropertyField(_preserveHotUpdateAssemblies);
|
||||
EditorGUILayout.PropertyField(_hotUpdateDllCompileOutputRootDir);
|
||||
EditorGUILayout.PropertyField(_externalHotUpdateAssemblyDirs);
|
||||
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
|
||||
EditorGUILayout.PropertyField(_patchAOTAssemblies);
|
||||
EditorGUILayout.PropertyField(_outputLinkFile);
|
||||
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
|
||||
EditorGUILayout.PropertyField(_maxGenericReferenceIteration);
|
||||
EditorGUILayout.PropertyField(_maxMethodBridgeGenericIteration);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
_serializedObject.ApplyModifiedProperties();
|
||||
HybridCLRSettings.Save();
|
||||
}
|
||||
}
|
||||
private IDisposable CreateSettingsWindowGUIScope()
|
||||
{
|
||||
var unityEditorAssembly = Assembly.GetAssembly(typeof(EditorWindow));
|
||||
var type = unityEditorAssembly.GetType("UnityEditor.SettingsWindow+GUIScope");
|
||||
return Activator.CreateInstance(type) as IDisposable;
|
||||
}
|
||||
|
||||
public override void OnDeactivate()
|
||||
{
|
||||
base.OnDeactivate();
|
||||
EditorStatusWatcher.OnEditorFocused -= OnEditorFocused;
|
||||
HybridCLRSettings.Save();
|
||||
}
|
||||
|
||||
static HybridCLRSettingsProvider provider;
|
||||
static HybridCLRSettingsProvider s_provider;
|
||||
|
||||
[SettingsProvider]
|
||||
public static SettingsProvider CreateMyCustomSettingsProvider()
|
||||
{
|
||||
if (HybridCLRSettings.Instance && provider == null)
|
||||
if (s_provider == null)
|
||||
{
|
||||
provider = new HybridCLRSettingsProvider();
|
||||
using (var so = new SerializedObject(HybridCLRSettings.Instance))
|
||||
{
|
||||
provider.keywords = GetSearchKeywordsFromSerializedObject(so);
|
||||
}
|
||||
s_provider = new HybridCLRSettingsProvider();
|
||||
}
|
||||
return provider;
|
||||
return s_provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using System.IO;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Settings
|
||||
{
|
||||
[FilePath("ProjectSettings/HybridCLRSettings.asset")]
|
||||
public class HybridCLRSettings : ScriptableSingleton<HybridCLRSettings>
|
||||
|
||||
public class HybridCLRSettings : ScriptableObject
|
||||
{
|
||||
[Tooltip("enable HybridCLR")]
|
||||
public bool enable = true;
|
||||
@@ -51,10 +52,47 @@ namespace HybridCLR.Editor.Settings
|
||||
[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;
|
||||
|
||||
private static HybridCLRSettings s_Instance;
|
||||
|
||||
public static HybridCLRSettings Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!s_Instance)
|
||||
{
|
||||
LoadOrCreate();
|
||||
}
|
||||
return s_Instance;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetFilePath()
|
||||
{
|
||||
return "ProjectSettings/HybridCLRSettings.asset";
|
||||
}
|
||||
|
||||
public static HybridCLRSettings LoadOrCreate()
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
Object[] objs = InternalEditorUtility.LoadSerializedFileAndForget(filePath);
|
||||
s_Instance = objs.Length > 0 ? (HybridCLRSettings)objs[0] : (s_Instance ?? CreateInstance<HybridCLRSettings>());
|
||||
return s_Instance;
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
if (!s_Instance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string filePath = GetFilePath();
|
||||
string directoryName = Path.GetDirectoryName(filePath);
|
||||
Directory.CreateDirectory(directoryName);
|
||||
var obj = new Object[1] { s_Instance };
|
||||
InternalEditorUtility.SaveToSerializedFileAndForget(obj, filePath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Settings
|
||||
{
|
||||
public class ScriptableSingleton<T> : ScriptableObject where T : ScriptableObject
|
||||
{
|
||||
private static T s_Instance;
|
||||
public static T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!s_Instance)
|
||||
{
|
||||
LoadOrCreate();
|
||||
}
|
||||
return s_Instance;
|
||||
}
|
||||
}
|
||||
public static T LoadOrCreate()
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
if (!string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
var arr = InternalEditorUtility.LoadSerializedFileAndForget(filePath);
|
||||
s_Instance = arr.Length > 0 ? arr[0] as T : s_Instance??CreateInstance<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"save location of {nameof(ScriptableSingleton<T>)} is invalid");
|
||||
}
|
||||
return s_Instance;
|
||||
}
|
||||
|
||||
public static void Save(bool saveAsText = true)
|
||||
{
|
||||
if (!s_Instance)
|
||||
{
|
||||
Debug.LogError("Cannot save ScriptableSingleton: no instance!");
|
||||
return;
|
||||
}
|
||||
|
||||
string filePath = GetFilePath();
|
||||
if (!string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
string directoryName = Path.GetDirectoryName(filePath);
|
||||
if (!Directory.Exists(directoryName))
|
||||
{
|
||||
Directory.CreateDirectory(directoryName);
|
||||
}
|
||||
UnityEngine.Object[] obj = new T[1] { s_Instance };
|
||||
InternalEditorUtility.SaveToSerializedFileAndForget(obj, filePath, saveAsText);
|
||||
}
|
||||
}
|
||||
protected static string GetFilePath()
|
||||
{
|
||||
return typeof(T).GetCustomAttributes(inherit: true)
|
||||
.Where(v => v is FilePathAttribute)
|
||||
.Cast<FilePathAttribute>()
|
||||
.FirstOrDefault()
|
||||
?.filepath;
|
||||
}
|
||||
}
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class FilePathAttribute : Attribute
|
||||
{
|
||||
internal string filepath;
|
||||
/// <summary>
|
||||
/// 单例存放路径
|
||||
/// </summary>
|
||||
/// <param name="path">相对 Project 路径</param>
|
||||
public FilePathAttribute(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentException("Invalid relative path (it is empty)");
|
||||
}
|
||||
if (path[0] == '/')
|
||||
{
|
||||
path = path.Substring(1);
|
||||
}
|
||||
filepath = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.Presets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Settings
|
||||
{
|
||||
public class SettingsPresetReceiver : PresetSelectorReceiver
|
||||
{
|
||||
private Object m_Target;
|
||||
private Preset m_InitialValue;
|
||||
private SettingsProvider m_Provider;
|
||||
|
||||
internal void Init(Object target, SettingsProvider provider)
|
||||
{
|
||||
m_Target = target;
|
||||
m_InitialValue = new Preset(target);
|
||||
m_Provider = provider;
|
||||
}
|
||||
public override void OnSelectionChanged(Preset selection)
|
||||
{
|
||||
if (selection != null)
|
||||
{
|
||||
Undo.RecordObject(m_Target, "Apply Preset " + selection.name);
|
||||
selection.ApplyTo(m_Target);
|
||||
}
|
||||
else
|
||||
{
|
||||
Undo.RecordObject(m_Target, "Cancel Preset");
|
||||
m_InitialValue.ApplyTo(m_Target);
|
||||
}
|
||||
m_Provider.Repaint();
|
||||
}
|
||||
public override void OnSelectionClosed(Preset selection)
|
||||
{
|
||||
OnSelectionChanged(selection);
|
||||
Object.DestroyImmediate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Code Philosophy Technology Ltd.
|
||||
Copyright (c) 2025 Code Philosophy Technology Ltd.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
- [README 中文](./README.md)
|
||||
- [README English](./README_EN.md)
|
||||
|
||||
# HybridCLR
|
||||
|
||||
[](https://github.com/focus-creative-games/hybridclr/blob/main/LICENSE)
|
||||
@@ -10,6 +7,10 @@
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
[README 中文](./README.md) | [README English](./README_EN.md)
|
||||
|
||||
[Github](https://github.com/focus-creative-games/hybridclr) | [Gitee](https://gitee.com/focus-creative-games/hybridclr)
|
||||
|
||||
HybridCLR是一个**特性完整、零成本、高性能、低内存**的**近乎完美**的Unity全平台原生c#热更新解决方案。
|
||||
|
||||
HybridCLR扩充了il2cpp运行时代码,使它由纯[AOT](https://en.wikipedia.org/wiki/Ahead-of-time_compilation) runtime变成AOT+Interpreter 混合runtime,进而原生支持动态加载assembly,从底层彻底支持了热更新。使用HybridCLR技术的游戏不仅能在Android平台,也能在IOS、Consoles、WebGL等所有il2cpp支持的平台上高效运行。
|
||||
@@ -24,7 +25,6 @@ HybridCLR扩充了il2cpp运行时代码,使它由纯[AOT](https://en.wikipedia
|
||||
- [快速上手](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)
|
||||
- [商业项目案例](https://hybridclr.doc.code-philosophy.com/docs/other/businesscase)
|
||||
|
||||
|
||||
## 特性
|
||||
|
||||
- 近乎完整实现了[ECMA-335规范](https://www.ecma-international.org/publications-and-standards/standards/ecma-335/),只有极少量的[不支持的特性](https://hybridclr.doc.code-philosophy.com/docs/basic/notsupportedfeatures)。
|
||||
@@ -34,14 +34,16 @@ HybridCLR扩充了il2cpp运行时代码,使它由纯[AOT](https://en.wikipedia
|
||||
- 执行高效。实现了一个极其高效的寄存器解释器,所有指标都大幅优于其他热更新方案。[性能测试报告](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指令
|
||||
- 支持PInvoke
|
||||
- 支持一些il2cpp不支持的特性,如\_\_makeref、 \_\_reftype、\_\_refvalue指令
|
||||
- 支持独创的 **Differential Hybrid Execution(DHE)** 差分混合执行技术,即可以对AOT dll任意增删改,会智能地让未改动的函数以AOT方式运行,变化或者新增的函数以interpreter模式运行,让热更新的游戏逻辑的运行性能基本达到原生AOT的水平
|
||||
- 支持 **热重载** 技术,可以100%卸载程序集
|
||||
- 支持**热重载**技术,可以100%卸载程序集
|
||||
- 支持动态**Hotfix**技术,可以运行过程中无感修复代码bug
|
||||
- 支持现代的dll加密技术,有效保障代码安全
|
||||
|
||||
## 支持的版本与平台
|
||||
|
||||
- 支持2019.4.x、2020.3.x、2021.3.x、2022.3.x、2023.2.x、6000.0.x全系列LTS版本
|
||||
- 支持2019.4.x、2020.3.x、2021.3.x、2022.3.x、2023.2.x、6000.x.y 所有LTS版本
|
||||
- 支持所有il2cpp支持的平台
|
||||
- 支持团结引擎和鸿蒙平台
|
||||
|
||||
@@ -69,10 +71,11 @@ HybridCLR已经被广泛验证是非常高效、稳定的Unity热更新解决方
|
||||
|
||||
## 支持与联系
|
||||
|
||||
- 官方1群:651188171(满)
|
||||
- 新手1群:428404198(满)
|
||||
- 新手2群:**680274677(推荐)**
|
||||
- discord频道 https://discord.gg/BATfNfJnm2
|
||||
- 官方1群(3000人):651188171(满)
|
||||
- 新手1群(3000人):428404198(满)
|
||||
- 新手2群(2000人):680274677(满)
|
||||
- 新手3群(2000人):**920714552(推荐)**
|
||||
- discord频道 `https://discord.gg/BATfNfJnm2`
|
||||
- 商业合作邮箱: business#code-philosophy.com
|
||||
- [商业化支持](https://hybridclr.doc.code-philosophy.com/docs/business/intro)
|
||||
|
||||
|
||||
+3
-2
@@ -41,7 +41,7 @@ Welcome to embrace modern native C# hot update technology!
|
||||
|
||||
## 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 LTS versions including 2019.4.x, 2020.3.x, 2021.3.x, 2022.3.x, 2023.2.x, 6000.x.y.
|
||||
- Supports all platforms supported by il2cpp.
|
||||
- Supports Tuanjie(China) Engine and HarmonyOS platform.
|
||||
|
||||
@@ -71,7 +71,8 @@ You can view the [list of known top companies using HybridCLR and their launched
|
||||
|
||||
- Official Group 1: 651188171 (Full)
|
||||
- Beginner Group 1: 428404198 (Full)
|
||||
- Beginner Group 2: **680274677 (Recommended)**
|
||||
- Beginner Group 2: 680274677 (Full)
|
||||
- Beginner Group 3: **920714552 (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)
|
||||
|
||||
+185
@@ -1,5 +1,190 @@
|
||||
# ReleaseLog
|
||||
|
||||
## 8.2.0
|
||||
|
||||
Release Date: 2025-06-12.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] fix line number mistake in stacktrace
|
||||
- [fix] Fixed bug that PDBImage::SetupStackFrameInfo didn't set ilOffset and sourceCodeLineNumber of stackFrame when SequencePoint not found
|
||||
- [merge] merge il2cpp changes from 2022.3.54-2022.3.63
|
||||
|
||||
### Editor
|
||||
|
||||
- [change] changed from throw exception to logError when not supported pinvoke or reverse pinvoke method parameter type was found
|
||||
|
||||
## 8.1.0
|
||||
|
||||
Release Date: 2025-05-29.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [opt] **important**! use std::unordered_set for s_GenericInst to reduce the time cost of Assembly.Load to 33% of the original.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] fix bug of GenericArgumentContext that inflate ByRef and SZArray to Ptr.
|
||||
|
||||
## 8.0.0
|
||||
|
||||
Release Date: 2025-05-02.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] support define PInvoke method in interpreter assembly
|
||||
- [new] InterpreterImage initialize ImplMap for PInvoke methods.
|
||||
- [new] RawImageBase support ModuleRef and ImplMap table.
|
||||
- [fix] fixed a compilation error on PS4 platform for the code `TokenGenericContextType key = { token, genericContext };` — the C++ compiler version on PS4 is too old to support this initialization syntax for std::tuple.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] fix error of computing CallingConvention in MethodBridge/Generator::BuildCalliMethods
|
||||
- [new] generate Managed2NativeFunction for PInvoke method
|
||||
- [change] AssemblyResolver also resolves `*.dll.bytes` files besides `*.dll`.
|
||||
- [change] change type of the first argument `methodPointer` of Managed2NativeFunctionPointer from `const void*` to `Il2CppMethodPointer`
|
||||
- [change] the shared type of ElementType.FnPtr is changed from IntPtr to UIntPtr
|
||||
- [change] validate unsupported parameter type(.e.g string) in MonoPInvokeCallback signature when generate MethodBridge file
|
||||
- [opt] optimization unnecessary initialization of typeArgsStack and methodArgsStack of GenericArgumentContext
|
||||
- [refactor] refactor code of settings.
|
||||
- [refactor] move ReversePInvokeWrap/Analyzer.cs to MethodBridge/MonoPInvokeCallbackAnalyzer.cs
|
||||
|
||||
## 7.10.0
|
||||
|
||||
Release Date: 2025-04-22.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] fix the bug that doesn't lock g_MetadataLock in PDBImage::SetupStackFrameInfo.
|
||||
- [change] remove Il2CppTypeHash and Il2CppTypeEqualTo, replace with il2cpp::metadata::Il2CppTypeHash and il2cpp::metadata::Il2CppTypeEqualityComparer.
|
||||
- [merge] merge il2cpp changes from tuanjie 1.3.4 to 1.5.0, base unity from 2022.3.48 to 2022.3.55 .
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] fix bug of `CompileDll(BuildTarget target)` that use EditorUserBuildSettings.activeBuildTarget instead of target to call CompileDll.
|
||||
- [opt] AOTAssemblyMetadataStripper strips AOT assembly resources. (#54)
|
||||
|
||||
## 7.9.0
|
||||
|
||||
Release Date: 2025-03-31.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [merge] merge il2cpp changes from 6000.0.30f1 to 6000.0.44f1
|
||||
|
||||
## 7.8.1
|
||||
|
||||
Release Date: 2025-03-24.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] fix bug of CreateInitLocals when size <= 16
|
||||
- [change] remove unnecessary `frame->ip = (byte*)ip;` assignment in LOAD_PREV_FRAME()
|
||||
|
||||
## 7.8.0
|
||||
|
||||
Release Date: 2025-03-24.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [opt] fixed a **critical** bug where taking the address of the ip variable severely impacted compiler optimizations, leading to significant performance degradation.
|
||||
- [opt] add HiOpCodeEnum::None case to interpreter loop. avoid decrement *ip when compute jump table, boosts about 5% performance.
|
||||
- [opt] opt InitLocals and InitInlineLocals in small size cases
|
||||
- [opt] reorder MethodInfo fields to reduce memory size
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] fixed the bug where BashUtil.RemoveDir failed to run under certain circumstances on macOS systems.
|
||||
|
||||
## 7.7.0
|
||||
|
||||
Release Date: 2025-03-12.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [change] fixed the issue that HYBRIDCLR_ENABLE_PROFILER was disabled in release build
|
||||
- [fix] fix a crash in PDBImage::SetMethodDebugInfo when GetMethodDataFromCache returns nullptr
|
||||
- [fix] fix assert bug of InterpreterDelegateInvoke when method->parameters_count - curMethod->parameters_count == 1
|
||||
- [fix] fix compiler error of initialize constructor code `{a, b}` for `std::tuple<void*,void*>` in PS5
|
||||
- [opt] removed unnecessary pdb lock in PDBImage
|
||||
- [change] fix some compiler warnings
|
||||
- [change] HYBRIDCLR_ENABLE_STRACKTRACE was enabled in both DEBUG and RELEASE build without considering HYBRIDCLR_ENABLE_STRACE_TRACE_IN_WEBGL_RELEASE_BUILD flag.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] fixed hook failed in version below MacOS 11
|
||||
- [change] CompileDllActiveBuildTarget and GenerateAll use EditorUserBuildSettings.development to compile hot update dll.
|
||||
- [remove] remove option HybridCLRSettings.enableProfilerInReleaseBuild
|
||||
- [remove] remove option HybridCLRSettings.enableStraceTraceInWebGLReleaseBuild
|
||||
|
||||
## 7.6.0
|
||||
|
||||
Release Date: 2025-03-01.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] fixed the bug in ClassFieldLayoutCalculator where it incorrectly handles [StructLayout] and blittable attribute when calculating the layout for structs.
|
||||
- [fix] fix bug of computing explicit struct layout caused by commit "199b1b1a789d760828bd33e7e1438261cd1f8d15"
|
||||
- [fix] fix the code `TokenGenericContextType key = { token, genericContext }` has compiler error in PS5
|
||||
- [merge] merge il2cpp changes from 2021.3.44f1 to 2021.3.49f1
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] fixed the bug in the MethodBridge generator where it incorrectly handles [StructLayout] and blittable attribute when generating code for struct classes.
|
||||
- [new] add AssemblySorter to sort assemblies by reference order
|
||||
|
||||
## 7.5.0
|
||||
|
||||
Release Date: 2025-02-05.
|
||||
|
||||
### Editor
|
||||
|
||||
- [revert] Revert 'support preserve UnityEngine core types when GenerateLinkXml'.
|
||||
|
||||
## 7.4.1
|
||||
|
||||
Release Date: 2025-01-19.
|
||||
|
||||
### Editor
|
||||
|
||||
[fix] fixe the bug that preserving UnityEngine.PerformanceReportingModule when generating link.xml would cause the Android app built with Unity 2019 to crash on startup.
|
||||
|
||||
## 7.4.0
|
||||
|
||||
Release Date: 2025-01-17.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [new] calli supports call both native function pointer and managed method
|
||||
|
||||
### Editor
|
||||
|
||||
- [new] add Managed2NativeFunctionPointer MethodBridge functions
|
||||
- [new] support preserve UnityEngine core types when GenerateLinkXml
|
||||
- [fix] fixed the bug in AOTAssemblyMetadataStripper::Strip where ModuleWriterOptions MetadataFlags.PreserveRids was not used.
|
||||
- [fix] fixed the bug where StripAOTDllCommand did not set BuildPlayerOptions.subtarget in Unity 2021+ versions, causing failure when publishing dedicated buildTarget.
|
||||
- [change] add UnityVersion.h.tpl and AssemblyManifest.cpp.tpl, Il2CppDefGenerator doesn't generates and override code file from same one
|
||||
- [change] add MethodBridge.cpp.tpl. MethodBridgeGeneratorCommand doesn't generate and override from same file
|
||||
|
||||
## 7.3.0
|
||||
|
||||
Release Date: 2024-12-31.
|
||||
|
||||
### Runtime
|
||||
|
||||
- [fix] fix bug that Image::ReadRuntimeHandleFromMemberRef didn't inflate parent type when read field of GenericType
|
||||
- [fix] fix an issue occurred in InterpreterImage::GenerateCustomAttributesCacheInternal where HYBRIDCLR_METADATA_MALLOC was incorrectly used to allocate the cache. When occasional contention occurs, releasing memory using HYBRIDCLR_FREE causes a crash.
|
||||
- [fix] fixed a potential deadlock issue in Unity 2019 and 2020 versions within InterpreterImage::GenerateCustomAttributesCacheInternal, where il2cpp::vm::g_MetadataLock was held before running ConstructCustomAttribute.
|
||||
- [fix] fixed a bug in Unity 2019 and 2020 within InterpreterImage::GenerateCustomAttributesCacheInternal, where cache memory leaks occurred under multithreading contention.
|
||||
- [fix] fix the bug that InterpreterImage::ConstructCustomAttribute doesn't set write barrier for field
|
||||
- [fix] fix the bug that `InterpreterImage::InitTypeDefs_2` runs after `InitClassLayouts`, causing the `packingSize` field to be incorrectly initialized.
|
||||
- [fix] fix the bug in ClassFieldLayoutCalculator::LayoutFields where the alignment calculation incorrectly considers naturalAlignment, resulting in field offsets that are inconsistent with the actual field offsets in AOT. This bug originates from IL2CPP itself and only occurs in Unity 2021 and earlier versions.
|
||||
|
||||
### Editor
|
||||
|
||||
- [fix] fix the issue in Unity 6000 where the modification of the trimmed AOT DLL output directory for the visionOS build target caused CopyStrippedAOTAssemblies::GetStripAssembliesDir2021 to fail in copying AOT DLLs.
|
||||
- [fix] fix the bug where MissingMetadataChecker can't detect references to newly added AOT assemblies.
|
||||
|
||||
## 7.2.0
|
||||
|
||||
Release Date: 2024-12-9.
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "com.code-philosophy.hybridclr",
|
||||
"version": "7.2.0",
|
||||
"version": "8.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",
|
||||
"category": "Scripting",
|
||||
"documentationUrl": "https://hybridclr.doc.code-philosophy.com/#/",
|
||||
"changelogUrl": "https://hybridclr.doc.code-philosophy.com/#/other/changelog",
|
||||
"licensesUrl": "https://github.com/focus-creative-games/hybridclr_unity/blob/main/LICENSE",
|
||||
|
||||
Reference in New Issue
Block a user