Skip to content

Commit 11adac3

Browse files
committed
bootstrap.py: Report build status
Move some code from x.py to bootstrap.py
1 parent 3b45466 commit 11adac3

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

src/bootstrap/bootstrap.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# option. This file may not be copied, modified, or distributed
99
# except according to those terms.
1010

11+
from __future__ import print_function
1112
import argparse
1213
import contextlib
1314
import datetime
@@ -501,7 +502,7 @@ def build_triple(self):
501502

502503
return "{}-{}".format(cputype, ostype)
503504

504-
def main():
505+
def bootstrap():
505506
parser = argparse.ArgumentParser(description='Build rust')
506507
parser.add_argument('--config')
507508
parser.add_argument('--clean', action='store_true')
@@ -564,8 +565,6 @@ def main():
564565
rb._rustc_channel, rb._rustc_date = data['rustc'].split('-', 1)
565566
rb._cargo_rev = data['cargo']
566567

567-
start_time = time()
568-
569568
# Fetch/build the bootstrap
570569
rb.build = rb.build_triple()
571570
rb.download_stage0()
@@ -582,9 +581,19 @@ def main():
582581
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
583582
rb.run(args, env)
584583

585-
end_time = time()
586-
587-
print("Build completed in %s" % format_build_time(end_time - start_time))
584+
def main():
585+
start_time = time()
586+
try:
587+
bootstrap()
588+
print("Build completed successfully in %s" % format_build_time(time() - start_time))
589+
except (SystemExit, KeyboardInterrupt) as e:
590+
if hasattr(e, 'code') and isinstance(e.code, int):
591+
exit_code = e.code
592+
else:
593+
exit_code = 1
594+
print(e)
595+
print("Build completed unsuccessfully in %s" % format_build_time(time() - start_time))
596+
sys.exit(exit_code)
588597

589598
if __name__ == '__main__':
590599
main()

x.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
# option. This file may not be copied, modified, or distributed
1010
# except according to those terms.
1111

12-
import sys
12+
# This file is only a "symlink" to boostrap.py, all logic should go there.
13+
1314
import os
14-
dir = os.path.dirname(__file__)
15-
sys.path.append(os.path.abspath(os.path.join(dir, "src", "bootstrap")))
15+
import sys
16+
rust_dir = os.path.dirname(os.path.abspath(__file__))
17+
sys.path.append(os.path.join(rust_dir, "src", "bootstrap"))
1618

1719
import bootstrap
18-
19-
try:
20-
bootstrap.main()
21-
except KeyboardInterrupt:
22-
sys.exit()
20+
bootstrap.main()

0 commit comments

Comments
 (0)