Skip to content

fix(shared): remove glob from rerun condition in build.rs#393

Merged
0xB10C merged 1 commit intopeer-observer:masterfrom
RazorBest:fix-shared-build-protobuf-check
Mar 27, 2026
Merged

fix(shared): remove glob from rerun condition in build.rs#393
0xB10C merged 1 commit intopeer-observer:masterfrom
RazorBest:fix-shared-build-protobuf-check

Conversation

@RazorBest
Copy link
Copy Markdown
Contributor

@RazorBest RazorBest commented Mar 27, 2026

The build command for crates that depend on the local shared crate always triggered the build of shared, even if nothing was modified. The issue came from the usage of rerun_if_changed, which was given the ../protobuf/* path. It doesn't support globs, and it treated * like a file name. And, when a path is not found, cargo just triggers the build every time.

This also improves the runtime of github workflows.

This is very easy to test:

  • Run cargo build twice in a row, on a crate that depends on shared.
  • Observe the difference in compile times between the two builds. Second time should be under 1s.
  • Modify something in protobuf/ (example protobuf/README.md), and run cargo build again
  • Observe that shared gets recompiled

Before:

cd extractors/p2p/ && cargo build
cargo build
...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.60s

After:

cd extractors/p2p/ && cargo build
cargo build
...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s

Documentation reference: https://docs.rs/cargo-build/latest/cargo_build/fn.rerun_if_changed.html

// Always rerun when non-existent file chosen

@0xB10C
Copy link
Copy Markdown
Collaborator

0xB10C commented Mar 27, 2026

It doesn't support globs, and it treated * like a file name.

TIL! Thanks for looking into this! I had noticed this, but didn't dive deeper.

@0xB10C
Copy link
Copy Markdown
Collaborator

0xB10C commented Mar 27, 2026

Tested this! Reduced the re-build time when re-building the whole project from 3.4s to 0.08s for me! Thank you @RazorBest!

@0xB10C 0xB10C merged commit f6cf351 into peer-observer:master Mar 27, 2026
12 checks passed
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.

2 participants