@@ -485,16 +485,6 @@ def __init__(self, config_toml="", args=FakeArgs()):
485
485
self .color = args .color
486
486
self .warnings = args .warnings
487
487
488
- profile = self .get_toml ('profile' )
489
- if profile is not None :
490
- include_file = 'config.{}.toml' .format (profile )
491
- include_dir = os .path .join (self .rust_root , 'src' , 'bootstrap' , 'defaults' )
492
- include_path = os .path .join (include_dir , include_file )
493
- # HACK: This works because `self.get_toml()` returns the first match it finds for a
494
- # specific key, so appending our defaults at the end allows the user to override them
495
- with open (include_path ) as included_toml :
496
- self .config_toml += os .linesep + included_toml .read ()
497
-
498
488
config_verbose_count = self .get_toml ('verbose' , 'build' )
499
489
if config_verbose_count is not None :
500
490
self .verbose = max (self .verbose , int (config_verbose_count ))
@@ -794,9 +784,12 @@ def get_toml(self, key, section=None):
794
784
>>> rb.get_toml("key1")
795
785
'true'
796
786
"""
787
+ return RustBuild .get_toml_static (self .config_toml , key , section )
797
788
789
+ @staticmethod
790
+ def get_toml_static (config_toml , key , section = None ):
798
791
cur_section = None
799
- for line in self . config_toml .splitlines ():
792
+ for line in config_toml .splitlines ():
800
793
section_match = re .match (r'^\s*\[(.*)\]\s*$' , line )
801
794
if section_match is not None :
802
795
cur_section = section_match .group (1 )
@@ -805,7 +798,7 @@ def get_toml(self, key, section=None):
805
798
if match is not None :
806
799
value = match .group (1 )
807
800
if section is None or section == cur_section :
808
- return self .get_string (value ) or value .strip ()
801
+ return RustBuild .get_string (value ) or value .strip ()
809
802
return None
810
803
811
804
def cargo (self ):
@@ -1054,6 +1047,16 @@ def bootstrap(args):
1054
1047
with open (toml_path ) as config :
1055
1048
config_toml = config .read ()
1056
1049
1050
+ profile = RustBuild .get_toml_static (config_toml , 'profile' )
1051
+ if profile is not None :
1052
+ include_file = 'config.{}.toml' .format (profile )
1053
+ include_dir = os .path .join (rust_root , 'src' , 'bootstrap' , 'defaults' )
1054
+ include_path = os .path .join (include_dir , include_file )
1055
+ # HACK: This works because `self.get_toml()` returns the first match it finds for a
1056
+ # specific key, so appending our defaults at the end allows the user to override them
1057
+ with open (include_path ) as included_toml :
1058
+ config_toml += os .linesep + included_toml .read ()
1059
+
1057
1060
# Configure initial bootstrap
1058
1061
build = RustBuild (config_toml , args )
1059
1062
build .check_vendored_status ()
0 commit comments