]> git.proxmox.com Git - rustc.git/blame - src/bootstrap/bin/rustdoc.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / src / bootstrap / bin / rustdoc.rs
CommitLineData
54a0048b
SL
1//! Shim which is passed to Cargo as "rustdoc" when running the bootstrap.
2//!
3//! See comments in `src/bootstrap/rustc.rs` for more information.
4
32a655c1
SL
5#![deny(warnings)]
6
a7813a04
XL
7extern crate bootstrap;
8
54a0048b
SL
9use std::env;
10use std::process::Command;
a7813a04 11use std::path::PathBuf;
54a0048b
SL
12
13fn main() {
14 let args = env::args_os().skip(1).collect::<Vec<_>>();
9e0c209e 15 let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
2c00a5a8 16 let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
9e0c209e 17 let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
32a655c1 18 let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
a7813a04 19
2c00a5a8
XL
20 use std::str::FromStr;
21
22 let verbose = match env::var("RUSTC_VERBOSE") {
23 Ok(s) => usize::from_str(&s).expect("RUSTC_VERBOSE should be an integer"),
24 Err(_) => 0,
25 };
26
5bcae85e 27 let mut dylib_path = bootstrap::util::dylib_path();
8faf50e0 28 dylib_path.insert(0, PathBuf::from(libdir.clone()));
54a0048b 29
b7449926
XL
30 //FIXME(misdreavus): once stdsimd uses cfg(rustdoc) instead of cfg(dox), remove the `--cfg dox`
31 //arguments here
54a0048b
SL
32 let mut cmd = Command::new(rustdoc);
33 cmd.args(&args)
c30ab7b3
SL
34 .arg("--cfg")
35 .arg(format!("stage{}", stage))
36 .arg("--cfg")
37 .arg("dox")
32a655c1
SL
38 .arg("--sysroot")
39 .arg(sysroot)
c30ab7b3
SL
40 .env(bootstrap::util::dylib_path_var(),
41 env::join_paths(&dylib_path).unwrap());
cc61c64b 42
041b39d2
XL
43 // Force all crates compiled by this compiler to (a) be unstable and (b)
44 // allow the `rustc_private` feature to link to other unstable crates
45 // also in the sysroot.
46 if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
47 cmd.arg("-Z").arg("force-unstable-if-unmarked");
cc61c64b 48 }
abe05a73
XL
49 if let Some(linker) = env::var_os("RUSTC_TARGET_LINKER") {
50 cmd.arg("--linker").arg(linker).arg("-Z").arg("unstable-options");
51 }
52
53 // Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick
54 // it up so we can make rustdoc print this into the docs
55 if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
56 // This "unstable-options" can be removed when `--crate-version` is stabilized
0531ce1d
XL
57 cmd.arg("-Z")
58 .arg("unstable-options")
abe05a73
XL
59 .arg("--crate-version").arg(version);
60 }
cc61c64b 61
2c00a5a8
XL
62 if verbose > 1 {
63 eprintln!("rustdoc command: {:?}", cmd);
8faf50e0 64 eprintln!("libdir: {:?}", libdir);
2c00a5a8
XL
65 }
66
54a0048b
SL
67 std::process::exit(match cmd.status() {
68 Ok(s) => s.code().unwrap_or(1),
69 Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
70 })
71}