Skip to content

Commit

Permalink
fix(tuner): Don't copy the tuner binaries in the runtime tools folder
Browse files Browse the repository at this point in the history
This avoids transient issues when upgrading the bootstrapper on the same runtime folder, while having tuner changes.

(cherry picked from commit c51731f)
  • Loading branch information
jeromelaban authored and mergify[bot] committed May 12, 2023
1 parent ebfec27 commit 1b157b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Uno.Wasm.Bootstrap/ShellTask.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -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))}\"");

Expand Down
1 change: 1 addition & 0 deletions src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj
Expand Up @@ -225,6 +225,7 @@
<ItemGroup>
<_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" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets
Expand Up @@ -267,6 +267,7 @@
TargetFrameworkVersion="$(TargetFrameworkVersion)"
UseFileIntegrity="$(WashShellUseFileIntegrity)"
WasmShellMode="$(WasmShellMode)"
WasmTunerBinPath="$(MSBuildThisFileDirectory)/wasm-tuner/net5.0/wasm-tuner.dll"
WebAppBasePath="$(WasmShellWebAppBasePath)"
>
<Output TaskParameter="OutputPackagePath" PropertyName="WasmShellOutputPackagePath" />
Expand Down
8 changes: 7 additions & 1 deletion src/Uno.Wasm.Packager/packager.cs
Expand Up @@ -508,6 +508,7 @@ class WasmOptions {
string extra_emccflags = "";
string extra_linkerflags = "";
string linker_optimization_level = "";
string wasm_tuner_path = "";
var linker_args = new List<string>();

var opts = new WasmOptions () {
Expand Down Expand Up @@ -564,6 +565,7 @@ class WasmOptions {
{ "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 },
};

Expand Down Expand Up @@ -1410,7 +1412,11 @@ class WasmOptions {

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");
Expand Down

0 comments on commit 1b157b0

Please sign in to comment.