Skip to content

Commit 71fd3ab

Browse files
committed
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.
1 parent 8841bee commit 71fd3ab

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

src/bootstrap/flags.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub enum Subcommand {
143143
args: Vec<String>,
144144
},
145145
Setup {
146-
profile: Profile,
146+
profile: Option<Profile>,
147147
},
148148
}
149149

@@ -628,14 +628,15 @@ Arguments:
628628
|path| format!("{} is not a valid UTF8 string", path.to_string_lossy())
629629
));
630630

631-
profile_string.parse().unwrap_or_else(|err| {
631+
let profile = profile_string.parse().unwrap_or_else(|err| {
632632
eprintln!("error: {}", err);
633633
eprintln!("help: the available profiles are:");
634634
eprint!("{}", Profile::all_for_help("- "));
635635
crate::detail_exit(1);
636-
})
636+
});
637+
Some(profile)
637638
} else {
638-
t!(crate::setup::interactive_path())
639+
None
639640
};
640641
Subcommand::Setup { profile }
641642
}

src/bootstrap/lib.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -542,16 +542,6 @@ impl Build {
542542
metrics: metrics::BuildMetrics::init(),
543543
};
544544

545-
build.verbose("finding compilers");
546-
cc_detect::find(&mut build);
547-
// When running `setup`, the profile is about to change, so any requirements we have now may
548-
// be different on the next invocation. Don't check for them until the next time x.py is
549-
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
550-
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
551-
build.verbose("running sanity check");
552-
sanity::check(&mut build);
553-
}
554-
555545
// If local-rust is the same major.minor as the current version, then force a
556546
// local-rebuild
557547
let local_version_verbose =
@@ -567,16 +557,32 @@ impl Build {
567557
build.local_rebuild = true;
568558
}
569559

570-
// Make sure we update these before gathering metadata so we don't get an error about missing
571-
// Cargo.toml files.
572-
let rust_submodules =
573-
["src/tools/rust-installer", "src/tools/cargo", "library/backtrace", "library/stdarch"];
574-
for s in rust_submodules {
575-
build.update_submodule(Path::new(s));
576-
}
560+
build.verbose("finding compilers");
561+
cc_detect::find(&mut build);
562+
// When running `setup`, the profile is about to change, so any requirements we have now may
563+
// be different on the next invocation. Don't check for them until the next time x.py is
564+
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
565+
//
566+
// Similarly, for `setup` we don't actually need submodules or cargo metadata.
567+
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
568+
build.verbose("running sanity check");
569+
sanity::check(&mut build);
577570

578-
build.verbose("learning about cargo");
579-
metadata::build(&mut build);
571+
// Make sure we update these before gathering metadata so we don't get an error about missing
572+
// Cargo.toml files.
573+
let rust_submodules = [
574+
"src/tools/rust-installer",
575+
"src/tools/cargo",
576+
"library/backtrace",
577+
"library/stdarch",
578+
];
579+
for s in rust_submodules {
580+
build.update_submodule(Path::new(s));
581+
}
582+
583+
build.verbose("learning about cargo");
584+
metadata::build(&mut build);
585+
}
580586

581587
build
582588
}

src/bootstrap/setup.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ impl fmt::Display for Profile {
8181
}
8282
}
8383

84-
pub fn setup(config: &Config, profile: Profile) {
84+
pub fn setup(config: &Config, profile: Option<Profile>) {
8585
let path = &config.config.clone().unwrap_or(PathBuf::from("config.toml"));
86+
let profile = profile.unwrap_or_else(|| t!(interactive_path()));
8687

8788
if path.exists() {
8889
eprintln!(

0 commit comments

Comments
 (0)