diff options
| -rw-r--r-- | src/bootstrap/bootstrap.py | 2 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 14 | ||||
| -rw-r--r-- | src/bootstrap/flags.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/setup.rs | 20 |
5 files changed, 21 insertions, 21 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 532e072bc7e..1777dae594f 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1303,8 +1303,6 @@ def bootstrap(help_triggered): env["BOOTSTRAP_PARENT_ID"] = str(os.getpid()) env["BOOTSTRAP_PYTHON"] = sys.executable env["RUSTC_BOOTSTRAP"] = '1' - if toml_path: - env["BOOTSTRAP_CONFIG"] = toml_path if build.rustc_commit is not None: env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1' run(args, env=env, verbose=build.verbose, is_bootstrap=True) diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 0a5bda50687..d7f474bfc80 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -657,7 +657,15 @@ impl Config { } }; - let mut toml = flags.config.as_deref().map(get_toml).unwrap_or_else(TomlConfig::default); + // check --config first, then `$RUST_BOOTSTRAP_CONFIG` first, then `config.toml` + let toml_path = flags + .config + .clone() + .or_else(|| env::var_os("RUST_BOOTSTRAP_CONFIG").map(PathBuf::from)) + .unwrap_or_else(|| PathBuf::from("config.toml")); + let mut toml = + if toml_path.exists() { get_toml(&toml_path) } else { TomlConfig::default() }; + if let Some(include) = &toml.profile { let mut include_path = config.src.clone(); include_path.push("src"); @@ -669,9 +677,7 @@ impl Config { } config.changelog_seen = toml.changelog_seen; - if let Some(cfg) = flags.config { - config.config = cfg; - } + config.config = toml_path; let build = toml.build.unwrap_or_default(); diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index e34b40a93ff..1a4e6a96888 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -3,7 +3,6 @@ //! This module implements the command-line parsing of the build system which //! has various flags to configure how it's run. -use std::env; use std::path::PathBuf; use std::process; @@ -541,7 +540,6 @@ Arguments: // Get any optional paths which occur after the subcommand let mut paths = matches.free[1..].iter().map(|p| p.into()).collect::<Vec<PathBuf>>(); - let cfg_file = env::var_os("BOOTSTRAP_CONFIG").map(PathBuf::from); let verbose = matches.opt_present("verbose"); // User passed in -h/--help? @@ -671,7 +669,7 @@ Arguments: } else { None }, - config: cfg_file, + config: matches.opt_str("config").map(PathBuf::from), jobs: matches.opt_str("jobs").map(|j| j.parse().expect("`jobs` should be a number")), cmd, incremental: matches.opt_present("incremental"), diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index ccc8516a89a..c2780a232ed 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -629,7 +629,7 @@ impl Build { } if let Subcommand::Setup { profile } = &self.config.cmd { - return setup::setup(&self.config.src, *profile); + return setup::setup(&self.config, *profile); } { diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index 9a9ef0b7695..e1235829b3a 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -1,5 +1,5 @@ -use crate::TargetSelection; use crate::{t, VERSION}; +use crate::{Config, TargetSelection}; use std::env::consts::EXE_SUFFIX; use std::fmt::Write as _; use std::fs::File; @@ -81,24 +81,22 @@ impl fmt::Display for Profile { } } -pub fn setup(src_path: &Path, profile: Profile) { - let cfg_file = env::var_os("BOOTSTRAP_CONFIG").map(PathBuf::from); +pub fn setup(config: &Config, profile: Profile) { + let path = &config.config; - if cfg_file.as_ref().map_or(false, |f| f.exists()) { - let file = cfg_file.unwrap(); + if path.exists() { println!( "error: you asked `x.py` to setup a new config file, but one already exists at `{}`", - file.display() + path.display() ); - println!("help: try adding `profile = \"{}\"` at the top of {}", profile, file.display()); + println!("help: try adding `profile = \"{}\"` at the top of {}", profile, path.display()); println!( "note: this will use the configuration in {}", - profile.include_path(src_path).display() + profile.include_path(&config.src).display() ); std::process::exit(1); } - let path = cfg_file.unwrap_or_else(|| "config.toml".into()); let settings = format!( "# Includes one of the default files in src/bootstrap/defaults\n\ profile = \"{}\"\n\ @@ -107,7 +105,7 @@ pub fn setup(src_path: &Path, profile: Profile) { ); t!(fs::write(path, settings)); - let include_path = profile.include_path(src_path); + let include_path = profile.include_path(&config.src); println!("`x.py` will now use the configuration at {}", include_path.display()); let build = TargetSelection::from_user(&env!("BUILD_TRIPLE")); @@ -138,7 +136,7 @@ pub fn setup(src_path: &Path, profile: Profile) { println!(); - t!(install_git_hook_maybe(src_path)); + t!(install_git_hook_maybe(&config.src)); println!(); |
