接入obfuz->2.0

This commit is contained in:
Alex-Rachel
2025-07-26 08:10:41 +08:00
parent f2c7ff4336
commit cb86d8868e
713 changed files with 57092 additions and 10 deletions

View File

@@ -0,0 +1,132 @@
using HybridCLR.Editor.AOT;
using HybridCLR.Editor.Meta;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
namespace HybridCLR.Editor.Commands
{
using Analyzer = HybridCLR.Editor.AOT.Analyzer;
public static class AOTReferenceGeneratorCommand
{
[MenuItem("HybridCLR/Generate/AOTGenericReference", priority = 102)]
public static void CompileAndGenerateAOTGenericReference()
{
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
CompileDllCommand.CompileDll(target);
GenerateAOTGenericReference(target);
}
/// <summary>
/// 计算热更代码中的泛型引用
/// </summary>
/// <param name="target"></param>
public static void GenerateAOTGenericReference(BuildTarget target)
{
var gs = SettingsUtil.HybridCLRSettings;
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames);
var analyzer = new Analyzer(new Analyzer.Options
{
MaxIterationCount = Math.Min(20, gs.maxGenericReferenceIteration),
Collector = collector,
});
analyzer.Run();
var writer = new GenericReferenceWriter();
writer.Write(analyzer.AotGenericTypes.ToList(), analyzer.AotGenericMethods.ToList(), $"{Application.dataPath}/{gs.outputAOTGenericReferenceFile}");
AssetDatabase.Refresh();
}
//[MenuItem("HybridCLR/Generate/AOTGenericReference2", priority = 103)]
//public static void GeneratedAOTGenericReferenceExcludeExists()
//{
// GeneratedAOTGenericReferenceExcludeExists(EditorUserBuildSettings.activeBuildTarget);
//}
/// <summary>
/// 计算热更新代码中的泛型引用但排除AOT已经存在的泛型引用
/// </summary>
/// <param name="target"></param>
///
public static void GeneratedAOTGenericReferenceExcludeExistsAOTClassAndMethods(BuildTarget target)
{
var gs = SettingsUtil.HybridCLRSettings;
List<string> hotUpdateDllNames = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
AssemblyReferenceDeepCollector hotUpdateCollector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames);
var hotUpdateAnalyzer = new Analyzer(new Analyzer.Options
{
MaxIterationCount = Math.Min(10, gs.maxGenericReferenceIteration),
Collector = hotUpdateCollector,
});
hotUpdateAnalyzer.Run();
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/AOTGenericReference`");
}
AssemblyReferenceDeepCollector aotCollector = new AssemblyReferenceDeepCollector(MetaUtil.CreateAOTAssemblyResolver(target), aotAssemblyNames);
var aotAnalyzer = new Analyzer(new Analyzer.Options
{
MaxIterationCount = Math.Min(10, gs.maxGenericReferenceIteration),
Collector = aotCollector,
ComputeAotAssembly = true,
});
aotAnalyzer.Run();
var (resultTypes, resultMethods) = ExcludeExistAOTGenericTypeAndMethodss(hotUpdateAnalyzer.AotGenericTypes.ToList(), hotUpdateAnalyzer.AotGenericMethods.ToList(), aotAnalyzer.AotGenericTypes.ToList(), aotAnalyzer.AotGenericMethods.ToList());
var writer = new GenericReferenceWriter();
writer.Write(resultTypes, resultMethods, $"{Application.dataPath}/{gs.outputAOTGenericReferenceFile}");
AssetDatabase.Refresh();
}
private static (List<GenericClass>, List<GenericMethod>) ExcludeExistAOTGenericTypeAndMethodss(List<GenericClass> hotUpdateTypes, List<GenericMethod> hotUpdateMethods, List<GenericClass> aotTypes, List<GenericMethod> aotMethods)
{
var types = new List<GenericClass>();
var typeSig2Type = hotUpdateTypes.ToDictionary(t => t.Type.DefinitionAssembly.Name + ":" + t.ToTypeSig(), t => t);
foreach (var t in aotTypes)
{
string key = t.Type.DefinitionAssembly.Name + ":" + t.ToTypeSig();
if (typeSig2Type.TryGetValue(key, out var removedType))
{
typeSig2Type.Remove(key);
Debug.Log($"remove AOT type:{removedType.ToTypeSig()} ");
}
}
var methodSig2Method = hotUpdateMethods.ToDictionary(m => m.Method.DeclaringType.DefinitionAssembly.Name + ":" + m.ToMethodSpec().ToString(), m => m);
foreach (var m in aotMethods)
{
string key = m.Method.DeclaringType.DefinitionAssembly.Name + ":" + m.ToMethodSpec().ToString();
if (methodSig2Method.TryGetValue(key, out var removedMethod))
{
methodSig2Method.Remove(key);
Debug.Log($"remove AOT method:{removedMethod.ToMethodSpec()} ");
}
}
return (typeSig2Type.Values.ToList(), methodSig2Method.Values.ToList());
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b464872c07f6ba4f9a4e4a02ca9a28c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditor.Build.Player;
using UnityEngine;
namespace HybridCLR.Editor.Commands
{
public class CompileDllCommand
{
public static void CompileDll(string buildDir, BuildTarget target, bool developmentBuild)
{
var group = BuildPipeline.GetBuildTargetGroup(target);
ScriptCompilationSettings scriptCompilationSettings = new ScriptCompilationSettings();
scriptCompilationSettings.group = group;
scriptCompilationSettings.target = target;
scriptCompilationSettings.options = developmentBuild ? ScriptCompilationOptions.DevelopmentBuild : ScriptCompilationOptions.None;
Directory.CreateDirectory(buildDir);
ScriptCompilationResult scriptCompilationResult = PlayerBuildInterface.CompilePlayerScripts(scriptCompilationSettings, buildDir);
#if UNITY_2022
UnityEditor.EditorUtility.ClearProgressBar();
#endif
Debug.Log($"compile finish!!! buildDir:{buildDir} target:{target} development:{developmentBuild}");
}
public static void CompileDll(BuildTarget target)
{
CompileDll(target, EditorUserBuildSettings.development);
}
public static void CompileDll(BuildTarget target, bool developmentBuild)
{
CompileDll(SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target), target, developmentBuild);
}
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget", priority = 100)]
public static void CompileDllActiveBuildTarget()
{
CompileDll(EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.development);
}
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Release", priority = 102)]
public static void CompileDllActiveBuildTargetRelease()
{
CompileDll(EditorUserBuildSettings.activeBuildTarget, false);
}
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Development", priority = 104)]
public static void CompileDllActiveBuildTargetDevelopment()
{
CompileDll(EditorUserBuildSettings.activeBuildTarget, true);
}
[MenuItem("HybridCLR/CompileDll/Win32", priority = 200)]
public static void CompileDllWin32()
{
CompileDll(BuildTarget.StandaloneWindows);
}
[MenuItem("HybridCLR/CompileDll/Win64", priority = 201)]
public static void CompileDllWin64()
{
CompileDll(BuildTarget.StandaloneWindows64);
}
[MenuItem("HybridCLR/CompileDll/MacOS", priority = 202)]
public static void CompileDllMacOS()
{
CompileDll(BuildTarget.StandaloneOSX);
}
[MenuItem("HybridCLR/CompileDll/Linux", priority = 203)]
public static void CompileDllLinux()
{
CompileDll(BuildTarget.StandaloneLinux64);
}
[MenuItem("HybridCLR/CompileDll/Android", priority = 210)]
public static void CompileDllAndroid()
{
CompileDll(BuildTarget.Android);
}
[MenuItem("HybridCLR/CompileDll/IOS", priority = 220)]
public static void CompileDllIOS()
{
CompileDll(BuildTarget.iOS);
}
[MenuItem("HybridCLR/CompileDll/WebGL", priority = 230)]
public static void CompileDllWebGL()
{
CompileDll(BuildTarget.WebGL);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf11b6c8bbc5afd4cb4a11921e5bd81e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using HybridCLR.Editor.Link;
using HybridCLR.Editor.Settings;
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 = Application.unityVersion,
HotUpdateAssemblies = SettingsUtil.HotUpdateAssemblyNamesIncludePreserved,
UnityVersionTemplateFile = $"{SettingsUtil.TemplatePathInPackage}/UnityVersion.h.tpl",
UnityVersionOutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/UnityVersion.h",
AssemblyManifestTemplateFile = $"{SettingsUtil.TemplatePathInPackage}/AssemblyManifest.cpp.tpl",
AssemblyManifestOutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/AssemblyManifest.cpp",
};
var g = new Il2CppDef.Il2CppDefGenerator(options);
g.Generate();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5165a065d05497c43a2fff885f31ed07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using HybridCLR.Editor.Link;
using HybridCLR.Editor.Meta;
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace HybridCLR.Editor.Commands
{
using Analyzer = HybridCLR.Editor.Link.Analyzer;
public static class LinkGeneratorCommand
{
[MenuItem("HybridCLR/Generate/LinkXml", priority = 100)]
public static void GenerateLinkXml()
{
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
CompileDllCommand.CompileDll(target);
GenerateLinkXml(target);
}
public static void GenerateLinkXml(BuildTarget target)
{
var ls = SettingsUtil.HybridCLRSettings;
List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies));
var refTypes = analyzer.CollectRefs(hotfixAssemblies);
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
var linkXmlWriter = new LinkXmlWriter();
linkXmlWriter.Write($"{Application.dataPath}/{ls.outputLinkFile}", refTypes);
AssetDatabase.Refresh();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4f5b96abdbc4c424eb1bc3bc34b3a1a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
using HybridCLR.Editor;
using HybridCLR.Editor.ABI;
using HybridCLR.Editor.Meta;
using HybridCLR.Editor.MethodBridge;
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 UnityEditor.Build;
using UnityEngine;
namespace HybridCLR.Editor.Commands
{
using Analyzer = HybridCLR.Editor.MethodBridge.Analyzer;
public class MethodBridgeGeneratorCommand
{
public static void CleanIl2CppBuildCache()
{
string il2cppBuildCachePath = SettingsUtil.Il2CppBuildCacheDir;
if (!Directory.Exists(il2cppBuildCachePath))
{
return;
}
Debug.Log($"clean il2cpp build cache:{il2cppBuildCachePath}");
Directory.Delete(il2cppBuildCachePath, true);
}
private static void GenerateMethodBridgeCppFile(IReadOnlyCollection<GenericMethod> genericMethods, List<RawMonoPInvokeCallbackMethodInfo> reversePInvokeMethods, IReadOnlyCollection<CallNativeMethodSignatureInfo> calliMethodSignatures, string tempFile, string outputFile)
{
string templateCode = File.ReadAllText(tempFile, Encoding.UTF8);
var g = new Generator(new Generator.Options()
{
TemplateCode = templateCode,
OutputFile = outputFile,
GenericMethods = genericMethods,
ReversePInvokeMethods = reversePInvokeMethods,
CalliMethodSignatures = calliMethodSignatures,
Development = EditorUserBuildSettings.development,
});
g.Generate();
Debug.LogFormat("[MethodBridgeGeneratorCommand] output:{0}", outputFile);
}
[MenuItem("HybridCLR/Generate/MethodBridgeAndReversePInvokeWrapper", priority = 101)]
public static void GenerateMethodBridgeAndReversePInvokeWrapper()
{
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
GenerateMethodBridgeAndReversePInvokeWrapper(target);
}
public static void GenerateMethodBridgeAndReversePInvokeWrapper(BuildTarget target)
{
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`");
}
AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateAOTAssemblyResolver(target), aotAssemblyNames);
var methodBridgeAnalyzer = new Analyzer(new Analyzer.Options
{
MaxIterationCount = Math.Min(20, SettingsUtil.HybridCLRSettings.maxMethodBridgeGenericIteration),
Collector = collector,
});
methodBridgeAnalyzer.Run();
List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls));
var reversePInvokeAnalyzer = new MonoPInvokeCallbackAnalyzer(cache, hotUpdateDlls);
reversePInvokeAnalyzer.Run();
var calliAnalyzer = new CalliAnalyzer(cache, hotUpdateDlls);
calliAnalyzer.Run();
var pinvokeAnalyzer = new PInvokeAnalyzer(cache, hotUpdateDlls);
pinvokeAnalyzer.Run();
var callPInvokeMethodSignatures = pinvokeAnalyzer.PInvokeMethodSignatures;
string templateFile = $"{SettingsUtil.TemplatePathInPackage}/MethodBridge.cpp.tpl";
string outputFile = $"{SettingsUtil.GeneratedCppDir}/MethodBridge.cpp";
var callNativeMethodSignatures = calliAnalyzer.CalliMethodSignatures.Concat(pinvokeAnalyzer.PInvokeMethodSignatures).ToList();
GenerateMethodBridgeCppFile(methodBridgeAnalyzer.GenericMethods, reversePInvokeAnalyzer.ReversePInvokeMethods, callNativeMethodSignatures, templateFile, outputFile);
CleanIl2CppBuildCache();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46bc62d5236f5e941850776c435a9560
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditor.Build;
namespace HybridCLR.Editor.Commands
{
public static class PrebuildCommand
{
/// <summary>
/// 按照必要的顺序,执行所有生成操作,适合打包前操作
/// </summary>
[MenuItem("HybridCLR/Generate/All", priority = 200)]
public static void GenerateAll()
{
var installer = new Installer.InstallerController();
if (!installer.HasInstalledHybridCLR())
{
throw new BuildFailedException($"You have not initialized HybridCLR, please install it via menu 'HybridCLR/Installer'");
}
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
CompileDllCommand.CompileDll(target, EditorUserBuildSettings.development);
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
// 这几个生成依赖HotUpdateDlls
LinkGeneratorCommand.GenerateLinkXml(target);
// 生成裁剪后的aot dll
StripAOTDllCommand.GenerateStripedAOTDlls(target);
// 桥接函数生成依赖于AOT dll必须保证已经build过生成AOT dll
MethodBridgeGeneratorCommand.GenerateMethodBridgeAndReversePInvokeWrapper(target);
AOTReferenceGeneratorCommand.GenerateAOTGenericReference(target);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c20f09bfbe3f32143aae872d3813d9e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,196 @@
using HybridCLR.Editor.BuildProcessors;
using HybridCLR.Editor.Installer;
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;
using static UnityEngine.Networking.UnityWebRequest;
namespace HybridCLR.Editor.Commands
{
public static class StripAOTDllCommand
{
[MenuItem("HybridCLR/Generate/AOTDlls", priority = 105)]
public static void GenerateStripedAOTDlls()
{
GenerateStripedAOTDlls(EditorUserBuildSettings.activeBuildTarget);
}
static BuildOptions GetBuildPlayerOptions(BuildTarget buildTarget)
{
BuildOptions options = BuildOptions.None;
bool development = EditorUserBuildSettings.development;
if (development)
{
options |= BuildOptions.Development;
}
if (EditorUserBuildSettings.allowDebugging && development)
{
options |= BuildOptions.AllowDebugging;
}
if (EditorUserBuildSettings.connectProfiler && (development || buildTarget == BuildTarget.WSAPlayer))
{
options |= BuildOptions.ConnectWithProfiler;
}
if (EditorUserBuildSettings.buildWithDeepProfilingSupport && development)
{
options |= BuildOptions.EnableDeepProfilingSupport;
}
#if UNITY_2021_2_OR_NEWER
options |= BuildOptions.CleanBuildCache;
#endif
return options;
}
private static string GetLocationPathName(string buildDir, BuildTarget target)
{
switch(target)
{
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64: return $"{buildDir}/{PlayerSettings.productName}.exe";
case BuildTarget.StandaloneOSX: return buildDir;
case BuildTarget.iOS: return buildDir;
case BuildTarget.Android: return buildDir;
case BuildTarget.StandaloneLinux64: return $"{buildDir}/{PlayerSettings.productName}";
default: return buildDir;
}
}
public static void GenerateStripedAOTDlls(BuildTarget target)
{
string outputPath = $"{SettingsUtil.HybridCLRDataDir}/StrippedAOTDllsTempProj/{target}";
BashUtil.RemoveDir(outputPath);
var buildOptions = GetBuildPlayerOptions(target);
bool oldExportAndroidProj = EditorUserBuildSettings.exportAsGoogleAndroidProject;
#if UNITY_EDITOR_OSX
bool oldCreateSolution = UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject;
#elif UNITY_EDITOR_WIN
bool oldCreateSolution = UnityEditor.WindowsStandalone.UserBuildSettings.createSolution;
#endif
#if TUANJIE_2022_3_OR_NEWER
bool oldOpenHarmonyProj = EditorUserBuildSettings.exportAsOpenHarmonyProject;
#endif
bool oldBuildScriptsOnly = EditorUserBuildSettings.buildScriptsOnly;
string oldBuildLocation = EditorUserBuildSettings.GetBuildLocation(target);
try
{
CheckSettings.DisableMethodBridgeDevelopmentFlagChecking = true;
EditorUserBuildSettings.buildScriptsOnly = true;
string location = GetLocationPathName(outputPath, target);
EditorUserBuildSettings.SetBuildLocation(target, location);
switch (target)
{
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
{
#if UNITY_EDITOR_WIN
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = true;
#endif
break;
}
case BuildTarget.StandaloneOSX:
{
#if UNITY_EDITOR_OSX
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = true;
#endif
break;
}
#if TUANJIE_2022_3_OR_NEWER
case BuildTarget.HMIAndroid:
#endif
case BuildTarget.Android:
{
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
break;
}
#if TUANJIE_2022_3_OR_NEWER
case BuildTarget.OpenHarmony:
{
EditorUserBuildSettings.exportAsOpenHarmonyProject = true;
break;
}
#endif
}
Debug.Log($"GenerateStripedAOTDlls build option:{buildOptions}");
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions()
{
scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray(),
locationPathName = location,
options = buildOptions,
target = target,
targetGroup = BuildPipeline.GetBuildTargetGroup(target),
#if UNITY_2021_1_OR_NEWER
subtarget = (int)EditorUserBuildSettings.standaloneBuildSubtarget,
#endif
};
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
{
throw new Exception("GenerateStripedAOTDlls failed");
}
}
finally
{
CheckSettings.DisableMethodBridgeDevelopmentFlagChecking = false;
EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly;
EditorUserBuildSettings.SetBuildLocation(target, oldBuildLocation);
switch (target)
{
case BuildTarget.StandaloneWindows:
case BuildTarget.StandaloneWindows64:
{
#if UNITY_EDITOR_WIN
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = oldCreateSolution;
#endif
break;
}
case BuildTarget.StandaloneOSX:
{
#if UNITY_EDITOR_OSX
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = oldCreateSolution;
#endif
break;
}
#if TUANJIE_2022_3_OR_NEWER
case BuildTarget.HMIAndroid:
#endif
case BuildTarget.Android:
{
EditorUserBuildSettings.exportAsGoogleAndroidProject = oldExportAndroidProj;
break;
}
#if TUANJIE_2022_3_OR_NEWER
case BuildTarget.OpenHarmony:
{
EditorUserBuildSettings.exportAsOpenHarmonyProject = oldOpenHarmonyProj;
break;
}
#endif
}
}
Debug.Log($"GenerateStripedAOTDlls target:{target} path:{outputPath}");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21fb0a02f23185141a4a3df67fe61789
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: