use std::fs::{self, File};
use std::path::{Path, PathBuf};
use std::process::Command;
+use std::env;
use build_helper::{output, mtime, up_to_date};
use filetime::FileTime;
build.clear_if_dirty(&out_dir, &build.compiler_path(compiler));
let mut cargo = build.cargo(compiler, Mode::Libstd, target, "build");
let mut features = build.std_features();
+
+ if let Ok(target) = env::var("MACOSX_STD_DEPLOYMENT_TARGET") {
+ cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
+ }
+
// When doing a local rebuild we tell cargo that we're stage1 rather than
// stage0. This works fine if the local rust and being-built rust have the
// same view of what the default allocator is, but fails otherwise. Since
let out_dir = build.cargo_out(compiler, Mode::Libtest, target);
build.clear_if_dirty(&out_dir, &libstd_stamp(build, compiler, target));
let mut cargo = build.cargo(compiler, Mode::Libtest, target, "build");
+ if let Ok(target) = env::var("MACOSX_STD_DEPLOYMENT_TARGET") {
+ cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
+ }
cargo.arg("--manifest-path")
.arg(build.src.join("src/libtest/Cargo.toml"));
build.run(&mut cargo);
cargo.env("CFG_LLVM_ROOT", s);
}
// Building with a static libstdc++ is only supported on linux right now,
- // not for MSVC or OSX
+ // not for MSVC or macOS
if build.config.llvm_static_stdcpp &&
!target.contains("windows") &&
!target.contains("apple") {
cargo.env("CFG_DEFAULT_AR", s);
}
build.run(&mut cargo);
+ update_mtime(build, &librustc_stamp(build, compiler, target));
}
/// Same as `std_link`, only for librustc
build.cargo_out(compiler, Mode::Libtest, target).join(".libtest.stamp")
}
+/// Cargo's output path for librustc in a given stage, compiled by a particular
+/// compiler for the specified target.
+fn librustc_stamp(build: &Build, compiler: &Compiler, target: &str) -> PathBuf {
+ build.cargo_out(compiler, Mode::Librustc, target).join(".librustc.stamp")
+}
+
fn compiler_file(compiler: &Path, file: &str) -> PathBuf {
let out = output(Command::new(compiler)
.arg(format!("-print-file-name={}", file)));
}
}
+/// Build a tool in `src/tools`
+///
+/// This will build the specified tool with the specified `host` compiler in
+/// `stage` into the normal cargo output directory.
+pub fn maybe_clean_tools(build: &Build, stage: u32, target: &str, mode: Mode) {
+ let compiler = Compiler::new(stage, &build.config.build);
+
+ let stamp = match mode {
+ Mode::Libstd => libstd_stamp(build, &compiler, target),
+ Mode::Libtest => libtest_stamp(build, &compiler, target),
+ Mode::Librustc => librustc_stamp(build, &compiler, target),
+ _ => panic!(),
+ };
+ let out_dir = build.cargo_out(&compiler, Mode::Tool, target);
+ build.clear_if_dirty(&out_dir, &stamp);
+}
+
/// Build a tool in `src/tools`
///
/// This will build the specified tool with the specified `host` compiler in
let compiler = Compiler::new(stage, &build.config.build);
- // FIXME: need to clear out previous tool and ideally deps, may require
- // isolating output directories or require a pseudo shim step to
- // clear out all the info.
- //
- // Maybe when libstd is compiled it should clear out the rustc of the
- // corresponding stage?
- // let out_dir = build.cargo_out(stage, &host, Mode::Librustc, target);
- // build.clear_if_dirty(&out_dir, &libstd_stamp(build, stage, &host, target));
-
let mut cargo = build.cargo(&compiler, Mode::Tool, target, "build");
- let dir = build.src.join("src/tools").join(tool);
+ let mut dir = build.src.join(tool);
+ if !dir.exists() {
+ dir = build.src.join("src/tools").join(tool);
+ }
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
// We don't want to build tools dynamically as they'll be running across