hybridclr_unity/Editor/Commands/AOTReferenceGeneratorComman...

45 lines
1.6 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
{
using Analyzer = HybridCLR.Editor.AOT.Analyzer;
2022-09-22 08:56:07 +08:00
public static class AOTReferenceGeneratorCommand
{
2022-09-23 14:26:28 +08:00
[MenuItem("HybridCLR/Generate/AOTGenericReference", priority = 102)]
public static void CompileAndGenerateAOTGenericReference()
2022-09-22 08:56:07 +08:00
{
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
CompileDllCommand.CompileDll(target);
GenerateAOTGenericReference(target);
2022-09-22 08:56:07 +08:00
}
public static void GenerateAOTGenericReference(BuildTarget target)
2022-09-22 08:56:07 +08:00
{
2022-10-09 20:53:13 +08:00
var gs = SettingsUtil.HybridCLRSettings;
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
2022-09-22 08:56:07 +08:00
AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames);
var analyzer = new Analyzer(new Analyzer.Options
2022-09-22 08:56:07 +08:00
{
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
}
}
}