Skip to content

Commit

Permalink
[wasm] Remove System.Reflection.MetadataLoadContext from WasmAppBuild…
Browse files Browse the repository at this point in the history
…er (#44751)

Separates the assembly and reference assembly loading process from the WasmAppBuilder into a separate task in WasmLoadAssembliesAndReferences.cs

Refactors that loading process to take in assemblies, search paths, and the option to skip missing referenced assemblies, thereby reducing the original complexity with respect to MainAssembly, ExtraAssemblies and having at least one of Assemblies or AssemblySearchPaths

Applies the updated WasmAppBuilder and WasmLoadAssembliesAndReferences tasks to the library tests (tests.mobile.targets), browser sample (WasmSample.csproj), debugger-tests (debugger-tests.csproj), and the runtime tests (WasmTestRunner.proj)

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
Co-authored-by: Steve Pfister <steve.pfister@microsoft.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
  • Loading branch information
4 people authored Dec 10, 2020
1 parent f2e38c3 commit 57707b3
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 133 deletions.
13 changes: 6 additions & 7 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@
</WasmSatelliteAssemblies>
</ItemGroup>
<ItemGroup>
<AssemblySearchPaths Include="$(PublishDir)"/>
<Assemblies Include="$(PublishDir)\*.dll"/>
<WasmFilesToIncludeInFileSystem Include="@(ContentWithTargetPath)" />
<WasmFilesToIncludeInFileSystem Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.BuildReference)' == 'true' and !$([System.String]::new('%(ReferenceCopyLocalPaths.Identity)').EndsWith('.resources.dll'))" />
<WasmFilesToIncludeInFileSystem Include="@(WasmSatelliteAssemblies)" TargetPath="%(WasmSatelliteAssemblies.CultureName)\%(WasmSatelliteAssemblies.Filename)%(WasmSatelliteAssemblies.Extension)" />
<!-- Include files specified by test projects from publish dir -->
<WasmFilesToIncludeInFileSystem Include="@(WasmFilesToIncludeFromPublishDir -> '$(PublishDir)%(Identity)')" />
<ExtraAssemblies Include="$(PublishDir)$(AssemblyName).dll" />
<Assemblies Include="$(PublishDir)$(AssemblyName).dll" />
<!-- We need these facades for some tests. -->
<ExtraAssemblies Include="$(PublishDir)mscorlib.dll" />
<ExtraAssemblies Include="$(PublishDir)System.Drawing.dll" />
<Assemblies Include="$(PublishDir)mscorlib.dll" />
<Assemblies Include="$(PublishDir)System.Drawing.dll" />
</ItemGroup>
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)')" Text="MicrosoftNetCoreAppRuntimePackRidDir=$(MicrosoftNetCoreAppRuntimePackRidDir) doesn't exist" />
<WasmAppBuilder
Expand All @@ -175,10 +175,9 @@
MicrosoftNetCoreAppRuntimePackDir="$(MicrosoftNetCoreAppRuntimePackRidDir)"
MainAssembly="$(PublishDir)WasmTestRunner.dll"
MainJS="$(MonoProjectRoot)\wasm\runtime-test.js"
ExtraAssemblies="@(ExtraAssemblies)"
Assemblies="@(Assemblies)"
SatelliteAssemblies="@(WasmSatelliteAssemblies)"
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)"
AssemblySearchPaths="@(AssemblySearchPaths)" />
FilesToIncludeInFileSystem="@(WasmFilesToIncludeInFileSystem)" />
</Target>

<Target Name="AddTestRunnersToPublishedFiles"
Expand Down
14 changes: 12 additions & 2 deletions src/mono/netcore/sample/wasm/browser/WasmSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,30 @@

<UsingTask TaskName="WasmAppBuilder"
AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)"/>
<UsingTask TaskName="WasmLoadAssembliesAndReferences"
AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)"/>

<Target Name="BuildApp" DependsOnTargets="RebuildWasmAppBuilder;Build">
<ItemGroup>
<AssemblySearchPaths Include="bin"/>
<AssemblySearchPaths Include="$(MicrosoftNetCoreAppRuntimePackDir)native"/>
<AssemblySearchPaths Include="$(MicrosoftNetCoreAppRuntimePackDir)lib\$(NetCoreAppCurrent)"/>
</ItemGroup>

<WasmLoadAssembliesAndReferences
Assemblies="bin\WasmSample.dll;$(MicrosoftNetCoreAppRuntimePackDir)lib\$(NetCoreAppCurrent)\System.Private.Runtime.InteropServices.JavaScript.dll"
AssemblySearchPaths="@(AssemblySearchPaths)">
<Output TaskParameter="ReferencedAssemblies" ItemName="ReferencedAssemblies" />
</WasmLoadAssembliesAndReferences>

<WasmAppBuilder
AppDir="$(AppDir)"
ExtraAssemblies="$(MicrosoftNetCoreAppRuntimePackDir)lib\$(NetCoreAppCurrent)\System.Private.Runtime.InteropServices.JavaScript.dll"
MicrosoftNetCoreAppRuntimePackDir="$(MicrosoftNetCoreAppRuntimePackDir)"
MainAssembly="bin\WasmSample.dll"
MainJS="runtime.js"
AssemblySearchPaths="@(AssemblySearchPaths)"/>
Assemblies="@(ReferencedAssemblies)">
<Output TaskParameter="FileWrites" ItemName="FileWrites" />
</WasmAppBuilder>
<Exec Command="chmod a+x $(AppDir)/run-v8.sh" />
<Copy SourceFiles="bin\index.html;bin\server.py" DestinationFolder="$(AppDir)" />
</Target>
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ build:
EMSDK_PATH=$(EMSDK_PATH) $(TOP)/build.sh mono+libs.pretest -os Browser -c $(CONFIG) /p:ContinueOnError=false /p:StopOnFirstFailure=true

build-all:
EMSDK_PATH=$(EMSDK_PATH) $(TOP)/build.sh mono+libs -os Browser -c $(CONFIG) /p:ContinueOnError=false /p:StopOnFirstFailure=true
EMSDK_PATH=$(EMSDK_PATH) $(TOP)/build.sh mono+libs -os Browser -c $(CONFIG) /p:ContinueOnError=false /p:StopOnFirstFailure=true $(EXTRA_ARGS)

runtime:
EMSDK_PATH=$(EMSDK_PATH) $(TOP)/build.sh mono.runtime+mono.wasmruntime+libs.native+libs.pretest -os Browser -c $(CONFIG) /p:ContinueOnError=false /p:StopOnFirstFailure=true
Expand Down
15 changes: 13 additions & 2 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@

<UsingTask TaskName="WasmAppBuilder"
AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)"/>
<UsingTask TaskName="WasmLoadAssembliesAndReferences"
AssemblyFile="$(WasmAppBuilderTasksAssemblyPath)"/>

<Target Name="BuildApp" DependsOnTargets="RebuildWasmAppBuilder;Build">
<PropertyGroup>
<MicrosoftNetCoreAppRuntimePackDir>$(ArtifactsBinDir)microsoft.netcore.app.runtime.browser-wasm\Release\runtimes\browser-wasm\</MicrosoftNetCoreAppRuntimePackDir>
<MainAssembly>$(OutDir)debugger-test.dll</MainAssembly>
<_JavaScriptDllPath>$(ArtifactsBinDir)\System.Private.Runtime.InteropServices.JavaScript\$(NetCoreAppCurrent)-Browser-$(RuntimeConfiguration)\System.Private.Runtime.InteropServices.JavaScript.dll</_JavaScriptDllPath>
</PropertyGroup>
<ItemGroup>
<AssemblySearchPaths Include="$(MicrosoftNetCoreAppRuntimePackDir)native"/>
Expand All @@ -46,14 +50,21 @@
<ExtraFileForPublish Include="@(ReferenceCopyLocalPaths)" />
</ItemGroup>

<WasmLoadAssembliesAndReferences
Assemblies="$(MainAssembly);$(_JavaScriptDllPath)"
AssemblySearchPaths="@(AssemblySearchPaths)">
<Output TaskParameter="ReferencedAssemblies" ItemName="ReferencedAssemblies" />
</WasmLoadAssembliesAndReferences>

<WasmAppBuilder
AppDir="$(AppDir)"
MicrosoftNetCoreAppRuntimePackDir="$(MicrosoftNetCoreAppRuntimePackDir)"
MainAssembly="$(OutDir)debugger-test.dll"
MainJS="$(MonoProjectRoot)wasm\runtime-test.js"
DebugLevel="1"
AssemblySearchPaths="@(AssemblySearchPaths)"
ExtraAssemblies="$(ArtifactsBinDir)\System.Private.Runtime.InteropServices.JavaScript\$(NetCoreAppCurrent)-Browser-$(RuntimeConfiguration)\System.Private.Runtime.InteropServices.JavaScript.dll"/>
Assemblies="@(ReferencedAssemblies)">
<Output TaskParameter="FileWrites" ItemName="FileWrites" />
</WasmAppBuilder>

<Copy SourceFiles="@(ExtraFileForPublish)" DestinationFolder="$(AppDir)" />
</Target>
Expand Down
Loading

0 comments on commit 57707b3

Please sign in to comment.