File tree 9 files changed +37
-26
lines changed
9 files changed +37
-26
lines changed Original file line number Diff line number Diff line change @@ -11,22 +11,22 @@ doctest = false
11
11
12
12
[[bin]]
13
13
name = "bootstrap"
14
- path = "src/bins /main.rs"
14
+ path = "src/bin /main.rs"
15
15
test = false
16
16
17
17
[[bin]]
18
18
name = "rustc"
19
- path = "src/bins /rustc.rs"
19
+ path = "src/bin /rustc.rs"
20
20
test = false
21
21
22
22
[[bin]]
23
23
name = "rustdoc"
24
- path = "src/bins /rustdoc.rs"
24
+ path = "src/bin /rustdoc.rs"
25
25
test = false
26
26
27
27
[[bin]]
28
28
name = "sccache-plus-cl"
29
- path = "src/bins /sccache-plus-cl.rs"
29
+ path = "src/bin /sccache-plus-cl.rs"
30
30
test = false
31
31
32
32
[dependencies]
File renamed without changes.
Original file line number Diff line number Diff line change 15
15
//! switching compilers for the bootstrap and for build scripts will probably
16
16
//! never get replaced.
17
17
18
- include!("../utils/dylib_util.rs");
19
- include!("./_helper.rs");
20
-
21
18
use std::env;
22
19
use std::path::PathBuf;
23
- use std::process::{exit, Child, Command};
20
+ use std::process::{Child, Command};
24
21
use std::time::Instant;
25
22
23
+ use dylib_util::{dylib_path, dylib_path_var};
24
+
25
+ #[path = "../utils/bin_helpers.rs"]
26
+ mod bin_helpers;
27
+
28
+ #[path = "../utils/dylib_util.rs"]
29
+ mod dylib_util;
30
+
26
31
fn main() {
27
32
let args = env::args_os().skip(1).collect::<Vec<_>>();
28
33
let arg = |name| args.windows(2).find(|args| args[0] == name).and_then(|args| args[1].to_str());
29
34
30
- let stage = parse_rustc_stage();
31
- let verbose = parse_rustc_verbose();
35
+ let stage = bin_helpers:: parse_rustc_stage();
36
+ let verbose = bin_helpers:: parse_rustc_verbose();
32
37
33
38
// Detect whether or not we're a build script depending on whether --target
34
39
// is passed (a bit janky...)
Original file line number Diff line number Diff line change 5
5
use std::env;
6
6
use std::ffi::OsString;
7
7
use std::path::PathBuf;
8
- use std::process::{exit, Command} ;
8
+ use std::process::Command;
9
9
10
- include!("../utils/ dylib_util.rs") ;
10
+ use dylib_util::{dylib_path, dylib_path_var} ;
11
11
12
- include!("./_helper.rs");
12
+ #[path = "../utils/bin_helpers.rs"]
13
+ mod bin_helpers;
14
+
15
+ #[path = "../utils/dylib_util.rs"]
16
+ mod dylib_util;
13
17
14
18
fn main() {
15
19
let args = env::args_os().skip(1).collect::<Vec<_>>();
16
20
17
- let stage = parse_rustc_stage();
18
- let verbose = parse_rustc_verbose();
21
+ let stage = bin_helpers:: parse_rustc_stage();
22
+ let verbose = bin_helpers:: parse_rustc_verbose();
19
23
20
24
let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
21
25
let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ //! This file is meant to be included directly from bootstrap shims to avoid a
2
+ //! dependency on the bootstrap library. This reduces the binary size and
3
+ //! improves compilation time by reducing the linking time.
4
+
1
5
/// Parses the value of the "RUSTC_VERBOSE" environment variable and returns it as a `usize`.
2
6
/// If it was not defined, returns 0 by default.
3
7
///
4
8
/// Panics if "RUSTC_VERBOSE" is defined with the value that is not an unsigned integer.
5
- fn parse_rustc_verbose() -> usize {
9
+ pub(crate) fn parse_rustc_verbose() -> usize {
6
10
use std::str::FromStr;
7
11
8
12
match std::env::var("RUSTC_VERBOSE") {
@@ -14,11 +18,11 @@ fn parse_rustc_verbose() -> usize {
14
18
/// Parses the value of the "RUSTC_STAGE" environment variable and returns it as a `String`.
15
19
///
16
20
/// If "RUSTC_STAGE" was not set, the program will be terminated with 101.
17
- fn parse_rustc_stage() -> String {
21
+ pub(crate) fn parse_rustc_stage() -> String {
18
22
std::env::var("RUSTC_STAGE").unwrap_or_else(|_| {
19
23
// Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead.
20
24
eprintln!("rustc shim: fatal: RUSTC_STAGE was not set");
21
25
eprintln!("rustc shim: note: use `x.py build -vvv` to see all environment variables set by bootstrap");
22
- exit(101);
26
+ std::process:: exit(101);
23
27
})
24
28
}
Original file line number Diff line number Diff line change 1
- // Various utilities for working with dylib paths.
2
- //
3
- // This file is meant to be included directly to avoid a dependency on the bootstrap library from
4
- // the rustc and rustdoc wrappers. This improves compilation time by reducing the linking time.
1
+ //! Various utilities for working with dylib paths.
5
2
6
3
/// Returns the environment variable which the dynamic library lookup path
7
4
/// resides in for this platform.
@@ -21,10 +18,10 @@ pub fn dylib_path_var() -> &'static str {
21
18
22
19
/// Parses the `dylib_path_var()` environment variable, returning a list of
23
20
/// paths that are members of this lookup path.
24
- pub fn dylib_path() -> Vec<PathBuf> {
25
- let var = match env::var_os(dylib_path_var()) {
21
+ pub fn dylib_path() -> Vec<std::path:: PathBuf> {
22
+ let var = match std:: env::var_os(dylib_path_var()) {
26
23
Some(v) => v,
27
24
None => return vec![],
28
25
};
29
- env::split_paths(&var).collect()
26
+ std:: env::split_paths(&var).collect()
30
27
}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ use crate::core::builder::Builder;
16
16
use crate::core::config::{Config, TargetSelection};
17
17
use crate::OnceCell;
18
18
19
- include!(" dylib_util.rs") ;
19
+ pub use crate::utils:: dylib_util::{dylib_path, dylib_path_var} ;
20
20
21
21
/// A helper macro to `unwrap` a result except also print out details like:
22
22
///
Original file line number Diff line number Diff line change 5
5
pub(crate) mod cache;
6
6
pub(crate) mod cc_detect;
7
7
pub(crate) mod channel;
8
+ pub(crate) mod dylib_util;
8
9
pub(crate) mod helpers;
9
10
pub(crate) mod job;
10
11
#[cfg(feature = "build-metrics")]
You can’t perform that action at this time.
0 commit comments