summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-06-16 20:27:14 (GMT)
committerEvan Martin <martine@danga.com>2012-06-16 20:27:14 (GMT)
commita08b8c8344ca2eae02539e2a6f702dcfd197091c (patch)
tree3b71b6fbe49aa6c3b580742b9d8be2726c13f500
parentd064dc5881a12ed962b6ae6e0c62be31c93df34b (diff)
downloadNinja-a08b8c8344ca2eae02539e2a6f702dcfd197091c.zip
Ninja-a08b8c8344ca2eae02539e2a6f702dcfd197091c.tar.gz
Ninja-a08b8c8344ca2eae02539e2a6f702dcfd197091c.tar.bz2
rearrange shell quoting in configure.py
-rwxr-xr-xconfigure.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/configure.py b/configure.py
index 9eb2a48..ef0622f 100755
--- a/configure.py
+++ b/configure.py
@@ -123,7 +123,7 @@ else:
'-fno-rtti',
'-fno-exceptions',
'-fvisibility=hidden', '-pipe',
- "'-DNINJA_PYTHON=\"%s\"'" % (options.with_python,)]
+ "-DNINJA_PYTHON=\"%s\"" % options.with_python]
if options.debug:
cflags += ['-D_GLIBCXX_DEBUG', '-D_GLIBCXX_DEBUG_PEDANTIC']
else:
@@ -147,12 +147,21 @@ else:
elif options.profile == 'pprof':
libs.append('-lprofiler')
+def shell_escape(str):
+ """Escape str such that it's interpreted as a single argument by the shell."""
+ # This isn't complete, but it's just enough to make NINJA_PYTHON work.
+ # TODO: do the appropriate thing for Windows-style cmd here, perhaps by
+ # just returning the input string.
+ if '"' in str:
+ return "'%s'" % str.replace("'", "\'")
+ return str
+
if 'CFLAGS' in configure_env:
cflags.append(configure_env['CFLAGS'])
-n.variable('cflags', ' '.join(cflags))
+n.variable('cflags', ' '.join(shell_escape(flag) for flag in cflags))
if 'LDFLAGS' in configure_env:
ldflags.append(configure_env['LDFLAGS'])
-n.variable('ldflags', ' '.join(ldflags))
+n.variable('ldflags', ' '.join(shell_escape(flag) for flag in ldflags))
n.newline()
if platform == 'windows':