Skip to content

Commit

Permalink
Fix relative build.target-dir configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed May 16, 2016
1 parent 8bdec5e commit dcd8b41
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cargo/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ impl Config {
if let Some(dir) = env::var_os("CARGO_TARGET_DIR") {
*self.target_dir.borrow_mut() = Some(Filesystem::new(self.cwd.join(dir)));
} else if let Some(val) = try!(self.get_path("build.target-dir")) {
*self.target_dir.borrow_mut() = Some(Filesystem::new(val.val));
let val = self.cwd.join(val.val);
*self.target_dir.borrow_mut() = Some(Filesystem::new(val));
}
Ok(())
}
Expand Down
30 changes: 30 additions & 0 deletions tests/test_cargo_compile_custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1892,3 +1892,33 @@ test!(non_utf8_output {
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
});

test!(custom_target_dir {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = []
[dependencies]
a = { path = "a" }
"#)
.file("src/lib.rs", "")
.file(".cargo/config", r#"
[build]
target-dir = 'test'
"#)
.file("a/Cargo.toml", r#"
[project]
name = "a"
version = "0.5.0"
authors = []
build = "build.rs"
"#)
.file("a/build.rs", "fn main() {}")
.file("a/src/lib.rs", "");

assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
});

0 comments on commit dcd8b41

Please sign in to comment.