Skip to content

Commit

Permalink
Rollup merge of #78842 - shepmaster:bootstrap-rustfmt, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Honor the rustfmt setting in config.toml

Prior to this, setting the rustfmt configuration was ignored:

```
% mkdir example

% cd example

% ../configure --set build.rustfmt=/usr/bin/true

% ../x.py fmt
./x.py fmt is not supported on this channel
failed to run: /Users/shep/Projects/rust/example/build/bootstrap/debug/bootstrap fmt
Build completed unsuccessfully in 0:00:01
```

And after:

```
% ../x.py fmt
Build completed successfully in 0:00:11
```

r? `@Mark-Simulacrum`
  • Loading branch information
m-ou-se authored Nov 8, 2020
2 parents 2489ff7 + 8cae2f1 commit cb90042
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,18 @@ impl Config {
set(&mut config.missing_tools, t.missing_tools);
}

// Cargo does not provide a RUSTFMT environment variable, so we
// synthesize it manually. Note that we also later check the config.toml
// and set this to that path if necessary.
let rustfmt = config.initial_rustc.with_file_name(exe("rustfmt", config.build));
config.initial_rustfmt = if rustfmt.exists() { Some(rustfmt) } else { None };
config.initial_rustfmt = config.initial_rustfmt.or_else({
let build = config.build;
let initial_rustc = &config.initial_rustc;

move || {
// Cargo does not provide a RUSTFMT environment variable, so we
// synthesize it manually.
let rustfmt = initial_rustc.with_file_name(exe("rustfmt", build));

if rustfmt.exists() { Some(rustfmt) } else { None }
}
});

// Now that we've reached the end of our configuration, infer the
// default values for all options that we haven't otherwise stored yet.
Expand Down

0 comments on commit cb90042

Please sign in to comment.