Skip to content

Commit

Permalink
Auto merge of rust-lang#2703 - alexcrichton:target-dir-abs-path, r=al…
Browse files Browse the repository at this point in the history
…excrichton

Fix relative `build.target-dir` configuration

Closes rust-lang#2700
  • Loading branch information
bors committed May 18, 2016
2 parents 6d9d5b1 + dcd8b41 commit 48fd9de
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 48fd9de

Please sign in to comment.