buildman: Improve [make-flags] section parser to allow quoted strings
authorCristian Ciocaltea <cristian.ciocaltea@gmail.com>
Sun, 24 Nov 2019 20:30:26 +0000 (22:30 +0200)
committerSimon Glass <sjg@chromium.org>
Tue, 10 Dec 2019 12:54:55 +0000 (05:54 -0700)
The parser responsible for the '[make-flags]' section in
the '.buildman' settings file is currently not able to
handle quoted strings, as given in the sample bellow:

[make-flags]
qemu_arm=HOSTCC="cc -isystem /add/include" HOSTLDFLAGS="-L/add/lib"

This patch replaces the simple string splitter based on the <space>
delimiter with a regex tokenizer that preserves spaces inside double
quoted strings.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
tools/buildman/toolchain.py

index cc26e2ede5737bb0814fda9216cde42ee0faf73f..086a4d47cdfcad2531a4dd9383ccec0174bd5f0b 100644 (file)
@@ -435,9 +435,10 @@ class Toolchains:
         self._make_flags['target'] = board.target
         arg_str = self.ResolveReferences(self._make_flags,
                            self._make_flags.get(board.target, ''))
-        args = arg_str.split(' ')
+        args = re.findall("(?:\".*?\"|\S)+", arg_str)
         i = 0
         while i < len(args):
+            args[i] = args[i].replace('"', '')
             if not args[i]:
                 del args[i]
             else: