Skip to content

Commit 8d65591

Browse files
committed
rustbuild: Tighten dependencies of build scripts
Ensure that `rerun-if-changed` is printed for all build scripts to ensure that they've all got the right list of dependencies.
1 parent 80ec1b9 commit 8d65591

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

src/liballoc_jemalloc/build.rs

+16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(warnings)]
12+
1113
extern crate build_helper;
1214
extern crate gcc;
1315

@@ -18,6 +20,7 @@ use build_helper::run;
1820

1921
fn main() {
2022
println!("cargo:rustc-cfg=cargobuild");
23+
println!("cargo:rerun-if-changed=build.rs");
2124

2225
let target = env::var("TARGET").unwrap();
2326
let host = env::var("HOST").unwrap();
@@ -40,6 +43,19 @@ fn main() {
4043
let cflags = compiler.args().iter().map(|s| s.to_str().unwrap())
4144
.collect::<Vec<_>>().join(" ");
4245

46+
let mut stack = src_dir.join("../jemalloc")
47+
.read_dir().unwrap()
48+
.map(|e| e.unwrap())
49+
.collect::<Vec<_>>();
50+
while let Some(entry) = stack.pop() {
51+
let path = entry.path();
52+
if entry.file_type().unwrap().is_dir() {
53+
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
54+
} else {
55+
println!("cargo:rerun-if-changed={}", path.display());
56+
}
57+
}
58+
4359
let mut cmd = Command::new("sh");
4460
cmd.arg(src_dir.join("../jemalloc/configure").to_str().unwrap()
4561
.replace("C:\\", "/c/")

src/libcore/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(warnings)]
12+
1113
fn main() {
1214
// Remove this whenever snapshots and rustbuild nightlies are synced.
1315
println!("cargo:rustc-cfg=cargobuild");
16+
println!("cargo:rerun-if-changed=build.rs")
1417
}

src/libstd/build.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(warnings)]
12+
1113
extern crate gcc;
1214
extern crate build_helper;
1315

1416
use std::env;
15-
use std::fs;
1617
use std::path::PathBuf;
1718
use std::process::Command;
1819

1920
use build_helper::run;
2021

2122
fn main() {
2223
println!("cargo:rustc-cfg=cargobuild");
24+
println!("cargo:rerun-if-changed=build.rs");
2325

2426
let target = env::var("TARGET").unwrap();
2527
let host = env::var("HOST").unwrap();
@@ -65,8 +67,16 @@ fn build_libbacktrace(host: &str, target: &str) {
6567
println!("cargo:rustc-link-lib=static=backtrace");
6668
println!("cargo:rustc-link-search=native={}/.libs", build_dir.display());
6769

68-
if fs::metadata(&build_dir.join(".libs/libbacktrace.a")).is_ok() {
69-
return
70+
let mut stack = src_dir.read_dir().unwrap()
71+
.map(|e| e.unwrap())
72+
.collect::<Vec<_>>();
73+
while let Some(entry) = stack.pop() {
74+
let path = entry.path();
75+
if entry.file_type().unwrap().is_dir() {
76+
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
77+
} else {
78+
println!("cargo:rerun-if-changed={}", path.display());
79+
}
7080
}
7181

7282
let compiler = gcc::Config::new().get_compiler();

src/rustc/libc_shim/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(warnings)]
12+
1113
// See comments in Cargo.toml for why this exists
1214

1315
fn main() {
1416
println!("cargo:rustc-cfg=stdbuild");
17+
println!("cargo:rerun-if-changed=build.rs");
1518
}

0 commit comments

Comments
 (0)