From f2187093f8d19c39071502c9e95bacabd5febd88 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 23 Feb 2017 18:49:54 +0300 Subject: Add/remove `rerun-if-changed` when necessary --- src/liballoc_jemalloc/build.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/liballoc_jemalloc') diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index a3402bf3994..cd2e8e4ec20 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -21,8 +21,6 @@ use std::process::Command; use build_helper::{run, rerun_if_changed_anything_in_dir, up_to_date}; fn main() { - println!("cargo:rerun-if-changed=build.rs"); - // FIXME: This is a hack to support building targets that don't // support jemalloc alongside hosts that do. The jemalloc build is // controlled by a feature of the std crate, and if that feature -- cgit 1.4.1-3-g733a5 From aeadc81ddcf25df677f75d781aa2ec9d732bb6f4 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 3 Mar 2017 02:15:56 +0300 Subject: Build compiler-rt and sanitizers only once --- src/build_helper/lib.rs | 37 +++++++++++++++++++++++++++++++++++- src/liballoc_jemalloc/build.rs | 40 +++++++++++++++------------------------ src/libcompiler_builtins/build.rs | 16 ++++++++++++---- src/librustc_asan/build.rs | 21 +++++++++++--------- src/librustc_lsan/build.rs | 21 +++++++++++--------- src/librustc_msan/build.rs | 21 +++++++++++--------- src/librustc_tsan/build.rs | 21 +++++++++++--------- src/libstd/build.rs | 32 ++++++++++++------------------- 8 files changed, 123 insertions(+), 86 deletions(-) (limited to 'src/liballoc_jemalloc') diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 08f1f31c2d7..2aac5ba6a10 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -12,7 +12,7 @@ extern crate filetime; -use std::fs; +use std::{fs, env}; use std::process::{Command, Stdio}; use std::path::{Path, PathBuf}; @@ -166,6 +166,41 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool { } } +pub struct NativeLibBoilerplate { + pub skip_build: bool, + pub src_dir: PathBuf, + pub out_dir: PathBuf, + pub timestamp: PathBuf, +} + +pub fn native_lib_boilerplate(src_name: &str, + out_name: &str, + link_name: &str, + timestamp_name: &str, + search_subdir: &str) + -> NativeLibBoilerplate { + let current_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + let src_dir = current_dir.join("..").join(src_name); + rerun_if_changed_anything_in_dir(&src_dir); + + let out_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or(env::var_os("OUT_DIR").unwrap()); + let out_dir = PathBuf::from(out_dir).join(out_name); + let _ = fs::create_dir_all(&out_dir); + println!("cargo:rustc-link-lib=static={}", link_name); + println!("cargo:rustc-link-search=native={}", out_dir.join(search_subdir).display()); + + let timestamp = out_dir.join(timestamp_name); + let skip_build = up_to_date(Path::new("build.rs"), ×tamp) && + up_to_date(&src_dir, ×tamp); + + NativeLibBoilerplate { + skip_build: skip_build, + src_dir: src_dir, + out_dir: out_dir, + timestamp: timestamp, + } +} + fn dir_up_to_date(src: &Path, threshold: &FileTime) -> bool { t!(fs::read_dir(src)).map(|e| t!(e)).all(|e| { let meta = t!(e.metadata()); diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index cd2e8e4ec20..cc1e74ccbbf 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -15,10 +15,10 @@ extern crate build_helper; extern crate gcc; use std::env; -use std::fs::{self, File}; -use std::path::{Path, PathBuf}; +use std::fs::File; +use std::path::PathBuf; use std::process::Command; -use build_helper::{run, rerun_if_changed_anything_in_dir, up_to_date}; +use build_helper::{run, native_lib_boilerplate}; fn main() { // FIXME: This is a hack to support building targets that don't @@ -59,20 +59,10 @@ fn main() { return; } - let build_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or(env::var_os("OUT_DIR").unwrap()); - let build_dir = PathBuf::from(build_dir).join("jemalloc"); - let _ = fs::create_dir_all(&build_dir); - - if target.contains("windows") { - println!("cargo:rustc-link-lib=static=jemalloc"); - } else { - println!("cargo:rustc-link-lib=static=jemalloc_pic"); - } - println!("cargo:rustc-link-search=native={}/lib", build_dir.display()); - let src_dir = env::current_dir().unwrap().join("../jemalloc"); - rerun_if_changed_anything_in_dir(&src_dir); - let timestamp = build_dir.join("rustbuild.timestamp"); - if up_to_date(&Path::new("build.rs"), ×tamp) && up_to_date(&src_dir, ×tamp) { + let link_name = if target.contains("windows") { "jemalloc" } else { "jemalloc_pic" }; + let native = native_lib_boilerplate("jemalloc", "jemalloc", link_name, + "rustbuild.timestamp", "lib"); + if native.skip_build { return } @@ -86,12 +76,12 @@ fn main() { .join(" "); let mut cmd = Command::new("sh"); - cmd.arg(src_dir.join("configure") - .to_str() - .unwrap() - .replace("C:\\", "/c/") - .replace("\\", "/")) - .current_dir(&build_dir) + cmd.arg(native.src_dir.join("configure") + .to_str() + .unwrap() + .replace("C:\\", "/c/") + .replace("\\", "/")) + .current_dir(&native.out_dir) .env("CC", compiler.path()) .env("EXTRA_CFLAGS", cflags.clone()) // jemalloc generates Makefile deps using GCC's "-MM" flag. This means @@ -164,7 +154,7 @@ fn main() { run(&mut cmd); let mut make = Command::new(build_helper::make(&host)); - make.current_dir(&build_dir) + make.current_dir(&native.out_dir) .arg("build_lib_static"); // mingw make seems... buggy? unclear... @@ -186,5 +176,5 @@ fn main() { .compile("libpthread_atfork_dummy.a"); } - t!(File::create(×tamp)); + t!(File::create(&native.timestamp)); } diff --git a/src/libcompiler_builtins/build.rs b/src/libcompiler_builtins/build.rs index 564404ca71d..ff5111a15be 100644 --- a/src/libcompiler_builtins/build.rs +++ b/src/libcompiler_builtins/build.rs @@ -39,6 +39,7 @@ extern crate gcc; use std::collections::BTreeMap; use std::env; use std::path::Path; +use build_helper::native_lib_boilerplate; struct Sources { // SYMBOL -> PATH TO SOURCE @@ -80,7 +81,17 @@ fn main() { return; } + // Can't reuse `sources` list for the freshness check becuse it doesn't contain header files. + // Use the produced library itself as a timestamp. + let out_name = "libcompiler-rt.a"; + let native = native_lib_boilerplate("compiler-rt", "compiler-rt", "compiler-rt", + out_name, "."); + if native.skip_build { + return + } + let cfg = &mut gcc::Config::new(); + cfg.out_dir(native.out_dir); if target.contains("msvc") { // Don't pull in extra libraries on MSVC @@ -405,8 +416,5 @@ fn main() { cfg.file(Path::new("../compiler-rt/lib/builtins").join(src)); } - // Can't reuse `sources` list becuse it doesn't contain header files. - build_helper::rerun_if_changed_anything_in_dir(Path::new("../compiler-rt")); - - cfg.compile("libcompiler-rt.a"); + cfg.compile(out_name); } diff --git a/src/librustc_asan/build.rs b/src/librustc_asan/build.rs index 3e95e0dbebe..4772d145775 100644 --- a/src/librustc_asan/build.rs +++ b/src/librustc_asan/build.rs @@ -8,30 +8,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[macro_use] extern crate build_helper; extern crate cmake; -use std::path::PathBuf; use std::env; +use std::fs::File; +use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let dst = Config::new("../compiler-rt") + let native = native_lib_boilerplate("compiler-rt", "asan", "clang_rt.asan-x86_64", + "rustbuild.timestamp", "build/lib/linux"); + if native.skip_build { + return + } + + Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") .define("COMPILER_RT_BUILD_BUILTINS", "OFF") .define("COMPILER_RT_BUILD_XRAY", "OFF") .define("LLVM_CONFIG_PATH", llvm_config) + .out_dir(&native.out_dir) .build_target("asan") .build(); - println!("cargo:rustc-link-search=native={}", - dst.join("build/lib/linux").display()); - println!("cargo:rustc-link-lib=static=clang_rt.asan-x86_64"); - - build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR") - .unwrap()) - .join("../compiler-rt")); + t!(File::create(&native.timestamp)); } } diff --git a/src/librustc_lsan/build.rs b/src/librustc_lsan/build.rs index ec968f51184..b71493db49a 100644 --- a/src/librustc_lsan/build.rs +++ b/src/librustc_lsan/build.rs @@ -8,30 +8,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[macro_use] extern crate build_helper; extern crate cmake; -use std::path::PathBuf; use std::env; +use std::fs::File; +use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let dst = Config::new("../compiler-rt") + let native = native_lib_boilerplate("compiler-rt", "lsan", "clang_rt.lsan-x86_64", + "rustbuild.timestamp", "build/lib/linux"); + if native.skip_build { + return + } + + Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") .define("COMPILER_RT_BUILD_BUILTINS", "OFF") .define("COMPILER_RT_BUILD_XRAY", "OFF") .define("LLVM_CONFIG_PATH", llvm_config) + .out_dir(&native.out_dir) .build_target("lsan") .build(); - println!("cargo:rustc-link-search=native={}", - dst.join("build/lib/linux").display()); - println!("cargo:rustc-link-lib=static=clang_rt.lsan-x86_64"); - - build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR") - .unwrap()) - .join("../compiler-rt")); + t!(File::create(&native.timestamp)); } } diff --git a/src/librustc_msan/build.rs b/src/librustc_msan/build.rs index 466fa641dea..07c4e807e7b 100644 --- a/src/librustc_msan/build.rs +++ b/src/librustc_msan/build.rs @@ -8,30 +8,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[macro_use] extern crate build_helper; extern crate cmake; -use std::path::PathBuf; use std::env; +use std::fs::File; +use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let dst = Config::new("../compiler-rt") + let native = native_lib_boilerplate("compiler-rt", "msan", "clang_rt.msan-x86_64", + "rustbuild.timestamp", "build/lib/linux"); + if native.skip_build { + return + } + + Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") .define("COMPILER_RT_BUILD_BUILTINS", "OFF") .define("COMPILER_RT_BUILD_XRAY", "OFF") .define("LLVM_CONFIG_PATH", llvm_config) + .out_dir(&native.out_dir) .build_target("msan") .build(); - println!("cargo:rustc-link-search=native={}", - dst.join("build/lib/linux").display()); - println!("cargo:rustc-link-lib=static=clang_rt.msan-x86_64"); - - build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR") - .unwrap()) - .join("../compiler-rt")); + t!(File::create(&native.timestamp)); } } diff --git a/src/librustc_tsan/build.rs b/src/librustc_tsan/build.rs index 95ce237b267..3bd30fd203c 100644 --- a/src/librustc_tsan/build.rs +++ b/src/librustc_tsan/build.rs @@ -8,30 +8,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[macro_use] extern crate build_helper; extern crate cmake; -use std::path::PathBuf; use std::env; +use std::fs::File; +use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let dst = Config::new("../compiler-rt") + let native = native_lib_boilerplate("compiler-rt", "tsan", "clang_rt.tsan-x86_64", + "rustbuild.timestamp", "build/lib/linux"); + if native.skip_build { + return + } + + Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") .define("COMPILER_RT_BUILD_BUILTINS", "OFF") .define("COMPILER_RT_BUILD_XRAY", "OFF") .define("LLVM_CONFIG_PATH", llvm_config) + .out_dir(&native.out_dir) .build_target("tsan") .build(); - println!("cargo:rustc-link-search=native={}", - dst.join("build/lib/linux").display()); - println!("cargo:rustc-link-lib=static=clang_rt.tsan-x86_64"); - - build_helper::rerun_if_changed_anything_in_dir(&PathBuf::from(env::var("CARGO_MANIFEST_DIR") - .unwrap()) - .join("../compiler-rt")); + t!(File::create(&native.timestamp)); } } diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 834e3d09211..ef1d3c84f2a 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -15,10 +15,9 @@ extern crate build_helper; extern crate gcc; use std::env; -use std::fs::{self, File}; -use std::path::{Path, PathBuf}; +use std::fs::File; use std::process::Command; -use build_helper::{run, rerun_if_changed_anything_in_dir, up_to_date}; +use build_helper::{run, native_lib_boilerplate}; fn main() { let target = env::var("TARGET").expect("TARGET was not set"); @@ -68,16 +67,9 @@ fn main() { } fn build_libbacktrace(host: &str, target: &str) { - let build_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or(env::var_os("OUT_DIR").unwrap()); - let build_dir = PathBuf::from(build_dir).join("libbacktrace"); - let _ = fs::create_dir_all(&build_dir); - - println!("cargo:rustc-link-lib=static=backtrace"); - println!("cargo:rustc-link-search=native={}/.libs", build_dir.display()); - let src_dir = env::current_dir().unwrap().join("../libbacktrace"); - rerun_if_changed_anything_in_dir(&src_dir); - let timestamp = build_dir.join("rustbuild.timestamp"); - if up_to_date(&Path::new("build.rs"), ×tamp) && up_to_date(&src_dir, ×tamp) { + let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", + "rustbuild.timestamp", ".libs"); + if native.skip_build { return } @@ -88,10 +80,10 @@ fn build_libbacktrace(host: &str, target: &str) { .collect::>().join(" "); cflags.push_str(" -fvisibility=hidden"); run(Command::new("sh") - .current_dir(&build_dir) - .arg(src_dir.join("configure").to_str().unwrap() - .replace("C:\\", "/c/") - .replace("\\", "/")) + .current_dir(&native.out_dir) + .arg(native.src_dir.join("configure").to_str().unwrap() + .replace("C:\\", "/c/") + .replace("\\", "/")) .arg("--with-pic") .arg("--disable-multilib") .arg("--disable-shared") @@ -104,9 +96,9 @@ fn build_libbacktrace(host: &str, target: &str) { .env("CFLAGS", cflags)); run(Command::new(build_helper::make(host)) - .current_dir(&build_dir) - .arg(format!("INCDIR={}", src_dir.display())) + .current_dir(&native.out_dir) + .arg(format!("INCDIR={}", native.src_dir.display())) .arg("-j").arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set"))); - t!(File::create(×tamp)); + t!(File::create(&native.timestamp)); } -- cgit 1.4.1-3-g733a5 From 428f063fcdc35e048ff79d059a8963334ba2281c Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 3 Mar 2017 20:11:04 +0300 Subject: Automate timestamp creation and build skipping for native libraries Add comments --- src/Cargo.lock | 4 ++-- src/build_helper/lib.rs | 33 ++++++++++++++++++++------------- src/liballoc_jemalloc/build.rs | 13 ++++--------- src/libcompiler_builtins/build.rs | 15 ++++++--------- src/librustc_asan/build.rs | 14 +++++--------- src/librustc_lsan/build.rs | 14 +++++--------- src/librustc_msan/build.rs | 14 +++++--------- src/librustc_tsan/build.rs | 14 +++++--------- src/libstd/build.rs | 15 ++++----------- 9 files changed, 56 insertions(+), 80 deletions(-) (limited to 'src/liballoc_jemalloc') diff --git a/src/Cargo.lock b/src/Cargo.lock index aa4d65de0ac..f4174693a57 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -487,7 +487,7 @@ name = "libgit2-sys" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "curl-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.43 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -502,7 +502,7 @@ name = "libssh2-sys" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.7 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 2aac5ba6a10..dffaebbd929 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -13,6 +13,7 @@ extern crate filetime; use std::{fs, env}; +use std::fs::File; use std::process::{Command, Stdio}; use std::path::{Path, PathBuf}; @@ -166,19 +167,29 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool { } } +#[must_use] pub struct NativeLibBoilerplate { - pub skip_build: bool, pub src_dir: PathBuf, pub out_dir: PathBuf, - pub timestamp: PathBuf, } +impl Drop for NativeLibBoilerplate { + fn drop(&mut self) { + t!(File::create(self.out_dir.join("rustbuild.timestamp"))); + } +} + +// Perform standard preparations for native libraries that are build only once for all stages. +// Emit rerun-if-changed and linking attributes for Cargo, check if any source files are +// updated, calculate paths used later in actual build with CMake/make or C/C++ compiler. +// If Err is returned, then everything is up-to-date and further build actions can be skipped. +// Timestamps are created automatically when the result of `native_lib_boilerplate` goes out +// of scope, so all the build actions should be completed until then. pub fn native_lib_boilerplate(src_name: &str, out_name: &str, link_name: &str, - timestamp_name: &str, search_subdir: &str) - -> NativeLibBoilerplate { + -> Result { let current_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let src_dir = current_dir.join("..").join(src_name); rerun_if_changed_anything_in_dir(&src_dir); @@ -189,15 +200,11 @@ pub fn native_lib_boilerplate(src_name: &str, println!("cargo:rustc-link-lib=static={}", link_name); println!("cargo:rustc-link-search=native={}", out_dir.join(search_subdir).display()); - let timestamp = out_dir.join(timestamp_name); - let skip_build = up_to_date(Path::new("build.rs"), ×tamp) && - up_to_date(&src_dir, ×tamp); - - NativeLibBoilerplate { - skip_build: skip_build, - src_dir: src_dir, - out_dir: out_dir, - timestamp: timestamp, + let timestamp = out_dir.join("rustbuild.timestamp"); + if !up_to_date(Path::new("build.rs"), ×tamp) || !up_to_date(&src_dir, ×tamp) { + Ok(NativeLibBoilerplate { src_dir: src_dir, out_dir: out_dir }) + } else { + Err(()) } } diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs index cc1e74ccbbf..ae040a23906 100644 --- a/src/liballoc_jemalloc/build.rs +++ b/src/liballoc_jemalloc/build.rs @@ -10,12 +10,10 @@ #![deny(warnings)] -#[macro_use] extern crate build_helper; extern crate gcc; use std::env; -use std::fs::File; use std::path::PathBuf; use std::process::Command; use build_helper::{run, native_lib_boilerplate}; @@ -60,11 +58,10 @@ fn main() { } let link_name = if target.contains("windows") { "jemalloc" } else { "jemalloc_pic" }; - let native = native_lib_boilerplate("jemalloc", "jemalloc", link_name, - "rustbuild.timestamp", "lib"); - if native.skip_build { - return - } + let native = match native_lib_boilerplate("jemalloc", "jemalloc", link_name, "lib") { + Ok(native) => native, + _ => return, + }; let compiler = gcc::Config::new().get_compiler(); // only msvc returns None for ar so unwrap is okay @@ -175,6 +172,4 @@ fn main() { .file("pthread_atfork_dummy.c") .compile("libpthread_atfork_dummy.a"); } - - t!(File::create(&native.timestamp)); } diff --git a/src/libcompiler_builtins/build.rs b/src/libcompiler_builtins/build.rs index ff5111a15be..bcd3a92dd43 100644 --- a/src/libcompiler_builtins/build.rs +++ b/src/libcompiler_builtins/build.rs @@ -82,16 +82,13 @@ fn main() { } // Can't reuse `sources` list for the freshness check becuse it doesn't contain header files. - // Use the produced library itself as a timestamp. - let out_name = "libcompiler-rt.a"; - let native = native_lib_boilerplate("compiler-rt", "compiler-rt", "compiler-rt", - out_name, "."); - if native.skip_build { - return - } + let native = match native_lib_boilerplate("compiler-rt", "compiler-rt", "compiler-rt", ".") { + Ok(native) => native, + _ => return, + }; let cfg = &mut gcc::Config::new(); - cfg.out_dir(native.out_dir); + cfg.out_dir(&native.out_dir); if target.contains("msvc") { // Don't pull in extra libraries on MSVC @@ -416,5 +413,5 @@ fn main() { cfg.file(Path::new("../compiler-rt/lib/builtins").join(src)); } - cfg.compile(out_name); + cfg.compile("libcompiler-rt.a"); } diff --git a/src/librustc_asan/build.rs b/src/librustc_asan/build.rs index 4772d145775..2df2e001e6f 100644 --- a/src/librustc_asan/build.rs +++ b/src/librustc_asan/build.rs @@ -8,23 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[macro_use] extern crate build_helper; extern crate cmake; use std::env; -use std::fs::File; use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let native = native_lib_boilerplate("compiler-rt", "asan", "clang_rt.asan-x86_64", - "rustbuild.timestamp", "build/lib/linux"); - if native.skip_build { - return - } + let native = match native_lib_boilerplate("compiler-rt", "asan", "clang_rt.asan-x86_64", + "build/lib/linux") { + Ok(native) => native, + _ => return, + }; Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") @@ -34,7 +32,5 @@ fn main() { .out_dir(&native.out_dir) .build_target("asan") .build(); - - t!(File::create(&native.timestamp)); } } diff --git a/src/librustc_lsan/build.rs b/src/librustc_lsan/build.rs index b71493db49a..005163f4102 100644 --- a/src/librustc_lsan/build.rs +++ b/src/librustc_lsan/build.rs @@ -8,23 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[macro_use] extern crate build_helper; extern crate cmake; use std::env; -use std::fs::File; use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let native = native_lib_boilerplate("compiler-rt", "lsan", "clang_rt.lsan-x86_64", - "rustbuild.timestamp", "build/lib/linux"); - if native.skip_build { - return - } + let native = match native_lib_boilerplate("compiler-rt", "lsan", "clang_rt.lsan-x86_64", + "build/lib/linux") { + Ok(native) => native, + _ => return, + }; Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") @@ -34,7 +32,5 @@ fn main() { .out_dir(&native.out_dir) .build_target("lsan") .build(); - - t!(File::create(&native.timestamp)); } } diff --git a/src/librustc_msan/build.rs b/src/librustc_msan/build.rs index 07c4e807e7b..c438b525046 100644 --- a/src/librustc_msan/build.rs +++ b/src/librustc_msan/build.rs @@ -8,23 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[macro_use] extern crate build_helper; extern crate cmake; use std::env; -use std::fs::File; use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let native = native_lib_boilerplate("compiler-rt", "msan", "clang_rt.msan-x86_64", - "rustbuild.timestamp", "build/lib/linux"); - if native.skip_build { - return - } + let native = match native_lib_boilerplate("compiler-rt", "msan", "clang_rt.msan-x86_64", + "build/lib/linux") { + Ok(native) => native, + _ => return, + }; Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") @@ -34,7 +32,5 @@ fn main() { .out_dir(&native.out_dir) .build_target("msan") .build(); - - t!(File::create(&native.timestamp)); } } diff --git a/src/librustc_tsan/build.rs b/src/librustc_tsan/build.rs index 3bd30fd203c..055b344d2e9 100644 --- a/src/librustc_tsan/build.rs +++ b/src/librustc_tsan/build.rs @@ -8,23 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[macro_use] extern crate build_helper; extern crate cmake; use std::env; -use std::fs::File; use build_helper::native_lib_boilerplate; use cmake::Config; fn main() { if let Some(llvm_config) = env::var_os("LLVM_CONFIG") { - let native = native_lib_boilerplate("compiler-rt", "tsan", "clang_rt.tsan-x86_64", - "rustbuild.timestamp", "build/lib/linux"); - if native.skip_build { - return - } + let native = match native_lib_boilerplate("compiler-rt", "tsan", "clang_rt.tsan-x86_64", + "build/lib/linux") { + Ok(native) => native, + _ => return, + }; Config::new(&native.src_dir) .define("COMPILER_RT_BUILD_SANITIZERS", "ON") @@ -34,7 +32,5 @@ fn main() { .out_dir(&native.out_dir) .build_target("tsan") .build(); - - t!(File::create(&native.timestamp)); } } diff --git a/src/libstd/build.rs b/src/libstd/build.rs index ef1d3c84f2a..9fb83ad7598 100644 --- a/src/libstd/build.rs +++ b/src/libstd/build.rs @@ -10,12 +10,10 @@ #![deny(warnings)] -#[macro_use] extern crate build_helper; extern crate gcc; use std::env; -use std::fs::File; use std::process::Command; use build_helper::{run, native_lib_boilerplate}; @@ -24,7 +22,7 @@ fn main() { let host = env::var("HOST").expect("HOST was not set"); if cfg!(feature = "backtrace") && !target.contains("apple") && !target.contains("msvc") && !target.contains("emscripten") && !target.contains("fuchsia") && !target.contains("redox") { - build_libbacktrace(&host, &target); + let _ = build_libbacktrace(&host, &target); } if target.contains("linux") { @@ -66,12 +64,8 @@ fn main() { } } -fn build_libbacktrace(host: &str, target: &str) { - let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", - "rustbuild.timestamp", ".libs"); - if native.skip_build { - return - } +fn build_libbacktrace(host: &str, target: &str) -> Result<(), ()> { + let native = native_lib_boilerplate("libbacktrace", "libbacktrace", "backtrace", ".libs")?; let compiler = gcc::Config::new().get_compiler(); // only msvc returns None for ar so unwrap is okay @@ -99,6 +93,5 @@ fn build_libbacktrace(host: &str, target: &str) { .current_dir(&native.out_dir) .arg(format!("INCDIR={}", native.src_dir.display())) .arg("-j").arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set"))); - - t!(File::create(&native.timestamp)); + Ok(()) } -- cgit 1.4.1-3-g733a5