Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 33 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: main
on:
push:
branches: [master]
tags:
- "v*.*.*"
pull_request:
branches: [master]
workflow_dispatch:
Expand Down Expand Up @@ -57,17 +59,9 @@ jobs:
run: |
brew install wabt;
if: matrix.os == 'macos-latest'
# Check simd for rust builds
- name: Check 2d simd rust build
- name: Check simd rust build
run: |
if ! wasm-objdump -d builds/rapier2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1
fi
- name: Check 3d simd compat build
run: |
if ! wasm-objdump -d builds/rapier3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1
fi
./scripts/verify_simd_rust.sh
- uses: actions/upload-artifact@v4
with:
name: pkg no-compat ${{ matrix.os }}
Expand All @@ -92,16 +86,17 @@ jobs:
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: npm ci;
- name: Prepare compat builds
run: |
./builds/prepare_builds/prepare_all_projects.sh
- run: npm ci;
- name: Build rapier-compat
run: |
cd rapier-compat;
npm ci;
npm run build;
npm run test;
cd -;
# Install dependencies to check simd for builds
- name: Install wabt
run: |
Expand All @@ -112,24 +107,17 @@ jobs:
brew install wabt;
if: matrix.os == 'macos-latest'
# Check simd for compat builds
- name: Check 2d simd compat build
- name: Check simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/2d-simd/pkg/rapier_wasm2d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 2d simd compat build does not include simd opcode prefix." && exit 1;
fi
- name: Check 3d simd compat build
run: |
if ! wasm-objdump -d rapier-compat/builds/3d-simd/pkg/rapier_wasm3d_bg.wasm | grep :\\sfd ; then
>&2 echo "ERROR: 3d simd compat build does not include simd opcode prefix." && exit 1;
fi
./scripts/verify_simd_compat.sh
# Upload
- uses: actions/upload-artifact@v4
with:
name: pkg compat ${{ matrix.os }}
path: |
rapier-compat/builds/*/pkg
overwrite: true
publish:
publish-canary:
runs-on: ubuntu-latest
needs: [build, build-compat]
if: github.ref == 'refs/heads/master'
Expand All @@ -152,3 +140,27 @@ jobs:
./publish_all_canary.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-prod:
runs-on: ubuntu-latest
needs: [build, build-compat]
# To avoid releasing a wrong version: check this commit is tagged
if: startsWith(github.event.workflow_run.head_branch, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: pkg no-compat ubuntu-latest
path: builds
- uses: actions/download-artifact@v4
with:
name: pkg compat ubuntu-latest
path: rapier-compat/builds
- uses: actions/setup-node@v4
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
- name: Publish projects
run: |
./publish_all_prod.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

## Building packages manually

### Rust

From the root of the repository, run:

```shell
Expand All @@ -41,10 +43,28 @@ From the root of the repository, run:
Note that `prepare_all_projects.sh` only needs to be run once. It needs to be re-run if any file from the
`builds/prepare_builds` directory (and subdirectories) are modified.

The built packages will be in `builds/rapier2d/pkg`, `builds/rapier3d/pkg`, etc. To build the `-compat` variant of the
The built packages will be in `builds/rapier2d/pkg`, `builds/rapier3d/pkg`, etc.

### Compat version

To build the `-compat` variant of the
packages, run `npm run build` in the `rapier-compat` directory. Note that this will only work if you already ran
`prepare_all_projects.sh`. The compat packages are then generated in, e.g., `rapier-compat/builds/3d/pkg`.

```shell
git clean -fxd # Delete all untracked files.
./builds/prepare_builds/prepare_all_projects.sh
cd rapier-compat;
npm ci;
npm run build;
```

### Building packages in CI

Pushing a tag `v*.*.*` will trigger a CI for production release.

This can fail due to artifacts not available, restart the job manually if needed.

## Feature selection

Multiple NPM packages exist for Rapier, depending on your needs:
Expand Down
42 changes: 42 additions & 0 deletions scripts/verify_simd_compat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

is_error=0

check_simd_opcode_compat() {
local dimension=$1
local features_flag=$2

local file_path="rapier-compat/builds/${dimension}${features_flag}/pkg/rapier_wasm${dimension}_bg.wasm"

echo "wasm-objdump -d $file_path" >&2
if [ "$features_flag" = "-simd" ]; then
if ! wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension}${features_flag} compat build should include simd opcode prefix." && exit 1
fi
else
if wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension} ${features_flag} compat build should not include simd opcode prefix." && exit 1
fi
fi
}

## simd

check_simd_opcode_compat "2d" "-simd" || is_error=1
check_simd_opcode_compat "3d" "-simd" || is_error=1


## not simd

check_simd_opcode_compat "2d" "-deterministic" || is_error=1
check_simd_opcode_compat "3d" "-deterministic" || is_error=1

check_simd_opcode_compat "2d" "" || is_error=1
check_simd_opcode_compat "3d" "" || is_error=1

if [ $is_error = 1 ]; then
echo "ERROR: SIMD check in rust builds failed."
exit 1
else
echo "SIMD check in rust builds: All checks passed."
fi
42 changes: 42 additions & 0 deletions scripts/verify_simd_rust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

is_error=0

check_simd_opcode_rust() {
local dimension=$1
local features_flag=$2

local file_path="builds/rapier${dimension}${features_flag}/pkg/rapier_wasm${dimension}_bg.wasm"

if [ "$features_flag" = "-simd" ]; then
if ! wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension}${features_flag} build should include simd opcode prefix." && exit 1
fi
else
if wasm-objdump -d $file_path | grep :\\sfd > /dev/null ; then
>&2 echo "ERROR: ${dimension} ${features_flag} build should not include simd opcode prefix." && exit 1
fi
fi
}

## simd

check_simd_opcode_rust "2d" "-simd" || is_error=1
check_simd_opcode_rust "3d" "-simd" || is_error=1


## not simd

check_simd_opcode_rust "2d" "-deterministic" || is_error=1
check_simd_opcode_rust "3d" "-deterministic" || is_error=1

check_simd_opcode_rust "2d" "" || is_error=1
check_simd_opcode_rust "3d" "" || is_error=1


if [ $is_error = 1 ]; then
echo "ERROR: SIMD check in rust builds failed."
exit 1
else
echo "SIMD check in rust builds: All checks passed."
fi