Skip to content

Commit a0158b8

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

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/bootstrap/configure.py

Lines changed: 14 additions & 6 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)
@@ -589,11 +590,17 @@ def parse_example_config(known_args, config):
589590
with open(rust_dir + "/bootstrap.example.toml") as example_config:
590591
example_lines = example_config.read().split("\n")
591592
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)
593+
if line.count("=") == 1 and not line.startswith("# "):
594+
key = line.split("=")[0]
595+
key = key.strip(" #")
596+
parts = key.split(".");
597+
if len(parts) > 1:
598+
cur_section = parts[0]
599+
if not (cur_section in sections):
600+
sections[cur_section] = ["[" + cur_section + "]"]
601+
section_order.append(cur_section)
602+
elif cur_section is None:
603+
top_level_keys.append(key)
597604
if line.startswith("["):
598605
cur_section = line[1:-1]
599606
if cur_section.startswith("target"):
@@ -605,7 +612,8 @@ def parse_example_config(known_args, config):
605612
sections[cur_section] = [line]
606613
section_order.append(cur_section)
607614
else:
608-
sections[cur_section].append(line)
615+
# remove just the `section.` part from the line, if present.
616+
sections[cur_section].append(re.sub("(#?)([a-zA-Z_-]+\\.)?(.*)", "\\1\\3", line))
609617

610618
# Fill out the `targets` array by giving all configured targets a copy of the
611619
# `target` section we just loaded from the example config

0 commit comments

Comments
 (0)