Skip to content

Commit

Permalink
rustdoc: implement --sysroot
Browse files Browse the repository at this point in the history
with the same semantics as rustc. This let us build documentation for a
crate that depends on a custom sysroot.
  • Loading branch information
Jorge Aparicio committed Sep 19, 2016
1 parent 5f6f838 commit e0c60b4
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 @@ -30,6 +30,7 @@ use errors::emitter::ColorConfig;

use std::cell::{RefCell, Cell};
use std::rc::Rc;
use std::path::PathBuf;

use visit_ast::RustdocVisitor;
use clean;
Expand Down Expand Up @@ -101,7 +102,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 @@ -113,7 +115,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 e0c60b4

Please sign in to comment.