diff options
| author | bors <bors@rust-lang.org> | 2022-03-11 13:56:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-11 13:56:33 +0000 |
| commit | af8604faddc44b27a59d1a719ff6ceca8bc145eb (patch) | |
| tree | 3ebff941cb237e063071d52aab12375e4b77297d /src | |
| parent | f58d51b3c00b1e30acd75aead202eb2248bb33f9 (diff) | |
| parent | fb3d1264588181496f95ca484affcfcbd7005f74 (diff) | |
| download | rust-af8604faddc44b27a59d1a719ff6ceca8bc145eb.tar.gz rust-af8604faddc44b27a59d1a719ff6ceca8bc145eb.zip | |
Auto merge of #94845 - Dylan-DPC:rollup-3phylaq, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #93283 (Fix for localized windows editions in testcase fn read_link() Issue#93211) - #94592 (Fallback to top-level config.toml if not present in current directory, and remove fallback for env vars and CLI flags) - #94776 (Optimize ascii::escape_default) - #94840 (update `replace_bound_vars_with_placeholders` doc comment) - #94842 (Remove unnecessary try_opt for operations that cannot fail) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 12 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 23 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 1777dae594f..71b8f3c4553 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1233,16 +1233,18 @@ def bootstrap(help_triggered): build.verbose = args.verbose build.clean = args.clean - # Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then fallback to `config.toml` (if it - # exists). + # Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`, + # then `config.toml` in the root directory. toml_path = args.config or os.getenv('RUST_BOOTSTRAP_CONFIG') - if not toml_path and os.path.exists('config.toml'): + using_default_path = toml_path is None + if using_default_path: toml_path = 'config.toml' - - if toml_path: if not os.path.exists(toml_path): toml_path = os.path.join(build.rust_root, toml_path) + # Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path, + # but not if `config.toml` hasn't been created. + if not using_default_path or os.path.exists(toml_path): with open(toml_path) as config: build.config_toml = config.read() diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 73a855ae4d7..0c0a4733231 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -647,7 +647,8 @@ impl Config { let get_toml = |file: &Path| { use std::process; - let contents = t!(fs::read_to_string(file), "`include` config not found"); + let contents = + t!(fs::read_to_string(file), format!("config file {} not found", file.display())); match toml::from_str(&contents) { Ok(table) => table, Err(err) => { @@ -657,14 +658,24 @@ impl Config { } }; - // check --config first, then `$RUST_BOOTSTRAP_CONFIG` first, then `config.toml` + // Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`, then `config.toml` in the root directory. 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() }; + .or_else(|| env::var_os("RUST_BOOTSTRAP_CONFIG").map(PathBuf::from)); + let using_default_path = toml_path.is_none(); + let mut toml_path = toml_path.unwrap_or_else(|| PathBuf::from("config.toml")); + if using_default_path && !toml_path.exists() { + toml_path = config.src.join(toml_path); + } + + // Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path, + // but not if `config.toml` hasn't been created. + let mut toml = if !using_default_path || toml_path.exists() { + get_toml(&toml_path) + } else { + TomlConfig::default() + }; if let Some(include) = &toml.profile { let mut include_path = config.src.clone(); |
