mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-09 17:44:48 +09:00
[wasm] Use source built emsdk packages for the runtime build (#100266)
* Use the emsdk transport packages to build wasm instead of a cloned emsdk Works for the most part out of the box, but fails on the part where we npm install after the libraries build. The reason for the failure is our node transport package is incomplete. If you replace it with a legit node, the build works fully. * Pull in node transport package as opposed to the one packaged in emsdk. Streamline package deps * Make paths friendly for windows * Work in windows transport packages, copy python to its own directory, and adjust a bunch of paths * Bump to latest version of node that contains icu * Add windows deps and add DOTNET_EMSCRIPTEN_NODE_PATH because windows can't see npm without it * Bump emscripten packages to the latest * Fix typos in Version.Details.xml * Switch out to the plain mariner container to ensure no EMSDK already exists * Revert back to the browser-wasm docker image and bump to the latest * Container type-o * Fix condition where the node path isn't set properly * Provision even when building offsets * Fix goofy paths * Update new template to use the latest browser-wasm container * Don't put python.exe on the path for windows, but the folder instead * So that was a bad idea. May have to have emsdk_env.cmd have two entries * Fix offsets generation for browser * Fix emsdk's python path It is not versioned anymore as we use the content of our nugets * Fix EMSDK_PATH on non-windows platforms * Do not add link flags to compile flags To avoid: C:\helix\work\correlation\build\wasm-shared\WasmApp.Common.targets(825,5): error : emcc: warning: linker setting ignored during compilation: 'EXPORT_ES6' [-Wunused-command-line-argument] [C:\helix\work\workitem\e\publish\ProxyProjectForAOTOnHelix.proj] C:\helix\work\correlation\build\wasm-shared\WasmApp.Common.targets(825,5): error : emcc: warning: linker setting ignored during compilation: 'EXPORT_EXCEPTION_HANDLING_HELPERS' [-Wunused-command-line-argument] [C:\helix\work\workitem\e\publish\ProxyProjectForAOTOnHelix.proj] * Set the emsdk paths relative to the script location * Escape few characters and fix the added script * Fix .emscripten script * Use EM_CONFIG intead of __file__ * Fix emsdk_env.cmd script * Revert "Do not add link flags to compile flags" This reverts commit eb19ade3ef901669a7e6bcc944703837f26f5173. * Revert changes in package-lock.json * Feedback + cleaning * More cleaning * Try not to use the replace in the EMSDK_PATH * Better property names * Use package and emsdk version properties Co-authored-by: Larry Ewing <lewing@microsoft.com> * Use the updated properties * Fix emsdk version * Use a single version of emsdk and take node version from flow * Update eng/Version.Details.xml Co-authored-by: Larry Ewing <lewing@microsoft.com> --------- Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com> Co-authored-by: Radek Doulik <radek.doulik@gmail.com> Co-authored-by: Radek Doulik <radekdoulik@gmail.com> Co-authored-by: Larry Ewing <lewing@microsoft.com>
This commit is contained in:
parent
02e348b505
commit
52638488c4
12 changed files with 198 additions and 44 deletions
|
@ -414,5 +414,37 @@
|
|||
<Uri>https://github.com/dotnet/installer</Uri>
|
||||
<Sha>fa261b952d702c6bd604728fcbdb58ac071a22b1</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.linux-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.linux-musl-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.linux-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.linux-musl-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.osx-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.osx-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.win-arm64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="runtime.win-x64.Microsoft.NETCore.Runtime.Wasm.Node.Transport" Version="9.0.0-alpha.1.24175.1">
|
||||
<Uri>https://github.com/dotnet/node</Uri>
|
||||
<Sha>308c7d0f1fa19bd1e7b768ad13646f5206133cdb</Sha>
|
||||
</Dependency>
|
||||
</ToolsetDependencies>
|
||||
</Dependencies>
|
||||
|
|
|
@ -256,5 +256,9 @@
|
|||
<!-- installer version, for testing workloads -->
|
||||
<MicrosoftDotnetSdkInternalVersion>9.0.100-preview.5.24253.16</MicrosoftDotnetSdkInternalVersion>
|
||||
<SdkVersionForWorkloadTesting>$(MicrosoftDotnetSdkInternalVersion)</SdkVersionForWorkloadTesting>
|
||||
<runtimewinx64MicrosoftNETCoreRuntimeWasmNodeTransportPackageVersion>9.0.0-alpha.1.24175.1</runtimewinx64MicrosoftNETCoreRuntimeWasmNodeTransportPackageVersion>
|
||||
<EmsdkPackageVersion>$(MicrosoftNETRuntimeEmscriptenVersion)</EmsdkPackageVersion>
|
||||
<NodePackageVersion>$(runtimewinx64MicrosoftNETCoreRuntimeWasmNodeTransportPackageVersion)</NodePackageVersion>
|
||||
<EmsdkVersion>3.1.34</EmsdkVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
@ -56,7 +56,7 @@ if /i "%__Arch%" == "wasm" (
|
|||
set "EMSDK_PATH=!EMSDK_PATH:\=/!"
|
||||
if not "!EMSDK_PATH:~-1!" == "/" set "EMSDK_PATH=!EMSDK_PATH!/"
|
||||
|
||||
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
||||
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
||||
set __UseEmcmake=1
|
||||
)
|
||||
if /i "%__Os%" == "wasi" (
|
||||
|
@ -107,7 +107,7 @@ if not "%__ConfigureOnly%" == "1" (
|
|||
)
|
||||
|
||||
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.cmd" > 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%
|
||||
)
|
||||
|
|
|
@ -100,7 +100,7 @@ extends:
|
|||
image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8
|
||||
|
||||
browser_wasm:
|
||||
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-webassembly-20230913040940-1edc1c6
|
||||
image: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-webassembly
|
||||
env:
|
||||
ROOTFS_DIR: /crossrootfs/x64
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@
|
|||
<IncludeHelixCorrelationPayload>false</IncludeHelixCorrelationPayload>
|
||||
<EnableDefaultBuildHelixWorkItems>false</EnableDefaultBuildHelixWorkItems>
|
||||
|
||||
<!-- on unix CI has emscripten provisioned in $(EMSDK_PATH) as `/usr/local/emscripten`. -->
|
||||
<EMSDK_PATH Condition="$([MSBuild]::IsOSPlatform('WINDOWS')) and '$(EMSDK_PATH)' == ''">$(RepoRoot)src\mono\browser\emsdk\</EMSDK_PATH>
|
||||
<EMSDK_PATH Condition="'$(EMSDK_PATH)' == ''">$([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'browser', 'emsdk'))</EMSDK_PATH>
|
||||
<EmSdkDirForHelixPayload>$(HelixDependenciesStagingPath)\emsdk</EmSdkDirForHelixPayload>
|
||||
<DebuggerHost Condition="'$(DebuggerHost)' == ''">chrome</DebuggerHost>
|
||||
|
||||
|
|
|
@ -167,4 +167,4 @@ build-app-host:
|
|||
$(DOTNET) build $(TOP)/src/mono/wasm/host $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS)
|
||||
|
||||
patch-deterministic:
|
||||
cd emsdk/upstream/emscripten/ && patch -p1 < ../../../runtime/deterministic.diff
|
||||
cd emsdk/emscripten/ && patch -p1 < ../../../runtime/deterministic.diff
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<_EmccDefaultsRspPath>$(NativeBinDir)src\emcc-default.rsp</_EmccDefaultsRspPath>
|
||||
<_EmccCompileRspPath>$(NativeBinDir)src\emcc-compile.rsp</_EmccCompileRspPath>
|
||||
<_EmccLinkRspPath>$(NativeBinDir)src\emcc-link.rsp</_EmccLinkRspPath>
|
||||
<EmSdkLLVMAr>$(EMSDK_PATH)\upstream\bin\llvm-ar</EmSdkLLVMAr>
|
||||
<EmSdkLLVMAr>$(EMSDK_PATH)\bin\llvm-ar</EmSdkLLVMAr>
|
||||
<EmSdkLLVMAr Condition="$([MSBuild]::IsOSPlatform('Windows'))">$(EmSdkLLVMAr).exe</EmSdkLLVMAr>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -397,12 +397,12 @@
|
|||
<CMakeBuildRuntimeConfigureCmd Condition="'$(WasmEnableJsInteropByValue)' == 'true'">$(CMakeBuildRuntimeConfigureCmd) -DENABLE_JS_INTEROP_BY_VALUE=1</CMakeBuildRuntimeConfigureCmd>
|
||||
<CMakeBuildRuntimeConfigureCmd>$(CMakeBuildRuntimeConfigureCmd) $(CMakeConfigurationEmsdkPath)</CMakeBuildRuntimeConfigureCmd>
|
||||
|
||||
<CMakeBuildRuntimeConfigureCmd Condition="'$(OS)' == 'Windows_NT'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))" && $(CMakeBuildRuntimeConfigureCmd)</CMakeBuildRuntimeConfigureCmd>
|
||||
<CMakeBuildRuntimeConfigureCmd Condition="'$(OS)' == 'Windows_NT'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.cmd'))" && $(CMakeBuildRuntimeConfigureCmd)</CMakeBuildRuntimeConfigureCmd>
|
||||
<CMakeBuildRuntimeConfigureCmd Condition="'$(OS)' != 'Windows_NT'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&1 && $(CMakeBuildRuntimeConfigureCmd)'</CMakeBuildRuntimeConfigureCmd>
|
||||
|
||||
<CMakeOptions Condition="'$(MonoVerboseBuild)' != ''">-v</CMakeOptions>
|
||||
<CMakeBuildRuntimeCmd>cmake --build . --config $(Configuration) $(CmakeOptions)</CMakeBuildRuntimeCmd>
|
||||
<CMakeBuildRuntimeCmd Condition="'$(OS)' == 'Windows_NT'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))" && $(CMakeBuildRuntimeCmd)</CMakeBuildRuntimeCmd>
|
||||
<CMakeBuildRuntimeCmd Condition="'$(OS)' == 'Windows_NT'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.cmd'))" && $(CMakeBuildRuntimeCmd)</CMakeBuildRuntimeCmd>
|
||||
<CMakeBuildRuntimeCmd Condition="'$(OS)' != 'Windows_NT'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&1 && $(CMakeBuildRuntimeCmd)'</CMakeBuildRuntimeCmd>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -4,25 +4,18 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<EmscriptenSdkToolsPath>$([MSBuild]::EnsureTrailingSlash($(EMSDK_PATH)))</EmscriptenSdkToolsPath>
|
||||
<EmscriptenUpstreamBinPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'upstream', 'bin'))</EmscriptenUpstreamBinPath>
|
||||
<EmscriptenUpstreamEmscriptenPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'upstream', 'emscripten'))</EmscriptenUpstreamEmscriptenPath>
|
||||
|
||||
<_NodeToolsBasePath>$(EmscriptenSdkToolsPath)node</_NodeToolsBasePath>
|
||||
<EmscriptenUpstreamBinPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'bin'))</EmscriptenUpstreamBinPath>
|
||||
<EmscriptenUpstreamEmscriptenPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'emscripten'))</EmscriptenUpstreamEmscriptenPath>
|
||||
|
||||
<!-- gets the path like emsdk/python/3.7.4-2_64bit -->
|
||||
<_NodeToolsVersionedPath Condition="Exists($(_NodeToolsBasePath))">$([System.IO.Directory]::GetDirectories($(_NodeToolsBasePath)))</_NodeToolsVersionedPath>
|
||||
<EmscriptenNodeToolsPath Condition="'$(_NodeToolsVersionedPath)' != ''">$(_NodeToolsVersionedPath)</EmscriptenNodeToolsPath>
|
||||
<EmscriptenNodeToolsPath Condition="'$(EmscriptenNodeToolsPath)' != ''">$([MSBuild]::NormalizeDirectory($(EmscriptenNodeToolsPath)))</EmscriptenNodeToolsPath>
|
||||
<EmscriptenNodeToolsPath Condition="'$(EmscriptenNodeToolsPath)' == ''">$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'node', 'bin'))</EmscriptenNodeToolsPath>
|
||||
|
||||
<_UsingEMSDK_PATH>true</_UsingEMSDK_PATH>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Emscripten uses system python on Linux, so we don't need $(EmscriptenPythonToolsPath) -->
|
||||
<PropertyGroup Condition="!$([MSBuild]::IsOSPlatform('linux'))">
|
||||
<_PythonToolsBasePath>$(EmscriptenSdkToolsPath)python</_PythonToolsBasePath>
|
||||
<_PythonToolsVersionedPath Condition="Exists($(_PythonToolsBasePath))">$([System.IO.Directory]::GetDirectories($(_PythonToolsBasePath)))</_PythonToolsVersionedPath>
|
||||
<EmscriptenPythonToolsPath Condition="'$(_PythonToolsVersionedPath)' != ''">$(_PythonToolsVersionedPath)</EmscriptenPythonToolsPath>
|
||||
<EmscriptenPythonToolsPath Condition="'$(EmscriptenPythonToolsPath)' != ''">$([MSBuild]::NormalizeDirectory($(EmscriptenPythonToolsPath)))</EmscriptenPythonToolsPath>
|
||||
<EmscriptenPythonToolsPath>$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath)python))</EmscriptenPythonToolsPath>
|
||||
|
||||
<_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenPythonToolsPath)' == '' or !Exists('$(EmscriptenPythonToolsPath)'))">%24(EmscriptenPythonToolsPath)=$(EmscriptenPythonToolsPath) </_EMSDKMissingPaths>
|
||||
</PropertyGroup>
|
||||
|
@ -31,9 +24,9 @@
|
|||
<ItemGroup>
|
||||
<EmscriptenPrependPATH Include="$(EmscriptenSdkToolsPath)" />
|
||||
<EmscriptenPrependPATH Include="$(EmscriptenUpstreamBinPath)" />
|
||||
<EmscriptenPrependPATH Include="$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'upstream', 'emscripten'))" />
|
||||
<EmscriptenPrependPATH Include="$([MSBuild]::NormalizeDirectory($(EmscriptenSdkToolsPath), 'emscripten'))" />
|
||||
|
||||
<EmscriptenPrependPATH Include="$(EmscriptenNodeToolsPath)bin" />
|
||||
<EmscriptenPrependPATH Include="$(EmscriptenNodeToolsPath)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(EmscriptenPythonToolsPath)' != ''">
|
||||
|
|
|
@ -44,7 +44,7 @@ set(ignoreMeEmsdkPath "${EMSDK_PATH}")
|
|||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_custom_command(TARGET dotnet.native
|
||||
POST_BUILD COMMAND ${EMSDK_PATH}/upstream/bin/wasm-opt --enable-exception-handling ${CONFIGURATION_WASM_OPT_FLAGS} --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.native.wasm -o ${NATIVE_BIN_DIR}/dotnet.native.wasm
|
||||
POST_BUILD COMMAND ${EMSDK_PATH}/bin/wasm-opt --enable-exception-handling ${CONFIGURATION_WASM_OPT_FLAGS} --strip-dwarf ${NATIVE_BIN_DIR}/dotnet.native.wasm -o ${NATIVE_BIN_DIR}/dotnet.native.wasm
|
||||
COMMENT "Stripping debug symbols from dotnet.native.wasm using wasm-opt")
|
||||
endif()
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ def rewrite_package_json(path):
|
|||
|
||||
|
||||
emsdk_path = sys.argv[1]
|
||||
emscripten_path = os.path.join(emsdk_path, "upstream", "emscripten")
|
||||
emscripten_path = os.path.join(emsdk_path, "emscripten")
|
||||
node_root = os.path.join(emsdk_path, "node")
|
||||
node_paths = glob(node_root)
|
||||
upgrade = True
|
||||
|
|
|
@ -77,6 +77,8 @@
|
|||
<!-- by default, do dynamic components -->
|
||||
<!-- TODO: Change to dynamic as default once package/deploy is fixed for all targets -->
|
||||
<MonoComponentsStatic Condition="'$(MonoComponentsStatic)' == ''">true</MonoComponentsStatic>
|
||||
<NeedEmscriptenPackages Condition="'$(TargetsBrowser)' == 'true' or '$(MonoGenerateOffsetsOSGroups)' == 'browser'">true</NeedEmscriptenPackages>
|
||||
<NeedEmscriptenPackages Condition="'$(NeedEmscriptenPackages)' == ''">false</NeedEmscriptenPackages>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">
|
||||
|
@ -87,6 +89,20 @@
|
|||
GeneratePathProperty="true" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(NeedEmscriptenPackages)' == 'true'">
|
||||
<PackageReference Include="Microsoft.NET.Runtime.Emscripten.$(EmsdkVersion).Cache.$(_portableHostOS)-$(BuildArchitecture)"
|
||||
PrivateAssets="all"
|
||||
Version="$(EmsdkPackageVersion)"
|
||||
PackageArch="$(BuildArchitecture)" />
|
||||
<PackageReference Include="runtime.$(_portableHostOS)-$(BuildArchitecture).Microsoft.NETCore.Runtime.Wasm.Node.Transport"
|
||||
Version="$(NodePackageVersion)"
|
||||
PackageArch="$(BuildArchitecture)" />
|
||||
<PackageReference Include="Microsoft.NET.Runtime.Emscripten.$(EmsdkVersion).Sdk.$(_portableHostOS)-$(BuildArchitecture)"
|
||||
PrivateAssets="all"
|
||||
Version="$(EmsdkPackageVersion)"
|
||||
PackageArch="$(BuildArchitecture)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Like Wasm, Wasi needs a 64-bit python on windows to pinvoke into libClang.dll for offset generation.
|
||||
Only wasi doesn't come with its own python and windows uses 32-bit python, so refer to the transport pack instead.
|
||||
|
@ -145,7 +161,7 @@
|
|||
|
||||
<!-- Sets up emscripten if you don't have the EMSDK_PATH env variable set -->
|
||||
<Target Name="ProvisionEmscripten"
|
||||
Condition="'$(ShouldProvisionEmscripten)' == 'true' and '$(SkipMonoCrossJitConfigure)' != 'true'">
|
||||
Condition="'$(ShouldProvisionEmscripten)' == 'true'">
|
||||
<ReadLinesFromFile File="$(MSBuildThisFileDirectory)\browser\emscripten-version.txt">
|
||||
<Output TaskParameter="Lines" ItemName="_VersionLines" />
|
||||
</ReadLinesFromFile>
|
||||
|
@ -157,25 +173,133 @@
|
|||
<BrowserLocalPath>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'browser'))</BrowserLocalPath>
|
||||
<EmsdkLocalPath>emsdk</EmsdkLocalPath>
|
||||
<EmscriptenVersion>%(_VersionLines.Identity)</EmscriptenVersion>
|
||||
<_EmsdkPaths Condition="'$(HostOS)' != 'windows'">
|
||||
CURRENT_SCRIPT=
|
||||
DIR="."
|
||||
|
||||
<InstallCmd>$(EMSDK_PATH)/emsdk$(EmsdkExt) install $(EmscriptenVersion)</InstallCmd>
|
||||
<ActivateCmd>$(EMSDK_PATH)/emsdk$(EmsdkExt) activate $(EmscriptenVersion)</ActivateCmd>
|
||||
<InstallCmd Condition="'$(HostOS)' == 'windows'">powershell -NonInteractive -command "& $(InstallCmd); Exit $LastExitCode "</InstallCmd>
|
||||
<ActivateCmd Condition="'$(HostOS)' == 'windows'">powershell -NonInteractive -command "& $(ActivateCmd); Exit $LastExitCode "</ActivateCmd>
|
||||
<PythonCmd Condition="'$(HostOS)' == 'windows'and '$(TargetsBrowser)' == 'true'">setlocal EnableDelayedExpansion && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))" && !EMSDK_PYTHON!</PythonCmd>
|
||||
# use shell specific method to get the path
|
||||
# to the current file being source'd.
|
||||
#
|
||||
# To add a shell, add another conditional below,
|
||||
# then add tests to scripts/test_source_env.sh
|
||||
|
||||
if [ -n "%24{BASH_SOURCE-}" ]%3B then
|
||||
CURRENT_SCRIPT="%24BASH_SOURCE"
|
||||
elif [ -n "%24{ZSH_VERSION-}" ]%3B then
|
||||
CURRENT_SCRIPT="%24{(%):-%x}"
|
||||
elif [ -n "%24{KSH_VERSION-}" ]%3B then
|
||||
CURRENT_SCRIPT=%24{.sh.file}
|
||||
fi
|
||||
|
||||
if [ -n "%24{CURRENT_SCRIPT-}" ]%3B then
|
||||
DIR=%24(dirname "%24CURRENT_SCRIPT")
|
||||
if [ -h "%24CURRENT_SCRIPT" ]%3B then
|
||||
# Now work out actual DIR since this is part of a symlink.
|
||||
# Since we can't be sure that readlink or realpath
|
||||
# are available, use tools more likely to be installed.
|
||||
# (This will still fail if sed is not available.)
|
||||
SYMDIR=%24(dirname "%24(ls -l "%24CURRENT_SCRIPT" | sed -n "s/.*-> //p")")
|
||||
if [ -z "%24SYMDIR" ]%3B then
|
||||
SYMDIR="."
|
||||
fi
|
||||
FULLDIR="%24DIR/%24SYMDIR"
|
||||
DIR=%24(cd "%24FULLDIR" > /dev/null 2>&1%3B /bin/pwd)
|
||||
unset SYMDIR
|
||||
unset FULLDIR
|
||||
fi
|
||||
fi
|
||||
unset CURRENT_SCRIPT
|
||||
|
||||
if [ ! -f "%24DIR/emscripten/emcmake.py" ]%3B then
|
||||
echo "Error: unable to determine 'emsdk' directory. Perhaps you are using a shell or" 1>&2
|
||||
echo " environment that this script does not support." 1>&2
|
||||
echo 1>&2
|
||||
echo "A possible solution is to source this script while in the 'emsdk' directory." 1>&2
|
||||
echo 1>&2
|
||||
unset DIR
|
||||
return
|
||||
fi
|
||||
|
||||
export EMSDK_PATH=%24{DIR}/
|
||||
unset DIR
|
||||
|
||||
export DOTNET_EMSCRIPTEN_LLVM_ROOT=%24{EMSDK_PATH}bin/
|
||||
export DOTNET_EMSCRIPTEN_NODE_JS=%24{EMSDK_PATH}node/bin/node
|
||||
export DOTNET_EMSCRIPTEN_BINARYEN_ROOT=%24{EMSDK_PATH}
|
||||
|
||||
</_EmsdkPaths>
|
||||
<_EmsdkPaths Condition="'$(HostOS)' == 'windows'">
|
||||
@echo off
|
||||
|
||||
set CURRENT_SCRIPT=%~dp0
|
||||
set EMSDK_PATH=%CURRENT_SCRIPT:~0,-1%\
|
||||
|
||||
set EMSDK_PYTHON=%EMSDK_PATH%python\python.exe
|
||||
set DOTNET_EMSCRIPTEN_LLVM_ROOT=%EMSDK_PATH%bin\
|
||||
set DOTNET_EMSCRIPTEN_NODE_JS=%EMSDK_PATH%node\bin\node
|
||||
set DOTNET_EMSCRIPTEN_NODE_PATH=%EMSDK_PATH%node\bin\
|
||||
set DOTNET_EMSCRIPTEN_BINARYEN_ROOT=%EMSDK_PATH%
|
||||
|
||||
</_EmsdkPaths>
|
||||
<_EmscriptenPaths>
|
||||
import os
|
||||
|
||||
emsdk_path = os.path.dirname(os.path.dirname(os.path.realpath(os.getenv('EM_CONFIG')).replace('\\', '/')))
|
||||
|
||||
LLVM_ROOT = emsdk_path + '/bin'
|
||||
NODE_JS = emsdk_path + '/node/bin/node'
|
||||
BINARYEN_ROOT = emsdk_path
|
||||
|
||||
FROZEN_CACHE = bool(os.getenv('FROZEN_CACHE', 'True'))
|
||||
|
||||
COMPILER_ENGINE = NODE_JS
|
||||
JS_ENGINES = [NODE_JS]
|
||||
</_EmscriptenPaths>
|
||||
<PythonCmd Condition="'$(HostOS)' == 'windows'and '$(TargetsBrowser)' == 'true'">setlocal EnableDelayedExpansion && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env$(ScriptExt)'))" && !EMSDK_PYTHON!</PythonCmd>
|
||||
</PropertyGroup>
|
||||
|
||||
<RemoveDir Directories="$(EMSDK_PATH)" />
|
||||
<Exec Command="git clone https://github.com/emscripten-core/emsdk.git emsdk"
|
||||
WorkingDirectory="$(BrowserLocalPath)"
|
||||
IgnoreStandardErrorWarningFormat="true" />
|
||||
<Exec Command="git checkout $(EmscriptenVersion) && $(InstallCmd) && $(ActivateCmd)"
|
||||
WorkingDirectory="$(EMSDK_PATH)"
|
||||
IgnoreStandardErrorWarningFormat="true" />
|
||||
<Exec Command="$(PythonCmd) -m pip install certifi && $(PythonCmd) -m pip install pip-system-certs"
|
||||
Condition="'$(HostOS)' == 'windows'"
|
||||
WorkingDirectory="$(EMSDK_PATH)"
|
||||
IgnoreStandardErrorWarningFormat="true" />
|
||||
|
||||
<ItemGroup>
|
||||
<EmsdkFiles Condition="'%(PackageReference.Identity)' != 'runtime.$(_portableHostOS)-$(BuildArchitecture).Microsoft.NETCore.Runtime.Wasm.Node.Transport' and '%(PackageReference.Identity)' != 'Microsoft.NET.Runtime.Emscripten.3.1.34.Python.win-$(BuildArchitecture)'"
|
||||
Include="$(NuGetPackageRoot)\$([System.String]::Copy(%(PackageReference.Identity)).ToLowerInvariant())\%(PackageReference.Version)\tools\**" />
|
||||
<NodeFiles Condition="'%(PackageReference.Identity)' == 'runtime.$(_portableHostOS)-$(BuildArchitecture).Microsoft.NETCore.Runtime.Wasm.Node.Transport'"
|
||||
Include="$(NuGetPackageRoot)\$([System.String]::Copy(%(PackageReference.Identity)).ToLowerInvariant())\%(PackageReference.Version)\tools\$(_portableHostOS)-$(BuildArchitecture)\**" />
|
||||
<PythonFiles Condition="'$(HostOS)' == 'windows' and '%(PackageReference.Identity)' == 'Microsoft.NET.Runtime.Emscripten.3.1.34.Python.win-$(BuildArchitecture)'"
|
||||
Include="$(NuGetPackageRoot)\$([System.String]::Copy(%(PackageReference.Identity)).ToLowerInvariant())\%(PackageReference.Version)\tools\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<Copy SourceFiles="@(EmsdkFiles)" DestinationFolder="$(EMSDK_PATH)/%(RecursiveDir)">
|
||||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
||||
</Copy>
|
||||
<Copy SourceFiles="@(NodeFiles)" DestinationFolder="$(EMSDK_PATH)node/%(RecursiveDir)">
|
||||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
||||
</Copy>
|
||||
<Copy Condition="'$(HostOS)' == 'windows'" SourceFiles="@(PythonFiles)" DestinationFolder="$(EMSDK_PATH)python/%(RecursiveDir)">
|
||||
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
|
||||
</Copy>
|
||||
<ReadLinesFromFile File="$(EMSDK_PATH)emsdk_env$(ScriptExt)">
|
||||
<Output TaskParameter="Lines" PropertyName="_EmsdkEnvFileText" />
|
||||
</ReadLinesFromFile>
|
||||
<WriteLinesToFile File="$(EMSDK_PATH)emsdk_env$(ScriptExt)"
|
||||
Overwrite="true"
|
||||
Lines="$(_EmsdkPaths);$(_EmsdkEnvFileText)" />
|
||||
<WriteLinesToFile File="$(EMSDK_PATH)emscripten/.emscripten"
|
||||
Overwrite="true"
|
||||
Lines="$(_EmscriptenPaths)" />
|
||||
<!-- Fixup files that were symlinks originally (on Linux/Mac, Windows has an equivalent already) -->
|
||||
<ItemGroup>
|
||||
<NodeModulesBinFiles Include="$(EMSDK_PATH)node\bin\npm.js" />
|
||||
</ItemGroup>
|
||||
<WriteLinesToFile
|
||||
Condition="$([MSBuild]::IsOSPlatform(Linux)) or $([MSBuild]::IsOSPlatform(OSX))"
|
||||
Lines="#!/usr/bin/env node;require('../lib/node_modules/%(Filename)/lib/cli.js')(process)"
|
||||
File="%(NodeModulesBinFiles.RootDir)%(NodeModulesBinFiles.Directory)%(NodeModulesBinFiles.Filename)"
|
||||
Overwrite="true" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ShouldProvisionEmscripten>false</ShouldProvisionEmscripten>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<!-- Sets up WASI SDK if you don't have the WASI_SDK_PATH env variable set -->
|
||||
|
@ -599,14 +723,16 @@
|
|||
<PropertyGroup>
|
||||
<EMSDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(EMSDK_PATH)').Replace('\', '/'))</EMSDK_PATH>
|
||||
<WASI_SDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/'))</WASI_SDK_PATH>
|
||||
<_EmsdkEnvScriptPath>$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env$(ScriptExt)'))</_EmsdkEnvScriptPath>
|
||||
|
||||
<_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) "$(MonoProjectRoot.TrimEnd('\/'))"</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoSkipInitCompiler)' != 'true' and '$(HostOS)' != 'windows'">sh -c 'build_arch="$(_CompilerTargetArch)" compiler="$(MonoCCompiler)" . "$(RepositoryEngineeringCommonDir)native/init-compiler.sh" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoSkipInitCompiler)' == 'true' and '$(HostOS)' != 'windows'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsWasi)' == 'true'">$(_MonoCMakeConfigureCommand) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot"</_MonoCMakeConfigureCommand>
|
||||
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' != 'windows'">bash -c 'source $(EMSDK_PATH)/emsdk_env.sh 2>&1 && emcmake $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))" && emcmake $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' != 'windows'">bash -c 'source $(_EmsdkEnvScriptPath) 2>&1 && emcmake $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && call "$(_EmsdkEnvScriptPath)" && emcmake $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
|
||||
<_MonoCMakeConfigureCommand Condition="'$(TargetsWasi)' == 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" && cmake $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
|
||||
|
||||
<_MonoCMakeBuildCommand>cmake --build . --target install --config $(Configuration)</_MonoCMakeBuildCommand>
|
||||
|
@ -796,7 +922,7 @@
|
|||
<MonoAotCrossOffsetsToolParams Include="--libclang="$(MonoLibClang)"" />
|
||||
<MonoAotCrossOffsetsToolParams Condition="'$(MonoAotOffsetsPrefix)' != ''" Include="--prefix="$(MonoAotOffsetsPrefix)"" />
|
||||
<MonoAotCrossOffsetsToolParams Condition="'$(MonoAotCMakeSysroot)' != ''" Include="--sysroot="$(MonoAotCMakeSysroot)"" />
|
||||
<MonoAotCrossOffsetsToolParams Condition="'$(TargetsBrowser)' == 'true'" Include="--emscripten-sdk="$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'upstream', 'emscripten').TrimEnd('\/'))"" />
|
||||
<MonoAotCrossOffsetsToolParams Condition="'$(TargetsBrowser)' == 'true'" Include="--emscripten-sdk="$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emscripten').TrimEnd('\/'))"" />
|
||||
<MonoAotCrossOffsetsToolParams Condition="'$(TargetsWasi)' == 'true'" Include="--sysroot="$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share/wasi-sysroot'))" --wasi-sdk="$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)').TrimEnd('\/'))"" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.WebAssembly.Build.Tasks
|
|||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
string envScriptPath = Path.Combine(EmSdkPath, "emsdk_env.bat");
|
||||
string envScriptPath = Path.Combine(EmSdkPath, "emsdk_env.cmd");
|
||||
if (!CheckEnvScript(envScriptPath))
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue