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

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

Issue 10408026: Try to fix defines containing '#' characters with cl.exe. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 7 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 | « pylib/gyp/generator/msvs.py ('k') | test/defines/defines.gyp » ('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 1387)
+++ pylib/gyp/generator/ninja.py (working copy)
@@ -71,6 +71,16 @@
return "'" + arg.replace("'", "'" + '"\'"' + "'") + "'"
+def Define(d, flavor):
+ """Takes a preprocessor define and returns a -D parameter that's ninja- and
+ shell-escaped."""
+ if flavor == 'win':
+ # cl.exe replaces literal # characters with = in preprocesor definitions for
+ # some reason. Octal-encode to work around that.
+ d = d.replace('#', '\\%03o' % ord('#'))
+ return QuoteShellArgument(ninja_syntax.escape('-D' + d), flavor)
+
+
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.
@@ -635,9 +645,7 @@
# Create an intermediate file to store preprocessed results.
intermediate_plist = self.GypPathToUniqueOutput(
os.path.basename(info_plist))
- defines = ' '.join(
- [QuoteShellArgument(ninja_syntax.escape('-D' + d), self.flavor)
- for d in defines])
+ defines = ' '.join([Define(d, self.flavor) for d in defines])
info_plist = self.ninja.build(intermediate_plist, 'infoplist', info_plist,
variables=[('defines',defines)])
@@ -679,9 +687,7 @@
cflags_cc = config.get('cflags_cc', [])
defines = config.get('defines', []) + extra_defines
- self.WriteVariableList('defines',
- [QuoteShellArgument(ninja_syntax.escape('-D' + d), self.flavor)
- for d in defines])
+ self.WriteVariableList('defines', [Define(d, self.flavor) for d in defines])
if self.flavor == 'win':
self.WriteVariableList('rcflags',
[QuoteShellArgument(self.ExpandSpecial(f), self.flavor)
« no previous file with comments | « pylib/gyp/generator/msvs.py ('k') | test/defines/defines.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698