hybridclr_unity/Editor/Commands/AOTReferenceGeneratorComman...

50 lines
1.7 KiB
C#
Raw Normal View History

2022-09-22 08:56:07 +08:00
using HybridCLR.Editor.AOT;
using HybridCLR.Editor.Meta;
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 AOTReferenceGeneratorCommand
{
2022-09-23 14:26:28 +08:00
[MenuItem("HybridCLR/Generate/AOTGenericReference", priority = 102)]
2022-09-22 08:56:07 +08:00
public static void GenerateAOTGenericReference()
{
GenerateAOTGenericReference(true);
}
public static void GenerateAOTGenericReference(bool compileDll)
{
// 此处理论会有点问题,打每个平台的时候,都得针对当前平台生成桥接函数
// 但影响不大,先这样吧
if (compileDll)
{
CompileDllCommand.CompileDllActiveBuildTarget();
}
2022-10-09 20:53:13 +08:00
var gs = SettingsUtil.HybridCLRSettings;
2022-09-22 08:56:07 +08:00
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget), SettingsUtil.HotUpdateAssemblyNames))
2022-09-22 08:56:07 +08:00
{
var analyzer = new Analyzer(new Analyzer.Options
{
MaxIterationCount = Math.Min(20, gs.maxGenericReferenceIteration),
Collector = collector,
});
2022-09-22 08:56:07 +08:00
analyzer.Run();
2022-09-22 08:56:07 +08:00
var writer = new GenericReferenceWriter();
writer.Write(analyzer.AotGenericTypes.ToList(), analyzer.AotGenericMethods.ToList(), $"{Application.dataPath}/{gs.outputAOTGenericReferenceFile}");
AssetDatabase.Refresh();
}
2022-09-22 08:56:07 +08:00
}
}
}