8
8
# option. This file may not be copied, modified, or distributed
9
9
# except according to those terms.
10
10
11
+ from __future__ import print_function
11
12
import argparse
12
13
import contextlib
13
14
import datetime
@@ -501,7 +502,7 @@ def build_triple(self):
501
502
502
503
return "{}-{}" .format (cputype , ostype )
503
504
504
- def main ():
505
+ def bootstrap ():
505
506
parser = argparse .ArgumentParser (description = 'Build rust' )
506
507
parser .add_argument ('--config' )
507
508
parser .add_argument ('--clean' , action = 'store_true' )
@@ -564,8 +565,6 @@ def main():
564
565
rb ._rustc_channel , rb ._rustc_date = data ['rustc' ].split ('-' , 1 )
565
566
rb ._cargo_rev = data ['cargo' ]
566
567
567
- start_time = time ()
568
-
569
568
# Fetch/build the bootstrap
570
569
rb .build = rb .build_triple ()
571
570
rb .download_stage0 ()
@@ -582,9 +581,19 @@ def main():
582
581
env ["BOOTSTRAP_PARENT_ID" ] = str (os .getpid ())
583
582
rb .run (args , env )
584
583
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 )
588
597
589
598
if __name__ == '__main__' :
590
599
main ()
0 commit comments