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

Unified Diff: build/gyp_chromium

Issue 106143002: gyp_chromium: Escape " for gn files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/gyp_chromium
diff --git a/build/gyp_chromium b/build/gyp_chromium
index 64e4ff5e969449556111d4345def7ca80e4273cc..05bc3fa09eb86b2e16a18616b9d69a3e7232b56f 100755
--- a/build/gyp_chromium
+++ b/build/gyp_chromium
@@ -72,6 +72,12 @@ def FormatKeyForGN(key):
return ''.join([c if c in string.ascii_letters else '_' for c in key])
+def EscapeStringForGN(s):
+ """Converts a string to a GN string literal."""
+ # Escape $ characters which have special meaning to GN.
+ return '"' + s.replace('$', '\\$').replace('"', '\\"') + '"'
+
+
def GetVarsStringForGN(supplemental_files):
vars_dict = {}
@@ -84,8 +90,7 @@ def GetVarsStringForGN(supplemental_files):
raise
variables = file_data.get('variables', [])
for v in variables:
- vars_dict[FormatKeyForGN(v)] = '"' + \
- str(variables[v]).replace("$", "\\$") + '"'
+ vars_dict[FormatKeyForGN(v)] = EscapeStringForGN(str(variables[v]))
env_string = os.environ.get('GYP_DEFINES', '')
items = shlex.split(env_string)
@@ -94,8 +99,7 @@ def GetVarsStringForGN(supplemental_files):
# Some GYP variables have hyphens, which we don't support.
key = FormatKeyForGN(tokens[0])
if len(tokens) == 2:
- # Escape $ characters which have special meaning to GN.
- vars_dict[key] = '"' + tokens[1].replace("$", "\\$") + '"'
+ vars_dict[key] = EscapeStringForGN(tokens[1])
else:
# No value supplied, treat it as a boolean and set it.
vars_dict[key] = 'true'
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698