From 1d50dfcb6ec0dd04a3ad572540f5984e35bdcac2 Mon Sep 17 00:00:00 2001 From: walon Date: Tue, 5 Sep 2023 17:28:06 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20StripAOTDllCommand=E7=94=9F=E6=88=90AOT?= =?UTF-8?q?=20dll=E6=97=B6=E7=9A=84BuildOption=E9=87=87=E7=94=A8=E5=BD=93?= =?UTF-8?q?=E5=89=8DPlayer=E7=9A=84=E8=AE=BE=E7=BD=AE=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=BD=93=E6=89=93=E5=8C=85=E5=BC=80=E5=90=AFdevelopme?= =?UTF-8?q?nt=E6=97=B6=EF=BC=8C=20StripAOTDllCommand=E7=94=9F=E6=88=90Rele?= =?UTF-8?q?ase=20aot=20dll=EF=BC=8C=E8=80=8C=E6=89=93=E5=8C=85=E7=94=9F?= =?UTF-8?q?=E6=88=90debug=20aot=20dll=EF=BC=8C=E4=BA=A7=E7=94=9F=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E5=85=83=E6=95=B0=E6=8D=AE=E5=8F=8A=E6=A1=A5=E6=8E=A5?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=94=9F=E6=88=90=E4=B8=8D=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E7=9A=84=E4=B8=A5=E9=87=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Commands/StripAOTDllCommand.cs | 37 ++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/Editor/Commands/StripAOTDllCommand.cs b/Editor/Commands/StripAOTDllCommand.cs index 4c27b47..84ee454 100644 --- a/Editor/Commands/StripAOTDllCommand.cs +++ b/Editor/Commands/StripAOTDllCommand.cs @@ -3,10 +3,12 @@ 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 { @@ -18,6 +20,37 @@ namespace HybridCLR.Editor.Commands GenerateStripedAOTDlls(EditorUserBuildSettings.activeBuildTarget); } + static BuildOptions GetBuildPlayerOptions(BuildTarget buildTarget) + { + BuildOptions options = BuildOptions.BuildScriptsOnly; + 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) @@ -37,7 +70,7 @@ namespace HybridCLR.Editor.Commands string outputPath = $"{SettingsUtil.HybridCLRDataDir}/StrippedAOTDllsTempProj/{target}"; BashUtil.RemoveDir(outputPath); - var buildOptions = BuildOptions.BuildScriptsOnly; + var buildOptions = GetBuildPlayerOptions(target); #if UNITY_2021_2_OR_NEWER buildOptions |= BuildOptions.CleanBuildCache; #endif @@ -75,6 +108,8 @@ namespace HybridCLR.Editor.Commands } } + Debug.Log($"GenerateStripedAOTDlls build option:{buildOptions}"); + BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions() { scenes = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray(),