]>
Commit | Line | Data |
---|---|---|
54a0048b SL |
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 | ||
32a655c1 SL |
15 | #![deny(warnings)] |
16 | ||
a7813a04 XL |
17 | extern crate bootstrap; |
18 | ||
54a0048b SL |
19 | use std::env; |
20 | use std::process::Command; | |
a7813a04 | 21 | use std::path::PathBuf; |
54a0048b SL |
22 | |
23 | fn main() { | |
24 | let args = env::args_os().skip(1).collect::<Vec<_>>(); | |
9e0c209e | 25 | let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set"); |
2c00a5a8 | 26 | let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set"); |
9e0c209e | 27 | let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set"); |
32a655c1 | 28 | let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set"); |
a7813a04 | 29 | |
2c00a5a8 XL |
30 | use std::str::FromStr; |
31 | ||
32 | let verbose = match env::var("RUSTC_VERBOSE") { | |
33 | Ok(s) => usize::from_str(&s).expect("RUSTC_VERBOSE should be an integer"), | |
34 | Err(_) => 0, | |
35 | }; | |
36 | ||
5bcae85e | 37 | let mut dylib_path = bootstrap::util::dylib_path(); |
a7813a04 | 38 | dylib_path.insert(0, PathBuf::from(libdir)); |
54a0048b SL |
39 | |
40 | let mut cmd = Command::new(rustdoc); | |
41 | cmd.args(&args) | |
c30ab7b3 SL |
42 | .arg("--cfg") |
43 | .arg(format!("stage{}", stage)) | |
44 | .arg("--cfg") | |
45 | .arg("dox") | |
32a655c1 SL |
46 | .arg("--sysroot") |
47 | .arg(sysroot) | |
c30ab7b3 SL |
48 | .env(bootstrap::util::dylib_path_var(), |
49 | env::join_paths(&dylib_path).unwrap()); | |
cc61c64b | 50 | |
041b39d2 XL |
51 | // Force all crates compiled by this compiler to (a) be unstable and (b) |
52 | // allow the `rustc_private` feature to link to other unstable crates | |
53 | // also in the sysroot. | |
54 | if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() { | |
55 | cmd.arg("-Z").arg("force-unstable-if-unmarked"); | |
cc61c64b | 56 | } |
abe05a73 XL |
57 | if let Some(linker) = env::var_os("RUSTC_TARGET_LINKER") { |
58 | cmd.arg("--linker").arg(linker).arg("-Z").arg("unstable-options"); | |
59 | } | |
60 | ||
61 | // Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick | |
62 | // it up so we can make rustdoc print this into the docs | |
63 | if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") { | |
64 | // This "unstable-options" can be removed when `--crate-version` is stabilized | |
65 | cmd.arg("-Z").arg("unstable-options") | |
66 | .arg("--crate-version").arg(version); | |
ff7c6d11 XL |
67 | |
68 | // While we can assume that `-Z unstable-options` is set, let's also force rustdoc to panic | |
69 | // if pulldown rendering differences are found | |
70 | cmd.arg("--deny-render-differences"); | |
abe05a73 | 71 | } |
cc61c64b | 72 | |
2c00a5a8 XL |
73 | if verbose > 1 { |
74 | eprintln!("rustdoc command: {:?}", cmd); | |
75 | } | |
76 | ||
54a0048b SL |
77 | std::process::exit(match cmd.status() { |
78 | Ok(s) => s.code().unwrap_or(1), | |
79 | Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e), | |
80 | }) | |
81 | } |