Skip to content

Commit

Permalink
Merge pull request #722 from unoplatform/mergify/bp/release/stable/7.…
Browse files Browse the repository at this point in the history
…0/pr-721

fix(tuner): Don't copy the tuner binaries in the runtime tools folder (backport #721)
  • Loading branch information
jeromelaban authored May 12, 2023
2 parents ebfec27 + 0634594 commit f335ab6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/Uno.Wasm.Bootstrap/ShellTask.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
22 changes: 0 additions & 22 deletions src/Uno.Wasm.Bootstrap/UnoInstallSDKTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } = "";

Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -136,7 +131,6 @@ private async Task InstallNetCoreWasmSdk(CancellationToken ct)
{
void WriteTools()
{
WriteWasmTuner();
WriteCilStrip();
}

Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@
TargetFramework="$(TargetFramework)"
TargetFrameworkIdentifier="$(TargetFrameworkIdentifier)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
WasmTunerOverrideFolderPath="$(MSBuildThisFileDirectory)/wasm-tuner/$(_WasmShellToolSuffix)"
>
<Output TaskParameter="SdkPath" PropertyName="_UnoMonoSdkPath" />
<Output TaskParameter="PackagerBinPath" PropertyName="_UnoMonoPackagerBinPath" />
Expand Down Expand Up @@ -267,6 +266,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
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();

var opts = new WasmOptions () {
Expand Down Expand Up @@ -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 },
};

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

0 comments on commit f335ab6

Please sign in to comment.