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,6 @@ |
return arg[len(prefix):] |
return arg |
- |
-def QuoteShellArgument(arg): |
- """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. |
- 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. |
@@ -188,6 +178,17 @@ |
# Relative path from base dir to build dir. |
self.base_to_build = os.path.join(InvertRelativePath(base_dir), build_dir) |
+ def QuoteShellArgument(self, arg): |
Nico
2012/02/20 23:17:49
nit: I would've made flavor a parameter instead
scottmg
2012/02/21 00:14:44
Done.
|
+ """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 self.flavor == 'win': |
+ return gyp.msvs_emulation.QuoteCmdExeArgument(arg) |
+ return "'" + arg.replace("'", "'" + '"\'"' + "'") + "'" |
+ |
def ExpandSpecial(self, path, product_dir=None): |
"""Expand specials like $!PRODUCT_DIR in |path|. |
@@ -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]) |
+ [self.QuoteShellArgument(ninja_syntax.escape('-D' + d)) |
+ 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)) |
+ [self.QuoteShellArgument(ninja_syntax.escape('-D' + d)) |
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 = self.QuoteShellArgument(output) |
target_postbuilds = self.xcode_settings.GetTargetPostbuilds( |
- self.config_name, output, QuoteShellArgument(output_binary), quiet=True) |
+ self.config_name, |
+ output, |
+ self.QuoteShellArgument(output_binary), |
+ quiet=True) |
postbuilds = gyp.xcode_emulation.GetSpecPostbuildCommands( |
spec, self.GypPathToNinja, quiet=True) |
postbuilds = target_postbuilds + postbuilds |