Skip to content

Rerun ruby-rbs-sys build script when C sources change - #3198

Open
ksss wants to merge 1 commit into
ruby:masterfrom
ksss:rust-sys-rerun-if-changed
Open

ksss wants to merge 1 commit into
ruby:masterfrom
ksss:rust-sys-rerun-if-changed

Conversation

@ksss

@ksss ksss commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

rust/ruby-rbs-sys/build.rs is not re-run when src/*.c changes. After touch src/string.c, cargo build -v prints Fresh ruby-rbs-sys and the C code is not rebuilt.

bindgen's CargoCallbacks emits cargo:rerun-if-changed for headers only. Emitting even one such line disables cargo's default of watching every file in the package, so src/*.c drops out of the watch list.

Impact

Users installing from crates.io are not affected (the vendored files are real files). Developers who edit C inside this repository and run the rust/ tests are: they get green results against stale objects.

Fix

Emit cargo:rerun-if-changed for the C source directory and the include directory in build(). Cargo walks a directory recursively by mtime, including through the vendor/rbs/{src,include} symlinks.

Verification

With cargo build -v -p ruby-rbs-sys:

  • Before: touch src/string.c → still Fresh ruby-rbs-sys
  • After: no change → Fresh
  • After: touch src/string.c → Dirty ... vendor/rbs/src has changed, recompiled
  • After: touch include/rbs/string.h → Dirty ... vendor/rbs/include has changed, recompiled

🤖 Generated with Claude Code

bindgen's `CargoCallbacks` emits `rerun-if-changed` for headers only.
Emitting even one such line disables cargo's default of watching every
file in the package, so edits to `src/*.c` no longer re-ran the build
script and `rust/` tests passed against stale objects.

Emit `rerun-if-changed` for the C source and include directories
explicitly. Cargo walks directories recursively by mtime.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant