RBS provides two Rust crates:
ruby-rbs-sys -- Low-level FFI bindings to the RBS C parserruby-rbs -- High-level safe Rust API for parsing RBS signaturesBoth crates are published to crates.io and are developed within the rust/ directory of this repository.
The Rust crates depend on the RBS C parser source code (include/, src/) and configuration (config.yml) from this repository. These files are vendored into each crate's vendor/rbs/ directory, which is managed by Rake tasks and not tracked by git.
The file rust/rbs_version records which version of RBS the Rust crates are pinned to.
After cloning the repository, set up the vendored source before building the Rust crates:
rake rust:rbs:sync # Uses the pinned version from rust/rbs_version
Then build and test:
cd rust
cargo test
rake rust:rbs:syncCopies the source files from the pinned version into each crate's vendor/rbs/. The copied files are made read-only to prevent accidental edits.
rake rust:rbs:pin[VERSION]Records a git tag in rust/rbs_version. For example:
rake rust:rbs:pin[v4.0.3]
rake rust:publish:ruby-rbs-sys / rake rust:publish:ruby-rbsPublishes each crate to crates.io individually. Each task:
rust/rbs_version is setSet RBS_RUST_PUBLISH_DRY_RUN=1 to only run the dry-run step and skip the actual publish to crates.io. This is used in CI to verify that the crates can be packaged correctly.
rake rust:rbs:symlinkIf your development needs unreleased version of RBS source code, use rake rust:rbs:symlink to set up symlinks in vendor directories to refer the worktree source code. Changes to the C parser source are immediately reflected in Rust builds.
Pin the RBS version to release against:
rake rust:rbs:pin[v4.0.3]
Sync the vendored source:
rake rust:rbs:sync
Update crate versions in rust/ruby-rbs-sys/Cargo.toml and rust/ruby-rbs/Cargo.toml.
Build and test:
cd rust && cargo test
Commit the version changes and rust/rbs_version:
git add rust/rbs_version rust/ruby-rbs-sys/Cargo.toml rust/ruby-rbs/Cargo.toml git commit -m "Bump Rust crate versions"
Publish each crate:
rake rust:publish:ruby-rbs-sys rake rust:publish:ruby-rbs