Compare commits

...

7 Commits

Author SHA1 Message Date
walon 521db6e38c [new] 创建1.0.0版本 2022-11-28 11:11:28 +08:00
walon c85adbe65b [refactor] UNITY_VERSION 相关定义从 Il2CppCompatibleDef.h 移到 il2cpp-config.h 2022-11-24 12:09:04 +08:00
walon b9ea9b21f3 [fix] 修复扫描Plugin assembly时未忽略~结尾的目录的bug 2022-11-18 19:38:21 +08:00
walon 429845bf9e [new] installer支持使用自定义仓库地址
[opt] 优化installer的显示
2022-11-09 11:28:09 +08:00
walon c95b7eaf3b [new] 为测试openupm而升到0.10.3 2022-11-07 15:27:38 +08:00
walon fdb9cc034a [fix] 修复检查更新未生效的bug 2022-11-06 20:16:38 +08:00
walon bdc0d772c8 [new] 支持 Differential Hybrid Execution基础版本 2022-11-05 22:22:39 +08:00
27 changed files with 547 additions and 27 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ namespace HybridCLR.Editor.BuildProcessors
HybridCLRSettings gs = SettingsUtil.HybridCLRSettings;
if (((gs.hotUpdateAssemblies?.Length + gs.hotUpdateAssemblyDefinitions?.Length) ?? 0) == 0)
{
throw new Exception($"HybridCLRSettings中未配置任何热更新模块");
Debug.LogWarning("[CheckSettings] HybridCLRSettings中未配置任何热更新模块");
}
}
@@ -0,0 +1,56 @@
using HybridCLR.Editor.DHE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
namespace HybridCLR.Editor.Commands
{
public static class DifferentialHybridExecutionCommand
{
[MenuItem("HybridCLR/Generate/DHEAssemblyList", priority = 110)]
public static void GenerateAssemblyList()
{
var options = new AssemblyListGenerator.Options()
{
DifferentialHybridAssembyList = (HybridCLRSettings.Instance.differentialHybridAssemblies ?? Array.Empty<string>()).ToList(),
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/Il2CppCompatibleDef.cpp",
};
var g = new AssemblyListGenerator(options);
g.Generate();
}
[MenuItem("HybridCLR/Generate/DHEAssemblyOptionDatas", priority = 111)]
public static void GenerateAssemblyOptionDatas()
{
GenerateAssemblyOptionDatas(true);
}
public static void GenerateAssemblyOptionDatas(bool compileDll)
{
if (compileDll)
{
CompileDllCommand.CompileDllActiveBuildTarget();
}
string[] differentialHybridAssemblyList = HybridCLRSettings.Instance.differentialHybridAssemblies;
if (differentialHybridAssemblyList == null || differentialHybridAssemblyList.Length == 0)
{
Debug.Log("[DifferentialHybridExecutionCommand.GenerateAssemblyOptionDatas] differentialHybridAssemblies is empty. skip generation.");
return;
}
var options = new AssemblyOptionDataGenerator.Options()
{
DifferentialHybridAssembyList = differentialHybridAssemblyList.ToList(),
OutputDir = $"{SettingsUtil.ProjectDir}/{HybridCLRSettings.Instance.differentialHybridOptionOutputDir}",
};
var g = new AssemblyOptionDataGenerator(options);
g.Generate();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 998b5f512dc60924e953a558ed250e15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
using HybridCLR.Editor.Link;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace HybridCLR.Editor.Commands
{
public static class Il2CppDefGeneratorCommand
{
[MenuItem("HybridCLR/Generate/Il2CppDef", priority = 104)]
public static void GenerateIl2CppDef()
{
var options = new Il2CppDef.Il2CppDefGenerator.Options()
{
UnityVersion = UnityEngine.Application.unityVersion,
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/il2cpp-config.h",
};
var g = new Il2CppDef.Il2CppDefGenerator(options);
g.Generate();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5165a065d05497c43a2fff885f31ed07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -15,6 +15,9 @@ namespace HybridCLR.Editor.Commands
[MenuItem("HybridCLR/Generate/All", priority = 200)]
public static void GenerateAll()
{
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
DifferentialHybridExecutionCommand.GenerateAssemblyList();
DifferentialHybridExecutionCommand.GenerateAssemblyOptionDatas();
// 顺序随意
ReversePInvokeWrapperGeneratorCommand.GenerateReversePInvokeWrapper();
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e6e11530acf7134796d0a439a6bbe61
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+44
View File
@@ -0,0 +1,44 @@
using HybridCLR.Editor.Template;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEngine;
namespace HybridCLR.Editor.DHE
{
public class AssemblyListGenerator
{
public class Options
{
public string OutputFile { get; set; }
public List<string> DifferentialHybridAssembyList { get; set; }
}
private readonly Options _options;
public AssemblyListGenerator(Options options)
{
_options = options;
}
public void Generate()
{
var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile));
List<string> lines = new List<string>();
foreach (var ass in _options.DifferentialHybridAssembyList)
{
lines.Add($"\t\t\"{ass}\",");
}
frr.Replace("DHE", string.Join("\n", lines));
frr.Commit(_options.OutputFile);
Debug.Log($"output:{_options.OutputFile}");
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d6be260bc9a8a40468a82b9ea49b89a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+68
View File
@@ -0,0 +1,68 @@
using dnlib.DotNet;
using HybridCLR.Editor.Commands;
using HybridCLR.Editor.Meta;
using HybridCLR.Runtime;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
namespace HybridCLR.Editor.DHE
{
public class AssemblyOptionDataGenerator
{
public class Options
{
public string OutputDir { get; set; }
public List<string> DifferentialHybridAssembyList { get; set; }
}
private readonly Options _options;
public AssemblyOptionDataGenerator(Options options)
{
_options = options;
}
public void Generate()
{
foreach(string assName in _options.DifferentialHybridAssembyList)
{
using (var assCollector = new AssemblyCache(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget)))
{
var ass = assCollector.LoadModule(assName);
var dhaOptions = new DifferentialHybridAssemblyOptions()
{
notChangeMethodTokens = new List<uint>(),
};
foreach (var type in ass.GetTypes())
{
foreach (var method in type.Methods)
{
var attr = method.CustomAttributes.Where(a => a.AttributeType.FullName == "HybridCLR.Runtime.UnchangedAttribute").FirstOrDefault();
if (attr != null)
{
if ((bool)attr.ConstructorArguments[0].Value)
{
dhaOptions.notChangeMethodTokens.Add(method.MDToken.Raw);
Debug.Log($"Unchanged method:{method.MDToken.Raw} {method}");
}
}
}
}
string outOptionFile = $"{_options.OutputDir}/{assName}.dhao.bytes";
File.WriteAllBytes(outOptionFile, dhaOptions.Marshal());
Debug.Log($"[AssemblyOptionDataGenerator] assembly:{ass} output:{outOptionFile}");
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4a4eda50e51d72d499b439da236a8371
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: da46bc9f1a4dece41a5c193166be9a30
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+59
View File
@@ -0,0 +1,59 @@
using HybridCLR.Editor.ABI;
using HybridCLR.Editor.Template;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEngine;
namespace HybridCLR.Editor.Il2CppDef
{
public class Il2CppDefGenerator
{
public class Options
{
public string OutputFile { get; set; }
public string UnityVersion { get; set; }
}
private readonly Options _options;
public Il2CppDefGenerator(Options options)
{
_options = options;
}
private static readonly Regex s_unityVersionPat = new Regex(@"(\d+)\.(\d+)\.(\d+)");
public void Generate()
{
var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile));
List<string> lines = new List<string>();
var match = s_unityVersionPat.Matches(_options.UnityVersion)[0];
int majorVer = int.Parse(match.Groups[1].Value);
int minorVer1 = int.Parse(match.Groups[2].Value);
int minorVer2 = int.Parse(match.Groups[3].Value);
lines.Add($"#define HYBRIDCLR_UNITY_VERSION {majorVer}{minorVer1.ToString("D2")}{minorVer2.ToString("D2")}");
lines.Add($"#define HYBRIDCLR_UNITY_{majorVer} 1");
for (int ver = 2019; ver <= 2024; ver++)
{
if (majorVer >= ver)
{
lines.Add($"#define HYBRIDCLR_UNITY_{ver}_OR_NEW 1");
}
}
frr.Replace("UNITY_VERSION", string.Join("\n", lines));
frr.Commit(_options.OutputFile);
Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile}");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 590419ee7e82ac24cbac9b8a48891fe0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+10 -4
View File
@@ -10,7 +10,7 @@ namespace HybridCLR.Editor.Installer
{
public static class BashUtil
{
public static int RunCommand(string workingDir, string program, string[] args)
public static int RunCommand(string workingDir, string program, string[] args, bool log = true)
{
using (Process p = new Process())
{
@@ -20,7 +20,10 @@ namespace HybridCLR.Editor.Installer
p.StartInfo.CreateNoWindow = true;
string argsStr = string.Join(" ", args.Select(arg => "\"" + arg + "\""));
p.StartInfo.Arguments = argsStr;
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
if (log)
{
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
}
p.Start();
p.WaitForExit();
return p.ExitCode;
@@ -28,7 +31,7 @@ namespace HybridCLR.Editor.Installer
}
public static (int ExitCode, string StdOut, string StdErr) RunCommand2(string workingDir, string program, string[] args)
public static (int ExitCode, string StdOut, string StdErr) RunCommand2(string workingDir, string program, string[] args, bool log = true)
{
using (Process p = new Process())
{
@@ -40,7 +43,10 @@ namespace HybridCLR.Editor.Installer
p.StartInfo.RedirectStandardError = true;
string argsStr = string.Join(" ", args.Select(arg => "\"" + arg + "\""));
p.StartInfo.Arguments = argsStr;
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
if (log)
{
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
}
p.Start();
p.WaitForExit();
+2 -2
View File
@@ -274,8 +274,8 @@ namespace HybridCLR.Editor.Installer
private static string GetRepoUrl(string repoName)
{
string repoProvider = SettingsUtil.HybridCLRSettings.cloneFromGitee ? "gitee" : "github";
return $"https://{repoProvider}.com/focus-creative-games/{repoName}";
string repoProvider = SettingsUtil.HybridCLRSettings.cloneHomeURL;
return $"{repoProvider}/{repoName}";
}
private void RunInitLocalIl2CppData(string il2cppBranch, string il2cppInstallPath)
+8 -2
View File
@@ -44,16 +44,22 @@ namespace HybridCLR.Editor.Installer
GUILayout.Space(10f);
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
GUILayout.Space(5f);
EditorGUILayout.BeginVertical("box");
bool hasInstall = m_Controller.HasInstalledHybridCLR();
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel);
if (hasInstall)
{
EditorGUILayout.LabelField($"HybridCLR 版本: {m_Controller.GetHybridCLRLocalVersion()}");
GUILayout.Space(5f);
EditorGUILayout.LabelField($"il2cpp_plus 版本: {m_Controller.GetIl2cppPlusLocalVersion(m_Controller.Il2CppBranch)}");
GUILayout.Space(5f);
GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
GUILayout.Space(40f);
}
GUILayout.Space(5f);
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select");
GUILayout.Space(10f);
GUIInstallButton("安装最新HybridCLR插件代码到本项目", "安装", InitHybridCLR);
+52 -9
View File
@@ -1,19 +1,62 @@
namespace HybridCLR.Editor.Installer
using System.IO;
namespace HybridCLR.Editor.Installer
{
public partial class InstallerController
{
public string GetHybridCLRLocalVersion()
{
string workDir = SettingsUtil.HybridCLRDataDir;
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
if (Directory.Exists(hybridclrRepoDir))
{
var ret = BashUtil.RunCommand2(hybridclrRepoDir, "git",
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
false);
if (ret.ExitCode == 0)
{
return ret.StdOut.Trim();
}
else
{
return "ERROR";
}
}
return "";
}
public string GetIl2cppPlusLocalVersion(string il2cppBranch)
{
string workDir = SettingsUtil.HybridCLRDataDir;
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
if (Directory.Exists(il2cppPlusRepoDir))
{
var ret = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", },
false);
if (ret.ExitCode == 0)
{
return ret.StdOut.Trim();
}
else
{
return "ERROR";
}
}
return "";
}
public bool HasUpdateIl2Cpp(string il2cppBranch)
{
string workDir = SettingsUtil.HybridCLRDataDir;
// last hash hybridclr
{
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
var ret1 = BashUtil.RunCommand2(hybridclrRepoDir, "git",
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", });
BashUtil.RunCommand2(hybridclrRepoDir, "git",
new string[] { "fetch", "depth=1" });
var ret1 = BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", }, false);
BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "fetch", "--depth=1" }, false);
var ret2 = BashUtil.RunCommand2(hybridclrRepoDir, "git",
new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", });
new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", }
, false);
if (ret1.StdOut != ret2.StdOut)
{
return true;
@@ -23,11 +66,11 @@
{
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
var ret1 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", });
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
new string[] { "fetch", "depth=1" });
new string[] { "fetch", "--depth=1" }, false);
var ret2 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", });
new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
if (ret1.StdOut != ret2.StdOut)
{
return true;
+1 -1
View File
@@ -21,7 +21,7 @@ namespace HybridCLR.Editor.Meta
private bool IsPluginDll(string dllPath)
{
var fileOrDirs = new HashSet<string>(dllPath.Split('\\', '/'));
return !fileOrDirs.Intersect(s_ignoreDirs).Any();
return !fileOrDirs.Any(dir => dir.EndsWith("~")) && !fileOrDirs.Intersect(s_ignoreDirs).Any();
}
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
+9 -3
View File
@@ -11,13 +11,15 @@ namespace HybridCLR.Editor
private SerializedObject _serializedObject;
private SerializedProperty _enable;
private SerializedProperty _useGlobalIl2cpp;
private SerializedProperty _cloneFromGitee;
private SerializedProperty _cloneHomeURL;
private SerializedProperty _hotUpdateAssemblyDefinitions;
private SerializedProperty _hotUpdateAssemblies;
private SerializedProperty _preserveHotUpdateAssemblies;
private SerializedProperty _hotUpdateDllCompileOutputRootDir;
private SerializedProperty _strippedAOTDllOutputRootDir;
private SerializedProperty _patchAOTAssemblies;
private SerializedProperty _differentialHybridAssemblies;
private SerializedProperty _differentialHybridOptionOutputDir;
private SerializedProperty _collectAssetReferenceTypes;
private SerializedProperty _outputLinkFile;
private SerializedProperty _outputAOTGenericReferenceFile;
@@ -37,13 +39,15 @@ namespace HybridCLR.Editor
_serializedObject = new SerializedObject(setting);
_enable = _serializedObject.FindProperty("enable");
_useGlobalIl2cpp = _serializedObject.FindProperty("useGlobalIl2cpp");
_cloneFromGitee = _serializedObject.FindProperty("cloneFromGitee");
_cloneHomeURL = _serializedObject.FindProperty("cloneHomeURL");
_hotUpdateAssemblyDefinitions = _serializedObject.FindProperty("hotUpdateAssemblyDefinitions");
_hotUpdateAssemblies = _serializedObject.FindProperty("hotUpdateAssemblies");
_preserveHotUpdateAssemblies = _serializedObject.FindProperty("preserveHotUpdateAssemblies");
_hotUpdateDllCompileOutputRootDir = _serializedObject.FindProperty("hotUpdateDllCompileOutputRootDir");
_strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir");
_patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies");
_differentialHybridAssemblies = _serializedObject.FindProperty("differentialHybridAssemblies");
_differentialHybridOptionOutputDir = _serializedObject.FindProperty("differentialHybridOptionOutputDir");
_collectAssetReferenceTypes = _serializedObject.FindProperty("collectAssetReferenceTypes");
_outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
@@ -123,7 +127,7 @@ namespace HybridCLR.Editor
_serializedObject.Update();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_enable);
EditorGUILayout.PropertyField(_cloneFromGitee);
EditorGUILayout.PropertyField(_cloneHomeURL);
EditorGUILayout.PropertyField(_useGlobalIl2cpp);
EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions);
EditorGUILayout.PropertyField(_hotUpdateAssemblies);
@@ -131,6 +135,8 @@ namespace HybridCLR.Editor
EditorGUILayout.PropertyField(_hotUpdateDllCompileOutputRootDir);
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
EditorGUILayout.PropertyField(_patchAOTAssemblies);
EditorGUILayout.PropertyField(_differentialHybridAssemblies);
EditorGUILayout.PropertyField(_differentialHybridOptionOutputDir);
EditorGUILayout.PropertyField(_collectAssetReferenceTypes);
EditorGUILayout.PropertyField(_outputLinkFile);
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
+8 -2
View File
@@ -11,8 +11,8 @@ namespace HybridCLR.Editor
[Header("使用全局安装的il2cpp")]
public bool useGlobalIl2cpp;
[Header("从gitee clone插件代码")]
public bool cloneFromGitee = true; // false 则从github上拉取
[Header("基准 git clone URL")]
public string cloneHomeURL = "https://gitee.com/focus-creative-games";
[Header("热更新Assembly Definitions")]
public AssemblyDefinitionAsset[] hotUpdateAssemblyDefinitions;
@@ -32,6 +32,12 @@ namespace HybridCLR.Editor
[Header("补充元数据AOT dlls")]
public string[] patchAOTAssemblies;
[Header("差分混合热更新 dlls")]
public string[] differentialHybridAssemblies;
[Header("差分混合热更新配置数据输出目录")]
public string differentialHybridOptionOutputDir = "Assets/StreamingAssets";
[Header("生成link.xml时扫描asset中引用的类型")]
public bool collectAssetReferenceTypes;
@@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace HybridCLR.Runtime
{
public class DifferentialHybridAssemblyOptions
{
public const uint Signature = 0xABCDABCD;
public List<uint> notChangeMethodTokens;
public byte[] Marshal()
{
var stream = new MemoryStream();
var writer = new BinaryWriter(stream);
writer.Write(Signature);
writer.Write((uint)notChangeMethodTokens.Count);
foreach (uint token in notChangeMethodTokens)
{
writer.Write(token);
}
writer.Flush();
stream.Flush();
byte[] result = new byte[stream.Length];
stream.Position = 0;
stream.Read(result, 0, result.Length);
Debug.Log($"HotPatchAssemblyConfig. options bytes:{result.Length}");
return result;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3394055921ccce643b09466544ea3634
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+53 -2
View File
@@ -31,7 +31,7 @@ namespace HybridCLR
#else
fixed(byte* data = dllBytes)
{
return (LoadImageErrorCode)LoadMetadataForAOTAssembly((IntPtr)data, dllBytes.Length, (int)mode);
return (LoadImageErrorCode)LoadMetadataForAOTAssembly(data, dllBytes.Length, (int)mode);
}
#endif
}
@@ -43,7 +43,58 @@ namespace HybridCLR
/// <param name="dllSize"></param>
/// <returns></returns>
[DllImport(dllName, EntryPoint = "RuntimeApi_LoadMetadataForAOTAssembly")]
public static extern int LoadMetadataForAOTAssembly(IntPtr dllBytes, int dllSize, int mode);
public static extern unsafe int LoadMetadataForAOTAssembly(byte* dllBytes, int dllSize, int mode);
//[DllImport(dllName, EntryPoint = "RuntimeApi_UseDifferentialHybridAOTAssembly")]
//public static unsafe LoadImageErrorCode UseDifferentialHybridAOTAssembly(string assemblyName)
//{
// byte[] nameBytes = System.Text.Encoding.UTF8.GetBytes(assemblyName);
// fixed(byte* namePtr = nameBytes)
// {
// }
//}
/// <summary>
/// 指示混合执行assembly使用原始的AOT代码。当assembly没有发生变化时必须调用此接口。
/// </summary>
/// <param name="assemblyName"></param>
/// <returns></returns>
#if UNITY_EDITOR
public static LoadImageErrorCode UseDifferentialHybridAOTAssembly(string assemblyName)
{
return LoadImageErrorCode.OK;
}
#else
[DllImport(dllName, EntryPoint = "RuntimeApi_UseDifferentialHybridAOTAssembly")]
public static extern LoadImageErrorCode UseDifferentialHybridAOTAssembly(string assemblyName);
#endif
/// <summary>
/// 加载差分混合执行 assembly
/// </summary>
/// <param name="dllBytes"></param>
/// <param name="optionBytes"></param>
/// <returns></returns>
public static unsafe LoadImageErrorCode LoadDifferentialHybridAssembly(byte[] dllBytes, byte[] optionBytes)
{
#if UNITY_EDITOR
return LoadImageErrorCode.OK;
#else
fixed(byte* dllBytesPtr = dllBytes)
{
fixed(byte* optionBytesPtr = optionBytes)
{
return (LoadImageErrorCode)LoadDifferentialHybridAssembly(dllBytesPtr, dllBytes.Length, optionBytesPtr, optionBytes.Length);
}
}
#endif
}
[DllImport(dllName, EntryPoint = "RuntimeApi_LoadDifferentialHybridAssembly")]
public static extern unsafe int LoadDifferentialHybridAssembly(byte* dllBytes, int dllSize, byte* optionBytesPtr, int optionBytesLength);
/// <summary>
/// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
+18
View File
@@ -0,0 +1,18 @@
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybridCLR.Runtime
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Struct)]
public class UnchangedAttribute : Attribute
{
public bool Unchanged { get; }
public UnchangedAttribute(bool unchanged = true)
{
Unchanged = unchanged;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 704603a2a0551f247a30e331ca476870
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "com.focus-creative-games.hybridclr_unity",
"version": "0.9.1",
"version": "1.0.0",
"displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime",