Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added wasi-sdk flow #307

Merged
merged 36 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ad1ca5e
Added wasi-sdk flow
mkhamoyan Jan 17, 2023
426b8ff
Added wasi in azure-pipelines
mkhamoyan Jan 17, 2023
2525da0
Removed container name
mkhamoyan Jan 17, 2023
a0cb465
Change Wasi_SDK_PATH for CI
mkhamoyan Jan 17, 2023
17beb4d
update paths
mkhamoyan Jan 17, 2023
3f2da6c
update path
mkhamoyan Jan 17, 2023
f38f521
update path
mkhamoyan Jan 17, 2023
915bc84
update path
mkhamoyan Jan 17, 2023
90c071d
change wasi-sdk-version
mkhamoyan Jan 17, 2023
b1ed769
Updated PatchWasiSdk
mkhamoyan Jan 18, 2023
d5fd0ef
update icu.proj
mkhamoyan Jan 18, 2023
a4b8734
update icu.proj
mkhamoyan Jan 18, 2023
a536b93
update the root
mkhamoyan Jan 18, 2023
bf0e0aa
update icu.proj
mkhamoyan Jan 18, 2023
a443d2c
upate icu.proj
mkhamoyan Jan 18, 2023
3f15161
update icu.proj
mkhamoyan Jan 18, 2023
2b441a6
update wasi clang paths
mkhamoyan Jan 18, 2023
a8e96b4
update comfiler-flags
mkhamoyan Jan 18, 2023
32e532b
update compiler_flags
mkhamoyan Jan 18, 2023
f244f8b
update compiler_flags
mkhamoyan Jan 18, 2023
4ab7653
update compiler flags
mkhamoyan Jan 18, 2023
d717f61
update compiler config
mkhamoyan Jan 18, 2023
2955160
update compiler-config
mkhamoyan Jan 18, 2023
24885c9
update
mkhamoyan Jan 18, 2023
1f7ff41
Fix icu for wasi
mkhamoyan Jan 19, 2023
a7d2c77
Added patch for icu changes
mkhamoyan Jan 20, 2023
40a1e89
update hardcoded HOST_PLATFORM
mkhamoyan Jan 20, 2023
605ef11
Remove not used host
mkhamoyan Jan 20, 2023
1163a29
update condition for platform check
mkhamoyan Jan 20, 2023
1b926d9
Merge branch 'dotnet/main' into icu_wasi_sdk
mkhamoyan Jan 24, 2023
ea55666
Refactoring
mkhamoyan Jan 24, 2023
17e2613
download wasi-sdk when needed
mkhamoyan Jan 25, 2023
30a53d9
Added comments
mkhamoyan Jan 25, 2023
3036bc2
Remove unused code
mkhamoyan Jan 25, 2023
ca26058
Removed extra line
mkhamoyan Jan 25, 2023
e435609
update
mkhamoyan Jan 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"remoteEnv": {
"EMSDK_PATH": "${containerWorkspaceFolder}/artifacts/emsdk",
"WASI_SDK_PATH": "${containerWorkspaceFolder}/artifacts/wasi-sdk",
},

// Use 'postCreateCommand' to run commands after the container is created.
Expand Down
10 changes: 9 additions & 1 deletion .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
if [[ "$__TargetOS" == Browser ]]; then
EMSDK_PATH=$PWD/artifacts/emsdk
rm -rf $EMSDK_PATH
git clone https://github.com/emscripten-core/emsdk.git $EMSDK_PATH
EMSCRIPTEN_VERSION="`cat ./.devcontainer/emscripten-version.txt 2>&1`"
cd $EMSDK_PATH && ./emsdk install $EMSCRIPTEN_VERSION
cd $EMSDK_PATH && ./emsdk activate $EMSCRIPTEN_VERSION
# ready to build, e.g.:
# ./build.sh /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:IcuTracing=true
# ./build.sh /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:IcuTracing=true
elif [[ "$__TargetOS" == Wasi ]]; then
WASI_SDK_PATH=$PWD/artifacts/wasi-sdk
rm -rf $WASI_SDK_PATH
git clone https://github.com/WebAssembly/wasi-sdk.git $WASI_SDK_PATH
# ready to build, e.g.:
# ./build.sh /p:TargetOS=Wasi /p:TargetArchitecture=wasm /p:IcuTracing=true
fi
1 change: 1 addition & 0 deletions .devcontainer/wasi-sdk-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
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'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest'))
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a future PR: This Publish Packages job should run for PRs too, and generate the packages, but skip the publishing part itself. This would ensure that the PR doesn't break packaging.

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))
steveisok marked this conversation as resolved.
Show resolved Hide resolved
ifeq ($(TARGET_ARCHITECTURE),wasm)
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved
$(eval $(call TargetBuildTemplate,icudt_wasm,icudt))
else
$(eval $(call TargetBuildTemplate,icudt_mobile,icudt))
endif
Expand Down
26 changes: 25 additions & 1 deletion eng/icu.proj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<Target Name="Build" Condition="'$(PackOnly)' != 'true'" DependsOnTargets="PatchEmscripten;CopyEmscriptenVersion">
<Target Name="Build" Condition="'$(PackOnly)' != 'true'" DependsOnTargets="PatchEmscripten;CopyEmscriptenVersion;PatchWasiSdk">
<Error Condition="'$(TargetOS)' == ''" Text="TargetOS needs to be specified!" />
<Error Condition="'$(TargetArchitecture)' == ''" Text="TargetArchitecture needs to be specified!" />

Expand Down Expand Up @@ -37,4 +37,28 @@
Lines="@(_ItemsFromEmscriptenVersionFile->Replace('&quot;', ''))"
Overwrite="true" />
</Target>
<Target Name="PatchWasiSdk" Condition="'$(TargetOS)' == 'Wasi'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to DownloadWasiSdk. Also I'm not clear if this is necessary when running on docker image with wasi SDK already in place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, now it will download wasi sdk only when needed.

<ReadLinesFromFile File="../.devcontainer/wasi-sdk-version.txt">
radical marked this conversation as resolved.
Show resolved Hide resolved
<Output TaskParameter="Lines" ItemName="_VersionLines" />
</ReadLinesFromFile>

<PropertyGroup>
<WASI_SDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/'))</WASI_SDK_PATH>
<WasiLocalPath>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', 'wasi'))</WasiLocalPath>
<WasiSdkVersion>%(_VersionLines.Identity)</WasiSdkVersion>
<WasiSdkUrl>https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz</WasiSdkUrl>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition for OS here too. And we can use <Error if the url is not set, eg. on windows.

<WasiSdkUrl Condition="'$(HostOS)' == 'osx'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz</WasiSdkUrl>
<WasiSdkUrl Condition="'$(HostOS)' == 'windows'" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-mingw.tar.gz</WasiSdkUrl>
</PropertyGroup>

<Exec Command="curl -L -o wasi-sdk-$WasiSdkVersion.0.tar.gz $(WasiSdkUrl) &amp;&amp; mkdir -p $(WASI_SDK_PATH) &amp;&amp; tar --strip-components=1 -xvzf wasi-sdk-$WasiSdkVersion.0.tar.gz -C $(WASI_SDK_PATH)"
Condition="'$(HostOS)' != 'windows'"
WorkingDirectory="$(ArtifactsDir)"
IgnoreStandardErrorWarningFormat="true" />

<Exec Command="powershell -NonInteractive -command &quot;&amp; .\provision.ps1 -WasiSdkUrl $(WasiSdkUrl) -WasiSdkVersion $(WasiSdkVersion) ; Exit $LastExitCode &quot;"
Condition="'$(HostOS)' == 'windows'"
WorkingDirectory="$(WasiLocalPath)"
IgnoreStandardErrorWarningFormat="true" />
</Target>
</Project>
10 changes: 10 additions & 0 deletions eng/icu.wasi.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ifeq ($(WASM_ENABLE_THREADS),true)
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved
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)"

check-env:
:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space -> tab

Suggested change
:
:

File renamed without changes.