]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: implement --sysroot
authorJorge Aparicio <japaricious@gmail.com>
Mon, 19 Sep 2016 20:56:38 +0000 (15:56 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Mon, 19 Sep 2016 20:56:38 +0000 (15:56 -0500)
with the same semantics as rustc. This let us build documentation for a
crate that depends on a custom sysroot.

src/librustdoc/core.rs
src/librustdoc/lib.rs

index 1e3804955e940ac8306cdfd1a70902f17f9e9a4e..2fde097ae7ac860fe296bad14ebb734edbf7c831 100644 (file)
@@ -30,6 +30,7 @@
 
 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)),
index cc5cdf9f4e74cb19337732523bc8bc1df62f37cc..4b6eb62b80c07e7a2b19f5ca3efc5d9c5fb46f1d 100644 (file)
@@ -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");