Skip to content

Commit

Permalink
rustbuild: Tighten dependencies of build scripts
Browse files Browse the repository at this point in the history
Ensure that `rerun-if-changed` is printed for all build scripts to ensure that
they've all got the right list of dependencies.
  • Loading branch information
alexcrichton committed May 11, 2016
1 parent 80ec1b9 commit 8d65591
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/liballoc_jemalloc/build.rs
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

extern crate build_helper;
extern crate gcc;

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

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

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

let mut stack = src_dir.join("../jemalloc")
.read_dir().unwrap()
.map(|e| e.unwrap())
.collect::<Vec<_>>();
while let Some(entry) = stack.pop() {
let path = entry.path();
if entry.file_type().unwrap().is_dir() {
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
} else {
println!("cargo:rerun-if-changed={}", path.display());
}
}

let mut cmd = Command::new("sh");
cmd.arg(src_dir.join("../jemalloc/configure").to_str().unwrap()
.replace("C:\\", "/c/")
Expand Down
3 changes: 3 additions & 0 deletions src/libcore/build.rs
Expand Up @@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

fn main() {
// Remove this whenever snapshots and rustbuild nightlies are synced.
println!("cargo:rustc-cfg=cargobuild");
println!("cargo:rerun-if-changed=build.rs")
}
16 changes: 13 additions & 3 deletions src/libstd/build.rs
Expand Up @@ -8,18 +8,20 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

extern crate gcc;
extern crate build_helper;

use std::env;
use std::fs;
use std::path::PathBuf;
use std::process::Command;

use build_helper::run;

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

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

if fs::metadata(&build_dir.join(".libs/libbacktrace.a")).is_ok() {
return
let mut stack = src_dir.read_dir().unwrap()
.map(|e| e.unwrap())
.collect::<Vec<_>>();
while let Some(entry) = stack.pop() {
let path = entry.path();
if entry.file_type().unwrap().is_dir() {
stack.extend(path.read_dir().unwrap().map(|e| e.unwrap()));
} else {
println!("cargo:rerun-if-changed={}", path.display());
}
}

let compiler = gcc::Config::new().get_compiler();
Expand Down
3 changes: 3 additions & 0 deletions src/rustc/libc_shim/build.rs
Expand Up @@ -8,8 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

// See comments in Cargo.toml for why this exists

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

0 comments on commit 8d65591

Please sign in to comment.