rustdoc: implement --sysroot
with the same semantics as rustc. This let us build documentation for a crate that depends on a custom sysroot.
This commit is contained in:
parent
5f6f838448
commit
e0c60b4d02
@ -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;
|
||||
@ -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.
|
||||
|
||||
@ -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)),
|
||||
|
@ -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")),
|
||||
)
|
||||
}
|
||||
|
||||
@ -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");
|
||||
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user