$failedBuilds = @()
-if (($os -eq "Browser") -and ($arch -ne "wasm")) {
+if ($os -eq "Browser") {
# override default arch for Browser, we only support wasm
$arch = "wasm"
+
+ if ($ninja -ne $True) {
+ # we need ninja for emscripten on windows
+ $ninja = $True
+ $arguments += " /p:Ninja=$ninja"
+ }
}
foreach ($config in $configuration) {
set __ExtraCmakeParams="-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams%
if /i "%__UseEmcmake%" == "1" (
- call !EMSDK_PATH!/emsdk_env.bat > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
+ call "!EMSDK_PATH!/emsdk_env.bat" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
) else (
"%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
)
:: Set CMakePath by evaluating the output from set-cmake-path.ps1.
:: In case of a failure the output is "exit /b 1".
-for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "%~dp0set-cmake-path.ps1"') do %%a
+for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass -File "%~dp0set-cmake-path.ps1"') do %%a
<Exec
IgnoreExitCode="true"
StandardOutputImportance="Low"
- Command="$(_AsnXmlDiffCmd) @(AsnXml -> '$(_AsnIntermediatePath)%(filename).cs') @(AsnXml -> '%(Identity).cs')">
+ Command="$(_AsnXmlDiffCmd) @(AsnXml -> '"$(_AsnIntermediatePath)%(filename).cs"') @(AsnXml -> '"%(Identity).cs"')">
<Output TaskParameter="ExitCode" ItemName="_AsnXmlDiffCode" />
</Exec>
</ItemGroup>
<PropertyGroup>
- <ILLinkArgs Condition="'@(_SuppressionsXmls)' != ''" >$(ILLinkArgs) --link-attributes @(_SuppressionsXmls->'%(FullPath)', ' --link-attributes ')</ILLinkArgs>
+ <ILLinkArgs Condition="'@(_SuppressionsXmls)' != ''" >$(ILLinkArgs) --link-attributes "@(_SuppressionsXmls->'%(FullPath)', '" --link-attributes "')"</ILLinkArgs>
</PropertyGroup>
<!-- When running from Desktop MSBuild, DOTNET_HOST_PATH is not set.
<ExeExt Condition="'$(OS)' == 'Windows_NT'">.exe</ExeExt>
<ScriptExt Condition="'$(OS)' == 'Windows_NT'">.cmd</ScriptExt>
<ScriptExt Condition="'$(OS)' != 'Windows_NT'">.sh</ScriptExt>
- <ExeExt Condition="'$(OS)' == 'Windows_NT'">.exe</ExeExt>
+ <EscapedQuoteW Condition="'$(OS)' == 'Windows_NT'">\"</EscapedQuoteW>
<CoreClrFileName Condition="'$(TargetsWindows)' == 'true'">coreclr.dll</CoreClrFileName>
<CoreClrFileName Condition="'$(TargetsOSX)' == 'true'">libcoreclr.dylib</CoreClrFileName>
<CoreClrFileName Condition="'$(TargetsMacCatalyst)' == 'true'">libcoreclr.dylib</CoreClrFileName>
<PropertyGroup>
<_MonoUseNinja Condition="'$(Ninja)' == 'true' or '$(_MonoFindNinjaExitCode)' == '0'">true</_MonoUseNinja>
</PropertyGroup>
+
+ <Exec Condition="'$(TargetArchitecture)' == 'wasm' and '$(OS)' == 'Windows_NT'" Command="cmake --version" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" StandardOutputImportance="Low" >
+ <Output TaskParameter="ExitCode" PropertyName="_MonoFindCmakeExitCode"/>
+ </Exec>
+ <Error Condition="'$(TargetArchitecture)' == 'wasm' and '$(OS)' == 'Windows_NT' and '$(_MonoFindCmakeExitCode)' != '0'" Text="cmake tool is required to build wasm on windows" />
+ <Exec Condition="'$(TargetArchitecture)' == 'wasm' and '$(OS)' == 'Windows_NT'" Command="ninja --version" IgnoreExitCode="true" IgnoreStandardErrorWarningFormat="true" StandardOutputImportance="Low" >
+ <Output TaskParameter="ExitCode" PropertyName="_MonoFindNinjaExitCode"/>
+ </Exec>
+ <Error Condition="'$(TargetArchitecture)' == 'wasm' and '$(OS)' == 'Windows_NT' and '$(_MonoFindNinjaExitCode)' != '0'" Text="ninja tool is required to build wasm on windows" />
+
</Target>
<!-- Sets up emscripten if you don't have the EMSDK_PATH env variable set -->
<Target Name="BuildMonoRuntime">
<ItemGroup>
<_MonoCMakeArgs Condition="'$(_MonoUseNinja)' == 'true'" Include="-G Ninja"/>
- <_MonoCMakeArgs Include="-DCMAKE_INSTALL_PREFIX=$(MonoObjDir)out"/>
+ <_MonoCMakeArgs Include="-DCMAKE_INSTALL_PREFIX="$(MonoObjDir)out""/>
<_MonoCMakeArgs Include="-DCMAKE_INSTALL_LIBDIR=lib"/>
<_MonoCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
<_MonoCMakeArgs Condition="'$(CMakeArgs)' != ''" Include="$(CMakeArgs)"/>
<_MonoCMakeArgs Include="-DENABLE_LLVM_RUNTIME=1"/>
<_MonoCFLAGS Include="-fexceptions"/>
<_MonoCXXFLAGS Include="-fexceptions"/>
- <_MonoCFLAGS Include="-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))"/>
+ <_MonoCFLAGS Include="$(EscapedQuoteW)-I$([MSBuild]::NormalizePath('$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)', 'runtimes', 'browser-wasm', 'native', 'include'))$(EscapedQuoteW)"/>
</ItemGroup>
<!-- iOS/tvOS specific options -->
<PropertyGroup Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">
</ItemGroup>
<PropertyGroup>
- <_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) $(MonoProjectRoot.TrimEnd('\/'))</_MonoCMakeConfigureCommand>
+ <EMSDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(EMSDK_PATH)'))</EMSDK_PATH>
+ <_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) "$(MonoProjectRoot.TrimEnd('\/'))"</_MonoCMakeConfigureCommand>
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(OS)' != 'Windows_NT'">bash -c 'source $(RepositoryEngineeringDir)native/init-compiler.sh $(Platform) $(MonoCCompiler) && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' != 'false' and '$(OS)' == 'Windows_NT'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(Platform) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(_MonoRunInitCompiler)' == 'false'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(OS)' != 'Windows_NT'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&1 && emcmake $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
- <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(OS)' == 'Windows_NT'">call $(EMSDK_PATH)emsdk_env.bat && emcmake $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
+ <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(OS)' == 'Windows_NT'">call "$(EMSDK_PATH)emsdk_env.bat" && emcmake $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
<_MonoCMakeBuildCommand>cmake --build . --target install --config $(Configuration)</_MonoCMakeBuildCommand>
<_MonoCMakeBuildCommand Condition="'$(MonoVerboseBuild)' == 'true'">$(_MonoCMakeBuildCommand) --verbose</_MonoCMakeBuildCommand>
${pal_icushim_sources_base})
addprefix(icu_shim_sources "${ICU_SHIM_PATH}" "${icu_shim_sources_base}")
set_source_files_properties(${icu_shim_sources} PROPERTIES COMPILE_DEFINITIONS OSX_ICU_LIBRARY_PATH="${OSX_ICU_LIBRARY_PATH}")
- set_source_files_properties(${icu_shim_sources} PROPERTIES COMPILE_FLAGS "-I${ICU_INCLUDEDIR} -I${CMAKE_CURRENT_SOURCE_DIR}/../../../libraries/Native/Unix/System.Globalization.Native/ -I${CMAKE_CURRENT_SOURCE_DIR}/../../../libraries/Native/Unix/Common/ ${ICU_FLAGS}")
+ set_source_files_properties(${icu_shim_sources} PROPERTIES COMPILE_FLAGS "-I\"${ICU_INCLUDEDIR}\" -I\"${CMAKE_CURRENT_SOURCE_DIR}/../../../libraries/Native/Unix/System.Globalization.Native/\" -I\"${CMAKE_CURRENT_SOURCE_DIR}/../../../libraries/Native/Unix/Common/\" ${ICU_FLAGS}")
if(TARGET_WIN32)
set_source_files_properties(${icu_shim_sources} PROPERTIES LANGUAGE CXX)
endif()
<EmccFlags Condition="'$(WasmEnableES6)' == 'true'">$(EmccFlags) -s MODULARIZE=1 -s EXPORT_ES6=1</EmccFlags>
<EmccConfigurationFlags Condition="'$(Configuration)' == 'Debug'">-g -Os -s ASSERTIONS=1 -DENABLE_NETCORE=1 -DDEBUG=1</EmccConfigurationFlags>
<EmccConfigurationFlags Condition="'$(Configuration)' == 'Release'">-Oz --llvm-opts 2 -DENABLE_NETCORE=1</EmccConfigurationFlags>
- <StripCmd>$(EMSDK_PATH)/upstream/bin/wasm-opt --strip-dwarf $(NativeBinDir)/dotnet.wasm -o $(NativeBinDir)/dotnet.wasm</StripCmd>
+ <StripCmd>"$(EMSDK_PATH)/upstream/bin/wasm-opt" --strip-dwarf "$(NativeBinDir)/dotnet.wasm" -o "$(NativeBinDir)/dotnet.wasm"</StripCmd>
<WasmObjDir>$(ArtifactsObjDir)wasm</WasmObjDir>
<WasmVersionFile>$(WasmObjDir)\emcc-version.txt</WasmVersionFile>
<MonoIncludeDir>$(MonoArtifactsPath)include/mono-2.0</MonoIncludeDir>
<ICULibFiles Include="$(ICULibDir)/*.dat" />
</ItemGroup>
- <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) -Oz -I$(MonoIncludeDir) runtime/corebindings.c -c -o $(MonoObjDir)corebindings.o"
+ <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) -Oz -I"$(MonoIncludeDir)" runtime/corebindings.c -c -o "$(MonoObjDir)corebindings.o""
EmSdkPath="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />
- <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) -Oz -DCORE_BINDINGS -I$(MonoObjDir) -I$(MonoIncludeDir) runtime/driver.c -c -o $(MonoObjDir)driver.o"
+ <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) -Oz -DCORE_BINDINGS -I"$(MonoObjDir.TrimEnd('\/'))" -I"$(MonoIncludeDir)" runtime/driver.c -c -o "$(MonoObjDir)driver.o""
EmSdkPath="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />
DestinationFolder="$(MonoObjDir)"
SkipUnchangedFiles="true" />
- <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) -Oz -DGEN_PINVOKE=1 -I$(MonoObjDir) -I$(MonoIncludeDir) runtime/pinvoke.c -c -o $(MonoObjDir)pinvoke.o"
+ <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) -Oz -DGEN_PINVOKE=1 -I"$(MonoObjDir.TrimEnd('\/'))" -I"$(MonoIncludeDir)" runtime/pinvoke.c -c -o "$(MonoObjDir)pinvoke.o""
EmSdkPath="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />
- <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) --js-library runtime/library_mono.js --js-library runtime/binding_support.js --js-library runtime/dotnet_support.js --js-library $(SystemNativeDir)\pal_random.js $(MonoObjDir)/driver.o $(MonoObjDir)/pinvoke.o $(MonoObjDir)/corebindings.o @(MonoLibFiles->'%(FullPath)', ' ') -o $(NativeBinDir)/dotnet.js && $(StripCmd)"
+ <RunWithEmSdkEnv Command="$(EmccCmd) $(EmccFlags) $(EmccConfigurationFlags) --js-library runtime/library_mono.js --js-library runtime/binding_support.js --js-library runtime/dotnet_support.js --js-library "$(SystemNativeDir)\pal_random.js" "$(MonoObjDir)/driver.o" "$(MonoObjDir)/pinvoke.o" "$(MonoObjDir)/corebindings.o" "@(MonoLibFiles->'%(FullPath)', '" "')" -o "$(NativeBinDir)/dotnet.js" && $(StripCmd)"
EmSdkPath="$(EMSDK_PATH)"
IgnoreStandardErrorWarningFormat="true" />