diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-03-03 02:15:56 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-03-04 21:38:26 +0300 |
| commit | aeadc81ddcf25df677f75d781aa2ec9d732bb6f4 (patch) | |
| tree | d209490ee1c2b510925e19c754ce4b521653c240 /src/liballoc_jemalloc | |
| parent | a7c8afd28d45018f3c3af9dec569c36bd4dea10a (diff) | |
| download | rust-aeadc81ddcf25df677f75d781aa2ec9d732bb6f4.tar.gz rust-aeadc81ddcf25df677f75d781aa2ec9d732bb6f4.zip | |
Build compiler-rt and sanitizers only once
Diffstat (limited to 'src/liballoc_jemalloc')
| -rw-r--r-- | src/liballoc_jemalloc/build.rs | 40 |
1 files changed, 15 insertions, 25 deletions
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)); } |
