[new] 补充元数据支持使用超集aot dll,也就是可以使用原始aot dll而不再限定是裁减后的aot dll

main
walon 2022-10-26 11:28:49 +08:00
parent c12f1ee8e9
commit 77b7dea7bc
6 changed files with 27 additions and 9 deletions

View File

@ -68,10 +68,6 @@ namespace HybridCLR.Editor.Installer
public string Il2CppBranch => GetIl2CppPlusBranchByUnityVersion(Application.unityVersion); public string Il2CppBranch => GetIl2CppPlusBranchByUnityVersion(Application.unityVersion);
public string InitLocalIl2CppBatFile => Application.dataPath + "/../HybridCLRData/init_local_il2cpp_data.bat";
public string InitLocalIl2CppBashFile => Application.dataPath + "/../HybridCLRData/init_local_il2cpp_data.sh";
public InstallerController() public InstallerController()
{ {
PrepareIl2CppInstallPath(); PrepareIl2CppInstallPath();

View File

@ -0,0 +1,10 @@

namespace HybridCLR
{
public enum HomologousImageMode
{
Consistent, // AOT dll需要跟主工程精确一致即为裁剪后的AO dll
SuperSet, // AOT dll不需要跟主工程精确一致但必须包含裁剪后的AOT dll的所有元数据即为裁剪后dll的超集。推荐使用原始aot dll
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f0351553ad90e74aa586746b5965ded
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,6 +9,7 @@ namespace HybridCLR
AOT_ASSEMBLY_NOT_FIND, // 对应的AOT assembly未找到 AOT_ASSEMBLY_NOT_FIND, // 对应的AOT assembly未找到
HOMOLOGOUS_ONLY_SUPPORT_AOT_ASSEMBLY, // 不能给解释器assembly补充元数据 HOMOLOGOUS_ONLY_SUPPORT_AOT_ASSEMBLY, // 不能给解释器assembly补充元数据
HOMOLOGOUS_ASSEMBLY_HAS_LOADED, // 已经补充过了,不能再次补充 HOMOLOGOUS_ASSEMBLY_HAS_LOADED, // 已经补充过了,不能再次补充
INVALID_HOMOLOGOUS_MODE, // 非法HomologousImageMode
}; };
} }

View File

@ -24,14 +24,14 @@ namespace HybridCLR
/// <param name="dllBytes"></param> /// <param name="dllBytes"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotSupportedException"></exception> /// <exception cref="NotSupportedException"></exception>
public static unsafe LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllBytes) public static unsafe LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllBytes, HomologousImageMode mode)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return LoadImageErrorCode.OK; return LoadImageErrorCode.OK;
#else #else
fixed(byte* data = dllBytes) fixed(byte* data = dllBytes)
{ {
return (LoadImageErrorCode)LoadMetadataForAOTAssembly((IntPtr)data, dllBytes.Length); return (LoadImageErrorCode)LoadMetadataForAOTAssembly((IntPtr)data, dllBytes.Length, (int)mode);
} }
#endif #endif
} }
@ -43,7 +43,7 @@ namespace HybridCLR
/// <param name="dllSize"></param> /// <param name="dllSize"></param>
/// <returns></returns> /// <returns></returns>
[DllImport(dllName, EntryPoint = "RuntimeApi_LoadMetadataForAOTAssembly")] [DllImport(dllName, EntryPoint = "RuntimeApi_LoadMetadataForAOTAssembly")]
public static extern int LoadMetadataForAOTAssembly(IntPtr dllBytes, int dllSize); public static extern int LoadMetadataForAOTAssembly(IntPtr dllBytes, int dllSize, int mode);
/// <summary> /// <summary>
/// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小) /// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)

View File

@ -1,6 +1,6 @@
{ {
"name": "com.focus-creative-games.hybridclr_unity", "name": "com.focus-creative-games.hybridclr_unity",
"version": "0.8.0", "version": "0.9.0",
"displayName": "HybridCLR", "displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime", "category": "Runtime",