Skip to content

rerun cpp-overload-test build script when src/ changes - #63

Merged
teor2345 merged 1 commit into
rustfoundation:mainfrom
0xull:build-rs-rerun-if-changed
Oct 27, 2026
Merged

teor2345 merged 1 commit into
rustfoundation:mainfrom
0xull:build-rs-rerun-if-changed

Conversation

@0xull

@0xull 0xull commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

related to #61

adds cargo::rerun-if-changed=src to cpp-overload-test/build.rs.

once a build script prints any rerun-if line, cargo stops rescanning the package (cargo docs). so editing a cpp! block never reran the script, and the build failed with "This cpp! macro is not found in the library's rust-cpp metadata" until build.rs was touched.

after touch cpp-overload-test/src/stdcpp/forward_list.rs and cargo build -v:

before:

       Dirty cpp-overload-test v0.0.0 (...): the file `cpp-overload-test/src/stdcpp/forward_list.rs` has changed (...)

after:

       Dirty cpp-overload-test v0.0.0 (...): the file `cpp-overload-test/src` has changed (...)
     Running `.../target/debug/build/cpp-overload-test/<hash>/out/build_script_build`

edit:

the pr adds a CI test in the cpp-overload-test-ok job. it tests the cpp! code in src/rerun_check.rs, then copies rerun-check/rerun_check.rs over it to change the existing cpp! block and add a new one. after that it tests again without cargo clean. with the rerun-if-changed line removed, the second test fails with the metadata error. also, i updated the "Testing Quirks" section in README.md.

@0xull

This comment was marked as resolved.

@teor2345

This comment was marked as resolved.

teor2345

This comment was marked as resolved.

Signed-off-by: Ikeh Chukwuka <mrikehchukwuka@gmail.com>
@0xull
0xull force-pushed the build-rs-rerun-if-changed branch from 85794b2 to 9ca886f Compare October 26, 2026 05:43
@0xull
0xull requested a review from teor2345 October 26, 2026 05:45

@teor2345 teor2345 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good enough to go, thank you!

cargo test --all-features --package cpp-overload-test --lib
cargo test --doc --all-features --package cpp-overload-test
cargo fmt --package cpp-overload-test -- --check
- name: Check changed cpp! code is rebuilt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I would split this out into a separate job, but we're getting a lot of jobs now, so I don't think it matters that much.

If it turns out this job is always the slowest, or it fails, we can change it later.

// `cc` prints `rerun-if-env-changed` lines, which turns off Cargo's default rescan of the
// package, so instruct Cargo to rerun this script whenever `src/` changes and pick up
// `cpp!` updates.
println!("cargo::rerun-if-changed=src");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to upstream this fix to cpp. But this is an optional change, please prioritise completing your overloading wrapper PR during the Outreachy application period.

If you do have time to do both, feel free to include it in your Outreachy application.

@teor2345
teor2345 added this pull request to the merge queue Oct 27, 2026
@teor2345 teor2345 added bug Something isn't working outreachy Tasks for outreachy applicants labels Oct 27, 2026
Merged via the queue into rustfoundation:main with commit 6dbc2ad Oct 27, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working outreachy Tasks for outreachy applicants

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants