Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr wasm set runtimesrcdir for interpreter #1763

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Expand Up @@ -112,9 +112,12 @@ private static bool Validate(CommandLineOptions options, ILogger logger)
logger.WriteLineError($"The provided runtime \"{runtime}\" is invalid. Available options are: {string.Join(", ", Enum.GetNames(typeof(RuntimeMoniker)).Select(name => name.ToLower()))}.");
return false;
}
else if (runtimeMoniker == RuntimeMoniker.Wasm && !(options.AOTCompilerMode == MonoAotCompilerMode.wasm) && (options.WasmMainJs == null || options.WasmMainJs.IsNotNullButDoesNotExist()))
else if (runtimeMoniker == RuntimeMoniker.Wasm && options.WasmMainJs == null && options.RuntimeSrcDir == null) {
logger.WriteLine("Either runtimeSrcDir or WasmMainJS must be specified.");
}
else if (runtimeMoniker == RuntimeMoniker.Wasm && options.WasmMainJs.IsNotNullButDoesNotExist())
{
logger.WriteLineError($"The provided {nameof(options.WasmMainJs)} \"{options.WasmMainJs}\" does NOT exist. It MUST be provided.");
logger.WriteLineError($"The provided {nameof(options.WasmMainJs)} \"{options.WasmMainJs}\" does NOT exist.");
return false;
}
else if (runtimeMoniker == RuntimeMoniker.MonoAOTLLVM && (options.AOTCompilerPath == null || options.AOTCompilerPath.IsNotNullButDoesNotExist()))
Expand All @@ -123,7 +126,7 @@ private static bool Validate(CommandLineOptions options, ILogger logger)
}
else if (runtimeMoniker == RuntimeMoniker.Wasm && options.AOTCompilerMode == MonoAotCompilerMode.wasm && (options.RuntimeSrcDir == null || options.RuntimeSrcDir.IsNotNullButDoesNotExist()))
{
logger.WriteLineError($"The provided {nameof(options.RuntimeSrcDir)} \"{options.RuntimeSrcDir}\" does NOT exist. It MUST be provided.");
logger.WriteLineError($"The provided {nameof(options.RuntimeSrcDir)} \"{options.RuntimeSrcDir}\" does NOT exist. It MUST be provided for wasm-aot.");
return false;
}
}
Expand Down Expand Up @@ -422,7 +425,7 @@ private static Job MakeWasmJob(Job baseJob, CommandLineOptions options, TimeSpan
bool wasmAot = options.AOTCompilerMode == MonoAotCompilerMode.wasm;

var wasmRuntime = new WasmRuntime(
mainJs: options.WasmMainJs,
mainJs: options.WasmMainJs ?? new FileInfo(options.RuntimeSrcDir.ToString() + @"\src\mono\wasm\runtime-test.js"),
adamsitnik marked this conversation as resolved.
Show resolved Hide resolved
msBuildMoniker: msBuildMoniker,
javaScriptEngine: options.WasmJavascriptEngine?.FullName ?? "v8",
javaScriptEngineArguments: options.WasmJavaScriptEngineArguments,
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Templates/WasmCsProj.txt
Expand Up @@ -9,7 +9,7 @@
<AppDir>$(MSBuildThisFileDirectory)\bin\$TFM$\browser-wasm\publish</AppDir>
<AssemblyName>$PROGRAMNAME$</AssemblyName>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>$(RuntimeSrcDir)\src\mono\wasm\runtime-test.js</WasmMainJSPath>
<WasmMainJSPath>$MAINJS$</WasmMainJSPath>
<MicrosoftNetCoreAppRuntimePackDir>$RUNTIMEPACK$</MicrosoftNetCoreAppRuntimePackDir>
<UsingBrowserRuntimeWorkload>false</UsingBrowserRuntimeWorkload>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
Expand Down
7 changes: 6 additions & 1 deletion src/BenchmarkDotNet/Toolchains/MonoWasm/WasmGenerator.cs
Expand Up @@ -66,6 +66,9 @@ protected void GenerateProjectInterpreter(BuildPartition buildPartition, Artifac
{
BenchmarkCase benchmark = buildPartition.RepresentativeBenchmarkCase;
var projectFile = GetProjectFilePath(benchmark.Descriptor.Type, logger);

WasmRuntime runtime = (WasmRuntime)buildPartition.Runtime;

using (var file = new StreamReader(File.OpenRead(projectFile.FullName)))
{
var (customProperties, sdkName) = GetSettingsThatNeedsToBeCopied(file, projectFile);
Expand All @@ -76,12 +79,14 @@ protected void GenerateProjectInterpreter(BuildPartition buildPartition, Artifac
.Replace("$CSPROJPATH$", projectFile.FullName)
.Replace("$TFM$", TargetFrameworkMoniker)
.Replace("$PROGRAMNAME$", artifactsPaths.ProgramName)
.Replace("$RUNTIMESRCDIR$", runtime.RuntimeSrcDir.ToString())
.Replace("$COPIEDSETTINGS$", customProperties)
.Replace("$CONFIGURATIONNAME$", buildPartition.BuildConfiguration)
.Replace("$SDKNAME$", sdkName)
.Replace("$RUNTIMEPACK$", CustomRuntimePack ?? "")
.Replace("$TARGET$", CustomRuntimePack != null ? "PublishWithCustomRuntimePack" : "Publish")
.ToString();
.Replace("$MAINJS$", runtime.MainJs.ToString())
.ToString();

File.WriteAllText(artifactsPaths.ProjectFilePath, content);
}
Expand Down