Skip to content

Commit 3775be8

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#36586 - japaric:rustdoc-sysroot, r=alexcrichton
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
2 parents c816720 + e0c60b4 commit 3775be8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/librustdoc/core.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use errors::emitter::ColorConfig;
3232
use std::cell::{RefCell, Cell};
3333
use std::mem;
3434
use std::rc::Rc;
35+
use std::path::PathBuf;
3536

3637
use visit_ast::RustdocVisitor;
3738
use clean;
@@ -127,7 +128,8 @@ pub fn run_core(search_paths: SearchPaths,
127128
cfgs: Vec<String>,
128129
externs: config::Externs,
129130
input: Input,
130-
triple: Option<String>) -> (clean::Crate, RenderInfo)
131+
triple: Option<String>,
132+
maybe_sysroot: Option<PathBuf>) -> (clean::Crate, RenderInfo)
131133
{
132134
// Parse, resolve, and typecheck the given crate.
133135

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

141143
let sessopts = config::Options {
142-
maybe_sysroot: None,
144+
maybe_sysroot: maybe_sysroot,
143145
search_paths: search_paths,
144146
crate_types: vec!(config::CrateTypeRlib),
145147
lint_opts: vec!((warning_lint, lint::Allow)),

src/librustdoc/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
186186
own theme", "PATH")),
187187
unstable(optmulti("Z", "",
188188
"internal and debugging options (only on nightly build)", "FLAG")),
189+
stable(optopt("", "sysroot", "Override the system root", "PATH")),
189190
)
190191
}
191192

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

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

381383
tx.send(core::run_core(paths, cfgs, externs, Input::File(cr),
382-
triple)).unwrap();
384+
triple, maybe_sysroot)).unwrap();
383385
});
384386
let (mut krate, renderinfo) = rx.recv().unwrap();
385387
info!("finished with rustc");

0 commit comments

Comments
 (0)