@@ -466,6 +466,8 @@ def __init__(self):
466
466
self .clean = False
467
467
self .verbose = False
468
468
self .json_output = False
469
+ self .color = 'auto'
470
+ self .warnings = 'default'
469
471
470
472
class RustBuild (object ):
471
473
"""Provide all the methods required to build Rust"""
@@ -477,9 +479,11 @@ def __init__(self, config_toml="", args=FakeArgs()):
477
479
478
480
self .config_toml = config_toml
479
481
480
- self .verbose = args .verbose != 0
481
482
self .clean = args .clean
482
483
self .json_output = args .json_output
484
+ self .verbose = args .verbose
485
+ self .color = args .color
486
+ self .warnings = args .warnings
483
487
484
488
profile = self .get_toml ('profile' )
485
489
if profile is not None :
@@ -491,6 +495,10 @@ def __init__(self, config_toml="", args=FakeArgs()):
491
495
with open (include_path ) as included_toml :
492
496
self .config_toml += os .linesep + included_toml .read ()
493
497
498
+ config_verbose_count = self .get_toml ('verbose' , 'build' )
499
+ if config_verbose_count is not None :
500
+ self .verbose = max (self .verbose , int (config_verbose_count ))
501
+
494
502
self .use_vendored_sources = self .get_toml ('vendor' , 'build' ) == 'true'
495
503
self .use_locked_deps = self .get_toml ('locked-deps' , 'build' ) == 'true'
496
504
@@ -505,6 +513,7 @@ def __init__(self, config_toml="", args=FakeArgs()):
505
513
506
514
self .build = args .build or self .build_triple ()
507
515
516
+
508
517
def download_toolchain (self ):
509
518
"""Fetch the build system for Rust, written in Rust
510
519
@@ -859,22 +868,22 @@ def bootstrap_binary(self):
859
868
"""
860
869
return os .path .join (self .build_dir , "bootstrap" , "debug" , "bootstrap" )
861
870
862
- def build_bootstrap (self , color , warnings , verbose_count ):
871
+ def build_bootstrap (self ):
863
872
"""Build bootstrap"""
864
873
env = os .environ .copy ()
865
874
if "GITHUB_ACTIONS" in env :
866
875
print ("::group::Building bootstrap" )
867
876
else :
868
877
print ("Building bootstrap" , file = sys .stderr )
869
878
870
- args = self .build_bootstrap_cmd (env , color , warnings , verbose_count )
879
+ args = self .build_bootstrap_cmd (env )
871
880
# Run this from the source directory so cargo finds .cargo/config
872
881
run (args , env = env , verbose = self .verbose , cwd = self .rust_root )
873
882
874
883
if "GITHUB_ACTIONS" in env :
875
884
print ("::endgroup::" )
876
885
877
- def build_bootstrap_cmd (self , env , color , warnings , verbose_count ):
886
+ def build_bootstrap_cmd (self , env ):
878
887
"""For tests."""
879
888
build_dir = os .path .join (self .build_dir , "bootstrap" )
880
889
if self .clean and os .path .exists (build_dir ):
@@ -928,10 +937,10 @@ def build_bootstrap_cmd(self, env, color, warnings, verbose_count):
928
937
if target_linker is not None :
929
938
env ["RUSTFLAGS" ] += " -C linker=" + target_linker
930
939
env ["RUSTFLAGS" ] += " -Wrust_2018_idioms -Wunused_lifetimes"
931
- if warnings == "default" :
940
+ if self . warnings == "default" :
932
941
deny_warnings = self .get_toml ("deny-warnings" , "rust" ) != "false"
933
942
else :
934
- deny_warnings = warnings == "deny"
943
+ deny_warnings = self . warnings == "deny"
935
944
if deny_warnings :
936
945
env ["RUSTFLAGS" ] += " -Dwarnings"
937
946
@@ -942,7 +951,7 @@ def build_bootstrap_cmd(self, env, color, warnings, verbose_count):
942
951
self .cargo ()))
943
952
args = [self .cargo (), "build" , "--manifest-path" ,
944
953
os .path .join (self .rust_root , "src/bootstrap/Cargo.toml" )]
945
- args .extend ("--verbose" for _ in range (verbose_count ))
954
+ args .extend ("--verbose" for _ in range (self . verbose ))
946
955
if self .use_locked_deps :
947
956
args .append ("--locked" )
948
957
if self .use_vendored_sources :
@@ -952,9 +961,9 @@ def build_bootstrap_cmd(self, env, color, warnings, verbose_count):
952
961
args .append ("build-metrics" )
953
962
if self .json_output :
954
963
args .append ("--message-format=json" )
955
- if color == "always" :
964
+ if self . color == "always" :
956
965
args .append ("--color=always" )
957
- elif color == "never" :
966
+ elif self . color == "never" :
958
967
args .append ("--color=never" )
959
968
try :
960
969
args += env ["CARGOFLAGS" ].split ()
@@ -1049,18 +1058,13 @@ def bootstrap(args):
1049
1058
build = RustBuild (config_toml , args )
1050
1059
build .check_vendored_status ()
1051
1060
1052
- verbose_count = args .verbose
1053
- config_verbose_count = build .get_toml ('verbose' , 'build' )
1054
- if config_verbose_count is not None :
1055
- verbose_count = max (args .verbose , int (config_verbose_count ))
1056
-
1057
1061
if not os .path .exists (build .build_dir ):
1058
1062
os .makedirs (build .build_dir )
1059
1063
1060
1064
# Fetch/build the bootstrap
1061
1065
build .download_toolchain ()
1062
1066
sys .stdout .flush ()
1063
- build .build_bootstrap (args . color , args . warnings , verbose_count )
1067
+ build .build_bootstrap ()
1064
1068
sys .stdout .flush ()
1065
1069
1066
1070
# Run the bootstrap
0 commit comments