);
}
+macro_rules! std {
+ ($host:ident => $target:ident, stage = $stage:literal) => {
+ compile::Std::new(
+ Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },
+ TargetSelection::from_user(stringify!($target)),
+ )
+ };
+}
+
+macro_rules! rustc {
+ ($host:ident => $target:ident, stage = $stage:literal) => {
+ compile::Rustc::new(
+ Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },
+ TargetSelection::from_user(stringify!($target)),
+ )
+ };
+}
+
#[test]
fn test_valid() {
// make sure multi suite paths are accepted
assert!(run_build(&[path], config).contains::<tool::CargoTest>());
}
+/// Ensure that if someone passes both a single crate and `library`, all library crates get built.
+#[test]
+fn alias_and_path_for_library() {
+ let mut cache =
+ run_build(&["library".into(), "core".into()], configure("build", &["A"], &["A"]));
+ assert_eq!(
+ first(cache.all::<compile::Std>()),
+ &[std!(A => A, stage = 0), std!(A => A, stage = 1)]
+ );
+}
+
mod defaults {
use super::{configure, first, run_build};
use crate::builder::*;
let a = TargetSelection::from_user("A");
assert_eq!(
first(cache.all::<compile::Std>()),
- &[
- compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
- ]
+ &[std!(A => A, stage = 0), std!(A => A, stage = 1),]
);
assert!(!cache.all::<compile::Assemble>().is_empty());
// Make sure rustdoc is only built once.
// - this is the compiler it's _linked_ to, not built with.
&[tool::Rustdoc { compiler: Compiler { host: a, stage: 1 } }],
);
- assert_eq!(
- first(cache.all::<compile::Rustc>()),
- &[compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },]
- );
+ assert_eq!(first(cache.all::<compile::Rustc>()), &[rustc!(A => A, stage = 0)],);
}
#[test]
let mut cache = run_build(&[], config);
let a = TargetSelection::from_user("A");
- assert_eq!(
- first(cache.all::<compile::Std>()),
- &[compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },]
- );
+ assert_eq!(first(cache.all::<compile::Std>()), &[std!(A => A, stage = 0)]);
assert!(!cache.all::<compile::Assemble>().is_empty());
assert_eq!(
first(cache.all::<tool::Rustdoc>()),
assert_eq!(
first(cache.all::<compile::Std>()),
&[
- compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 0 }, target: b },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
+ std!(A => A, stage = 0),
+ std!(A => A, stage = 1),
+ std!(A => B, stage = 0),
+ std!(A => B, stage = 1),
]
);
assert_eq!(
);
assert_eq!(
first(cache.all::<compile::Rustc>()),
- &[
- compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: b },
- ]
+ &[rustc!(A => A, stage = 0), rustc!(A => B, stage = 0),]
);
}
assert_eq!(
first(cache.all::<compile::Std>()),
&[
- compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },
+ std!(A => A, stage = 0),
+ std!(A => A, stage = 1),
+ std!(A => A, stage = 2),
+ std!(A => B, stage = 1),
+ std!(A => B, stage = 2),
],
);
assert_eq!(first(cache.all::<dist::Src>()), &[dist::Src]);
#[test]
fn dist_only_cross_host() {
- let a = TargetSelection::from_user("A");
let b = TargetSelection::from_user("B");
let mut config = configure(&["A", "B"], &["A", "B"]);
config.docs = false;
);
assert_eq!(
first(cache.all::<compile::Rustc>()),
- &[
- compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b },
- ]
+ &[rustc!(A => A, stage = 0), rustc!(A => B, stage = 1),]
);
}
assert_eq!(
first(cache.all::<compile::Std>()),
&[
- compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },
+ std!(A => A, stage = 0),
+ std!(A => A, stage = 1),
+ std!(A => A, stage = 2),
+ std!(A => B, stage = 1),
+ std!(A => B, stage = 2),
]
);
assert_eq!(
let mut builder = Builder::new(&build);
builder.run_step_descriptions(
&Builder::get_step_descriptions(Kind::Build),
- &["compiler/rustc".into(), "library/std".into()],
+ &["compiler/rustc".into(), "library".into()],
);
- let a = TargetSelection::from_user("A");
- let b = TargetSelection::from_user("B");
- let c = TargetSelection::from_user("C");
-
assert_eq!(
first(builder.cache.all::<compile::Std>()),
&[
- compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: b },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: b },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
+ std!(A => A, stage = 0),
+ std!(A => A, stage = 1),
+ std!(A => A, stage = 2),
+ std!(A => B, stage = 1),
+ std!(A => B, stage = 2),
+ std!(A => C, stage = 2),
]
);
- assert!(!builder.cache.all::<compile::Assemble>().is_empty());
+ assert_eq!(builder.cache.all::<compile::Assemble>().len(), 5);
assert_eq!(
first(builder.cache.all::<compile::Rustc>()),
&[
- compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a },
- compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: a },
- compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: b },
- compile::Rustc { compiler: Compiler { host: a, stage: 2 }, target: b },
+ rustc!(A => A, stage = 0),
+ rustc!(A => A, stage = 1),
+ rustc!(A => A, stage = 2),
+ rustc!(A => B, stage = 1),
+ rustc!(A => B, stage = 2),
]
);
}
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
let a = TargetSelection::from_user("A");
- let c = TargetSelection::from_user("C");
assert_eq!(
first(builder.cache.all::<compile::Std>()),
- &[
- compile::Std { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 1 }, target: a },
- compile::Std { compiler: Compiler { host: a, stage: 2 }, target: c },
- ]
+ &[std!(A => A, stage = 0), std!(A => A, stage = 1), std!(A => C, stage = 2),]
);
assert_eq!(
first(builder.cache.all::<compile::Assemble>()),
);
assert_eq!(
first(builder.cache.all::<compile::Rustc>()),
- &[
- compile::Rustc { compiler: Compiler { host: a, stage: 0 }, target: a },
- compile::Rustc { compiler: Compiler { host: a, stage: 1 }, target: a },
- ]
+ &[rustc!(A => A, stage = 0), rustc!(A => A, stage = 1),]
);
}