Skip to content

Commit f2ab02d

Browse files
Install wasi-sdk in local
1 parent 6637ffb commit f2ab02d

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

src/swift/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
/Packages
44
/*.xcodeproj
55
xcuserdata/
6+
7+
/.wasi-sdk

src/swift/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
MAKEFILE_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
2+
WASI_SDK_DIR ?= $(MAKEFILE_DIR)/.wasi-sdk
3+
4+
5+
build: .wasi-sdk/dummy
6+
swift build --triple wasm32-unknown-wasi \
7+
-Xswiftc -Xclang-linker \
8+
-Xswiftc --sysroot=$(WASI_SDK_DIR)/share/wasi-sysroot \
9+
-Xlinker --allow-undefined
10+
.wasi-sdk/dummy:
11+
./script/install-wasi-sdk.sh $(WASI_SDK_DIR)
12+
touch .wasi-sdk/dummy

src/swift/script/install-wasi-sdk.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -x
4+
INSTALL_PATH=$1
5+
6+
WASI_SDK_DOWNLOAD_URL="https://github.com/swiftwasm/wasi-sdk/releases/download/0.2.0-swiftwasm/dist-ubuntu-latest.tgz.zip"
7+
8+
TMP_DIR=$(mktemp -d)
9+
pushd $TMP_DIR
10+
wget -O dist-wasi-sdk.tgz.zip $WASI_SDK_DOWNLOAD_URL
11+
unzip dist-wasi-sdk.tgz.zip -d .
12+
WASI_SDK_TAR_PATH=$(find . -type f -name "wasi-sdk-*")
13+
WASI_SDK_FULL_NAME=$(basename $WASI_SDK_TAR_PATH -linux.tar.gz)
14+
tar xfz $WASI_SDK_TAR_PATH
15+
popd
16+
17+
mv $TMP_DIR/$WASI_SDK_FULL_NAME $INSTALL_PATH

0 commit comments

Comments
 (0)