Skip to content

Commit 817436d

Browse files
sorafujitanikddnewton
authored andcommitted
Document the pregenerated bindings workflow
1 parent 52e92bc commit 817436d

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

docs/releasing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ chruby ruby-4.1.0-dev && BUNDLE_GEMFILE=gemfiles/4.1/Gemfile bundle install
5757
bundle exec rake cargo:build
5858
```
5959

60+
* Regenerate `rust/ruby-prism-sys/src/bindings.rs` with `bundle exec rake cargo:bindings`. CI fails if the committed file is stale.
61+
6062
* Commit all of the updated files:
6163

6264
```sh

rust/ruby-prism-sys/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,20 @@ In addition to the Ruby prism dependencies, you shouldn't need anything else bes
3232

3333
### Updating bindings
3434

35-
`build.rs` (which gets called as part of running `cargo build`, `cargo test`, etc) is where we tell
36-
`bindgen` which types, functions, etc. that we want it to generate for us. It's smart enough to know
37-
to generate dependencies for items we specify in there (ex. `pm_parser_t` has fields of type
38-
`pm_token_t`, but we don't need to tell `bindgen` about `pm_token_t`--it'll figure it out and
39-
generate bindings for that type too).
40-
41-
If you want to generate new bindings, update `build.rs` accordingly, then run `cargo doc` and check
42-
the docs; that should tell you if `bindgen` generated all the things you need or not.
35+
The bindings are pregenerated and committed at `src/bindings.rs`, so building this crate does not
36+
require `bindgen` or libclang. `build/main.rs` is where we tell `bindgen` which types, functions,
37+
etc. that we want it to generate for us. It's smart enough to know to generate dependencies for
38+
items we specify in there (ex. `pm_parser_t` has fields of type `pm_token_t`, but we don't need to
39+
tell `bindgen` about `pm_token_t`--it'll figure it out and generate bindings for that type too).
40+
41+
If you want to generate new bindings, update the allowlist in `build/main.rs` accordingly, then run
42+
`bundle exec rake cargo:bindings` from the repository root (this requires libclang) to regenerate
43+
`src/bindings.rs`. CI regenerates the bindings and fails if the committed file is stale.
44+
45+
The `buildtime_bindgen` feature is the escape hatch that regenerates the bindings with `bindgen` at
46+
build time instead of using the pregenerated file. It's needed when `RUBY_PRISM_CFLAGS` contains
47+
defines that change the API surface, since the pregenerated bindings only reflect the default
48+
configuration.
4349

4450
### Testing
4551

0 commit comments

Comments
 (0)