about summary refs log tree commit diff
path: root/src/liballoc_jemalloc
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2017-02-01 00:27:51 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2017-02-02 22:40:42 +0300
commita5b603b1bf1e9d74227a8a3b2f73acd558b952ef (patch)
treeff9d004f3566a87c49ca157f778e40007625c993 /src/liballoc_jemalloc
parentc0253304ea9d40103dc7d1055b7fa090b48781f8 (diff)
downloadrust-a5b603b1bf1e9d74227a8a3b2f73acd558b952ef.tar.gz
rust-a5b603b1bf1e9d74227a8a3b2f73acd558b952ef.zip
Build libbacktrace/jemalloc only when their timestamps are older than sources
Diffstat (limited to 'src/liballoc_jemalloc')
-rw-r--r--src/liballoc_jemalloc/build.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs
index c982f98e63d..7e616c0ff27 100644
--- a/src/liballoc_jemalloc/build.rs
+++ b/src/liballoc_jemalloc/build.rs
@@ -10,13 +10,15 @@
 
 #![deny(warnings)]
 
+#[macro_use]
 extern crate build_helper;
 extern crate gcc;
 
-use std::{env, fs};
-use std::path::PathBuf;
+use std::env;
+use std::fs::{self, File};
+use std::path::{Path, PathBuf};
 use std::process::Command;
-use build_helper::{run, rerun_if_changed_anything_in_dir};
+use build_helper::{run, rerun_if_changed_anything_in_dir, up_to_date};
 
 fn main() {
     println!("cargo:rustc-cfg=cargobuild");
@@ -69,12 +71,13 @@ fn main() {
     } else if !target.contains("windows") && !target.contains("musl") {
         println!("cargo:rustc-link-lib=pthread");
     }
-    if !cfg!(stage0) && target == host {
+    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"), &timestamp) && up_to_date(&src_dir, &timestamp) {
         return
     }
 
-    let src_dir = env::current_dir().unwrap().join("../jemalloc");
-    rerun_if_changed_anything_in_dir(&src_dir);
     let compiler = gcc::Config::new().get_compiler();
     // only msvc returns None for ar so unwrap is okay
     let ar = build_helper::cc2ar(compiler.path(), &target).unwrap();
@@ -184,4 +187,6 @@ fn main() {
             .file("pthread_atfork_dummy.c")
             .compile("libpthread_atfork_dummy.a");
     }
+
+    t!(File::create(&timestamp));
 }