-
-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nathan Ricci
authored
Jul 15, 2020
1 parent
a4dd37c
commit 0928895
Showing
25 changed files
with
564 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<configuration> | ||
<packageSources> | ||
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" /> | ||
</packageSources> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/BenchmarkDotNet/Engines/NoAcknowledgementConsoleHost.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.IO; | ||
using BenchmarkDotNet.Validators; | ||
using JetBrains.Annotations; | ||
|
||
namespace BenchmarkDotNet.Engines | ||
{ | ||
/* This class is used by wasm because wasm cannot read from the console. | ||
* This potentially breaks communication with Diagnosers. */ | ||
public sealed class NoAcknowledgementConsoleHost : IHost | ||
{ | ||
private readonly TextWriter outWriter; | ||
|
||
public NoAcknowledgementConsoleHost([NotNull]TextWriter outWriter) | ||
{ | ||
this.outWriter = outWriter ?? throw new ArgumentNullException(nameof(outWriter)); | ||
} | ||
|
||
public void Write(string message) => outWriter.Write(message); | ||
|
||
public void WriteLine() => outWriter.WriteLine(); | ||
|
||
public void WriteLine(string message) => outWriter.WriteLine(message); | ||
|
||
public void SendSignal(HostSignal hostSignal) => WriteLine(Engine.Signals.ToMessage(hostSignal)); | ||
|
||
public void SendError(string message) => outWriter.WriteLine($"{ValidationErrorReporter.ConsoleErrorPrefix} {message}"); | ||
|
||
public void ReportResults(RunResults runResults) => runResults.Print(outWriter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using BenchmarkDotNet.Jobs; | ||
|
||
namespace BenchmarkDotNet.Environments | ||
{ | ||
public class WasmRuntime : Runtime, IEquatable<WasmRuntime> | ||
{ | ||
public static readonly WasmRuntime Default = new WasmRuntime("Wasm"); | ||
|
||
public WasmRuntime(string name) : base(RuntimeMoniker.Wasm, "net5.0", name) | ||
{ | ||
} | ||
|
||
public WasmRuntime(string name, string msBuildMoniker) : base(RuntimeMoniker.Wasm, msBuildMoniker, name) | ||
{ | ||
} | ||
|
||
public override bool Equals(object obj) => obj is WasmRuntime other && Equals(other); | ||
|
||
public bool Equals(WasmRuntime other) => base.Equals(other); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="$SDKNAME$" DefaultTargets="Publish"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<OutputPath>bin</OutputPath> | ||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> | ||
<TargetFramework>$TFM$</TargetFramework> | ||
<AppDir>$(MSBuildThisFileDirectory)\bin\$TFM$\browser-wasm\publish</AppDir> | ||
<AssemblyName>$PROGRAMNAME$</AssemblyName> | ||
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier> | ||
$COPIEDSETTINGS$ | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="$CODEFILENAME$" Exclude="bin\**;obj\**;**\*.xproj;packages\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$CSPROJPATH$" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Reflection; | ||
using BenchmarkDotNet.Toolchains.MonoWasm; | ||
|
||
public class WasmAppBuilder | ||
{ | ||
private readonly WasmSettings WasmSettings; | ||
private readonly string TargetFrameworkMoniker; | ||
|
||
public WasmAppBuilder(WasmSettings wasmSettings, string targetFrameworkMoniker) | ||
{ | ||
WasmSettings = wasmSettings; | ||
TargetFrameworkMoniker = targetFrameworkMoniker; | ||
} | ||
|
||
public bool BuildApp (string programName, string projectRoot) | ||
{ | ||
string[] assemblies; | ||
string appDir = Path.Combine(projectRoot, $"bin", TargetFrameworkMoniker, "browser-wasm", "publish"); | ||
string outputDir = Path.Combine(appDir, "output"); | ||
|
||
string mainAssemblyPath = Path.Combine(appDir, $"{programName}.dll"); | ||
|
||
if (!File.Exists(mainAssemblyPath)) | ||
throw new ArgumentException($"File MainAssembly='{mainAssemblyPath}' doesn't exist."); | ||
if (!File.Exists(WasmSettings.WasmMainJS)) | ||
throw new ArgumentException($"File MainJS='{WasmSettings.WasmMainJS}' doesn't exist."); | ||
|
||
var paths = new List<string>(); | ||
assemblies = Directory.GetFiles(appDir, "*.dll"); | ||
|
||
// Create app | ||
Directory.CreateDirectory(outputDir); | ||
Directory.CreateDirectory(Path.Combine(outputDir, "managed")); | ||
foreach (var assembly in assemblies) | ||
File.Copy(assembly, Path.Combine(outputDir, "managed", Path.GetFileName(assembly)), true); | ||
|
||
foreach (var f in new string[] { "dotnet.wasm", "dotnet.js" }) | ||
File.Copy(Path.Combine(appDir, f), Path.Combine(outputDir, f), true); | ||
|
||
File.Copy(WasmSettings.WasmMainJS, Path.Combine(outputDir, "runtime.js"), true); | ||
|
||
using (var sw = File.CreateText(Path.Combine(outputDir, "mono-config.js"))) | ||
{ | ||
sw.WriteLine("config = {"); | ||
sw.WriteLine("\tvfs_prefix: \"managed\","); | ||
sw.WriteLine("\tdeploy_prefix: \"managed\","); | ||
sw.WriteLine("\tenable_debugging: 0,"); | ||
sw.WriteLine("\tassembly_list: ["); | ||
foreach (var assembly in assemblies) | ||
{ | ||
sw.Write("\t\t\"" + Path.GetFileName(assembly) + "\""); | ||
sw.WriteLine(","); | ||
} | ||
sw.WriteLine ("\t],"); | ||
sw.WriteLine("\tfiles_to_map: [],"); | ||
|
||
sw.WriteLine ("}"); | ||
} | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.