about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhlosioneer <mattmdrr2@gmail.com>2018-02-26 20:45:52 -0500
committerPhlosioneer <mattmdrr2@gmail.com>2018-02-26 20:45:52 -0500
commitffb6291cd032e3b0577bf67a2b6d932d6ba0787c (patch)
treeea6decc8c2196858d2fce67783cd901b47064330
parent6070d3e47e5e9f15575a3bd33583358b52bc6eda (diff)
downloadrust-ffb6291cd032e3b0577bf67a2b6d932d6ba0787c.tar.gz
rust-ffb6291cd032e3b0577bf67a2b6d932d6ba0787c.zip
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.
-rw-r--r--src/bootstrap/bootstrap.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 603a97ddfd4..f5fcf4ba0f5 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -670,7 +670,7 @@ class RustBuild(object):
         self._download_url = 'https://dev-static.rust-lang.org'
 
 
-def bootstrap():
+def bootstrap(help_triggered):
     """Configure, fetch, build and run the initial bootstrap"""
     parser = argparse.ArgumentParser(description='Build rust')
     parser.add_argument('--config')
@@ -708,7 +708,7 @@ def bootstrap():
             print('      and so in order to preserve your $HOME this will now')
             print('      use vendored sources by default. Note that if this')
             print('      does not work you should run a normal build first')
-            print('      before running a command like `sudo make install`')
+            print('      before running a command like `sudo ./x.py install`')
 
     if build.use_vendored_sources:
         if not os.path.exists('.cargo'):
@@ -734,7 +734,10 @@ def bootstrap():
     if 'dev' in data:
         build.set_dev_environment()
 
-    build.update_submodules()
+    # No help text depends on submodules. This check saves ~1 minute of git commands, even if
+    # all the submodules are present and downloaded!
+    if not help_triggered:
+        build.update_submodules()
 
     # Fetch/build the bootstrap
     build.build = args.build or build.build_triple()
@@ -760,7 +763,13 @@ def main():
     help_triggered = (
         '-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
     try:
-        bootstrap()
+        # If the user is asking for help, let them know that the whole download-and-build
+        # process has to happen before anything is printed out.
+        if help_triggered:
+            print("NOTE: Downloading and compiling bootstrap requirements before processing")
+            print("      --help command. See src/bootstrap/README.md for help with common")
+            print("      commands.")
+        bootstrap(help_triggered)
         if not help_triggered:
             print("Build completed successfully in {}".format(
                 format_build_time(time() - start_time)))