Skip to content

Commit

Permalink
feat: support wasi target (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Apr 29, 2024
1 parent 5351f0a commit 0100765
Show file tree
Hide file tree
Showing 41 changed files with 1,851 additions and 3,211 deletions.
168 changes: 0 additions & 168 deletions .eslintrc.yml

This file was deleted.

86 changes: 62 additions & 24 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: yarn build
build: yarn build --target x86_64-apple-darwin
- host: windows-latest
build: yarn build
build: yarn build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: windows-latest
build: |
Expand All @@ -41,20 +41,13 @@ jobs:
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: CC=clang yarn build --target x86_64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
build: yarn build --target x86_64-unknown-linux-musl -x
- host: macos-latest
target: aarch64-apple-darwin
build: |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
export CC=$(xcrun -f clang);
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
yarn build --target aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
build: CC=clang yarn build --target aarch64-unknown-linux-gnu --use-napi-cross
Expand All @@ -73,24 +66,26 @@ jobs:
- host: windows-latest
target: aarch64-pc-windows-msvc
build: yarn build --target aarch64-pc-windows-msvc
name: stable - ${{ matrix.settings.target }} - node@18
- host: ubuntu-latest
target: wasm32-wasi-preview1-threads
build: |
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz
tar -xvf wasi-sdk-22.0-linux.tar.gz
export WASI_SDK_PATH="$(pwd)/wasi-sdk-22.0"
yarn build --target wasm32-wasi-preview1-threads
name: stable - ${{ matrix.settings.target }} - node@20
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
if: ${{ !matrix.settings.docker }}
with:
node-version: 18
node-version: 20
cache: yarn
- name: Download tar.node
if: ${{ matrix.settings.host == 'ubuntu-latest' }}
run: |
npm pack @napi-rs/tar-linux-x64-gnu@latest
tar -xzf napi-rs-tar-*.tgz
mv package/tar.linux-x64-gnu.node .
rm napi-rs-tar-*.tgz
rm -rf package
run: wget https://www.unpkg.com/@napi-rs/tar-linux-x64-gnu/tar.linux-x64-gnu.node
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -109,7 +104,7 @@ jobs:
- uses: goto-bus-stop/setup-zig@v2
if: ${{ contains(matrix.settings.target, 'musl') }}
with:
version: 0.11.0
version: 0.12.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
Expand All @@ -124,7 +119,7 @@ jobs:
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 18
node-version: 20
architecture: x86
- name: Build
run: ${{ matrix.settings.build }}
Expand All @@ -133,10 +128,12 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
path: |
${{ env.APP_NAME }}.*.node
${{ env.APP_NAME }}.*.wasm
if-no-files-found: error
build-freebsd:
runs-on: macos-12
runs-on: macos-13
name: Build FreeBSD
steps:
- uses: actions/checkout@v4
Expand All @@ -149,7 +146,7 @@ jobs:
with:
operating_system: freebsd
version: '13.2'
memory: 13G
memory: 8G
cpu_count: 3
environment_variables: DEBUG RUSTUP_IO_THREADS
shell: bash
Expand Down Expand Up @@ -191,8 +188,13 @@ jobs:
settings:
- host: windows-latest
target: x86_64-pc-windows-msvc
architecture: x64
- host: macos-latest
target: x86_64-apple-darwin
architecture: x64
- host: macos-latest
target: aarch64-apple-darwin
architecture: arm64
node:
- '18'
- '20'
Expand All @@ -204,6 +206,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
cache: yarn
architecture: ${{ matrix.settings.architecture }}
- name: Install dependencies
run: yarn install
- name: Download artifacts
Expand Down Expand Up @@ -390,6 +393,38 @@ jobs:
set -e
yarn test
ls -la
test-nodejs-wasi:
name: Test bindings on wasm32-wasi - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- '18'
- '20'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
- name: Install dependencies
run: yarn install
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-wasm32-wasi-preview1-threads
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: yarn test
env:
NAPI_RS_FORCE_WASI: '1'
publish:
name: Publish
runs-on: ubuntu-latest
Expand All @@ -401,19 +436,22 @@ jobs:
- test-linux-aarch64-gnu-binding
- test-linux-aarch64-musl-binding
- test-linux-arm-gnueabihf-binding
- test-nodejs-wasi
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: yarn
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: create npm dirs
run: yarn napi create-npm-dirs
- name: Move artifacts
run: yarn artifacts
- name: List packages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'yarn'

- name: Install
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Install dependencies
run: yarn install

- name: ESLint
- name: oxlint
run: yarn lint

- name: Cargo fmt
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,6 @@ Cargo.lock
!.yarn/sdks
!.yarn/versions

x86_64-unknown-linux-gnu
x86_64-unknown-linux-gnu
*.wasm
/npm
Loading

0 comments on commit 0100765

Please sign in to comment.