]> git.lizzy.rs Git - rust.git/blob - src/bootstrap/bin/rustdoc.rs
remove implementation detail from doc
[rust.git] / src / bootstrap / bin / rustdoc.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Shim which is passed to Cargo as "rustdoc" when running the bootstrap.
12 //!
13 //! See comments in `src/bootstrap/rustc.rs` for more information.
14
15 #![deny(warnings)]
16
17 extern crate bootstrap;
18
19 use std::env;
20 use std::process::Command;
21 use std::path::PathBuf;
22
23 fn main() {
24     let args = env::args_os().skip(1).collect::<Vec<_>>();
25     let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
26     let libdir = env::var_os("RUSTC_LIBDIR").expect("RUSTC_LIBDIR was not set");
27     let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
28     let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
29
30     let mut dylib_path = bootstrap::util::dylib_path();
31     dylib_path.insert(0, PathBuf::from(libdir));
32
33     let mut cmd = Command::new(rustdoc);
34     cmd.args(&args)
35         .arg("--cfg")
36         .arg(format!("stage{}", stage))
37         .arg("--cfg")
38         .arg("dox")
39         .arg("--sysroot")
40         .arg(sysroot)
41         .env(bootstrap::util::dylib_path_var(),
42              env::join_paths(&dylib_path).unwrap());
43
44     // Force all crates compiled by this compiler to (a) be unstable and (b)
45     // allow the `rustc_private` feature to link to other unstable crates
46     // also in the sysroot.
47     if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
48         cmd.arg("-Z").arg("force-unstable-if-unmarked");
49     }
50     if let Some(linker) = env::var_os("RUSTC_TARGET_LINKER") {
51         cmd.arg("--linker").arg(linker).arg("-Z").arg("unstable-options");
52     }
53
54     // Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick
55     // it up so we can make rustdoc print this into the docs
56     if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
57         // This "unstable-options" can be removed when `--crate-version` is stabilized
58         cmd.arg("-Z").arg("unstable-options")
59            .arg("--crate-version").arg(version);
60
61         // While we can assume that `-Z unstable-options` is set, let's also force rustdoc to panic
62         // if pulldown rendering differences are found
63         cmd.arg("--deny-render-differences");
64     }
65
66     std::process::exit(match cmd.status() {
67         Ok(s) => s.code().unwrap_or(1),
68         Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
69     })
70 }