Skip to content

Commit 80f45ce

Browse files
Nathan Riccipavelsavaraadamsitnik
authored
[WASM] Fix rename of main.js to test-main.js (#1916)
Co-authored-by: pavelsavara <[email protected]> Co-authored-by: Adam Sitnik <[email protected]>
1 parent 11751a6 commit 80f45ce

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

docs/articles/guides/console-args.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,6 @@ dotnet run -c Release -- --filter * --runtimes netcoreapp2.0 netcoreapp2.1 --sta
222222
* `--runOncePerIteration` run the benchmark exactly once per iteration.
223223
* `--buildTimeout` build timeout in seconds.
224224
* `--wasmEngine` full path to a java script engine used to run the benchmarks, used by Wasm toolchain.
225-
* `--wasmMainJS` path to the main.js file used by Wasm toolchain. Mandatory when using \"--runtimes wasm\"
225+
* `--wasmMainJS` path to the test-main.js file used by Wasm toolchain. Mandatory when using \"--runtimes wasm\"
226226
* `--expose_wasm` arguments for the JavaScript engine used by Wasm toolchain.
227227
* `--customRuntimePack` specify the path to a custom runtime pack. Only used for wasm currently.

src/BenchmarkDotNet/Templates/WasmAotCsProj.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PublishTrimmed>true</PublishTrimmed>
1414
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
1515
<RunAOTCompilation>true</RunAOTCompilation>
16-
<WasmMainJSPath>$(RuntimeSrcDir)\src\mono\wasm\test-main.js</WasmMainJSPath>
16+
<WasmMainJSPath>$(RuntimeSrcDir)\src\mono\wasm\$MAINJS$</WasmMainJSPath>
1717
<WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
1818
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
1919
<WasmNativeWorkload>false</WasmNativeWorkload>

src/BenchmarkDotNet/Templates/WasmCsProj.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
1313
<PublishTrimmed>false</PublishTrimmed>
1414
<RunAOTCompilation>false</RunAOTCompilation>
15-
<WasmMainJSPath>$(RuntimeSrcDir)\src\mono\wasm\test-main.js</WasmMainJSPath>
15+
<WasmMainJSPath>$(RuntimeSrcDir)\src\mono\wasm\$MAINJS$/WasmMainJSPath>
1616
<WasmGenerateRunV8Script>true</WasmGenerateRunV8Script>
1717
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
1818
<WasmNativeWorkload>false</WasmNativeWorkload>

src/BenchmarkDotNet/Toolchains/Executor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ private ProcessStartInfo CreateStartInfo(BenchmarkCase benchmarkCase, ArtifactsP
116116
case WasmRuntime wasm:
117117
start.FileName = wasm.JavaScriptEngine;
118118
start.RedirectStandardInput = false;
119-
start.Arguments = $"{wasm.JavaScriptEngineArguments} main.js -- --run {artifactsPaths.ProgramName}.dll {args} ";
119+
120+
string main_js = runtime.RuntimeMoniker < RuntimeMoniker.WasmNet70 ? "main.js" : "test-main.js";
121+
122+
start.Arguments = $"{wasm.JavaScriptEngineArguments} {main_js} -- --run {artifactsPaths.ProgramName}.dll {args} ";
120123
start.WorkingDirectory = artifactsPaths.BinariesDirectoryPath;
121124
break;
122125
case MonoAotLLVMRuntime _:

src/BenchmarkDotNet/Toolchains/MonoWasm/WasmGenerator.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public class WasmGenerator : CsProjGenerator
1313
{
1414
private readonly string CustomRuntimePack;
1515
private readonly bool Aot;
16+
private readonly string MainJS;
1617

1718
public WasmGenerator(string targetFrameworkMoniker, string cliPath, string packagesPath, string customRuntimePack, bool aot)
1819
: base(targetFrameworkMoniker, cliPath, packagesPath, runtimeFrameworkVersion: null)
1920
{
2021
Aot = aot;
2122
CustomRuntimePack = customRuntimePack;
23+
MainJS = (targetFrameworkMoniker == "net5.0" || targetFrameworkMoniker == "net6.0") ? "main.js" : "test-main.js";
2224
}
2325

2426
protected override void GenerateProject(BuildPartition buildPartition, ArtifactsPaths artifactsPaths, ILogger logger)
@@ -56,6 +58,7 @@ protected void GenerateProjectAot(BuildPartition buildPartition, ArtifactsPaths
5658
.Replace("$COPIEDSETTINGS$", customProperties)
5759
.Replace("$CONFIGURATIONNAME$", buildPartition.BuildConfiguration)
5860
.Replace("$SDKNAME$", sdkName)
61+
.Replace("$MAINJS$", MainJS)
5962
.ToString();
6063

6164
File.WriteAllText(artifactsPaths.ProjectFilePath, content);
@@ -84,14 +87,15 @@ protected void GenerateProjectInterpreter(BuildPartition buildPartition, Artifac
8487
.Replace("$CONFIGURATIONNAME$", buildPartition.BuildConfiguration)
8588
.Replace("$SDKNAME$", sdkName)
8689
.Replace("$RUNTIMEPACK$", CustomRuntimePack ?? "")
90+
.Replace("$MAINJS$", MainJS)
8791
.Replace("$TARGET$", CustomRuntimePack != null ? "PublishWithCustomRuntimePack" : "Publish")
8892
.ToString();
8993

9094
File.WriteAllText(artifactsPaths.ProjectFilePath, content);
9195
}
9296
}
9397

94-
protected override string GetExecutablePath(string binariesDirectoryPath, string programName) => Path.Combine(binariesDirectoryPath, "main.js");
98+
protected override string GetExecutablePath(string binariesDirectoryPath, string programName) => Path.Combine(binariesDirectoryPath, MainJS);
9599

96100
protected override string GetBinariesDirectoryPath(string buildArtifactsDirectoryPath, string configuration)
97101
{

0 commit comments

Comments
 (0)