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-12-14 14:11:32 +08:00
|
|
|
|
public static void CompileAndGenerateAOTGenericReference()
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
2022-12-14 14:11:32 +08:00
|
|
|
|
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
|
|
|
|
CompileDllCommand.CompileDll(target);
|
|
|
|
|
GenerateAOTGenericReference(target);
|
2022-09-22 08:56:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 14:11:32 +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;
|
2022-12-14 14:11:32 +08:00
|
|
|
|
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNames;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2022-12-14 14:11:32 +08:00
|
|
|
|
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
2022-09-26 12:12:57 +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
|
|
|
|
|
2022-09-26 12:12:57 +08:00
|
|
|
|
analyzer.Run();
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2022-09-26 12:12:57 +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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|