Skip to content

Commit 8471c6b

Browse files
committed
bootstrap: add quoting support to avoid splitting
With this change, it is now possible to pass quotes to the configure script, such as `./configure.py --set=target.\"thumbv8m.main-none-eabi\".linker=/linker` , which will treat `thumbv8.main-none-eabi` as a whole part. Currently, the string would be split into two elements: `thumbv8`, and `main-none-eabi`.
1 parent 27e38f8 commit 8471c6b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/bootstrap/configure.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# ignore-tidy-linelength
44

55
from __future__ import absolute_import, division, print_function
6+
import shlex
67
import sys
78
import os
89
rust_dir = os.path.dirname(os.path.abspath(__file__))
@@ -288,8 +289,9 @@ def build(known_args):
288289

289290
def set(key, value, config):
290291
if isinstance(value, list):
291-
# Remove empty values, which value.split(',') tends to generate.
292-
value = [v for v in value if v]
292+
# Remove empty values, which value.split(',') tends to generate and
293+
# replace single quotes for double quotes to ensure correct parsing.
294+
value = [v.replace('\'', '"') for v in value if v]
293295

294296
s = "{:20} := {}".format(key, value)
295297
if len(s) < 70 or VERBOSE:
@@ -298,7 +300,13 @@ def set(key, value, config):
298300
p(s[:70] + " ...")
299301

300302
arr = config
301-
parts = key.split('.')
303+
304+
# Split `key` on periods using shell semantics.
305+
lexer = shlex.shlex(key, posix=True)
306+
lexer.whitespace = "."
307+
lexer.wordchars += "-"
308+
parts = list(lexer)
309+
302310
for i, part in enumerate(parts):
303311
if i == len(parts) - 1:
304312
if is_value_list(part) and isinstance(value, str):

0 commit comments

Comments
 (0)