diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7977f5..002657f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,17 +57,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 }} @@ -92,16 +84,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: | @@ -112,16 +105,9 @@ jobs: brew install wabt; if: matrix.os == 'macos-latest' # Check simd for compat builds - - name: Check 2d 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 + - name: Check 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: diff --git a/scripts/verify_simd_compat.sh b/scripts/verify_simd_compat.sh new file mode 100755 index 0000000..9c5f681 --- /dev/null +++ b/scripts/verify_simd_compat.sh @@ -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 \ No newline at end of file diff --git a/scripts/verify_simd_rust.sh b/scripts/verify_simd_rust.sh new file mode 100755 index 0000000..a4518e8 --- /dev/null +++ b/scripts/verify_simd_rust.sh @@ -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 \ No newline at end of file