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

[wasm] Wasm.Build.Tests: add support for shared builds #49398

Merged
merged 24 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
62197f0
[wasm] Wasm.Build.Tests: add support for shared builds
radical Mar 9, 2021
af44fea
[wasm] Wasm.Build.Tests: Add test for relinking with InvariantGlobali…
radical Mar 10, 2021
1b102b3
[wasm] Wasm.Build.Tests - Check `CultureInfo` for invariant culture
radical Mar 11, 2021
33d87f2
fix invariant+aot test
radical Mar 11, 2021
995cc89
[wasm] Fix the order of include paths
radical Mar 11, 2021
250653e
[wasm] Only test with Release config on CI
radical Mar 11, 2021
3cd29e0
[wasm] Fallback to `dotnet xharness` if `XHARNESS_CLI_PATH` is not set.
radical Mar 11, 2021
739881f
[wasm] fix invariant test - 'en-ES' -> 'es-ES'
radical Mar 11, 2021
fcf0da6
[wasm] RunWithEmSdkEnv: log the working directory also
radical Mar 11, 2021
cb7aff7
Merge remote-tracking branch 'origin/main' into wasm-build-tests
radical Mar 12, 2021
1ce676f
[wasm] Re-enable wasm build tests
radical Mar 12, 2021
522424a
[wasm] Add regression test for issue #49588
radical Mar 15, 2021
86b4b36
Merge remote-tracking branch 'origin/main' into wasm-build-tests
radical Mar 16, 2021
aae95e2
fix test
radical Mar 16, 2021
3540462
[wasm] Cleanup, and add more tests
radical Mar 17, 2021
5e90d6f
Merge remote-tracking branch 'origin/main' into wasm-build-tests
radical Mar 17, 2021
02045a3
Merge remote-tracking branch 'origin/main' into wasm-build-tests
radical Mar 17, 2021
c21da91
Update tests to track wasm relinking being default in some cases
radical Mar 17, 2021
d6e9732
Fix InvariantGlobalization to track change in wasm relinking defaults
radical Mar 18, 2021
da64faf
Merge remote-tracking branch 'origin/main' into wasm-build-tests
radical Mar 22, 2021
eaf1615
Merge remote-tracking branch 'origin/main' into wasm-build-tests
radical Mar 25, 2021
97b83b8
[wasm] Update emsdk check message to track changes
radical Mar 25, 2021
f463714
[wasm] Update tests to track changes
radical Mar 25, 2021
7caed5a
[wasm] Move Scenario=BuildWasmApps to be submitted first
radical Mar 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ jobs:
creator: dotnet-bot
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
scenarios:
- buildwasmapps
- normal
- wasmtestonbrowser
condition: >-
Expand Down
28 changes: 18 additions & 10 deletions src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)')" Text="MicrosoftNetCoreAppRuntimePackRidDir=$(MicrosoftNetCoreAppRuntimePackRidDir) doesn't exist" />
<Error Condition="@(WasmAssembliesToBundle->Count()) == 0" Text="WasmAssembliesToBundle item is empty. No assemblies to process" />

<Error Condition="'$(RunAOTCompilation)' == 'true' and ('$(EMSDK_PATH)' == '' or !Exists('$(EMSDK_PATH)'))"
Text="Cannot find emscripten sdk, required for AOT'ing assemblies. %24(EMSDK_PATH)=$(EMSDK_PATH)" />
<Error Condition="'$(WasmBuildNative)' == 'true' and ('$(EMSDK_PATH)' == '' or !Exists('$(EMSDK_PATH)'))"
Text="Cannot find emscripten sdk, required for native relinking. %24(EMSDK_PATH)=$(EMSDK_PATH)" />

<PropertyGroup>
<WasmGenerateAppBundle Condition="'$(WasmGenerateAppBundle)' == ''">true</WasmGenerateAppBundle>
<WasmNativeDebugSymbols Condition="'$(WasmNativeDebugSymbols)' == ''">true</WasmNativeDebugSymbols>
Expand Down Expand Up @@ -390,7 +395,8 @@
</Target>

<Target Name="_WasmBuildNative" DependsOnTargets="_WasmAotCompileApp;_WasmStripAOTAssemblies;_GenerateDriverGenC;_CheckEmccIsExpectedVersion" Condition="'$(WasmBuildNative)' == 'true'">
<Error Condition="'$(EmscriptenSdkToolsPath)' == ''" Text="%24(EmscriptenSdkToolsPath) should be set to emscripten sdk" />
<Error Condition="'$(_IsEMSDKMissing)' == 'true'"
Text="$(_EMSDKMissingErrorMessage) Emscripten SDK is required for building native files." />

<PropertyGroup>
<EmccFlagsFile>$([MSBuild]::NormalizePath($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src', 'emcc-flags.txt'))</EmccFlagsFile>
Expand Down Expand Up @@ -429,8 +435,8 @@
OutputPath="$(_WasmIntermediateOutputPath)icall-table.h" />
<PropertyGroup>
<EmccFlags Condition="'$(WasmLinkIcalls)' == 'true'">$(EmccFlags) -DLINK_ICALLS=1</EmccFlags>
<_WasmIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include'))</_WasmIncludeDir>
<_WasmSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src'))</_WasmSrcDir>
<_WasmRuntimePackIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include'))</_WasmRuntimePackIncludeDir>
<_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src'))</_WasmRuntimePackSrcDir>
</PropertyGroup>

<ItemGroup>
Expand All @@ -447,15 +453,15 @@
<_WasmObjectsToBuild Include="$(_WasmIntermediateOutputPath)driver.o"/>
<_WasmObjectsToBuild Include="$(_WasmIntermediateOutputPath)pinvoke.o"/>
<_WasmObjectsToBuild Include="$(_WasmIntermediateOutputPath)corebindings.o"/>
<_WasmObjectsToBuild SourcePath="$(_WasmSrcDir)%(FileName).c" />
<_WasmObjectsToBuild SourcePath="$(_WasmRuntimePackSrcDir)%(FileName).c" />

<_WasmObjects Include="@(_WasmRuntimePackNativeLibs->'$(MicrosoftNetCoreAppRuntimePackRidNativeDir)%(FileName)%(Extension)')" />
<_WasmObjects Include="@(_WasmObjectsToBuild)" />

<_DotnetJSSrcFile Include="$(_WasmSrcDir)library_mono.js" />
<_DotnetJSSrcFile Include="$(_WasmSrcDir)binding_support.js" />
<_DotnetJSSrcFile Include="$(_WasmSrcDir)dotnet_support.js" />
<_DotnetJSSrcFile Include="$(_WasmSrcDir)pal_random.js" />
<_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)library_mono.js" />
<_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)binding_support.js" />
<_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)dotnet_support.js" />
<_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)pal_random.js" />

<_AOTAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'" />
<_BitcodeFile Include="%(_WasmAssembliesInternal.LlvmBitcodeFile)" />
Expand All @@ -465,7 +471,7 @@
Text="Bug: Number of aot assemblies doesn't match the number of generated bitcode files. BitcodeFiles: @(_BitcodeFile->Count()) vs Assemblies: @(_AOTAssemblies->Count())" />

<PropertyGroup>
<EmccCFlags>$(EmccFlags) -DCORE_BINDINGS -DGEN_PINVOKE=1 "-I$(_WasmIncludeDir)mono-2.0" "-I$(_WasmIncludeDir)wasm"</EmccCFlags>
<EmccCFlags>$(EmccFlags) -DCORE_BINDINGS -DGEN_PINVOKE=1</EmccCFlags>
<EmccCFlags Condition="'$(WasmNativeDebugSymbols)' == 'true'">$(EmccCFlags) -g</EmccCFlags>

<!--
Expand All @@ -476,6 +482,8 @@
<EmccCFlags Condition="$(_WasmIntermediateOutputPath.EndsWith('\')) ">$(EmccCFlags) "-I$(_WasmIntermediateOutputPath)."</EmccCFlags>
<EmccCFlags Condition="!$(_WasmIntermediateOutputPath.EndsWith('\'))">$(EmccCFlags) "-I$(_WasmIntermediateOutputPath)"</EmccCFlags>

<EmccCFlags>$(EmccCFlags) &quot;-I$(_WasmRuntimePackIncludeDir)mono-2.0&quot; &quot;-I$(_WasmRuntimePackIncludeDir)wasm&quot;</EmccCFlags>

<EmccLDFlags>$(EmccFlags) -s TOTAL_MEMORY=536870912</EmccLDFlags>
<_WasmOptCommand>$([MSBuild]::NormalizePath('$(EmSdkUpstreamBinPath)', 'wasm-opt$(_ExeExt)'))</_WasmOptCommand>
</PropertyGroup>
Expand Down Expand Up @@ -529,7 +537,7 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_
<Exec Condition="'$(OS)' != 'Windows_NT'" Command="chmod a+x $(WasmRunV8ScriptPath)" />
</Target>

<Target Name="_CheckEmccIsExpectedVersion">
<Target Name="_CheckEmccIsExpectedVersion" Condition="'$(WasmBuildNative)' == 'true'">
<ReadLinesFromFile File="$([MSBuild]::NormalizePath($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src', 'emcc-version.txt'))">
<Output TaskParameter="Lines" PropertyName="RuntimeEmccVersion" />
</ReadLinesFromFile>
Expand Down
3 changes: 3 additions & 0 deletions src/tasks/WasmAppBuilder/RunWithEmSdkEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public override bool Execute()

Command = $"bash -c 'source {envScriptPath} > /dev/null 2>&1 && {Command}'";
}

var workingDir = string.IsNullOrEmpty(WorkingDirectory) ? Directory.GetCurrentDirectory() : WorkingDirectory;
Log.LogMessage(MessageImportance.Low, $"Working directory: {workingDir}");
Log.LogMessage(MessageImportance.Low, $"Using Command: {Command}");

return base.Execute() && !Log.HasLoggedErrors;
Expand Down
40 changes: 40 additions & 0 deletions src/tests/BuildWasmApps/Wasm.Build.Tests/BuildAndRunAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Xunit.Sdk;

#nullable enable

namespace Wasm.Build.Tests
{
/// <summary>
/// Example usage:
/// [BuildAndRun(aot: true, parameters: new object[] { arg1, arg2 })]
/// public void Test(BuildArgs, arg1, arg2, RunHost, id)
/// </summary>
[DataDiscoverer("Xunit.Sdk.DataDiscoverer", "xunit.core")]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class BuildAndRunAttribute : DataAttribute
{
private bool _aot;
private RunHost _host;
private object?[] _parameters;

public BuildAndRunAttribute(bool aot=false, RunHost host = RunHost.All, params object?[] parameters)
{
this._aot = aot;
this._host = host;
this._parameters = parameters;
}

public override IEnumerable<object?[]> GetData(MethodInfo testMethod)
=> BuildTestBase.ConfigWithAOTData(_aot)
.Multiply(_parameters)
.WithRunHosts(_host)
.UnwrapItemsAsArrays().ToList().Dump();
}
}
Loading