Skip to content

Commit ffb6291

Browse files
committed
Improve --help performance for x.py
Since compiling the bootstrap command doesn't require any submodules, we can skip updating submodules when a --help command is passed in. On my machine, this saves 1 minute if the submodules are already downloaded, and 10 minutes if run on a clean repo. This commit also adds a message before compiling/downloading anything when a --help command is passed in, to tell the user WHY --help takes so long to complete. It also points the user to the bootstrap README.md for faster help. Finally, this fixes one warning message that still referenced using make instead of x.py, even though x.py is now the standard way of building rust.
1 parent 6070d3e commit ffb6291

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/bootstrap/bootstrap.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ def set_dev_environment(self):
670670
self._download_url = 'https://dev-static.rust-lang.org'
671671

672672

673-
def bootstrap():
673+
def bootstrap(help_triggered):
674674
"""Configure, fetch, build and run the initial bootstrap"""
675675
parser = argparse.ArgumentParser(description='Build rust')
676676
parser.add_argument('--config')
@@ -708,7 +708,7 @@ def bootstrap():
708708
print(' and so in order to preserve your $HOME this will now')
709709
print(' use vendored sources by default. Note that if this')
710710
print(' does not work you should run a normal build first')
711-
print(' before running a command like `sudo make install`')
711+
print(' before running a command like `sudo ./x.py install`')
712712

713713
if build.use_vendored_sources:
714714
if not os.path.exists('.cargo'):
@@ -734,7 +734,10 @@ def bootstrap():
734734
if 'dev' in data:
735735
build.set_dev_environment()
736736

737-
build.update_submodules()
737+
# No help text depends on submodules. This check saves ~1 minute of git commands, even if
738+
# all the submodules are present and downloaded!
739+
if not help_triggered:
740+
build.update_submodules()
738741

739742
# Fetch/build the bootstrap
740743
build.build = args.build or build.build_triple()
@@ -760,7 +763,13 @@ def main():
760763
help_triggered = (
761764
'-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
762765
try:
763-
bootstrap()
766+
# If the user is asking for help, let them know that the whole download-and-build
767+
# process has to happen before anything is printed out.
768+
if help_triggered:
769+
print("NOTE: Downloading and compiling bootstrap requirements before processing")
770+
print(" --help command. See src/bootstrap/README.md for help with common")
771+
print(" commands.")
772+
bootstrap(help_triggered)
764773
if not help_triggered:
765774
print("Build completed successfully in {}".format(
766775
format_build_time(time() - start_time)))

0 commit comments

Comments
 (0)