Skip to content

Commit

Permalink
Prevent build.rs rerunning unnecessarily on all source changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 12, 2022
1 parent d493649 commit 4f157a8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions serde/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::str::{self, FromStr};
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
fn main() {
println!("cargo:rerun-if-changed=build.rs");

let minor = match rustc_minor_version() {
Some(minor) => minor,
None => return,
Expand Down
2 changes: 2 additions & 0 deletions serde_derive/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::str;
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
fn main() {
println!("cargo:rerun-if-changed=build.rs");

let minor = match rustc_minor_version() {
Some(minor) => minor,
None => return,
Expand Down
3 changes: 3 additions & 0 deletions serde_derive_internals/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::path::Path;

fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/mod.rs");

// Sometimes on Windows the git checkout does not correctly wire up the
// symlink from serde_derive_internals/src to serde_derive/src/internals.
// When this happens we'll just build based on relative paths within the git
Expand Down
2 changes: 2 additions & 0 deletions serde_test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::str::{self, FromStr};
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
fn main() {
println!("cargo:rerun-if-changed=build.rs");

let minor = match rustc_minor_version() {
Some(minor) => minor,
None => return,
Expand Down
2 changes: 2 additions & 0 deletions test_suite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ fn has_cargo_expand() -> bool {
}

fn main() {
println!("cargo:rerun-if-changed=build.rs");

if cfg!(feature = "expandtest") && has_cargo_expand() {
println!("cargo:rustc-cfg=expandtest");
}
Expand Down

0 comments on commit 4f157a8

Please sign in to comment.