[fix] 修复生成桥接函数时,如果热更新程序集未包含任何代码直接引用了某个aot程序集,则没有为该aot程序集生成桥接函数,导致出现NotSupportNative2Managed异常的bug
parent
4da7c1a524
commit
1bd27a3e22
|
@ -10,6 +10,7 @@ using System.Reflection;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.Commands
|
||||
|
@ -47,14 +48,20 @@ namespace HybridCLR.Editor.Commands
|
|||
public static void CompileAndGenerateMethodBridge()
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
GenerateMethodBridge(target);
|
||||
}
|
||||
|
||||
public static void GenerateMethodBridge(BuildTarget target)
|
||||
{
|
||||
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
|
||||
string aotDllDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
List<string> aotAssemblyNames = Directory.Exists(aotDllDir) ?
|
||||
Directory.GetFiles(aotDllDir, "*.dll", SearchOption.TopDirectoryOnly).Select(Path.GetFileNameWithoutExtension).ToList()
|
||||
: new List<string>();
|
||||
if (aotAssemblyNames.Count == 0)
|
||||
{
|
||||
throw new Exception($"no aot assembly found. please run `HybridCLR/Generate/All` or `HybridCLR/Generate/AotDlls` to generate aot dlls before runing `HybridCLR/Generate/MethodBridge`");
|
||||
}
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateAOTAssemblyResolver(target), aotAssemblyNames))
|
||||
{
|
||||
var analyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
|
|
|
@ -30,6 +30,11 @@ namespace HybridCLR.Editor.Meta
|
|||
return LoadedModules.Where(e => !_rootAssemblies.Contains(e.Key)).Select(e => e.Value).ToList();
|
||||
}
|
||||
|
||||
public List<ModuleDefMD> GetLoadedModules()
|
||||
{
|
||||
return LoadedModules.Select(e => e.Value).ToList();
|
||||
}
|
||||
|
||||
public List<ModuleDefMD> GetLoadedModulesOfRootAssemblies()
|
||||
{
|
||||
return _rootAssemblies.Select(ass => LoadedModules[ass]).ToList();
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace HybridCLR.Editor.MethodBridge
|
|||
{
|
||||
// 将所有非泛型函数全部加入函数列表,同时立马walk这些method。
|
||||
// 后续迭代中将只遍历MethodSpec
|
||||
foreach (var ass in _assemblyCollector.GetLoadedModulesExcludeRootAssemblies())
|
||||
foreach (var ass in _assemblyCollector.GetLoadedModules())
|
||||
{
|
||||
foreach (TypeDef typeDef in ass.GetTypes())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue