Don't update submodules for x setup
Before, the submodule handling was very jank and would update *between two interactive prompts*: ``` ; x setup Building rustbuild Finished dev [unoptimized] target(s) in 0.05s Welcome to the Rust project! What do you want to do with x.py? a) library: Contribute to the standard library Please choose one (a/b/c/d/e): a Updating submodule library/backtrace Submodule 'library/backtrace' (https://github.com/rust-lang/backtrace-rs.git) registered for path 'library/backtrace' error: you asked `x.py` to setup a new config file, but one already exists at `config.toml` Build completed unsuccessfully in 0:00:02 ``` That's not a great user experience because you need to wait a long time between prompts. It would be possible to move the submodule handling either before or after the prompt, but it seems better to just not require submodules to be checked out at all, to minimize the time spend waiting just to create a new configuration.
This commit is contained in:
parent
8841bee954
commit
71fd3abc73
@ -143,7 +143,7 @@ pub enum Subcommand {
|
||||
args: Vec<String>,
|
||||
},
|
||||
Setup {
|
||||
profile: Profile,
|
||||
profile: Option<Profile>,
|
||||
},
|
||||
}
|
||||
|
||||
@ -628,14 +628,15 @@ pub fn parse(args: &[String]) -> Flags {
|
||||
|path| format!("{} is not a valid UTF8 string", path.to_string_lossy())
|
||||
));
|
||||
|
||||
profile_string.parse().unwrap_or_else(|err| {
|
||||
let profile = profile_string.parse().unwrap_or_else(|err| {
|
||||
eprintln!("error: {}", err);
|
||||
eprintln!("help: the available profiles are:");
|
||||
eprint!("{}", Profile::all_for_help("- "));
|
||||
crate::detail_exit(1);
|
||||
})
|
||||
});
|
||||
Some(profile)
|
||||
} else {
|
||||
t!(crate::setup::interactive_path())
|
||||
None
|
||||
};
|
||||
Subcommand::Setup { profile }
|
||||
}
|
||||
|
@ -542,16 +542,6 @@ pub fn new(mut config: Config) -> Build {
|
||||
metrics: metrics::BuildMetrics::init(),
|
||||
};
|
||||
|
||||
build.verbose("finding compilers");
|
||||
cc_detect::find(&mut build);
|
||||
// When running `setup`, the profile is about to change, so any requirements we have now may
|
||||
// be different on the next invocation. Don't check for them until the next time x.py is
|
||||
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
|
||||
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
|
||||
build.verbose("running sanity check");
|
||||
sanity::check(&mut build);
|
||||
}
|
||||
|
||||
// If local-rust is the same major.minor as the current version, then force a
|
||||
// local-rebuild
|
||||
let local_version_verbose =
|
||||
@ -567,16 +557,32 @@ pub fn new(mut config: Config) -> Build {
|
||||
build.local_rebuild = true;
|
||||
}
|
||||
|
||||
// Make sure we update these before gathering metadata so we don't get an error about missing
|
||||
// Cargo.toml files.
|
||||
let rust_submodules =
|
||||
["src/tools/rust-installer", "src/tools/cargo", "library/backtrace", "library/stdarch"];
|
||||
for s in rust_submodules {
|
||||
build.update_submodule(Path::new(s));
|
||||
}
|
||||
build.verbose("finding compilers");
|
||||
cc_detect::find(&mut build);
|
||||
// When running `setup`, the profile is about to change, so any requirements we have now may
|
||||
// be different on the next invocation. Don't check for them until the next time x.py is
|
||||
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
|
||||
//
|
||||
// Similarly, for `setup` we don't actually need submodules or cargo metadata.
|
||||
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
|
||||
build.verbose("running sanity check");
|
||||
sanity::check(&mut build);
|
||||
|
||||
build.verbose("learning about cargo");
|
||||
metadata::build(&mut build);
|
||||
// Make sure we update these before gathering metadata so we don't get an error about missing
|
||||
// Cargo.toml files.
|
||||
let rust_submodules = [
|
||||
"src/tools/rust-installer",
|
||||
"src/tools/cargo",
|
||||
"library/backtrace",
|
||||
"library/stdarch",
|
||||
];
|
||||
for s in rust_submodules {
|
||||
build.update_submodule(Path::new(s));
|
||||
}
|
||||
|
||||
build.verbose("learning about cargo");
|
||||
metadata::build(&mut build);
|
||||
}
|
||||
|
||||
build
|
||||
}
|
||||
|
@ -81,8 +81,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup(config: &Config, profile: Profile) {
|
||||
pub fn setup(config: &Config, profile: Option<Profile>) {
|
||||
let path = &config.config.clone().unwrap_or(PathBuf::from("config.toml"));
|
||||
let profile = profile.unwrap_or_else(|| t!(interactive_path()));
|
||||
|
||||
if path.exists() {
|
||||
eprintln!(
|
||||
|
Loading…
Reference in New Issue
Block a user