From 1b157b04abede7fd7c7a41afc8a53c0240868f32 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Fri, 12 May 2023 08:11:43 -0400 Subject: [PATCH 1/2] fix(tuner): Don't copy the tuner binaries in the runtime tools folder This avoids transient issues when upgrading the bootstrapper on the same runtime folder, while having tuner changes. (cherry picked from commit c51731fcf18132348f337df6fbf27403161329dc) --- src/Uno.Wasm.Bootstrap/ShellTask.cs | 3 +++ src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj | 1 + src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets | 1 + src/Uno.Wasm.Packager/packager.cs | 8 +++++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Uno.Wasm.Bootstrap/ShellTask.cs b/src/Uno.Wasm.Bootstrap/ShellTask.cs index 2d0eac50e..6bf342829 100644 --- a/src/Uno.Wasm.Bootstrap/ShellTask.cs +++ b/src/Uno.Wasm.Bootstrap/ShellTask.cs @@ -205,6 +205,8 @@ private FileNameObfuscationMode _assembliesFileNameObfuscationMode public string? CustomLinkerPath { get; set; } + public string? WasmTunerBinPath { get; set; } + public string? PWAManifestFile { get; set; } public bool EnableLongPathSupport { get; set; } = true; @@ -884,6 +886,7 @@ private void RunPackager() packagerParams.Add(referencePathsParameter); packagerParams.Add(GenerateAOTProfile ? "--profile=aot" : ""); packagerParams.Add(EnableLogProfiler ? "--profile=log" : ""); + packagerParams.Add(!string.IsNullOrEmpty(WasmTunerBinPath) ? $"\"--wasm-tuner-path={AlignPath(Path.GetFullPath(WasmTunerBinPath))}\"" : ""); packagerParams.Add($"\"--linker-optimization-level={GetEmccLinkerOptimizationLevel()}\""); packagerParams.Add($"\"{AlignPath(Path.GetFullPath(Assembly))}\""); diff --git a/src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj b/src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj index 2ea8c0fad..de20c5532 100644 --- a/src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj +++ b/src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj @@ -225,6 +225,7 @@ <_PackagerNet5Files Include="../Uno.Wasm.Packager/bin/$(Configuration)/net5.0/packager.*" /> <_TunerNet5Files Include="../Uno.Wasm.Tuner/bin/$(Configuration)/net5.0/wasm-tuner.*" /> + <_TunerNet5Files Include="../Uno.Wasm.Tuner/bin/$(Configuration)/net5.0/Mono.Cecil.*" /> <_TunerNet5Files Include="../Uno.Wasm.Tuner/bin/$(Configuration)/net5.0/System.Json.dll" /> <_TunerNet5Files Include="../Uno.Wasm.Tuner/bin/$(Configuration)/net5.0/System.Reflection.MetadataLoadContext.dll" /> diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index 5078638d8..a0bca5e94 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -267,6 +267,7 @@ TargetFrameworkVersion="$(TargetFrameworkVersion)" UseFileIntegrity="$(WashShellUseFileIntegrity)" WasmShellMode="$(WasmShellMode)" + WasmTunerBinPath="$(MSBuildThisFileDirectory)/wasm-tuner/net5.0/wasm-tuner.dll" WebAppBasePath="$(WasmShellWebAppBasePath)" > diff --git a/src/Uno.Wasm.Packager/packager.cs b/src/Uno.Wasm.Packager/packager.cs index a025a2720..2c117024b 100644 --- a/src/Uno.Wasm.Packager/packager.cs +++ b/src/Uno.Wasm.Packager/packager.cs @@ -508,6 +508,7 @@ int Run (string[] args) { string extra_emccflags = ""; string extra_linkerflags = ""; string linker_optimization_level = ""; + string wasm_tuner_path = ""; var linker_args = new List(); var opts = new WasmOptions () { @@ -564,6 +565,7 @@ int Run (string[] args) { { "illinker-path=", s => illinker_path = s }, { "extra-linkerflags=", s => extra_linkerflags = s }, { "linker-optimization-level=", s => linker_optimization_level = s }, + { "wasm-tuner-path=", s => wasm_tuner_path = s }, { "help", s => print_usage = true }, }; @@ -1410,7 +1412,11 @@ int Run (string[] args) { var linkerSearchPaths = root_search_paths.Concat(bcl_prefixes).Distinct().Select(p => $"-d \"{p}\" "); - var tunerCommand = is_netcore ? $"dotnet $tools_dir{Path.DirectorySeparatorChar}wasm-tuner.dll" : "mono $tools_dir/wasm-tuner.exe"; + var tunerCommand = $"dotnet " + + (string.IsNullOrEmpty(wasm_tuner_path) + ? $"$tools_dir{Path.DirectorySeparatorChar}wasm-tuner.dll" + : wasm_tuner_path); + var exitCommand = is_windows ? failOnError : "|| exit 1"; linker_args.Add($"-out ./linker-out --deterministic --disable-opt unreachablebodies"); From 0634594dcfc5a74f5a99b4c0e9fe3839da28f946 Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Fri, 12 May 2023 08:40:39 -0400 Subject: [PATCH 2/2] chore: remove tuner from sdk install (cherry picked from commit 79e9f80be9f9f0b342738cf89fd30c1eba217559) --- src/Uno.Wasm.Bootstrap/UnoInstallSDKTask.cs | 22 ------------------- .../build/Uno.Wasm.Bootstrap.targets | 1 - 2 files changed, 23 deletions(-) diff --git a/src/Uno.Wasm.Bootstrap/UnoInstallSDKTask.cs b/src/Uno.Wasm.Bootstrap/UnoInstallSDKTask.cs index 229f22ccf..092d13dbf 100644 --- a/src/Uno.Wasm.Bootstrap/UnoInstallSDKTask.cs +++ b/src/Uno.Wasm.Bootstrap/UnoInstallSDKTask.cs @@ -41,9 +41,6 @@ public class UnoInstallSDKTask_v0 : Microsoft.Build.Utilities.Task, ICancelableT [Required] public string PackagerOverrideFolderPath { get; set; } = ""; - [Required] - public string WasmTunerOverrideFolderPath { get; set; } = ""; - [Required] public string CilStripOverrideFolderPath { get; set; } = ""; @@ -75,8 +72,6 @@ public class UnoInstallSDKTask_v0 : Microsoft.Build.Utilities.Task, ICancelableT [Output] public string? PackagerBinPath { get; set; } - [Output] - public string? WasmTunerBinPath { get; set; } [Output] public string? PackagerProjectFile { get; private set; } @@ -136,7 +131,6 @@ private async Task InstallNetCoreWasmSdk(CancellationToken ct) { void WriteTools() { - WriteWasmTuner(); WriteCilStrip(); } @@ -267,22 +261,6 @@ private void MarkSDKExecutable() } } - private void WriteWasmTuner() - { - if (!string.IsNullOrEmpty(WasmTunerOverrideFolderPath)) - { - var basePath = Path.Combine(SdkPath, "tools"); - Directory.CreateDirectory(basePath); - - foreach (var file in Directory.EnumerateFiles(WasmTunerOverrideFolderPath)) - { - var destFileName = Path.Combine(basePath, Path.GetFileName(file)); - Log.LogMessage($"Copy wasm-tuner {file} to {destFileName}"); - File.Copy(file, destFileName, true); - } - } - } - private void WriteCilStrip() { if (!string.IsNullOrEmpty(CilStripOverrideFolderPath)) diff --git a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets index a0bca5e94..394ba3529 100644 --- a/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets +++ b/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets @@ -197,7 +197,6 @@ TargetFramework="$(TargetFramework)" TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)" TargetFrameworkVersion="$(TargetFrameworkVersion)" - WasmTunerOverrideFolderPath="$(MSBuildThisFileDirectory)/wasm-tuner/$(_WasmShellToolSuffix)" >