Skip to content

Commit

Permalink
Rollup merge of rust-lang#36586 - japaric:rustdoc-sysroot, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

rustdoc: implement --sysroot

with the same semantics as rustc. This let us build documentation for a
crate that depends on a custom sysroot.

r? @alexcrichton
cc @cbiffle
  • Loading branch information
Jonathan Turner authored Sep 27, 2016
2 parents c816720 + e0c60b4 commit 3775be8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use errors::emitter::ColorConfig;
use std::cell::{RefCell, Cell};
use std::mem;
use std::rc::Rc;
use std::path::PathBuf;

use visit_ast::RustdocVisitor;
use clean;
Expand Down Expand Up @@ -127,7 +128,8 @@ pub fn run_core(search_paths: SearchPaths,
cfgs: Vec<String>,
externs: config::Externs,
input: Input,
triple: Option<String>) -> (clean::Crate, RenderInfo)
triple: Option<String>,
maybe_sysroot: Option<PathBuf>) -> (clean::Crate, RenderInfo)
{
// Parse, resolve, and typecheck the given crate.

Expand All @@ -139,7 +141,7 @@ pub fn run_core(search_paths: SearchPaths,
let warning_lint = lint::builtin::WARNINGS.name_lower();

let sessopts = config::Options {
maybe_sysroot: None,
maybe_sysroot: maybe_sysroot,
search_paths: search_paths,
crate_types: vec!(config::CrateTypeRlib),
lint_opts: vec!((warning_lint, lint::Allow)),
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
own theme", "PATH")),
unstable(optmulti("Z", "",
"internal and debugging options (only on nightly build)", "FLAG")),
stable(optopt("", "sysroot", "Override the system root", "PATH")),
)
}

Expand Down Expand Up @@ -370,6 +371,7 @@ fn rust_input(cratefile: &str, externs: Externs, matches: &getopts::Matches) ->
}
let cfgs = matches.opt_strs("cfg");
let triple = matches.opt_str("target");
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);

let cr = PathBuf::from(cratefile);
info!("starting to run rustc");
Expand All @@ -379,7 +381,7 @@ fn rust_input(cratefile: &str, externs: Externs, matches: &getopts::Matches) ->
use rustc::session::config::Input;

tx.send(core::run_core(paths, cfgs, externs, Input::File(cr),
triple)).unwrap();
triple, maybe_sysroot)).unwrap();
});
let (mut krate, renderinfo) = rx.recv().unwrap();
info!("finished with rustc");
Expand Down

0 comments on commit 3775be8

Please sign in to comment.