about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNick Platt <platt.nicholas@gmail.com>2016-04-13 22:10:25 -0400
committerNick Platt <platt.nicholas@gmail.com>2016-04-13 22:10:25 -0400
commitffff91a8e8d1b29164db89019429a712feca4a18 (patch)
treea17a47dace96879b6f1dba729f505592b46de225
parent2b6020723115e77ebe94f228c0c9b977b9199c6e (diff)
downloadrust-ffff91a8e8d1b29164db89019429a712feca4a18.tar.gz
rust-ffff91a8e8d1b29164db89019429a712feca4a18.zip
rustbuild: Improve error messaging in bootstrap.py
For normal invocations, print a short error message and exit. When
the verbose option is enabled, also print the backtrace.
-rw-r--r--src/bootstrap/bootstrap.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 5de7e6957c6..5c50599fbf4 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -57,9 +57,10 @@ def run(args, verbose=False):
     ret = subprocess.Popen(args)
     code = ret.wait()
     if code != 0:
-        if not verbose:
-            print("failed to run: " + ' '.join(args))
-        raise RuntimeError("failed to run command")
+        err = "failed to run: " + ' '.join(args)
+        if verbose:
+            raise RuntimeError(err)
+        sys.exit(err)
 
 class RustBuild:
     def download_rust_nightly(self):
@@ -210,7 +211,10 @@ class RustBuild:
             if sys.platform == 'win32':
                 return 'x86_64-pc-windows-msvc'
             else:
-                raise
+                err = "uname not found"
+                if self.verbose:
+                    raise Exception(err)
+                sys.exit(err)
 
         # Darwin's `uname -s` lies and always returns i386. We have to use
         # sysctl instead.
@@ -253,7 +257,10 @@ class RustBuild:
                 cputype = 'x86_64'
             ostype = 'pc-windows-gnu'
         else:
-            raise ValueError("unknown OS type: " + ostype)
+            err = "unknown OS type: " + ostype
+            if self.verbose:
+                raise ValueError(err)
+            sys.exit(err)
 
         if cputype in {'i386', 'i486', 'i686', 'i786', 'x86'}:
             cputype = 'i686'
@@ -269,7 +276,10 @@ class RustBuild:
         elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
             cputype = 'x86_64'
         else:
-            raise ValueError("unknown cpu type: " + cputype)
+            err = "unknown cpu type: " + cputype
+            if self.verbose:
+                raise ValueError(err)
+            sys.exit(err)
 
         return cputype + '-' + ostype