Skip to content

Commit 48fd9de

Browse files
committed
Auto merge of #2703 - alexcrichton:target-dir-abs-path, r=alexcrichton
Fix relative `build.target-dir` configuration Closes #2700
2 parents 6d9d5b1 + dcd8b41 commit 48fd9de

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/cargo/util/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ impl Config {
366366
if let Some(dir) = env::var_os("CARGO_TARGET_DIR") {
367367
*self.target_dir.borrow_mut() = Some(Filesystem::new(self.cwd.join(dir)));
368368
} else if let Some(val) = try!(self.get_path("build.target-dir")) {
369-
*self.target_dir.borrow_mut() = Some(Filesystem::new(val.val));
369+
let val = self.cwd.join(val.val);
370+
*self.target_dir.borrow_mut() = Some(Filesystem::new(val));
370371
}
371372
Ok(())
372373
}

tests/test_cargo_compile_custom_build.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,3 +1892,33 @@ test!(non_utf8_output {
18921892
assert_that(p.cargo_process("build").arg("-v"),
18931893
execs().with_status(0));
18941894
});
1895+
1896+
test!(custom_target_dir {
1897+
let p = project("foo")
1898+
.file("Cargo.toml", r#"
1899+
[project]
1900+
name = "foo"
1901+
version = "0.5.0"
1902+
authors = []
1903+
1904+
[dependencies]
1905+
a = { path = "a" }
1906+
"#)
1907+
.file("src/lib.rs", "")
1908+
.file(".cargo/config", r#"
1909+
[build]
1910+
target-dir = 'test'
1911+
"#)
1912+
.file("a/Cargo.toml", r#"
1913+
[project]
1914+
name = "a"
1915+
version = "0.5.0"
1916+
authors = []
1917+
build = "build.rs"
1918+
"#)
1919+
.file("a/build.rs", "fn main() {}")
1920+
.file("a/src/lib.rs", "");
1921+
1922+
assert_that(p.cargo_process("build").arg("-v"),
1923+
execs().with_status(0));
1924+
});

0 commit comments

Comments
 (0)