From 4f157a8b81b88514a6d1fb384a57e82cc3c7ad0d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 12 Dec 2022 14:37:41 -0800 Subject: [PATCH] Prevent build.rs rerunning unnecessarily on all source changes --- serde/build.rs | 2 ++ serde_derive/build.rs | 2 ++ serde_derive_internals/build.rs | 3 +++ serde_test/build.rs | 2 ++ test_suite/build.rs | 2 ++ 5 files changed, 11 insertions(+) diff --git a/serde/build.rs b/serde/build.rs index 4fab6ad0f..ccbddd273 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -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, diff --git a/serde_derive/build.rs b/serde_derive/build.rs index 2aece0469..1249dab59 100644 --- a/serde_derive/build.rs +++ b/serde_derive/build.rs @@ -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, diff --git a/serde_derive_internals/build.rs b/serde_derive_internals/build.rs index b2a2d04ab..25b5ef313 100644 --- a/serde_derive_internals/build.rs +++ b/serde_derive_internals/build.rs @@ -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 diff --git a/serde_test/build.rs b/serde_test/build.rs index f7ca97417..b7f69d98f 100644 --- a/serde_test/build.rs +++ b/serde_test/build.rs @@ -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, diff --git a/test_suite/build.rs b/test_suite/build.rs index 957af7629..3ace7d3db 100644 --- a/test_suite/build.rs +++ b/test_suite/build.rs @@ -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"); }