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