From a5b603b1bf1e9d74227a8a3b2f73acd558b952ef Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 1 Feb 2017 00:27:51 +0300 Subject: Build libbacktrace/jemalloc only when their timestamps are older than sources --- src/liballoc_jemalloc/build.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/liballoc_jemalloc') 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"), ×tamp) && up_to_date(&src_dir, ×tamp) { 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(×tamp)); } -- cgit 1.4.1-3-g733a5