Skip to content

Commit ffff91a

Browse files
committed
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.
1 parent 2b60207 commit ffff91a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/bootstrap/bootstrap.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ def run(args, verbose=False):
5757
ret = subprocess.Popen(args)
5858
code = ret.wait()
5959
if code != 0:
60-
if not verbose:
61-
print("failed to run: " + ' '.join(args))
62-
raise RuntimeError("failed to run command")
60+
err = "failed to run: " + ' '.join(args)
61+
if verbose:
62+
raise RuntimeError(err)
63+
sys.exit(err)
6364

6465
class RustBuild:
6566
def download_rust_nightly(self):
@@ -210,7 +211,10 @@ def build_triple(self):
210211
if sys.platform == 'win32':
211212
return 'x86_64-pc-windows-msvc'
212213
else:
213-
raise
214+
err = "uname not found"
215+
if self.verbose:
216+
raise Exception(err)
217+
sys.exit(err)
214218

215219
# Darwin's `uname -s` lies and always returns i386. We have to use
216220
# sysctl instead.
@@ -253,7 +257,10 @@ def build_triple(self):
253257
cputype = 'x86_64'
254258
ostype = 'pc-windows-gnu'
255259
else:
256-
raise ValueError("unknown OS type: " + ostype)
260+
err = "unknown OS type: " + ostype
261+
if self.verbose:
262+
raise ValueError(err)
263+
sys.exit(err)
257264

258265
if cputype in {'i386', 'i486', 'i686', 'i786', 'x86'}:
259266
cputype = 'i686'
@@ -269,7 +276,10 @@ def build_triple(self):
269276
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
270277
cputype = 'x86_64'
271278
else:
272-
raise ValueError("unknown cpu type: " + cputype)
279+
err = "unknown cpu type: " + cputype
280+
if self.verbose:
281+
raise ValueError(err)
282+
sys.exit(err)
273283

274284
return cputype + '-' + ostype
275285

0 commit comments

Comments
 (0)