diff options
| author | onur-ozkan <work@onurozkan.dev> | 2023-10-07 23:33:27 +0300 |
|---|---|---|
| committer | onur-ozkan <work@onurozkan.dev> | 2023-10-17 10:06:48 +0300 |
| commit | acef1c2c576c778e7a3c8e249298eb10450ae7e8 (patch) | |
| tree | 9f12e853c417a138394ee4ad2eb6481439974aba /src/bootstrap | |
| parent | 631a116cd3b326096340691e60bf74e9868289a6 (diff) | |
| download | rust-acef1c2c576c778e7a3c8e249298eb10450ae7e8.tar.gz rust-acef1c2c576c778e7a3c8e249298eb10450ae7e8.zip | |
reorganize bootstrap bins and helper module utilizations
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/bin/_helper.rs | 25 | ||||
| -rw-r--r-- | src/bootstrap/src/bin/main.rs (renamed from src/bootstrap/bin/main.rs) | 0 | ||||
| -rw-r--r-- | src/bootstrap/src/bin/rustc.rs (renamed from src/bootstrap/bin/rustc.rs) | 15 | ||||
| -rw-r--r-- | src/bootstrap/src/bin/rustdoc.rs (renamed from src/bootstrap/bin/rustdoc.rs) | 14 | ||||
| -rw-r--r-- | src/bootstrap/src/bin/sccache-plus-cl.rs (renamed from src/bootstrap/bin/sccache-plus-cl.rs) | 0 |
5 files changed, 19 insertions, 35 deletions
diff --git a/src/bootstrap/bin/_helper.rs b/src/bootstrap/bin/_helper.rs deleted file mode 100644 index 46c574c5bf4..00000000000 --- a/src/bootstrap/bin/_helper.rs +++ /dev/null @@ -1,25 +0,0 @@ -/// Parses the value of the "RUSTC_VERBOSE" environment variable and returns it as a `usize`. -/// If it was not defined, returns 0 by default. -/// -/// Panics if "RUSTC_VERBOSE" is defined with the value that is not an unsigned integer. -fn parse_rustc_verbose() -> usize { - use std::str::FromStr; - - match std::env::var("RUSTC_VERBOSE") { - Ok(s) => usize::from_str(&s).expect("RUSTC_VERBOSE should be an integer"), - Err(_) => 0, - } -} - -/// Parses the value of the "RUSTC_STAGE" environment variable and returns it as a `String`. -/// -/// If "RUSTC_STAGE" was not set, the program will be terminated with 101. -#[allow(unused)] -fn parse_rustc_stage() -> String { - std::env::var("RUSTC_STAGE").unwrap_or_else(|_| { - // Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead. - eprintln!("rustc shim: fatal: RUSTC_STAGE was not set"); - eprintln!("rustc shim: note: use `x.py build -vvv` to see all environment variables set by bootstrap"); - exit(101); - }) -} diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/src/bin/main.rs index d87fb6a9cef..d87fb6a9cef 100644 --- a/src/bootstrap/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index 6cc5162120a..b050713265b 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -15,19 +15,24 @@ //! switching compilers for the bootstrap and for build scripts will probably //! never get replaced. -include!("../dylib_util.rs"); -include!("./_helper.rs"); - use std::env; use std::path::PathBuf; -use std::process::{exit, Child, Command}; +use std::process::{Child, Command}; use std::time::Instant; +use dylib_util::{dylib_path, dylib_path_var}; + +#[path = "../utils/bin_helpers.rs"] +mod bin_helpers; + +#[path = "../utils/dylib_util.rs"] +mod dylib_util; + fn main() { let args = env::args_os().skip(1).collect::<Vec<_>>(); let arg = |name| args.windows(2).find(|args| args[0] == name).and_then(|args| args[1].to_str()); - let verbose = parse_rustc_verbose(); + let verbose = bin_helpers::parse_rustc_verbose(); // Detect whether or not we're a build script depending on whether --target // is passed (a bit janky...) diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/src/bin/rustdoc.rs index 6561c1c1933..85d685475b4 100644 --- a/src/bootstrap/bin/rustdoc.rs +++ b/src/bootstrap/src/bin/rustdoc.rs @@ -5,17 +5,21 @@ use std::env; use std::ffi::OsString; use std::path::PathBuf; -use std::process::{exit, Command}; +use std::process::Command; -include!("../dylib_util.rs"); +use dylib_util::{dylib_path, dylib_path_var}; -include!("./_helper.rs"); +#[path = "../utils/bin_helpers.rs"] +mod bin_helpers; + +#[path = "../utils/dylib_util.rs"] +mod dylib_util; fn main() { let args = env::args_os().skip(1).collect::<Vec<_>>(); - let stage = parse_rustc_stage(); - let verbose = parse_rustc_verbose(); + let stage = bin_helpers::parse_rustc_stage(); + let verbose = bin_helpers::parse_rustc_verbose(); let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set"); let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set"); diff --git a/src/bootstrap/bin/sccache-plus-cl.rs b/src/bootstrap/src/bin/sccache-plus-cl.rs index 554c2dd4d81..554c2dd4d81 100644 --- a/src/bootstrap/bin/sccache-plus-cl.rs +++ b/src/bootstrap/src/bin/sccache-plus-cl.rs |
