Skip to content

Commit

Permalink
auto merge of rust-lang#330 : alexcrichton/cargo/fix-cargo-doc2, r=wy…
Browse files Browse the repository at this point in the history
…cats

This erroneously used util::process instead of the custom process function in
the cargo_rustc module.
  • Loading branch information
bors committed Aug 6, 2014
2 parents eebb219 + 6a2a2c9 commit 72dabaf
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 23 deletions.
47 changes: 30 additions & 17 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,24 @@ pub struct Profile {
opt_level: uint,
debug: bool,
test: bool,
doc: bool,
dest: Option<String>,
plugin: bool,
}

impl Profile {
fn default() -> Profile {
Profile {
env: String::new(),
opt_level: 0,
debug: false,
test: false,
doc: false,
dest: None,
plugin: false,
}
}

pub fn default_dev() -> Profile {
Profile {
env: "compile".to_string(), // run in the default environment only
Expand All @@ -122,50 +135,45 @@ impl Profile {
test: false, // whether or not to pass --test
dest: None,
plugin: false,
doc: false,
}
}

pub fn default_test() -> Profile {
Profile {
env: "test".to_string(), // run in the default environment only
opt_level: 0,
env: "test".to_string(),
debug: true,
test: true, // whether or not to pass --test
test: true,
dest: Some("test".to_string()),
plugin: false,
.. Profile::default()
}
}

pub fn default_bench() -> Profile {
Profile {
env: "bench".to_string(), // run in the default environment only
env: "bench".to_string(),
opt_level: 3,
debug: false,
test: true, // whether or not to pass --test
test: true,
dest: Some("bench".to_string()),
plugin: false,
.. Profile::default()
}
}

pub fn default_release() -> Profile {
Profile {
env: "release".to_string(), // run in the default environment only
env: "release".to_string(),
opt_level: 3,
debug: false,
test: false, // whether or not to pass --test
dest: Some("release".to_string()),
plugin: false,
.. Profile::default()
}
}

pub fn default_doc() -> Profile {
Profile {
env: "doc".to_string(),
opt_level: 0,
debug: false,
test: false,
dest: Some("doc-build".to_string()),
plugin: false,
doc: true,
.. Profile::default()
}
}

Expand All @@ -174,7 +182,7 @@ impl Profile {
}

pub fn is_doc(&self) -> bool {
self.env.as_slice() == "doc"
self.doc
}

pub fn is_test(&self) -> bool {
Expand Down Expand Up @@ -216,6 +224,11 @@ impl Profile {
self
}

pub fn doc(mut self, doc: bool) -> Profile {
self.doc = doc;
self
}

pub fn plugin(mut self, plugin: bool) -> Profile {
self.plugin = plugin;
self
Expand Down
3 changes: 2 additions & 1 deletion src/cargo/ops/cargo_rustc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ impl<'a, 'b> Context<'a, 'b> {
// doc-all == document everything, so look for doc targets and
// compile targets in dependencies
"doc-all" => target.get_profile().is_compile() ||
target.get_profile().is_doc(),
(target.get_profile().get_env() == "doc" &&
target.get_profile().is_doc()),
_ => target.get_profile().get_env() == self.env,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn rustdoc(package: &Package, target: &Target, cx: &mut Context) -> Work {
let kind = KindTarget;
let pkg_root = package.get_root();
let cx_root = cx.layout(kind).proxy().dest().dir_path().join("doc");
let rustdoc = util::process("rustdoc").cwd(pkg_root.clone());
let rustdoc = process("rustdoc", package, cx).cwd(pkg_root.clone());
let rustdoc = rustdoc.arg(target.get_src_path())
.arg("-o").arg(cx_root)
.arg("--crate-name").arg(target.get_name());
Expand Down
5 changes: 4 additions & 1 deletion src/cargo/util/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ fn normalize(libs: &[TomlLibTarget],
}

match dep {
Needed => ret.push(Profile::default_test().test(false)),
Needed => {
ret.push(Profile::default_test().test(false));
ret.push(Profile::default_doc().doc(false));
}
_ => {}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/support/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl PathExt for Path {
let stat = try!(path.stat());

let hour = 1000 * 3600;
let mut newtime = stat.modified - hour;
let newtime = stat.modified - hour;
fs::change_file_times(path, newtime, newtime)
}
}
Expand Down
16 changes: 14 additions & 2 deletions tests/test_cargo_compile_plugins.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use support::{project, execs};
use support::{project, execs, cargo_dir};
use hamcrest::assert_that;

fn setup() {
Expand All @@ -12,14 +12,24 @@ test!(plugin_to_the_max {
version = "0.0.1"
authors = []
[[lib]]
name = "foo_lib"
[dependencies.bar]
path = "../bar"
"#)
.file("src/main.rs", r#"
#![feature(phase)]
#[phase(plugin)] extern crate bar;
extern crate foo_lib;
fn main() {}
fn main() { foo_lib::foo(); }
"#)
.file("src/foo_lib.rs", r#"
#![feature(phase)]
#[phase(plugin)] extern crate bar;
pub fn foo() {}
"#);
let bar = project("bar")
.file("Cargo.toml", r#"
Expand Down Expand Up @@ -65,4 +75,6 @@ test!(plugin_to_the_max {

assert_that(foo.cargo_process("cargo-build"),
execs().with_status(0));
assert_that(foo.process(cargo_dir().join("cargo-doc")),
execs().with_status(0));
})

0 comments on commit 72dabaf

Please sign in to comment.