required_features_filterable: bool,
},
Only {
+ all_targets: bool,
lib: bool,
bins: FilterRule<'a>,
examples: FilterRule<'a>,
if all_targets {
CompileFilter::Only {
+ all_targets: true,
lib: true, bins: FilterRule::All,
examples: FilterRule::All, benches: FilterRule::All,
tests: FilterRule::All,
} else if lib_only || rule_bins.is_specific() || rule_tsts.is_specific()
|| rule_exms.is_specific() || rule_bens.is_specific() {
CompileFilter::Only {
+ all_targets: false,
lib: lib_only, bins: rule_bins,
examples: rule_exms, benches: rule_bens,
tests: rule_tsts,
pub fn matches(&self, target: &Target) -> bool {
match *self {
CompileFilter::Default { .. } => true,
- CompileFilter::Only { lib, bins, examples, tests, benches } => {
+ CompileFilter::Only { lib, bins, examples, tests, benches, .. } => {
let rule = match *target.kind() {
TargetKind::Bin => bins,
TargetKind::Test => tests,
};
generate_auto_targets(mode, pkg.targets(), profile, deps, required_features_filterable)
}
- CompileFilter::Only { lib, bins, examples, tests, benches } => {
+ CompileFilter::Only { all_targets, lib, bins, examples, tests, benches } => {
let mut targets = Vec::new();
if lib {
profile: profile,
required: true,
});
- } else {
+ } else if !all_targets {
bail!("no library targets found")
}
}
--emit=dep-info,link[..]")
);
}
+
+#[test]
+fn all_targets_no_lib() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .build();
+ assert_that(p.cargo("build").arg("-v").arg("--all-targets"),
+ execs().with_status(0)
+ // bin
+ .with_stderr_contains("\
+ [RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
+ --emit=dep-info,link[..]")
+ // bench
+ .with_stderr_contains("\
+ [RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
+ -C opt-level=3 --test [..]")
+ // unit test
+ .with_stderr_contains("\
+ [RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
+ -C debuginfo=2 --test [..]")
+ );
+}