[Lldb-commits] [PATCH] Append to CFLAGS_EXTRAS and LD_EXTRAS when building cmdline.
Robert Flack
flackr at gmail.com
Fri Apr 10 07:59:04 PDT 2015
Escape quotes and backslashes in environment variable assignments.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8942
Files:
test/plugins/builder_base.py
Index: test/plugins/builder_base.py
===================================================================
--- test/plugins/builder_base.py
+++ test/plugins/builder_base.py
@@ -78,8 +78,29 @@
# If d is None or an empty mapping, just return an empty string.
if not d:
return ""
- pattern = '%s="%s"' if "win32" in sys.platform else "%s='%s'"
- cmdline = " ".join([pattern % (k, v) for k, v in d.items()])
+
+ def escape(s, escape_chars):
+ """
+ Returns a string with the specified characters escaped by a backslash.
+ """
+ s = s.replace('\\', '\\\\')
+ for c in escape_chars:
+ s = s.replace(c, '\\' + c)
+ return s
+
+ def setOrAppendVariable(k, v):
+ """
+ Append to EXTRAS variables as clobbering them unsets extra flags passed
+ for cross compilation.
+ """
+ quote = '"' if "win32" in sys.platform else "'"
+ append_vars = ["CFLAGS_EXTRAS", "LD_EXTRAS"]
+ if k in append_vars and os.environ.has_key(k):
+ v = os.environ[k] + " " + v
+
+ return '%s=%s%s%s' % (k, quote, escape(v, quote), quote)
+
+ cmdline = " ".join([setOrAppendVariable(k, v) for k, v in d.items()])
return cmdline
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8942.23599.patch
Type: text/x-patch
Size: 1249 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150410/52d13a0b/attachment.bin>
More information about the lldb-commits
mailing list