Skip to content

Commit

Permalink
Fix wasm build when runtime configuration and configuration are diffe…
Browse files Browse the repository at this point in the history
…rent (dotnet#36855)

* Fix wasm build when runtime configuration and configuration are different

* PR Feedback
  • Loading branch information
safern authored May 22, 2020
1 parent c240d11 commit 2d0e6b4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/libraries/pretest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -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="$(MonoProjectRoot)wasm\wasm.proj" Condition="'$(TargetOS)' == 'Browser'" />
</ItemGroup>

<Target Name="RestoreTestHost"
Expand Down
9 changes: 0 additions & 9 deletions src/libraries/src.proj
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,4 @@
Projects="@(ApiCompatProject)"
Properties="$(TraversalGlobalProperties)" />
</Target>

<!-- Wasm runtimes depend on the mono runtime and libs to be built, so they can only be built here -->
<Target Name="BuildWasmPackageDependency"
Condition="'$(TargetOS)' == 'Browser'"
AfterTargets="Build">
<MSBuild Projects="$(MonoProjectRoot)\wasm\wasm.proj"
Properties="Configuration=$(Configuration);TargetOS=$(TargetOS);TargetArchitecture=$(TargetArchitecture)"/>
</Target>

</Project>
17 changes: 6 additions & 11 deletions src/mono/wasm/wasm.proj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.Build.NoTargets" DefaultTargets="BuildWasmRuntimes">
<Project Sdk="Microsoft.Build.Traversal">
<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
</PropertyGroup>

<UsingTask TaskName="PInvokeTableGenerator"
AssemblyFile="$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmAppBuilder', '$(MonoConfiguration)', '$(NetCoreAppCurrent)'))publish\WasmAppBuilder.dll"/>
AssemblyFile="$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'WasmAppBuilder', 'Debug', '$(NetCoreAppCurrent)', 'publish', 'WasmAppBuilder.dll'))"/>

<PropertyGroup>
<WasmPInvokeTablePath>$(MonoObjDir)wasm/pinvoke-table.h</WasmPInvokeTablePath>
Expand All @@ -28,14 +28,7 @@
<Error Condition="'$(EMSDK_PATH)' == ''" Text="The EMSDK_PATH environment variable should be set pointing to the emscripten SDK root dir."/>
</Target>

<Target Name="BuildWasmAppBuilder">
<!-- Need to publish this since it references System.Reflection.MetadataLoadContext -->
<MSBuild Projects="$(RepoRoot)\tools-local\tasks\mobile.tasks\WasmAppBuilder\WasmAppBuilder.csproj"
Properties="Configuration=$(Configuration)"
Targets="Restore;Build;Publish"/>
</Target>

<Target Name="BuildPInvokeTable" DependsOnTargets="CheckEnv;BuildWasmAppBuilder">
<Target Name="BuildPInvokeTable" DependsOnTargets="CheckEnv">
<MakeDir Directories="$(MonoObjDir)wasm"/>
<PInvokeTableGenerator
Modules="@(WasmPInvokeModules)"
Expand All @@ -44,7 +37,9 @@
/>
</Target>

<Target Name="BuildWasmRuntimes" DependsOnTargets="BuildPInvokeTable">
<Target Name="BuildWasmRuntimes"
AfterTargets="Build"
DependsOnTargets="BuildPInvokeTable">
<Exec Command="make -C $(MonoProjectRoot)wasm all SHELL=/bin/bash BINDIR=$(ArtifactsBinDir) MONO_BIN_DIR=$(MonoArtifactsPath) OBJDIR=$(ArtifactsObjDir) SYS_NATIVE_DIR=$(ArtifactsBinDir)/native/$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) CONFIG=$(Configuration) PINVOKE_TABLE=$(WasmPInvokeTablePath)" IgnoreStandardErrorWarningFormat="true"/>
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<Compile Include="PInvokeTableGenerator.cs" />
<Compile Include="WasmAppBuilder.cs" />
</ItemGroup>

<Target Name="PublishBuilder"
AfterTargets="Build"
DependsOnTargets="Publish" />
</Project>

0 comments on commit 2d0e6b4

Please sign in to comment.