Skip to content

Commit

Permalink
auto merge of #897 : alexcrichton/cargo/issue-879, r=brson
Browse files Browse the repository at this point in the history
Closes #879
  • Loading branch information
bors committed Nov 18, 2014
2 parents 88d1bfe + 79bc1a7 commit ca33200
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cargo/ops/cargo_rustc/mod.rs
Expand Up @@ -148,6 +148,8 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
// Now that we've figured out everything that we're going to do, do it!
try!(queue.execute(cx.config));

let out_dir = cx.layout(pkg, KindTarget).build_out(pkg).display().to_string();
cx.compilation.extra_env.insert("OUT_DIR".to_string(), Some(out_dir));
Ok(cx.compilation)
}

Expand Down
34 changes: 34 additions & 0 deletions tests/test_cargo_compile_custom_build.rs
Expand Up @@ -939,3 +939,37 @@ test!(transitive_dep_host {
assert_that(p.cargo_process("build"),
execs().with_status(0));
})

test!(test_a_lib_with_a_build_command {
let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.5.0"
authors = []
build = "build.rs"
"#)
.file("src/lib.rs", r#"
include!(concat!(env!("OUT_DIR"), "/foo.rs"))
/// ```
/// foo::bar();
/// ```
pub fn bar() {
assert_eq!(foo(), 1);
}
"#)
.file("build.rs", r#"
use std::os;
use std::io::File;
fn main() {
let out = Path::new(os::getenv("OUT_DIR").unwrap());
File::create(&out.join("foo.rs")).write_str("
fn foo() -> int { 1 }
").unwrap();
}
"#);
assert_that(p.cargo_process("test"),
execs().with_status(0));
})

0 comments on commit ca33200

Please sign in to comment.