diff --git a/Cargo.toml b/Cargo.toml index bfe450c60887..d674cc10d3ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ license = "MIT/Apache-2.0" name = "miri" repository = "https://github.com/solson/miri" version = "0.1.0" +build = "build.rs" [[bin]] doc = false diff --git a/build.rs b/build.rs new file mode 100644 index 000000000000..86ccf3cda1ab --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +use std::env; + +fn main() { + // Forward the profile to the main compilation + println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap()); +} diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 0f8865864ce3..c7e6149723d6 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -13,16 +13,15 @@ macro_rules! eprintln { } } -#[cfg(debug_assertions)] -const MIRI_PATH: &str = "target/debug/miri"; -#[cfg(not(debug_assertions))] -const MIRI_PATH: &str = "target/release/miri"; +fn miri_path() -> String { + format!("target/{}/miri", env!("PROFILE")) +} fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: bool) { eprintln!("## Running compile-fail tests in {} against miri for target {}", path, target); let mut config = compiletest::default_config(); config.mode = "compile-fail".parse().expect("Invalid mode"); - config.rustc_path = MIRI_PATH.into(); + config.rustc_path = miri_path().into(); if fullmir { if host != target { // skip fullmir on nonhost @@ -61,7 +60,7 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) { config.src_base = PathBuf::from(path); config.target = target.to_owned(); config.host = host.to_owned(); - config.rustc_path = MIRI_PATH.into(); + config.rustc_path = miri_path().into(); let mut flags = Vec::new(); if fullmir { if host != target {