update configure.py to handle new bootstrap.example.toml

This commit is contained in:
binarycat
2025-06-17 15:19:51 -05:00
parent 7eaf7386b9
commit 01fbeb8065
2 changed files with 25 additions and 8 deletions

View File

@@ -385,7 +385,7 @@
# #
# The default value for the `features` array is `[]`. However, please note that other flags in # The default value for the `features` array is `[]`. However, please note that other flags in
# `bootstrap.toml` might influence the features enabled for some tools. # `bootstrap.toml` might influence the features enabled for some tools.
#tool.TOOL_NAME.features = [FEATURE1, FEATURE2] #build.tool.TOOL_NAME.features = [FEATURE1, FEATURE2]
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation
#build.verbose = 0 #build.verbose = 0

View File

@@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function
import shlex import shlex
import sys import sys
import os import os
import re
rust_dir = os.path.dirname(os.path.abspath(__file__)) rust_dir = os.path.dirname(os.path.abspath(__file__))
rust_dir = os.path.dirname(rust_dir) rust_dir = os.path.dirname(rust_dir)
@@ -585,16 +586,31 @@ def parse_example_config(known_args, config):
section_order = [None] section_order = [None]
targets = {} targets = {}
top_level_keys = [] top_level_keys = []
comment_lines = []
with open(rust_dir + "/bootstrap.example.toml") as example_config: with open(rust_dir + "/bootstrap.example.toml") as example_config:
example_lines = example_config.read().split("\n") example_lines = example_config.read().split("\n")
for line in example_lines: for line in example_lines:
if cur_section is None: if line.count("=") == 1 and not line.startswith("# "):
if line.count("=") == 1: key = line.split("=")[0]
top_level_key = line.split("=")[0] key = key.strip(" #")
top_level_key = top_level_key.strip(" #") parts = key.split(".")
top_level_keys.append(top_level_key) if len(parts) > 1:
if line.startswith("["): cur_section = parts[0]
if cur_section not in sections:
sections[cur_section] = ["[" + cur_section + "]"]
section_order.append(cur_section)
elif cur_section is None:
top_level_keys.append(key)
# put the comment lines within the start of
# a new section, not outside it.
sections[cur_section] += comment_lines
comment_lines = []
# remove just the `section.` part from the line, if present.
sections[cur_section].append(
re.sub("(#?)([a-zA-Z_-]+\\.)?(.*)", "\\1\\3", line)
)
elif line.startswith("["):
cur_section = line[1:-1] cur_section = line[1:-1]
if cur_section.startswith("target"): if cur_section.startswith("target"):
cur_section = "target" cur_section = "target"
@@ -605,8 +621,9 @@ def parse_example_config(known_args, config):
sections[cur_section] = [line] sections[cur_section] = [line]
section_order.append(cur_section) section_order.append(cur_section)
else: else:
sections[cur_section].append(line) comment_lines.append(line)
sections[cur_section] += comment_lines
# Fill out the `targets` array by giving all configured targets a copy of the # Fill out the `targets` array by giving all configured targets a copy of the
# `target` section we just loaded from the example config # `target` section we just loaded from the example config
configured_targets = [build(known_args)] configured_targets = [build(known_args)]