Skip to content

Commit

Permalink
detect plat for wasi toolchain install
Browse files Browse the repository at this point in the history
  • Loading branch information
rajsite committed Aug 10, 2024
1 parent c5ec920 commit 1267108
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: make install-wasi-sdk-linux
- run: make install-wasi-sdk
- run: make vwasi
- run: |
git clone https://github.com/juj/emsdk.git
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
node-version: '16'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: make install-wasi-sdk-windows
- run: make install-wasi-sdk
- run: make vwasi
- run: choco install make -y
- run: choco install gnuwin32-coreutils.portable -y
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ vjs js:
vwasi:
cd make-it && make vwasi TARGET=wasm32-wasip2

install-wasi-sdk-linux:
cd make-it && make install-wasi-sdk-linux

install-wasi-sdk-windows:
cd make-it && make install-wasi-sdk-windows

install-wasi-sdk-mac:
cd make-it && make install-wasi-sdk-mac
install-wasi-sdk:
cd make-it && make install-wasi-sdk

unittest:
cd make-it && make $@
Expand Down
4 changes: 1 addition & 3 deletions docs/Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ Make sure you have `curl` and `tar` available on your CLI. On windows, make sure
From a console window (an **admin console** on windows) run the command relevant to your platform:

```console
make install-wasi-sdk-linux
make install-wasi-sdk-windows
make install-wasi-sdk-mac
make install-wasi-sdk
```

## Vireo Windows Native target
Expand Down
35 changes: 21 additions & 14 deletions make-it/EmMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,24 @@ help:
EMCC=emcc
WASI_VERSION=24
WASI_VERSION_FULL=${WASI_VERSION}.0
WASI_SDK_PATH=$(VIREO_SDK)/wasi-sdk-${WASI_VERSION_FULL}
ifeq ($(OS),Windows_NT)
WASI_SDK_TARGET=x86_64-windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
WASI_SDK_TARGET=x86_64-linux
endif
ifeq ($(UNAME_S),Darwin)
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
WASI_SDK_TARGET=x86_64-macos
endif
ifneq ($(filter arm%,$(UNAME_P)),)
WASI_SDK_TARGET=arm64-macos
endif
endif
endif
WASI_SDK_PATH=$(VIREO_SDK)/wasi-sdk-${WASI_VERSION_FULL}-${WASI_SDK_TARGET}
WASI_CC=${WASI_SDK_PATH}/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot --target=wasm32-wasip2

# release config
Expand Down Expand Up @@ -228,19 +245,9 @@ $(DIST)/vireo.min.js: $(DIST)/vireo.js
$(DIST):
@$(MKDIR) -p $(DIST)

install-wasi-sdk-linux:
cd .. && curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux.tar.gz --output wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
cd .. && tar xvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
cd .. && mv wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux wasi-sdk-${WASI_VERSION_FULL}

install-wasi-sdk-windows:
cd .. && curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-x86_64-windows.tar.gz --output wasi-sdk-${WASI_VERSION_FULL}-windows.tar.gz
cd .. && tar xvf wasi-sdk-${WASI_VERSION_FULL}-windows.tar.gz
cd .. && mv wasi-sdk-${WASI_VERSION_FULL}-x86_64-windows wasi-sdk-${WASI_VERSION_FULL}

install-wasi-sdk-mac:
cd .. && curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz --output wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz
cd .. && tar xvf wasi-sdk-${WASI_VERSION_FULL}-macos.tar.gz
install-wasi-sdk:
cd .. && curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-${WASI_SDK_TARGET}.tar.gz -O
cd .. && tar xvf wasi-sdk-${WASI_VERSION_FULL}-${WASI_SDK_TARGET}.tar.gz

list-variables:
$(foreach v, $(.VARIABLES), $(info $(v) = $($(v))))
Expand Down
10 changes: 2 additions & 8 deletions make-it/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,8 @@ vjs:
vwasi:
make -f EmMakefile vwasi

install-wasi-sdk-linux:
make -f EmMakefile install-wasi-sdk-linux

install-wasi-sdk-windows:
make -f EmMakefile install-wasi-sdk-windows

install-wasi-sdk-mac:
make -f EmMakefile install-wasi-sdk-mac
install-wasi-sdk:
make -f EmMakefile install-wasi-sdk

#========= node.js native module
node_js:
Expand Down

0 comments on commit 1267108

Please sign in to comment.