@@ -485,16 +485,6 @@ def __init__(self, config_toml="", args=FakeArgs()):
485485 self .color = args .color
486486 self .warnings = args .warnings
487487
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-
498488 config_verbose_count = self .get_toml ('verbose' , 'build' )
499489 if config_verbose_count is not None :
500490 self .verbose = max (self .verbose , int (config_verbose_count ))
@@ -794,9 +784,12 @@ def get_toml(self, key, section=None):
794784 >>> rb.get_toml("key1")
795785 'true'
796786 """
787+ return RustBuild .get_toml_static (self .config_toml , key , section )
797788
789+ @staticmethod
790+ def get_toml_static (config_toml , key , section = None ):
798791 cur_section = None
799- for line in self . config_toml .splitlines ():
792+ for line in config_toml .splitlines ():
800793 section_match = re .match (r'^\s*\[(.*)\]\s*$' , line )
801794 if section_match is not None :
802795 cur_section = section_match .group (1 )
@@ -805,7 +798,7 @@ def get_toml(self, key, section=None):
805798 if match is not None :
806799 value = match .group (1 )
807800 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 ()
809802 return None
810803
811804 def cargo (self ):
@@ -1054,6 +1047,16 @@ def bootstrap(args):
10541047 with open (toml_path ) as config :
10551048 config_toml = config .read ()
10561049
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+
10571060 # Configure initial bootstrap
10581061 build = RustBuild (config_toml , args )
10591062 build .check_vendored_status ()
0 commit comments