Skip to content

Commit

Permalink
Added wasi-sdk flow (#307)
Browse files Browse the repository at this point in the history
Added wasi-sdk flow
  • Loading branch information
mkhamoyan authored Jan 26, 2023
1 parent ca595a2 commit 4d40948
Show file tree
Hide file tree
Showing 17 changed files with 1,004 additions and 19 deletions.
3 changes: 3 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
<PropertyGroup>
<MicrosoftDotNetBuildTasksPackagingVersion>8.0.0-beta.23067.5</MicrosoftDotNetBuildTasksPackagingVersion>
</PropertyGroup>
<PropertyGroup>
<WasiSdkVersion>16</WasiSdkVersion>
</PropertyGroup>
</Project>
55 changes: 55 additions & 0 deletions eng/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,51 @@ stages:
artifactName: Artifacts_Browser_Threading
condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest'))

############ WASI BUILD ############
- job: Build_Wasi
displayName: Wasi
timeoutInMinutes: 360
pool:
${{ if eq(variables['System.TeamProject'], 'public') }}:
vmImage: ubuntu-20.04
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCore1ESPool-Internal
demands: ImageOverride -equals Build.Ubuntu.1804.Amd64
container:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-webassembly
steps:
- bash: |
./build.sh --ci --restore --build --configuration $(_BuildConfig) /p:TargetOS=Wasi /p:TargetArchitecture=wasm $(_InternalBuildArgs)
displayName: Build
- task: PublishPipelineArtifact@1
displayName: Upload artifacts
inputs:
targetPath: 'artifacts/bin'
artifactName: Artifacts_Wasi
condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest'))

- job: Build_Wasi_Threading
displayName: Wasi_Threading
timeoutInMinutes: 360
pool:
${{ if eq(variables['System.TeamProject'], 'public') }}:
vmImage: ubuntu-20.04
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCore1ESPool-Internal
demands: ImageOverride -equals Build.Ubuntu.1804.Amd64
container:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-20.04-webassembly
steps:
- bash: |
./build.sh --ci --restore --build --configuration $(_BuildConfig) /p:TargetOS=Wasi /p:TargetArchitecture=wasm /p:WasmEnableThreads=true $(_InternalBuildArgs)
displayName: Build
- task: PublishPipelineArtifact@1
displayName: Upload artifacts
inputs:
targetPath: 'artifacts/bin'
artifactName: Artifacts_Wasi_Threading
condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest'))

############ iOS BUILD ############
- job: Build_iOS
displayName: iOS
Expand Down Expand Up @@ -168,6 +213,8 @@ stages:
dependsOn:
- Build_Browser
- Build_Browser_Threading
- Build_Wasi
- Build_Wasi_Threading
- Build_iOS
- Build_MacCatalyst
- Build_tvOS
Expand All @@ -188,6 +235,14 @@ stages:
inputs:
artifact: Artifacts_Browser_Threading
path: 'artifacts/bin/browser-threading'
- task: DownloadPipelineArtifact@2
inputs:
artifact: Artifacts_Wasi
path: 'artifacts/bin'
- task: DownloadPipelineArtifact@2
inputs:
artifact: Artifacts_Wasi_Threading
path: 'artifacts/bin/wasi-threading'
- task: DownloadPipelineArtifact@2
inputs:
artifact: Artifacts_iOS
Expand Down
4 changes: 2 additions & 2 deletions eng/icu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ data-$(2): $(TARGET_OBJDIR)/$(1)/.stamp-configure | $(TARGET_OBJDIR)/$(1) $(TARG

endef

ifeq ($(TARGET_OS),browser)
$(eval $(call TargetBuildTemplate,icudt_browser,icudt))
ifeq ($(TARGET_ARCHITECTURE),wasm)
$(eval $(call TargetBuildTemplate,icudt_wasm,icudt))
else
$(eval $(call TargetBuildTemplate,icudt_mobile,icudt))
endif
Expand Down
26 changes: 24 additions & 2 deletions eng/icu.proj
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<Project>
<Target Name="Build" Condition="'$(PackOnly)' != 'true'" DependsOnTargets="PatchEmscripten;CopyEmscriptenVersion">
<Import Project="$(RepositoryEngineeringDir)Versions.props" />

<Target Name="Build" Condition="'$(PackOnly)' != 'true'" DependsOnTargets="PatchEmscripten;CopyEmscriptenVersion;DownloadWasiSdk">
<Error Condition="'$(TargetOS)' == ''" Text="TargetOS needs to be specified!" />
<Error Condition="'$(TargetArchitecture)' == ''" Text="TargetArchitecture needs to be specified!" />

<PropertyGroup>
<_ExtraParams Condition="'$(WasmEnableThreads)' == 'true'">WASM_ENABLE_THREADS=true</_ExtraParams>
</PropertyGroup>

<!-- Set WASI sdk path if WASI_SDK_PATH env variable is not set -->
<PropertyGroup Condition="'$(TargetOS)' == 'Wasi' and '$(WASI_SDK_PATH)' == ''">
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == ''">$(RepoRoot)artifacts/wasi-sdk</WASI_SDK_PATH>
</PropertyGroup>

<Copy SourceFiles="$(MSBuildThisFileDirectory)\..\icu-filters\curr-root.txt"
DestinationFiles="$(MSBuildThisFileDirectory)\..\icu\icu4c\source\data\curr\root.txt"/>
<Exec WorkingDirectory="$(MSBuildThisFileDirectory)"
Command="make -f icu.mk all TARGET_OS=$(TargetOS.ToLower()) TARGET_ARCHITECTURE=$(TargetArchitecture) ICU_TRACING=$(IcuTracing) $(_ExtraParams) SHELL=/bin/bash"
Command="make -f icu.mk all TARGET_OS=$(TargetOS.ToLower()) TARGET_ARCHITECTURE=$(TargetArchitecture) ICU_TRACING=$(IcuTracing) WASI_SDK_PATH=$(WASI_SDK_PATH) $(_ExtraParams) SHELL=/bin/bash"
IgnoreStandardErrorWarningFormat="true" />
</Target>
<Target Name="Restore" />
Expand All @@ -37,4 +44,19 @@
Lines="@(_ItemsFromEmscriptenVersionFile->Replace('&quot;', ''))"
Overwrite="true" />
</Target>

<!-- Download WASI sdk if WASI_SDK_PATH env variable is not set -->
<Target Name="DownloadWasiSdk" Condition="'$(TargetOS)' == 'Wasi' and '$(WASI_SDK_PATH)' == ''">
<PropertyGroup>
<_WasiLocalPath>$(RepoRoot)\artifacts</_WasiLocalPath>
<_WasiSdkUrl Condition="$([MSBuild]::IsOSPlatform('Linux'))">https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz</_WasiSdkUrl>
<_WasiSdkUrl Condition="$([MSBuild]::IsOSPlatform('OSX'))">https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz</_WasiSdkUrl>
</PropertyGroup>

<Error Condition="'$(_WasiSdkUrl)' == ''" Text="_WasiSdkUrl is not set!" />

<Exec Command="rm -rf wasi-sdk-*/ wasi-sdk/ &amp;&amp; curl -L -o- $(_WasiSdkUrl) --fail -S | tar -xvz &amp;&amp; mv wasi-sdk-$(WasiSdkVersion).*/ wasi-sdk/"
WorkingDirectory="$(_WasiLocalPath)"
IgnoreStandardErrorWarningFormat="true" />
</Target>
</Project>
29 changes: 29 additions & 0 deletions eng/icu.wasi.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# TODO: add other host platform/arch combinations
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
UNAME_R := $(shell uname -r)

ifeq ($(UNAME_S),Linux)
HOST_PLATFORM=x86_64-pc-linux-gnu
endif
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_M),arm64)
HOST_PLATFORM=arm64-apple-darwin$(UNAME_R)
endif
ifeq ($(UNAME_M),x86_64)
HOST_PLATFORM=x86_64-apple-darwin$(UNAME_R)
endif
endif
ifeq ($(WASM_ENABLE_THREADS),true)
THREADS_FLAG="-pthread"
endif

CONFIGURE_COMPILER_FLAGS += \
CFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CXXFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CC="$(WASI_SDK_PATH)/bin/clang --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
CXX="$(WASI_SDK_PATH)/bin/clang++ --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
--host=$(HOST_PLATFORM) --build=wasm32

check-env:
:
File renamed without changes.
Loading

0 comments on commit 4d40948

Please sign in to comment.