diff --git a/.github/workflows/bevy-rapier.yml b/.github/workflows/bevy-rapier.yml new file mode 100644 index 000000000..81364b50e --- /dev/null +++ b/.github/workflows/bevy-rapier.yml @@ -0,0 +1,142 @@ +name: Bevy plugin + +# `bindings/bevy_rapier` is its own Cargo workspace (it tracks Bevy's main branch), building +# `bevy_rapier2d` and `bevy_rapier3d` against the rapier crates of this repository. It runs +# on engine changes too, so a rapier change breaking the plugin is caught in its own PR. +on: + push: + branches: [master] + paths: + - "bindings/bevy_rapier/**" + - "src/**" + - "crates/rapier*/**" + - "crates/mjcf-rs/**" + - "Cargo.toml" + - "website/docs-examples/*/bevy/**" + - ".github/workflows/bevy-rapier.yml" + pull_request: + branches: [master] + paths: + - "bindings/bevy_rapier/**" + - "src/**" + - "crates/rapier*/**" + - "crates/mjcf-rs/**" + - "Cargo.toml" + - "website/docs-examples/*/bevy/**" + - ".github/workflows/bevy-rapier.yml" + workflow_dispatch: + +# A new push to a PR cancels the still-running build of the previous push. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + CARGO_PROFILE_DEV_DEBUG: none + +defaults: + run: + working-directory: bindings/bevy_rapier + +jobs: + check-fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - name: Check formatting + run: cargo fmt --all -- --check + doc: + runs-on: ubuntu-latest + env: + RUSTDOCFLAGS: -D warnings + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: bindings/bevy_rapier + - run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev + - name: Cargo doc + run: cargo doc --no-deps + test: + runs-on: ubuntu-latest + env: + RUSTFLAGS: -D warnings + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: bindings/bevy_rapier + - run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev + - run: cargo install cargo-all-features + - name: Clippy for bevy_rapier2d + run: cargo clippy --verbose -p bevy_rapier2d --examples + - name: Clippy for bevy_rapier3d + run: cargo clippy --verbose -p bevy_rapier3d --examples + - name: Clippy for bevy_rapier2d (debug-render, simd, serde) + run: cargo clippy --verbose -p bevy_rapier2d --features debug-render-2d,simd8,serde-serialize,picking-backend + - name: Clippy for bevy_rapier3d (debug-render, simd, serde) + run: cargo clippy --verbose -p bevy_rapier3d --features debug-render-3d,simd8,serde-serialize,picking-backend + - name: Test for bevy_rapier2d + run: cargo test --verbose -p bevy_rapier2d + - name: Test for bevy_rapier3d + run: cargo test --verbose -p bevy_rapier3d + - name: Test for no conflicting system order ambiguity + run: cargo run --bin ambiguity_detection + - name: Check all features individually + run: cargo check-all-features + test-wasm: + runs-on: ubuntu-latest + env: + RUSTFLAGS: -D warnings + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + targets: wasm32-unknown-unknown + - uses: Swatinem/rust-cache@v2 + with: + workspaces: bindings/bevy_rapier + - name: Clippy bevy_rapier2d + run: cd bevy_rapier2d && cargo clippy --verbose --features bevy/webgl2 --target wasm32-unknown-unknown + - name: Clippy bevy_rapier3d + run: cd bevy_rapier3d && cargo clippy --verbose --features bevy/webgl2 --target wasm32-unknown-unknown + dependencies: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check dependencies + uses: EmbarkStudios/cargo-deny-action@v2 + with: + manifest-path: bindings/bevy_rapier/Cargo.toml + # Checks the Bevy documentation snippets compile against the in-tree bevy_rapier. Both + # snippet crates are standalone workspaces sharing one target directory. + website-bevy-snippets: + runs-on: ubuntu-latest + env: + CARGO_TARGET_DIR: ${{ github.workspace }}/website/docs-examples/target + defaults: + run: + working-directory: website/docs-examples + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: | + website/docs-examples/2d/bevy -> ../../target + website/docs-examples/3d/bevy -> ../../target + - run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev + - name: Check the 2D snippets + run: cd 2d/bevy && cargo check --examples + - name: Check the 3D snippets + run: cd 3d/bevy && cargo check --examples diff --git a/.github/workflows/c-bindings.yml b/.github/workflows/c-bindings.yml index df4ebcc5b..b6ed38845 100644 --- a/.github/workflows/c-bindings.yml +++ b/.github/workflows/c-bindings.yml @@ -2,10 +2,10 @@ name: C bindings on: push: branches: [master] - paths: ['c/**', 'src/**', 'crates/rapier*/**', 'Cargo.toml', '.github/workflows/c-bindings.yml'] + paths: ['bindings/c/**', 'src/**', 'crates/rapier*/**', 'Cargo.toml', '.github/workflows/c-bindings.yml'] pull_request: branches: [master] - paths: ['c/**', 'src/**', 'crates/rapier*/**', 'Cargo.toml', '.github/workflows/c-bindings.yml'] + paths: ['bindings/c/**', 'src/**', 'crates/rapier*/**', 'Cargo.toml', '.github/workflows/c-bindings.yml'] workflow_dispatch: jobs: native: @@ -26,7 +26,7 @@ jobs: if: runner.os == 'Linux' run: sudo apt-get update && sudo apt-get install -y libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev - name: Configure - run: cmake -S c -B build/c -DRAPIER_DIMENSION=${{ matrix.variant.dimension }} -DRAPIER_PRECISION=${{ matrix.precision }} -DRAPIER_ENABLE_PARALLEL=${{ matrix.variant.parallel }} -DRAPIER_BUILD_TESTBED=ON -DRAPIER_PROFILE=debug -DRAPIER_CARGO_TARGET_DIR=${{ github.workspace }}/target + run: cmake -S bindings/c -B build/c -DRAPIER_DIMENSION=${{ matrix.variant.dimension }} -DRAPIER_PRECISION=${{ matrix.precision }} -DRAPIER_ENABLE_PARALLEL=${{ matrix.variant.parallel }} -DRAPIER_BUILD_TESTBED=ON -DRAPIER_PROFILE=debug -DRAPIER_CARGO_TARGET_DIR=${{ github.workspace }}/target - name: Build run: cmake --build build/c --config Release --parallel 2 - name: Test @@ -35,7 +35,7 @@ jobs: run: cmake --install build/c --config Release --prefix build/install - name: Consume installed package run: | - cmake -S c/tests/consumer -B build/consumer -DCMAKE_PREFIX_PATH=${{ github.workspace }}/build/install + cmake -S bindings/c/tests/consumer -B build/consumer -DCMAKE_PREFIX_PATH=${{ github.workspace }}/build/install cmake --build build/consumer --config Release ctest --test-dir build/consumer -C Release --output-on-failure abi-and-features: @@ -49,18 +49,18 @@ jobs: - run: cargo install cbindgen --version 0.29.4 --locked - name: Header matches source run: | - sh c/tools/generate-header.sh - git diff --exit-code -- c/include/rapier.h + sh bindings/c/tools/generate-header.sh + git diff --exit-code -- bindings/c/include/rapier.h - run: cargo fmt -p rapier-c-macros -p rapier3d-ffi -- --check - run: cargo test -p rapier-c-macros -p rapier2d-ffi -p rapier3d-ffi -p rapier2d-f64-ffi -p rapier3d-f64-ffi - run: cargo clippy -p rapier-c-macros -p rapier2d-ffi -p rapier3d-ffi -p rapier2d-f64-ffi -p rapier3d-f64-ffi --no-deps -- -D warnings - name: Every ABI symbol and both linkage modes - run: python3 c/tools/test-native.py + run: python3 bindings/c/tools/test-native.py - name: Optional feature combinations run: cargo check -p rapier2d-ffi -p rapier3d-ffi -p rapier2d-f64-ffi -p rapier3d-f64-ffi --features parallel,fem,enhanced-determinism - name: Eight-lane SIMD with parallel execution run: | - cmake -S c -B build/simd8 -DRAPIER_BUILD_TESTBED=ON -DRAPIER_TESTBED_GRAPHICS=OFF -DRAPIER_PROFILE=debug -DRAPIER_SIMD_LANES=8 -DRAPIER_ENABLE_PARALLEL=ON -DRAPIER_CARGO_TARGET_DIR=${{ github.workspace }}/target + cmake -S bindings/c -B build/simd8 -DRAPIER_BUILD_TESTBED=ON -DRAPIER_TESTBED_GRAPHICS=OFF -DRAPIER_PROFILE=debug -DRAPIER_SIMD_LANES=8 -DRAPIER_ENABLE_PARALLEL=ON -DRAPIER_CARGO_TARGET_DIR=${{ github.workspace }}/target cmake --build build/simd8 --parallel 2 ctest --test-dir build/simd8 --output-on-failure @@ -72,7 +72,7 @@ jobs: run: sudo apt-get update && sudo apt-get install -y doxygen - name: Generate and validate all API variants run: | - cmake -S c/doxygen -B build/c-docs + cmake -S bindings/c/doxygen -B build/c-docs cmake --build build/c-docs --target rapier_docs --parallel 2 - name: Upload HTML reference uses: actions/upload-artifact@v4 diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 362922d02..f47f5420b 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -9,9 +9,9 @@ on: env: CARGO_TERM_COLOR: always -# The engine package lives under python/rapier-py-3d (rapier3d, f32); the -# pure-Python testbed under python/rapier-testbed; the test suite under -# python/tests. +# The engine package lives under bindings/python/rapier-py-3d (rapier3d, f32); the +# pure-Python testbed under bindings/python/rapier-testbed; the test suite under +# bindings/python/tests. jobs: lint-rust: runs-on: ubuntu-latest @@ -66,11 +66,11 @@ jobs: # environment so the test suite can import it. - name: Build & install engine package shell: bash - run: python -m pip install --no-build-isolation ./python/rapier-py-3d + run: python -m pip install --no-build-isolation ./bindings/python/rapier-py-3d - name: Install testbed (no deps; engine package already present) shell: bash - run: python -m pip install --no-deps ./python/rapier-testbed + run: python -m pip install --no-deps ./bindings/python/rapier-testbed - name: Smoke (import surface) - run: python -m pytest python/tests/test_smoke.py python/tests/test_math.py -v + run: python -m pytest bindings/python/tests/test_smoke.py bindings/python/tests/test_math.py -v - name: Full test suite - run: python -m pytest python/tests/ -q --timeout=120 + run: python -m pytest bindings/python/tests/ -q --timeout=120 diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml index 64d01506e..68b8aa585 100644 --- a/.github/workflows/python-wheels.yml +++ b/.github/workflows/python-wheels.yml @@ -22,7 +22,7 @@ on: pull_request: branches: [master] paths: - - "python/**" + - "bindings/python/**" - ".github/workflows/python-wheels.yml" workflow_dispatch: @@ -53,7 +53,7 @@ jobs: command: build target: ${{ matrix.platform.target }} manylinux: ${{ matrix.platform.manylinux }} - args: --release --out dist -m python/${{ matrix.package.dir }}/Cargo.toml + args: --release --out dist -m bindings/python/${{ matrix.package.dir }}/Cargo.toml sccache: "true" - uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/rapier-ci-build.yml b/.github/workflows/rapier-ci-build.yml index 2724fb166..aa259fddc 100644 --- a/.github/workflows/rapier-ci-build.yml +++ b/.github/workflows/rapier-ci-build.yml @@ -312,7 +312,7 @@ jobs: run: cd website/docs-examples && cargo test # Checks the JavaScript documentation snippets build against the in-tree bindings, so a # snippet may use an API before it is released on npm. The snippet package depends on - # `typescript/builds/rapier{2,3}d/pkg` through a `file:` path, which this job builds first + # `bindings/typescript/builds/rapier{2,3}d/pkg` through a `file:` path, which this job builds first # (the same two steps a local checkout runs). website-javascript-snippets: runs-on: ubuntu-latest @@ -323,14 +323,14 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 with: - workspaces: typescript + workspaces: bindings/typescript - name: Generate the binding crates - working-directory: ./typescript + working-directory: ./bindings/typescript run: | npm ci cargo run -p prepare_builds -- -d dim${{ matrix.dimension == '2d' && '2' || '3' }} -f non-deterministic - name: Build the in-tree bindings - working-directory: ./typescript/builds/rapier${{ matrix.dimension }} + working-directory: ./bindings/typescript/builds/rapier${{ matrix.dimension }} run: | npm i npm run build:wasm diff --git a/.github/workflows/typescript-bindings.yml b/.github/workflows/typescript-bindings.yml index 416bdae7d..b0251380e 100644 --- a/.github/workflows/typescript-bindings.yml +++ b/.github/workflows/typescript-bindings.yml @@ -9,21 +9,21 @@ on: # the `paths` list below only ever gates the `master` pushes. tags: ["js-v*"] paths: - - "typescript/**" + - "bindings/typescript/**" - ".github/workflows/typescript-bindings.yml" pull_request: branches: [master] paths: - - "typescript/**" + - "bindings/typescript/**" - ".github/workflows/typescript-bindings.yml" workflow_dispatch: env: CARGO_TERM_COLOR: always -# The JS/Wasm bindings live under `typescript/`, which is a self-contained Cargo -# workspace (it pulls `rapier2d`/`rapier3d` from crates.io, not from the crates -# in this repo). Every step therefore runs inside that directory. +# The JS/Wasm bindings live under `bindings/typescript/`, which is a self-contained Cargo +# workspace (its `[patch.crates-io]` builds `rapier2d`/`rapier3d` from the crates +# of this repo). Every step therefore runs inside that directory. # Never cancel a run that can publish: interrupting the `publish` job partway # leaves some of the twelve packages released and the rest missing. @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: typescript + working-directory: bindings/typescript steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -54,7 +54,7 @@ jobs: runs-on: ${{ matrix.os }} defaults: run: - working-directory: typescript + working-directory: bindings/typescript env: RUSTFLAGS: -D warnings steps: @@ -66,8 +66,8 @@ jobs: ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - typescript/target/ - key: ${{ runner.os }}-cargo-js-${{ hashFiles('typescript/builds/prepare_builds/templates/Cargo.toml.tera') }} + bindings/typescript/target/ + key: ${{ runner.os }}-cargo-js-${{ hashFiles('bindings/typescript/builds/prepare_builds/templates/Cargo.toml.tera') }} restore-keys: | ${{ runner.os }}-cargo-js- - run: npm ci; @@ -101,7 +101,7 @@ jobs: with: name: pkg no-compat ${{ matrix.os }} path: | - typescript/builds/*/pkg + bindings/typescript/builds/*/pkg overwrite: true build-compat: strategy: @@ -110,7 +110,7 @@ jobs: runs-on: ${{ matrix.os }} defaults: run: - working-directory: typescript + working-directory: bindings/typescript env: RUSTFLAGS: -D warnings steps: @@ -122,8 +122,8 @@ jobs: ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - typescript/target/ - key: ${{ runner.os }}-cargo-js-${{ hashFiles('typescript/builds/prepare_builds/templates/Cargo.toml.tera') }} + bindings/typescript/target/ + key: ${{ runner.os }}-cargo-js-${{ hashFiles('bindings/typescript/builds/prepare_builds/templates/Cargo.toml.tera') }} restore-keys: | ${{ runner.os }}-cargo-js- - run: npm ci; @@ -161,7 +161,7 @@ jobs: with: name: pkg compat ${{ matrix.os }} path: | - typescript/rapier-compat/builds/*/pkg + bindings/typescript/rapier-compat/builds/*/pkg overwrite: true # Publishes with npm Trusted Publishing: instead of a long-lived `NPM_TOKEN`, # npm mints a short-lived credential from the GitHub OIDC token of this very @@ -186,17 +186,17 @@ jobs: id-token: write defaults: run: - working-directory: typescript + working-directory: bindings/typescript steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: name: pkg no-compat ubuntu-latest - path: typescript/builds + path: bindings/typescript/builds - uses: actions/download-artifact@v4 with: name: pkg compat ubuntu-latest - path: typescript/rapier-compat/builds + path: bindings/typescript/rapier-compat/builds # No `registry-url`: that would write an `.npmrc` expecting a # `NODE_AUTH_TOKEN`, which trusted publishing replaces. - uses: actions/setup-node@v4 diff --git a/.gitignore b/.gitignore index d3617f5f6..8a8e1f896 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,10 @@ package-lock.json # Python bindings: compiled extension modules that `maturin develop` stages # next to each package's Python sources (e.g. `_rapier3d.abi3.so`) and the # Sphinx build output. -python/rapier-py-*/python/**/_rapier*.so -python/rapier-py-*/python/**/_rapier*.pyd -python/rapier-py-*/python/**/_rapier*.dylib -python/docs/_build/ +bindings/python/rapier-py-*/python/**/_rapier*.so +bindings/python/rapier-py-*/python/**/_rapier*.pyd +bindings/python/rapier-py-*/python/**/_rapier*.dylib +bindings/python/docs/_build/ **/__pycache__/ *.pyc *.egg-info/ diff --git a/.run/Check_typescript_bindings__offline_.run.xml b/.run/Check_typescript_bindings__offline_.run.xml index 5b0ee15a6..2425c2663 100644 --- a/.run/Check_typescript_bindings__offline_.run.xml +++ b/.run/Check_typescript_bindings__offline_.run.xml @@ -2,7 +2,7 @@