This changes it so that only top-level targets requested on the command-line will be included in the output directory. Dependencies are no longer included.
Fixes #5444.
pub(super) host: Layout,
/// The target directory layout for the target (if different from then host)
pub(super) target: Option<Layout>,
- export_dir: Option<(PathBuf, Vec<Unit<'a>>)>,
+ /// Additional directory to include a copy of the outputs.
+ export_dir: Option<PathBuf>,
+ /// The root targets requested by the user on the command line (does not
+ /// include dependencies).
+ roots: Vec<Unit<'a>>,
ws: &'a Workspace<'cfg>,
metas: HashMap<Unit<'a>, Option<Metadata>>,
/// For each Unit, a list all files produced.
ws,
host,
target,
- export_dir: export_dir.map(|dir| (dir, roots.to_vec())),
+ export_dir,
+ roots: roots.to_vec(),
metas,
outputs,
}
}
pub fn export_dir(&self, unit: &Unit<'a>) -> Option<PathBuf> {
- let &(ref dir, ref roots) = self.export_dir.as_ref()?;
- if roots.contains(unit) {
- Some(dir.clone())
+ if self.roots.contains(unit) {
+ self.export_dir.clone()
} else {
None
}
// we don't want to link it up.
if out_dir.ends_with("deps") {
// Don't lift up library dependencies
- if self.ws.members().find(|&p| p == unit.pkg).is_none() && !unit.target.is_bin() {
- None
- } else {
+ if self.roots.contains(unit) {
Some((
out_dir.parent().unwrap().to_owned(),
if unit.mode.is_any_test() {
bin_stem
},
))
+ } else {
+ None
}
} else if bin_stem == file_stem {
None
p.cargo("check").arg("--test").arg("t1"),
execs().with_status(0),
);
- assert_that(&p.root().join("target/debug/libfoo.rmeta"), existing_file());
+ assert_that(
+ &p.root().join("target/debug/libfoo.rmeta"),
+ is_not(existing_file()),
+ );
assert_that(
&p.root().join("target/debug/libfoo.rlib"),
is_not(existing_file()),
p.cargo("check").arg("--example").arg("ex1"),
execs().with_status(0),
);
- assert_that(&p.root().join("target/debug/libfoo.rmeta"), existing_file());
+ assert_that(
+ &p.root().join("target/debug/libfoo.rmeta"),
+ is_not(existing_file()),
+ );
assert_that(
&p.root().join("target/debug/libfoo.rlib"),
is_not(existing_file()),
p.cargo("check").arg("--bench").arg("b1"),
execs().with_status(0),
);
- assert_that(&p.root().join("target/debug/libfoo.rmeta"), existing_file());
+ assert_that(
+ &p.root().join("target/debug/libfoo.rmeta"),
+ is_not(existing_file()),
+ );
assert_that(
&p.root().join("target/debug/libfoo.rlib"),
is_not(existing_file()),
use cargo::util::process;
use cargotest::sleep_ms;
use cargotest::support::paths::{self, CargoPathExt};
-use cargotest::support::{execs, main_file, project};
use cargotest::support::registry::Package;
-use hamcrest::{assert_that, existing_file};
+use cargotest::support::{execs, main_file, project};
+use hamcrest::{assert_that, existing_file, is_not};
#[test]
#[cfg(not(windows))] // I have no idea why this is failing spuriously on
assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.root().join("target/debug/libtop.rlib"), existing_file());
- assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());
+ assert_that(
+ &p.root().join("target/debug/libfoo.rlib"),
+ is_not(existing_file()),
+ );
}
#[test]