diff --git a/src/mono/wasm/build/WasmApp.props b/src/mono/wasm/build/WasmApp.props index c2c716734f7c89..6f496caa81e087 100644 --- a/src/mono/wasm/build/WasmApp.props +++ b/src/mono/wasm/build/WasmApp.props @@ -5,6 +5,14 @@ browser-wasm Publish - _BeforeWasmBuildApp;_WasmResolveReferences;_WasmBuildNative;_WasmGenerateAppBundle;_AfterWasmBuildApp + + _BeforeWasmBuildApp; + _WasmResolveReferences; + _WasmAotCompileApp; + _WasmStripAOTAssemblies; + _WasmBuildNative; + _WasmGenerateAppBundle; + _AfterWasmBuildApp + diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index c5042c84080cb2..0467636bd6c729 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -50,9 +50,16 @@ - $(WasmBuildAppAfterThisTarget) - This target is used as `AfterTargets` for `WasmBuildApp. this is what triggers the wasm app building. Defaults to `Publish`. - - $(EmccFlags) - This sets the initial emcc flags. - $(EmccVerbose) - Set to false to disable verbose emcc output. + - $(EmccLinkOptimizationFlag) - Optimization flag to use for the link step + - $(EmccCompileOptimizationFlag) - Optimization flag to use for compiling native files + + - $(EmccFlags) - Emcc flags used for both compiling native files, and linking + - $(EmccExtraLDFlags) - Extra emcc flags for linking + - $(EmccExtraCFlags) - Extra emcc flags for compiling native files + + Public items: - @(WasmExtraFilesToDeploy) - Files to copy to $(WasmAppDir). (relative path can be set via %(TargetPath) metadata) @@ -78,6 +85,17 @@ <_ExeExt Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">.exe true + + <_WasmNativeBuildDependsOn> + _CheckEmccIsExpectedVersion; + _PrepareForWasmBuildNative; + _GenerateDriverGenC; + _GeneratePInvokeTable; + _GenerateICallTable; + _WasmCompileNativeFiles; + _WasmLinkDotNet; + _CompleteWasmBuildNative + @@ -166,7 +184,15 @@ <_WasmAssembliesInternal Include="@(_AOT_InternalForceInterpretAssemblies)" /> + + <_AOTAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'" /> + <_BitcodeFile Include="%(_WasmAssembliesInternal.LlvmBitcodeFile)" /> + + <_WasmNativeFileForLinking Include="@(_BitcodeFile)" /> + + @@ -288,6 +314,8 @@ + + - + - $([MSBuild]::NormalizePath($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src', 'emcc-flags.txt')) true $(WasmBuildNative) + <_WasmICallTablePath>$(_WasmIntermediateOutputPath)icall-table.h + <_WasmRuntimeICallTablePath>$(_WasmIntermediateOutputPath)runtime-icall-table.h + <_WasmPInvokeTablePath>$(_WasmIntermediateOutputPath)pinvoke-table.h + + <_EmccOptimizationFlagDefault Condition="'$(_WasmDevel)' == 'true'">-O0 + + $(_EmccOptimizationFlagDefault) + $(_EmccOptimizationFlagDefault) - + - - $(_DefaultEmccFlags) $(EmccFlags) - $(EmccFlags) -v - -O0 $(EmccFlags) - $(EmccFlags) -s DISABLE_EXCEPTION_CATCHING=0 - $(EmccFlags) -g - $(EmccFlags) -DENABLE_AOT=1 -DDRIVER_GEN=1 - $(EmccFlags) -DINVARIANT_GLOBALIZATION=1 - + + <_EmccCommonFlags Include="$(_DefaultEmccFlags)" /> + <_EmccCommonFlags Include="$(EmccFlags)" /> + <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" /> + <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeStrip)' == 'false'" /> + <_EmccCommonFlags Include="-DENABLE_AOT=1" Condition="'$(RunAOTCompilation)' == 'true'" /> + <_EmccCommonFlags Include="-DDRIVER_GEN=1" Condition="'$(RunAOTCompilation)' == 'true'" /> + <_EmccCommonFlags Include="-DINVARIANT_GLOBALIZATION=1" Condition="'$(InvariantGlobalization)' == 'true'" /> + <_EmccCommonFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" /> + <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" /> + - - <_WasmPInvokeModules Include="libSystem.Native" /> - <_WasmPInvokeModules Include="libSystem.IO.Compression.Native" /> - <_WasmPInvokeModules Include="libSystem.Globalization.Native" /> - - - - - - - $(EmccFlags) -DLINK_ICALLS=1 <_WasmRuntimePackIncludeDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'include')) <_WasmRuntimePackSrcDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackRidNativeDir), 'src')) @@ -409,49 +428,90 @@ <_WasmObjects Include="@(_WasmObjectsToBuild->'%(OutputPath)')" /> <_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)\*.js" /> - - <_AOTAssemblies Include="@(_WasmAssembliesInternal)" Condition="'%(_WasmAssembliesInternal._InternalForceInterpret)' != 'true'" /> - <_BitcodeFile Include="%(_WasmAssembliesInternal.LlvmBitcodeFile)" /> + - + + + <_WasmPInvokeModules Include="libSystem.Native" /> + <_WasmPInvokeModules Include="libSystem.IO.Compression.Native" /> + <_WasmPInvokeModules Include="libSystem.Globalization.Native" /> + - - <_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" /> - <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" /> - <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)wasm" /> - + + - - $(EmccFlags) -DCORE_BINDINGS -DGEN_PINVOKE=1 - $(EmccCFlags) @(_EmccIncludePaths -> '"-I%(Identity)"', ' ') - $(EmccCFlags) -g + + - $(EmccFlags) -s TOTAL_MEMORY=536870912 - + + + + + + + <_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" /> + <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" /> + <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)wasm" /> + + + <_EmccCFlags Include="$(EmccCompileOptimizationFlag)" /> + <_EmccCFlags Include="@(_EmccCommonFlags)" /> + <_EmccCFlags Include="-DCORE_BINDINGS" /> + <_EmccCFlags Include="-DGEN_PINVOKE=1" /> + <_EmccCFlags Include=""-I%(_EmccIncludePaths.Identity)"" /> + <_EmccCFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" /> + <_EmccCFlags Include="$(EmccExtraCFlags)" /> + + + + <_EmccCompileRsp>$(_WasmIntermediateOutputPath)emcc-compile.rsp + + + - - + + + + - <_EmccLinkerArguments Include="$(EmccLDFlags)" /> - <_EmccLinkerArguments Include="--js-library "%(_DotnetJSSrcFile.Identity)"" /> - <_EmccLinkerArguments Include=""%(_BitcodeFile.Identity)"" /> - <_EmccLinkerArguments Include=""%(_WasmObjects.Identity)"" /> - <_EmccLinkerArguments Include="-o "$(_WasmIntermediateOutputPath)dotnet.js"" /> + <_WasmRuntimePackNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\*.a" /> + <_WasmObjects Include="@(_WasmRuntimePackNativeLibs)" /> + <_WasmObjects Include="@(_WasmObjectsToBuild->'%(OutputPath)')" /> + + + <_EmccLDFlags Include="$(EmccLinkOptimizationFlag)" /> + <_EmccLDFlags Include="@(_EmccCommonFlags)" /> + <_EmccLDFlags Include="-s TOTAL_MEMORY=536870912" /> + <_EmccLDFlags Include="$(EmccExtraLDFlags)" /> + + <_EmccLDFlags Include="--js-library "%(_DotnetJSSrcFile.Identity)"" /> + <_EmccLDFlags Include=""%(_WasmNativeFileForLinking.Identity)"" /> + <_EmccLDFlags Include=""%(_WasmObjects.Identity)"" /> + + <_EmccLDFlags Include="-o "$(_WasmIntermediateOutputPath)dotnet.js"" /> - <_EmccLinkerResponseFile>$(_WasmIntermediateOutputPath)emcc-link.rsp + <_EmccLinkRsp>$(_WasmIntermediateOutputPath)emcc-link.rsp - - - + + + + +