@@ -820,27 +820,21 @@ def check_vendored_status(self):
820820 if os .path .exists (cargo_dir ):
821821 shutil .rmtree (cargo_dir )
822822
823- def bootstrap (help_triggered ):
824- """Configure, fetch, build and run the initial bootstrap"""
825-
826- # If the user is asking for help, let them know that the whole download-and-build
827- # process has to happen before anything is printed out.
828- if help_triggered :
829- print ("info: Downloading and building bootstrap before processing --help" )
830- print (" command. See src/bootstrap/README.md for help with common" )
831- print (" commands." )
832-
833- parser = argparse .ArgumentParser (description = 'Build rust' )
823+ def parse_args ():
824+ """Parse the command line arguments that the python script needs."""
825+ parser = argparse .ArgumentParser (add_help = False )
826+ parser .add_argument ('-h' , '--help' , action = 'store_true' )
834827 parser .add_argument ('--config' )
835828 parser .add_argument ('--build-dir' )
836829 parser .add_argument ('--build' )
837830 parser .add_argument ('--color' , choices = ['always' , 'never' , 'auto' ])
838831 parser .add_argument ('--clean' , action = 'store_true' )
839832 parser .add_argument ('-v' , '--verbose' , action = 'count' , default = 0 )
840833
841- args = [a for a in sys .argv if a != '-h' and a != '--help' ]
842- args , _ = parser .parse_known_args (args )
834+ return parser .parse_known_args (sys .argv )[0 ]
843835
836+ def bootstrap (args ):
837+ """Configure, fetch, build and run the initial bootstrap"""
844838 # Configure initial bootstrap
845839 build = RustBuild ()
846840 build .rust_root = os .path .abspath (os .path .join (__file__ , '../../..' ))
@@ -918,23 +912,30 @@ def main():
918912 if len (sys .argv ) > 1 and sys .argv [1 ] == 'help' :
919913 sys .argv [1 ] = '-h'
920914
921- help_triggered = (
922- '-h' in sys .argv ) or ('--help' in sys .argv ) or (len (sys .argv ) == 1 )
915+ args = parse_args ()
916+ help_triggered = args .help or len (sys .argv ) == 1
917+
918+ # If the user is asking for help, let them know that the whole download-and-build
919+ # process has to happen before anything is printed out.
920+ if help_triggered :
921+ print (
922+ "info: Downloading and building bootstrap before processing --help command.\n "
923+ " See src/bootstrap/README.md for help with common commands."
924+ )
925+
926+ exit_code = 0
923927 try :
924- bootstrap (help_triggered )
925- if not help_triggered :
926- print ("Build completed successfully in {}" .format (
927- format_build_time (time () - start_time )))
928+ bootstrap (args )
928929 except (SystemExit , KeyboardInterrupt ) as error :
929930 if hasattr (error , 'code' ) and isinstance (error .code , int ):
930931 exit_code = error .code
931932 else :
932933 exit_code = 1
933934 print (error )
934- if not help_triggered :
935- print ( "Build completed unsuccessfully in {}" . format (
936- format_build_time (time () - start_time ) ))
937- sys .exit (exit_code )
935+
936+ if not help_triggered :
937+ print ( "Build completed successfully in" , format_build_time (time () - start_time ))
938+ sys .exit (exit_code )
938939
939940
940941if __name__ == '__main__' :
0 commit comments