Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: pylib/gyp/generator/ninja.py

Issue 9427002: Fix quoting shell args on Windows (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/generator/ninja.py
===================================================================
--- pylib/gyp/generator/ninja.py (revision 1214)
+++ pylib/gyp/generator/ninja.py (working copy)
@@ -5,6 +5,7 @@
import copy
import gyp
import gyp.common
+import gyp.msvs_emulation
import gyp.system_test
import gyp.xcode_emulation
import os.path
@@ -55,17 +56,17 @@
return arg[len(prefix):]
return arg
-
-def QuoteShellArgument(arg):
+def QuoteShellArgument(arg, flavor):
"""Quote a string such that it will be interpreted as a single argument
by the shell."""
# Rather than attempting to enumerate the bad shell characters, just
# whitelist common OK ones and quote anything else.
if re.match(r'^[a-zA-Z0-9_=-]+$', arg):
return arg # No quoting necessary.
+ if flavor == 'win':
+ return gyp.msvs_emulation.QuoteCmdExeArgument(arg)
return "'" + arg.replace("'", "'" + '"\'"' + "'") + "'"
-
def InvertRelativePath(path):
"""Given a relative path like foo/bar, return the inverse relative path:
the path from the relative path back to the origin dir.
@@ -556,7 +557,8 @@
intermediate_plist = self.GypPathToUniqueOutput(
os.path.basename(info_plist))
defines = ' '.join(
- [QuoteShellArgument(ninja_syntax.escape('-D' + d)) for d in defines])
+ [QuoteShellArgument(ninja_syntax.escape('-D' + d), self.flavor)
+ for d in defines])
info_plist = self.ninja.build(intermediate_plist, 'infoplist', info_plist,
variables=[('defines',defines)])
@@ -589,7 +591,7 @@
cflags_cc = config.get('cflags_cc', [])
self.WriteVariableList('defines',
- [QuoteShellArgument(ninja_syntax.escape('-D' + d))
+ [QuoteShellArgument(ninja_syntax.escape('-D' + d), self.flavor)
for d in config.get('defines', [])])
self.WriteVariableList('includes',
['-I' + self.GypPathToNinja(i)
@@ -785,9 +787,12 @@
returned string will start with ' && '."""
if not self.xcode_settings or spec['type'] == 'none' or not output:
return ''
- output = QuoteShellArgument(output)
+ output = QuoteShellArgument(output, self.flavor)
target_postbuilds = self.xcode_settings.GetTargetPostbuilds(
- self.config_name, output, QuoteShellArgument(output_binary), quiet=True)
+ self.config_name,
+ output,
+ QuoteShellArgument(output_binary, self.flavor),
+ quiet=True)
postbuilds = gyp.xcode_emulation.GetSpecPostbuildCommands(
spec, self.GypPathToNinja, quiet=True)
postbuilds = target_postbuilds + postbuilds
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698