@@ -820,27 +820,21 @@ def check_vendored_status(self):
820
820
if os .path .exists (cargo_dir ):
821
821
shutil .rmtree (cargo_dir )
822
822
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' )
834
827
parser .add_argument ('--config' )
835
828
parser .add_argument ('--build-dir' )
836
829
parser .add_argument ('--build' )
837
830
parser .add_argument ('--color' , choices = ['always' , 'never' , 'auto' ])
838
831
parser .add_argument ('--clean' , action = 'store_true' )
839
832
parser .add_argument ('-v' , '--verbose' , action = 'count' , default = 0 )
840
833
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 ]
843
835
836
+ def bootstrap (args ):
837
+ """Configure, fetch, build and run the initial bootstrap"""
844
838
# Configure initial bootstrap
845
839
build = RustBuild ()
846
840
build .rust_root = os .path .abspath (os .path .join (__file__ , '../../..' ))
@@ -918,23 +912,30 @@ def main():
918
912
if len (sys .argv ) > 1 and sys .argv [1 ] == 'help' :
919
913
sys .argv [1 ] = '-h'
920
914
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
923
927
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 )
928
929
except (SystemExit , KeyboardInterrupt ) as error :
929
930
if hasattr (error , 'code' ) and isinstance (error .code , int ):
930
931
exit_code = error .code
931
932
else :
932
933
exit_code = 1
933
934
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 )
938
939
939
940
940
941
if __name__ == '__main__' :
0 commit comments