Skip to content

Commit 03f32b9

Browse files
committed
Rollup merge of rust-lang#48569 - Phlosioneer:x-py-help-optimization, r=petrochenkov
Fixes rust-lang#47311. r? @nrc
2 parents a6f6f2e + 2269ff5 commit 03f32b9

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

src/bootstrap/bootstrap.py

+15-25
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ def __init__(self):
314314
self.build_dir = os.path.join(os.getcwd(), "build")
315315
self.clean = False
316316
self.config_toml = ''
317-
self.printed = False
318317
self.rust_root = os.path.abspath(os.path.join(__file__, '../../..'))
319318
self.use_locked_deps = ''
320319
self.use_vendored_sources = ''
@@ -336,7 +335,6 @@ def download_stage0(self):
336335
if self.rustc().startswith(self.bin_root()) and \
337336
(not os.path.exists(self.rustc()) or
338337
self.program_out_of_date(self.rustc_stamp())):
339-
self.print_what_bootstrap_means()
340338
if os.path.exists(self.bin_root()):
341339
shutil.rmtree(self.bin_root())
342340
filename = "rust-std-{}-{}.tar.gz".format(
@@ -362,7 +360,6 @@ def download_stage0(self):
362360
if self.cargo().startswith(self.bin_root()) and \
363361
(not os.path.exists(self.cargo()) or
364362
self.program_out_of_date(self.cargo_stamp())):
365-
self.print_what_bootstrap_means()
366363
filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build)
367364
self._download_stage0_helper(filename, "cargo")
368365
self.fix_executable("{}/bin/cargo".format(self.bin_root()))
@@ -563,23 +560,6 @@ def exe_suffix():
563560
return '.exe'
564561
return ''
565562

566-
def print_what_bootstrap_means(self):
567-
"""Prints more information about the build system"""
568-
if hasattr(self, 'printed'):
569-
return
570-
self.printed = True
571-
if os.path.exists(self.bootstrap_binary()):
572-
return
573-
if '--help' not in sys.argv or len(sys.argv) == 1:
574-
return
575-
576-
print('info: the build system for Rust is written in Rust, so this')
577-
print(' script is now going to download a stage0 rust compiler')
578-
print(' and then compile the build system itself')
579-
print('')
580-
print('info: in the meantime you can read more about rustbuild at')
581-
print(' src/bootstrap/README.md before the download finishes')
582-
583563
def bootstrap_binary(self):
584564
"""Return the path of the boostrap binary
585565
@@ -593,7 +573,6 @@ def bootstrap_binary(self):
593573

594574
def build_bootstrap(self):
595575
"""Build bootstrap"""
596-
self.print_what_bootstrap_means()
597576
build_dir = os.path.join(self.build_dir, "bootstrap")
598577
if self.clean and os.path.exists(build_dir):
599578
shutil.rmtree(build_dir)
@@ -678,8 +657,16 @@ def set_dev_environment(self):
678657
self._download_url = 'https://dev-static.rust-lang.org'
679658

680659

681-
def bootstrap():
660+
def bootstrap(help_triggered):
682661
"""Configure, fetch, build and run the initial bootstrap"""
662+
663+
# If the user is asking for help, let them know that the whole download-and-build
664+
# process has to happen before anything is printed out.
665+
if help_triggered:
666+
print("info: Downloading and building bootstrap before processing --help")
667+
print(" command. See src/bootstrap/README.md for help with common")
668+
print(" commands.")
669+
683670
parser = argparse.ArgumentParser(description='Build rust')
684671
parser.add_argument('--config')
685672
parser.add_argument('--build')
@@ -716,7 +703,7 @@ def bootstrap():
716703
print(' and so in order to preserve your $HOME this will now')
717704
print(' use vendored sources by default. Note that if this')
718705
print(' does not work you should run a normal build first')
719-
print(' before running a command like `sudo make install`')
706+
print(' before running a command like `sudo ./x.py install`')
720707

721708
if build.use_vendored_sources:
722709
if not os.path.exists('.cargo'):
@@ -742,7 +729,10 @@ def bootstrap():
742729
if 'dev' in data:
743730
build.set_dev_environment()
744731

745-
build.update_submodules()
732+
# No help text depends on submodules. This check saves ~1 minute of git commands, even if
733+
# all the submodules are present and downloaded!
734+
if not help_triggered:
735+
build.update_submodules()
746736

747737
# Fetch/build the bootstrap
748738
build.build = args.build or build.build_triple()
@@ -768,7 +758,7 @@ def main():
768758
help_triggered = (
769759
'-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
770760
try:
771-
bootstrap()
761+
bootstrap(help_triggered)
772762
if not help_triggered:
773763
print("Build completed successfully in {}".format(
774764
format_build_time(time() - start_time)))

0 commit comments

Comments
 (0)