未验证 提交 d9ba7001 编写于 作者: Z Zoltan Varga 提交者: GitHub

Add a BundleTestWasmApp target to build wasm test apps for libraries. (#36739)

Beginning of a BundleTestWasmApp target to build wasm test apps for libraries.
上级 511cadad
......@@ -50,10 +50,12 @@
<PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
<AppleAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleAppBuilder', 'Debug', '$(NetCoreAppCurrent)'))</AppleAppBuilderDir>
<AndroidAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidAppBuilder', 'Debug', '$(NetCoreAppCurrent)'))</AndroidAppBuilderDir>
<WasmAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmAppBuilder', 'Debug', '$(NetCoreAppCurrent)', 'publish'))</WasmAppBuilderDir>
<MonoAOTCompilerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'MonoAOTCompiler', 'Debug', '$(NetCoreAppCurrent)'))</MonoAOTCompilerDir>
<AppleAppBuilderTasksAssemblyPath>$([MSBuild]::NormalizePath('$(AppleAppBuilderDir)', 'AppleAppBuilder.dll'))</AppleAppBuilderTasksAssemblyPath>
<AndroidAppBuilderTasksAssemblyPath>$([MSBuild]::NormalizePath('$(AndroidAppBuilderDir)', 'AndroidAppBuilder.dll'))</AndroidAppBuilderTasksAssemblyPath>
<WasmAppBuilderTasksAssemblyPath>$([MSBuild]::NormalizePath('$(WasmAppBuilderDir)', 'WasmAppBuilder.dll'))</WasmAppBuilderTasksAssemblyPath>
<MonoAOTCompilerTasksAssemblyPath>$([MSBuild]::NormalizePath('$(MonoAOTCompilerDir)', 'MonoAOTCompiler.dll'))</MonoAOTCompilerTasksAssemblyPath>
</PropertyGroup>
......
set -ev
EXECUTION_DIR=$(dirname $0)
TEST_NAME=$1
TARGET_ARCH=$2
echo "Test: $1 Arch: $2"
cd $EXECUTION_DIR
v8 --expose_wasm runtime.js -- --enable-gc --run WasmTestRunner.dll $TEST_NAME
exit 0
......@@ -106,11 +106,29 @@
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
</Target>
<UsingTask TaskName="WasmAppBuilder"
AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)" />
<Target Condition="'$(TargetOS)' == 'Browser'" Name="BundleTestWasmApp">
<ItemGroup>
<AssemblySearchPaths Include="$(PublishDir)"/>
</ItemGroup>
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />
<WasmAppBuilder
AppDir="$(BundleDir)"
RuntimePackDir="$(RuntimePackRidDir)"
MainAssembly="$(PublishDir)\WasmTestRunner.dll"
MainJS="$(MonoProjectRoot)\wasm\runtime-test.js"
ExtraAssemblies="$(PublishDir)\$(AssemblyName).dll"
AssemblySearchPaths="@(AssemblySearchPaths)"/>
</Target>
<Target Name="AddTestRunnersToPublishedFiles"
AfterTargets="ComputeResolvedFilesToPublishList">
<ItemGroup>
<_runnerFilesToPublish Include="$(AndroidTestRunnerDir)*" Condition="'$(TargetOS)' == 'Android'" />
<_runnerFilesToPublish Include="$(AppleTestRunnerDir)*" Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'" />
<_runnerFilesToPublish Include="$(WasmTestRunnerDir)*" Condition="'$(TargetOS)' == 'Browser'" />
<ResolvedFileToPublish Include="@(_runnerFilesToPublish)" RelativePath="%(FileName)%(Extension)" CopyToPublishDirectory="PreserveNewest" PostprocessAssembly="true" />
</ItemGroup>
......@@ -132,5 +150,5 @@
<Target Name="PublishTestAsSelfContained"
Condition="'$(IsCrossTargetingBuild)' != 'true'"
AfterTargets="Build"
DependsOnTargets="UpdateRuntimePack;Publish;BundleTestAppleApp;BundleTestAndroidApp" />
DependsOnTargets="UpdateRuntimePack;Publish;BundleTestAppleApp;BundleTestAndroidApp;BundleTestWasmApp" />
</Project>
......@@ -25,6 +25,7 @@
<MobileRunnersDirSuffix>$(NetCoreAppCurrent)-$(Configuration)</MobileRunnersDirSuffix>
<AppleTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(MobileRunnersDirSuffix)'))</AppleTestRunnerDir>
<AndroidTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(MobileRunnersDirSuffix)'))</AndroidTestRunnerDir>
<WasmTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmTestRunner', '$(MobileRunnersDirSuffix)'))</WasmTestRunnerDir>
<RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
<SelfContained>true</SelfContained>
......
......@@ -4,6 +4,7 @@
<RunScriptInputName Condition="'$(TargetOS)' != 'Windows_NT'">RunnerTemplate.sh</RunScriptInputName>
<RunScriptInputName Condition="'$(TargetOS)' == 'iOS'">AppleRunnerTemplate.sh</RunScriptInputName>
<RunScriptInputName Condition="'$(TargetOS)' == 'Android'">AndroidRunnerTemplate.sh</RunScriptInputName>
<RunScriptInputName Condition="'$(TargetOS)' == 'Browser'">WasmRunnerTemplate.sh</RunScriptInputName>
<RunScriptInputPath>$(MSBuildThisFileDirectory)$(RunScriptInputName)</RunScriptInputPath>
......
// 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.Linq;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public class WasmTestRunner
{
public static int Main(string[] args)
{
Console.Write("Args: ");
foreach (string arg in args)
{
Console.Write(arg);
}
Console.WriteLine(".");
return 0;
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="WasmTestRunner.cs" />
<PackageReference Include="Microsoft.DotNet.XHarness.Tests.Runners" Version="$(MicrosoftDotNetXHarnessTestsRunnersVersion)" />
</ItemGroup>
</Project>
......@@ -18,6 +18,7 @@
<ProjectReference Include="$(CommonTestPath)AppleTestRunner\AppleTestRunner.csproj" Condition="'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS'"/>
<ProjectReference Include="$(CommonTestPath)AndroidTestRunner\AndroidTestRunner.csproj" Condition="'$(TargetOS)' == 'Android'" />
<ProjectReference Include="$(CommonTestPath)WasmTestRunner\WasmTestRunner.csproj" Condition="'$(TargetOS)' == 'Browser'" />
</ItemGroup>
<Target Name="RestoreTestHost"
......
......@@ -2,16 +2,18 @@ TOP=../../../../..
DOTNET_Q_ARGS=--nologo -v:q -consoleloggerparameters:NoSummary
CONFIG?=Release
all: build
build:
$(TOP)/.dotnet/dotnet build $(DOTNET_Q_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=Release
$(TOP)/.dotnet/dotnet build $(DOTNET_Q_ARGS) /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=$(CONFIG) WasmSample.csproj
clean:
rm -rf bin
run:
cd bin/Release/publish && ~/.jsvu/v8 --expose_wasm runtime.js -- --enable-gc --run WasmSample.dll
cd bin/$(CONFIG)/publish && ~/.jsvu/v8 --expose_wasm runtime.js -- --enable-gc --run WasmSample.dll
runtimepack:
EMSDK_PATH=$(TOP)/src/mono/wasm/emsdk $(TOP)/build.sh -c $(MONO_CONFIG) -os Browser -arch wasm -subset Mono+Libs
EMSDK_PATH=$(abspath $(TOP)/src/mono/wasm/emsdk) $(TOP)/build.sh -c $(CONFIG) -os Browser -arch wasm -subset Mono+Libs
......@@ -29,7 +29,7 @@
AppDir="$(AppDir)"
RuntimePackDir="$(RuntimePackDir)"
MainAssembly="bin\WasmSample.dll"
MainJS="runtime.js"
MainJS="$(MonoProjectRoot)\wasm\runtime-test.js"
AssemblySearchPaths="@(AssemblySearchPaths)"/>
<Exec Command="chmod a+x $(AppDir)/run-v8.sh" />
</Target>
......
......@@ -69,7 +69,7 @@ public class WasmAppBuilder : Task
File.Copy (assembly.Location, Path.Join (AppDir, "managed", Path.GetFileName (assembly.Location)), true);
foreach (var f in new string [] { "dotnet.wasm", "dotnet.js" })
File.Copy (Path.Join (RuntimePackDir, "native", "wasm", "runtimes", "release", f), Path.Join (AppDir, f), true);
File.Copy (MainJS!, Path.Join (AppDir, Path.GetFileName (MainJS!)), true);
File.Copy (MainJS!, Path.Join (AppDir, "runtime.js"), true);
using (var sw = File.CreateText (Path.Join (AppDir, "mono-config.js"))) {
sw.WriteLine ("config = {");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册