Skip to content

Commit 01fbeb8

Browse files
committed
update configure.py to handle new bootstrap.example.toml
1 parent 7eaf738 commit 01fbeb8

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

bootstrap.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@
385385
#
386386
# The default value for the `features` array is `[]`. However, please note that other flags in
387387
# `bootstrap.toml` might influence the features enabled for some tools.
388-
#tool.TOOL_NAME.features = [FEATURE1, FEATURE2]
388+
#build.tool.TOOL_NAME.features = [FEATURE1, FEATURE2]
389389

390390
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation
391391
#build.verbose = 0

src/bootstrap/configure.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shlex
77
import sys
88
import os
9+
import re
910

1011
rust_dir = os.path.dirname(os.path.abspath(__file__))
1112
rust_dir = os.path.dirname(rust_dir)
@@ -585,16 +586,31 @@ def parse_example_config(known_args, config):
585586
section_order = [None]
586587
targets = {}
587588
top_level_keys = []
589+
comment_lines = []
588590

589591
with open(rust_dir + "/bootstrap.example.toml") as example_config:
590592
example_lines = example_config.read().split("\n")
591593
for line in example_lines:
592-
if cur_section is None:
593-
if line.count("=") == 1:
594-
top_level_key = line.split("=")[0]
595-
top_level_key = top_level_key.strip(" #")
596-
top_level_keys.append(top_level_key)
597-
if line.startswith("["):
594+
if line.count("=") == 1 and not line.startswith("# "):
595+
key = line.split("=")[0]
596+
key = key.strip(" #")
597+
parts = key.split(".")
598+
if len(parts) > 1:
599+
cur_section = parts[0]
600+
if cur_section not in sections:
601+
sections[cur_section] = ["[" + cur_section + "]"]
602+
section_order.append(cur_section)
603+
elif cur_section is None:
604+
top_level_keys.append(key)
605+
# put the comment lines within the start of
606+
# a new section, not outside it.
607+
sections[cur_section] += comment_lines
608+
comment_lines = []
609+
# remove just the `section.` part from the line, if present.
610+
sections[cur_section].append(
611+
re.sub("(#?)([a-zA-Z_-]+\\.)?(.*)", "\\1\\3", line)
612+
)
613+
elif line.startswith("["):
598614
cur_section = line[1:-1]
599615
if cur_section.startswith("target"):
600616
cur_section = "target"
@@ -605,8 +621,9 @@ def parse_example_config(known_args, config):
605621
sections[cur_section] = [line]
606622
section_order.append(cur_section)
607623
else:
608-
sections[cur_section].append(line)
624+
comment_lines.append(line)
609625

626+
sections[cur_section] += comment_lines
610627
# Fill out the `targets` array by giving all configured targets a copy of the
611628
# `target` section we just loaded from the example config
612629
configured_targets = [build(known_args)]

0 commit comments

Comments
 (0)