Skip to content

Commit 159bb44

Browse files
committed
auto merge of #663 : alexcrichton/cargo/issue-648, r=brson
This means that if a project has a file with a space in the name it will properly have its freshness calculated as opposed to always having it as a candidate to be rebuilt. Closes #648
2 parents d5d8f5f + 3efe070 commit 159bb44

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/cargo/ops/cargo_rustc/fingerprint.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,18 @@ fn calculate_target_fresh(pkg: &Package, dep_info: &Path) -> CargoResult<bool> {
240240
}));
241241
let deps = line.slice_from(pos + 2);
242242

243-
for file in deps.split(' ').map(|s| s.trim()).filter(|s| !s.is_empty()) {
244-
match fs::stat(&pkg.get_root().join(file)) {
243+
let mut deps = deps.split(' ').map(|s| s.trim()).filter(|s| !s.is_empty());
244+
loop {
245+
let mut file = match deps.next() {
246+
Some(s) => s.to_string(),
247+
None => break,
248+
};
249+
while file.as_slice().ends_with("\\") {
250+
file.pop();
251+
file.push(' ');
252+
file.push_str(deps.next().unwrap())
253+
}
254+
match fs::stat(&pkg.get_root().join(file.as_slice())) {
245255
Ok(stat) if stat.modified <= mtime => {}
246256
Ok(stat) => {
247257
debug!("stale: {} -- {} vs {}", file, stat.modified, mtime);

tests/test_cargo_compile.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1643,3 +1643,22 @@ test!(dep_no_libs {
16431643
.with_stderr("\
16441644
Package `bar v0.0.0 ([..])` has no library targets"));
16451645
})
1646+
1647+
test!(recompile_space_in_name {
1648+
let foo = project("foo")
1649+
.file("Cargo.toml", r#"
1650+
[package]
1651+
name = "foo"
1652+
version = "0.0.0"
1653+
authors = []
1654+
1655+
[lib]
1656+
name = "foo"
1657+
path = "src/my lib.rs"
1658+
"#)
1659+
.file("src/my lib.rs", "");
1660+
assert_that(foo.cargo_process("build"), execs().with_status(0));
1661+
foo.root().move_into_the_past().assert();
1662+
assert_that(foo.process(cargo_dir().join("cargo")).arg("build"),
1663+
execs().with_status(0).with_stdout(""));
1664+
})

0 commit comments

Comments
 (0)