Skip to content

Commit

Permalink
Minor build script improvements
Browse files Browse the repository at this point in the history
I agree to license my contributions to each file under the terms
given at the top of each file I changed.
  • Loading branch information
weiznich committed Feb 16, 2017
1 parent 7787e36 commit 1d2939f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,11 @@ libc = "0.2.20"
untrusted = "0.3.2"

[build-dependencies]
# we do not use the gcc parallel feature because we do the
# parallelism ourself. This gives us a much higher level of
# control about what should be parallised in which way
gcc = "0.3"
target_build_utils = "0.2"
target_build_utils = { version = "0.2", default-features = false }
rayon = "0.6"

[target.'cfg(any(target_os = "redox", all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies]
Expand Down
29 changes: 19 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// TODO: Deny `unused_qualifications` after
// https://github.com/rust-lang/rust/issues/37345 is fixed.
#![allow(
// TODO
missing_docs,
unused_qualifications)]
#![deny(
Expand Down Expand Up @@ -237,13 +236,14 @@ const RING_BUILD_FILE: &'static [&'static str] = &["build.rs"];

#[cfg_attr(rustfmt, rustfmt_skip)]
const C_FLAGS: &'static [&'static str] =
&["-std=c1x",
&["-std=c1x", // GCC 4.6 requires "c1x" instead of "c11"
"-Wbad-function-cast",
"-Wmissing-field-initializers",
"-Wmissing-prototypes",
"-Wnested-externs",
"-Wstrict-prototypes"];

// GCC 4.6 requires "c++0x" instead of "c++11"
const CXX_FLAGS: &'static [&'static str] = &["-std=c++0x"];

#[cfg_attr(rustfmt, rustfmt_skip)]
Expand Down Expand Up @@ -465,6 +465,7 @@ fn build_library<P>(target: &Path, additional: P,
header_changed: bool)
where P: ParallelIterator<Item = String>
{
// Compile all the (dirty) source files into object files.
let objs = additional.chain(lib_src.par_iter().map(|a| String::from(*a)))
.weight_max()
.map(|f| compile(&f, &target_info, out_dir.clone(), header_changed))
Expand All @@ -474,6 +475,8 @@ fn build_library<P>(target: &Path, additional: P,
a.extend(b.into_iter());
a
});

//Rebuild the library if necessary.
if objs.par_iter()
.map(|f| Path::new(f))
.any(|p| need_run(&p, target)) {
Expand Down Expand Up @@ -519,14 +522,6 @@ fn compile(file: &str, target_info: &TargetInfo, mut out_dir: PathBuf,
for f in CXX_FLAGS {
let _ = c.flag(f);
}
if target_info.target_os() != "none" {
let _ = c.flag("-fstack-protector");
}
let _ = match (target_info.target_os(),
target_info.target_arch()) {
("macos", _) => c.flag("-gfull"),
_ => c.flag("-g3"),
};
let _ = c.cpp(true);
},
Some(Some("S")) => {},
Expand All @@ -535,6 +530,20 @@ fn compile(file: &str, target_info: &TargetInfo, mut out_dir: PathBuf,
for f in CPP_FLAGS {
let _ = c.flag(&f);
}
if target_info.target_os() != "none" &&
target_info.target_os() != "redox" {
let _ = c.flag("-fstack-protector");
}
let _ = match (target_info.target_os(), target_info.target_arch()) {
// ``-gfull`` is required for Darwin's |-dead_strip|.
("macos", _) => c.flag("-gfull"),
_ => c.flag("-g3"),
};
if env::var("OPT_LEVEL").unwrap() == "0" {
let _ = c.define("DEBUG", None);
} else {
let _ = c.define("NDEBUG", None);
}
let mut c = c.get_compiler().to_command();
let _ = c.arg("-c")
.arg("-o")
Expand Down
1 change: 0 additions & 1 deletion mk/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ fi

$CC_X --version
$CXX_X --version
make --version

cargo version
rustc --version
Expand Down

0 comments on commit 1d2939f

Please sign in to comment.