@@ -2,7 +2,6 @@
|
||||
using HybridCLR.Editor.Meta;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -23,110 +22,25 @@ namespace HybridCLR.Editor.Commands
|
||||
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
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDllNames), hotUpdateDllNames))
|
||||
{
|
||||
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))
|
||||
var analyzer = new Analyzer(new Analyzer.Options
|
||||
{
|
||||
typeSig2Type.Remove(key);
|
||||
Debug.Log($"remove AOT type:{removedType.ToTypeSig()} ");
|
||||
}
|
||||
}
|
||||
MaxIterationCount = Math.Min(20, gs.maxGenericReferenceIteration),
|
||||
Collector = collector,
|
||||
});
|
||||
|
||||
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()} ");
|
||||
}
|
||||
}
|
||||
analyzer.Run();
|
||||
|
||||
return (typeSig2Type.Values.ToList(), methodSig2Method.Values.ToList());
|
||||
var writer = new GenericReferenceWriter();
|
||||
writer.Write(analyzer.AotGenericTypes.ToList(), analyzer.AotGenericMethods.ToList(), $"{Application.dataPath}/{gs.outputAOTGenericReferenceFile}");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b464872c07f6ba4f9a4e4a02ca9a28c
|
||||
guid: 5c551ca444cd0af44bc060b024a9bc35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -25,15 +25,10 @@ namespace HybridCLR.Editor.Commands
|
||||
#if UNITY_2022
|
||||
UnityEditor.EditorUtility.ClearProgressBar();
|
||||
#endif
|
||||
Debug.Log($"compile finish!!! buildDir:{buildDir} target:{target} development:{developmentBuild}");
|
||||
Debug.Log("compile finish!!!");
|
||||
}
|
||||
|
||||
public static void CompileDll(BuildTarget target)
|
||||
{
|
||||
CompileDll(target, EditorUserBuildSettings.development);
|
||||
}
|
||||
|
||||
public static void CompileDll(BuildTarget target, bool developmentBuild)
|
||||
public static void CompileDll(BuildTarget target, bool developmentBuild = false)
|
||||
{
|
||||
CompileDll(SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target), target, developmentBuild);
|
||||
}
|
||||
@@ -41,16 +36,10 @@ namespace HybridCLR.Editor.Commands
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget", priority = 100)]
|
||||
public static void CompileDllActiveBuildTarget()
|
||||
{
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.development);
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget);
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Release", priority = 102)]
|
||||
public static void CompileDllActiveBuildTargetRelease()
|
||||
{
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget, false);
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Development", priority = 104)]
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget_Development", priority = 101)]
|
||||
public static void CompileDllActiveBuildTargetDevelopment()
|
||||
{
|
||||
CompileDll(EditorUserBuildSettings.activeBuildTarget, true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf11b6c8bbc5afd4cb4a11921e5bd81e
|
||||
guid: 33d7af1ee2e66f645a539ab3f1ffd005
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using HybridCLR.Editor.Link;
|
||||
using HybridCLR.Editor.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -20,10 +19,8 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
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",
|
||||
OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/UnityVersion.h",
|
||||
OutputFile2 = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/AssemblyManifest.cpp",
|
||||
};
|
||||
|
||||
var g = new Il2CppDef.Il2CppDefGenerator(options);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5165a065d05497c43a2fff885f31ed07
|
||||
guid: 835086949fb644c42b3bede85daafaf8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f5b96abdbc4c424eb1bc3bc34b3a1a4
|
||||
guid: 3a93a166688011348927f18ea533d9d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -30,31 +30,29 @@ namespace HybridCLR.Editor.Commands
|
||||
Directory.Delete(il2cppBuildCachePath, true);
|
||||
}
|
||||
|
||||
private static void GenerateMethodBridgeCppFile(IReadOnlyCollection<GenericMethod> genericMethods, List<RawMonoPInvokeCallbackMethodInfo> reversePInvokeMethods, IReadOnlyCollection<CallNativeMethodSignatureInfo> calliMethodSignatures, string tempFile, string outputFile)
|
||||
private static void GenerateMethodBridgeCppFile(Analyzer analyzer, string outputFile)
|
||||
{
|
||||
string templateCode = File.ReadAllText(tempFile, Encoding.UTF8);
|
||||
string templateCode = File.ReadAllText(outputFile, Encoding.UTF8);
|
||||
var g = new Generator(new Generator.Options()
|
||||
{
|
||||
TemplateCode = templateCode,
|
||||
OutputFile = outputFile,
|
||||
GenericMethods = genericMethods,
|
||||
ReversePInvokeMethods = reversePInvokeMethods,
|
||||
CalliMethodSignatures = calliMethodSignatures,
|
||||
Development = EditorUserBuildSettings.development,
|
||||
GenericMethods = analyzer.GenericMethods,
|
||||
});
|
||||
|
||||
g.PrepareMethods();
|
||||
g.Generate();
|
||||
Debug.LogFormat("[MethodBridgeGeneratorCommand] output:{0}", outputFile);
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/Generate/MethodBridgeAndReversePInvokeWrapper", priority = 101)]
|
||||
public static void GenerateMethodBridgeAndReversePInvokeWrapper()
|
||||
[MenuItem("HybridCLR/Generate/MethodBridge", priority = 101)]
|
||||
public static void CompileAndGenerateMethodBridge()
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
GenerateMethodBridgeAndReversePInvokeWrapper(target);
|
||||
GenerateMethodBridge(target);
|
||||
}
|
||||
|
||||
public static void GenerateMethodBridgeAndReversePInvokeWrapper(BuildTarget target)
|
||||
public static void GenerateMethodBridge(BuildTarget target)
|
||||
{
|
||||
string aotDllDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
|
||||
List<string> aotAssemblyNames = Directory.Exists(aotDllDir) ?
|
||||
@@ -64,33 +62,18 @@ namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
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
|
||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateAOTAssemblyResolver(target), aotAssemblyNames))
|
||||
{
|
||||
MaxIterationCount = Math.Min(20, SettingsUtil.HybridCLRSettings.maxMethodBridgeGenericIteration),
|
||||
Collector = collector,
|
||||
});
|
||||
var analyzer = 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);
|
||||
analyzer.Run();
|
||||
string outputFile = $"{SettingsUtil.GeneratedCppDir}/MethodBridge.cpp";
|
||||
GenerateMethodBridgeCppFile(analyzer, outputFile);
|
||||
}
|
||||
|
||||
CleanIl2CppBuildCache();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46bc62d5236f5e941850776c435a9560
|
||||
guid: d0c8247b111383b44afd088ac0bde458
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
|
||||
namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
@@ -16,13 +15,8 @@ namespace HybridCLR.Editor.Commands
|
||||
[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);
|
||||
CompileDllCommand.CompileDll(target);
|
||||
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
|
||||
|
||||
// 这几个生成依赖HotUpdateDlls
|
||||
@@ -32,7 +26,8 @@ namespace HybridCLR.Editor.Commands
|
||||
StripAOTDllCommand.GenerateStripedAOTDlls(target);
|
||||
|
||||
// 桥接函数生成依赖于AOT dll,必须保证已经build过,生成AOT dll
|
||||
MethodBridgeGeneratorCommand.GenerateMethodBridgeAndReversePInvokeWrapper(target);
|
||||
MethodBridgeGeneratorCommand.GenerateMethodBridge(target);
|
||||
ReversePInvokeWrapperGeneratorCommand.GenerateReversePInvokeWrapper(target);
|
||||
AOTReferenceGeneratorCommand.GenerateAOTGenericReference(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c20f09bfbe3f32143aae872d3813d9e9
|
||||
guid: f0862bf1b7a39754d8c6c6005d26f4d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using HybridCLR.Editor.ABI;
|
||||
using HybridCLR.Editor.Link;
|
||||
using HybridCLR.Editor.Meta;
|
||||
using HybridCLR.Editor.ReversePInvokeWrap;
|
||||
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;
|
||||
|
||||
namespace HybridCLR.Editor.Commands
|
||||
{
|
||||
|
||||
public static class ReversePInvokeWrapperGeneratorCommand
|
||||
{
|
||||
|
||||
[MenuItem("HybridCLR/Generate/ReversePInvokeWrapper", priority = 103)]
|
||||
|
||||
public static void CompileAndGenerateReversePInvokeWrapper()
|
||||
{
|
||||
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||
CompileDllCommand.CompileDll(target);
|
||||
GenerateReversePInvokeWrapper(target);
|
||||
}
|
||||
|
||||
public static void GenerateReversePInvokeWrapper(BuildTarget target)
|
||||
{
|
||||
List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
using (var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls)))
|
||||
{
|
||||
var analyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls);
|
||||
analyzer.Run();
|
||||
|
||||
string outputFile = $"{SettingsUtil.GeneratedCppDir}/ReversePInvokeMethodStub.cpp";
|
||||
|
||||
List<ABIReversePInvokeMethodInfo> methods = analyzer.BuildABIMethods();
|
||||
Debug.Log($"GenerateReversePInvokeWrapper. wraperCount:{methods.Sum(m => m.Count)} output:{outputFile}");
|
||||
var generator = new Generator();
|
||||
generator.Generate(methods, outputFile);
|
||||
Debug.LogFormat("[ReversePInvokeWrapperGeneratorCommand] output:{0}", outputFile);
|
||||
}
|
||||
MethodBridgeGeneratorCommand.CleanIl2CppBuildCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5b6fd817e50470408462a9703bfe7ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,4 @@
|
||||
using HybridCLR.Editor.BuildProcessors;
|
||||
using HybridCLR.Editor.Installer;
|
||||
using HybridCLR.Editor.Installer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -57,11 +56,11 @@ namespace HybridCLR.Editor.Commands
|
||||
switch(target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64: return $"{buildDir}/{PlayerSettings.productName}.exe";
|
||||
case BuildTarget.StandaloneWindows64: return $"{buildDir}/{target}";
|
||||
case BuildTarget.StandaloneOSX: return buildDir;
|
||||
case BuildTarget.iOS: return buildDir;
|
||||
case BuildTarget.Android: return buildDir;
|
||||
case BuildTarget.StandaloneLinux64: return $"{buildDir}/{PlayerSettings.productName}";
|
||||
case BuildTarget.StandaloneLinux64: return buildDir;
|
||||
default: return buildDir;
|
||||
}
|
||||
}
|
||||
@@ -72,124 +71,91 @@ namespace HybridCLR.Editor.Commands
|
||||
BashUtil.RemoveDir(outputPath);
|
||||
|
||||
var buildOptions = GetBuildPlayerOptions(target);
|
||||
#if UNITY_2021_2_OR_NEWER
|
||||
buildOptions |= BuildOptions.CleanBuildCache;
|
||||
#endif
|
||||
|
||||
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;
|
||||
EditorUserBuildSettings.buildScriptsOnly = true;
|
||||
|
||||
string location = GetLocationPathName(outputPath, target);
|
||||
string oldBuildLocation = EditorUserBuildSettings.GetBuildLocation(target);
|
||||
try
|
||||
EditorUserBuildSettings.SetBuildLocation(target, location);
|
||||
|
||||
switch (target)
|
||||
{
|
||||
CheckSettings.DisableMethodBridgeDevelopmentFlagChecking = true;
|
||||
EditorUserBuildSettings.buildScriptsOnly = true;
|
||||
|
||||
string location = GetLocationPathName(outputPath, target);
|
||||
EditorUserBuildSettings.SetBuildLocation(target, location);
|
||||
|
||||
switch (target)
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
{
|
||||
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,
|
||||
#if UNITY_EDITOR_WIN
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = true;
|
||||
#endif
|
||||
};
|
||||
|
||||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
|
||||
|
||||
|
||||
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||
break;
|
||||
}
|
||||
case BuildTarget.StandaloneOSX:
|
||||
{
|
||||
throw new Exception("GenerateStripedAOTDlls failed");
|
||||
#if UNITY_EDITOR_OSX
|
||||
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = true;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case BuildTarget.Android:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
CheckSettings.DisableMethodBridgeDevelopmentFlagChecking = false;
|
||||
EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly;
|
||||
EditorUserBuildSettings.SetBuildLocation(target, oldBuildLocation);
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
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),
|
||||
};
|
||||
|
||||
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
||||
|
||||
EditorUserBuildSettings.buildScriptsOnly = oldBuildScriptsOnly;
|
||||
EditorUserBuildSettings.SetBuildLocation(target, oldBuildLocation);
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case BuildTarget.StandaloneWindows:
|
||||
case BuildTarget.StandaloneWindows64:
|
||||
{
|
||||
#if UNITY_EDITOR_WIN
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = oldCreateSolution;
|
||||
UnityEditor.WindowsStandalone.UserBuildSettings.createSolution = oldCreateSolution;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case BuildTarget.StandaloneOSX:
|
||||
case BuildTarget.StandaloneOSX:
|
||||
{
|
||||
#if UNITY_EDITOR_OSX
|
||||
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = oldCreateSolution;
|
||||
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
|
||||
case BuildTarget.Android:
|
||||
{
|
||||
EditorUserBuildSettings.exportAsGoogleAndroidProject = oldExportAndroidProj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
||||
{
|
||||
throw new Exception("GenerateStripedAOTDlls failed");
|
||||
}
|
||||
Debug.Log($"GenerateStripedAOTDlls target:{target} path:{outputPath}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21fb0a02f23185141a4a3df67fe61789
|
||||
guid: c7d81ec59b79a534783f4186872f6c2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
Reference in New Issue
Block a user