Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor in used_in_plugin to target filenames #5490

Merged
merged 1 commit into from
May 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ fn compute_metadata<'a, 'cfg>(
// panic=abort and panic=unwind artifacts, additionally with various
// settings like debuginfo and whatnot.
unit.profile.hash(&mut hasher);
cx.used_in_plugin.contains(unit).hash(&mut hasher);
unit.mode.hash(&mut hasher);
if let Some(ref args) = bcx.extra_args_for(unit) {
args.hash(&mut hasher);
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
let mut queue = JobQueue::new(self.bcx);
self.prepare_units(export_dir, units)?;
self.prepare()?;
self.build_used_in_plugin_map(units)?;
custom_build::build_map(&mut self, units)?;

for unit in units.iter() {
Expand Down Expand Up @@ -261,6 +260,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
};

build_unit_dependencies(units, self.bcx, &mut self.unit_dependencies)?;
self.build_used_in_plugin_map(units)?;
let files = CompilationFiles::new(
units,
host_layout,
Expand Down Expand Up @@ -302,7 +302,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
///
/// This will recursively walk `units` and all of their dependencies to
/// determine which crate are going to be used in plugins or not.
pub fn build_used_in_plugin_map(&mut self, units: &[Unit<'a>]) -> CargoResult<()> {
fn build_used_in_plugin_map(&mut self, units: &[Unit<'a>]) -> CargoResult<()> {
let mut visited = HashSet::new();
for unit in units {
self.walk_used_in_plugin_map(unit, unit.target.for_host(), &mut visited)?;
Expand Down
68 changes: 68 additions & 0 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,3 +1164,71 @@ fn change_panic_mode() {
assert_that(p.cargo("build -p foo"), execs().with_status(0));
assert_that(p.cargo("build -p bar"), execs().with_status(0));
}

#[test]
fn dont_rebuild_based_on_plugins() {
let p = project("p")
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.1"

[workspace]
members = ['bar']

[dependencies]
proc-macro-thing = { path = 'proc-macro-thing' }
"#,
)
.file("src/lib.rs", "")
.file(
"proc-macro-thing/Cargo.toml",
r#"
[package]
name = "proc-macro-thing"
version = "0.1.1"

[lib]
proc-macro = true

[dependencies]
baz = { path = '../baz' }
"#,
)
.file("proc-macro-thing/src/lib.rs", "")
.file(
"bar/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.1.1"

[dependencies]
baz = { path = '../baz' }
"#,
)
.file("bar/src/main.rs", "fn main() {}")
.file(
"baz/Cargo.toml",
r#"
[package]
name = "baz"
version = "0.1.1"
"#,
)
.file("baz/src/lib.rs", "")
.build();

assert_that(p.cargo("build"), execs().with_status(0));
assert_that(p.cargo("build -p bar"), execs().with_status(0));
assert_that(
p.cargo("build"),
execs().with_status(0).with_stderr("[FINISHED] [..]\n"),
);
assert_that(
p.cargo("build -p bar"),
execs().with_status(0).with_stderr("[FINISHED] [..]\n"),
);
}