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`.
This commit is contained in:
parent
27e38f8fc7
commit
8471c6bb0c
@ -3,6 +3,7 @@
|
|||||||
# ignore-tidy-linelength
|
# ignore-tidy-linelength
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
rust_dir = os.path.dirname(os.path.abspath(__file__))
|
rust_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
@ -288,8 +289,9 @@ def build(known_args):
|
|||||||
|
|
||||||
def set(key, value, config):
|
def set(key, value, config):
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
# Remove empty values, which value.split(',') tends to generate.
|
# Remove empty values, which value.split(',') tends to generate and
|
||||||
value = [v for v in value if v]
|
# replace single quotes for double quotes to ensure correct parsing.
|
||||||
|
value = [v.replace('\'', '"') for v in value if v]
|
||||||
|
|
||||||
s = "{:20} := {}".format(key, value)
|
s = "{:20} := {}".format(key, value)
|
||||||
if len(s) < 70 or VERBOSE:
|
if len(s) < 70 or VERBOSE:
|
||||||
@ -298,7 +300,13 @@ def set(key, value, config):
|
|||||||
p(s[:70] + " ...")
|
p(s[:70] + " ...")
|
||||||
|
|
||||||
arr = config
|
arr = config
|
||||||
parts = key.split('.')
|
|
||||||
|
# Split `key` on periods using shell semantics.
|
||||||
|
lexer = shlex.shlex(key, posix=True)
|
||||||
|
lexer.whitespace = "."
|
||||||
|
lexer.wordchars += "-"
|
||||||
|
parts = list(lexer)
|
||||||
|
|
||||||
for i, part in enumerate(parts):
|
for i, part in enumerate(parts):
|
||||||
if i == len(parts) - 1:
|
if i == len(parts) - 1:
|
||||||
if is_value_list(part) and isinstance(value, str):
|
if is_value_list(part) and isinstance(value, str):
|
||||||
|
Loading…
Reference in New Issue
Block a user