about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-06-08 21:30:04 -0500
committerjyn <github@jyn.dev>2023-06-24 09:40:22 -0500
commit24e67d51a0fbf20910e19045e038fe646e5b0910 (patch)
tree04602533b2c32fbeaaeed368505dacc3ad81323e /src
parentc7af6fb5b8d75bc767c05585a63a0d075d8c3e5f (diff)
Don't test the profile override hack
It generates invalid TOML. I want to get rid of it eventually, but this avoids the issue in the meantime.
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/bootstrap.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 6d215224abf..3dae37ca350 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -485,16 +485,6 @@ class RustBuild(object):
         self.color = args.color
         self.warnings = args.warnings
 
-        profile = self.get_toml('profile')
-        if profile is not None:
-            include_file = 'config.{}.toml'.format(profile)
-            include_dir = os.path.join(self.rust_root, 'src', 'bootstrap', 'defaults')
-            include_path = os.path.join(include_dir, include_file)
-            # HACK: This works because `self.get_toml()` returns the first match it finds for a
-            # specific key, so appending our defaults at the end allows the user to override them
-            with open(include_path) as included_toml:
-                self.config_toml += os.linesep + included_toml.read()
-
         config_verbose_count = self.get_toml('verbose', 'build')
         if config_verbose_count is not None:
             self.verbose = max(self.verbose, int(config_verbose_count))
@@ -794,9 +784,12 @@ class RustBuild(object):
         >>> rb.get_toml("key1")
         'true'
         """
+        return RustBuild.get_toml_static(self.config_toml, key, section)
 
+    @staticmethod
+    def get_toml_static(config_toml, key, section=None):
         cur_section = None
-        for line in self.config_toml.splitlines():
+        for line in config_toml.splitlines():
             section_match = re.match(r'^\s*\[(.*)\]\s*$', line)
             if section_match is not None:
                 cur_section = section_match.group(1)
@@ -805,7 +798,7 @@ class RustBuild(object):
             if match is not None:
                 value = match.group(1)
                 if section is None or section == cur_section:
-                    return self.get_string(value) or value.strip()
+                    return RustBuild.get_string(value) or value.strip()
         return None
 
     def cargo(self):
@@ -1054,6 +1047,16 @@ def bootstrap(args):
         with open(toml_path) as config:
             config_toml = config.read()
 
+    profile = RustBuild.get_toml_static(config_toml, 'profile')
+    if profile is not None:
+        include_file = 'config.{}.toml'.format(profile)
+        include_dir = os.path.join(rust_root, 'src', 'bootstrap', 'defaults')
+        include_path = os.path.join(include_dir, include_file)
+        # HACK: This works because `self.get_toml()` returns the first match it finds for a
+        # specific key, so appending our defaults at the end allows the user to override them
+        with open(include_path) as included_toml:
+            config_toml += os.linesep + included_toml.read()
+
     # Configure initial bootstrap
     build = RustBuild(config_toml, args)
     build.check_vendored_status()