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

Side by Side Diff: build/gyp_chromium

Issue 144573004: gn/gyp: Escape \ in addition to $ and " in strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: foo Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # This script is wrapper for Chromium that adds some support for how GYP 7 # This script is wrapper for Chromium that adds some support for how GYP
8 # is invoked by Chromium beyond what can be done in the gclient hooks. 8 # is invoked by Chromium beyond what can be done in the gclient hooks.
9 9
10 import glob 10 import glob
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 """Returns the given GYP key reformatted for GN. 70 """Returns the given GYP key reformatted for GN.
71 71
72 GYP dictionary keys can be almost anything, but in GN they are identifiers 72 GYP dictionary keys can be almost anything, but in GN they are identifiers
73 and must follow the same rules. This reformats such keys to be valid GN 73 and must follow the same rules. This reformats such keys to be valid GN
74 identifiers.""" 74 identifiers."""
75 return ''.join([c if c in string.ascii_letters else '_' for c in key]) 75 return ''.join([c if c in string.ascii_letters else '_' for c in key])
76 76
77 77
78 def EscapeStringForGN(s): 78 def EscapeStringForGN(s):
79 """Converts a string to a GN string literal.""" 79 """Converts a string to a GN string literal."""
80 # Escape $ characters which have special meaning to GN. 80 for old, new in [('\\', '\\\\'), ('$', '\\$'), ('"', '\\"')]:
81 return '"' + s.replace('$', '\\$').replace('"', '\\"') + '"' 81 s = s.replace(old, new)
82 return '"' + s + '"'
82 83
83 84
84 def ProcessGypDefinesItems(items): 85 def ProcessGypDefinesItems(items):
85 """Converts a list of strings to a list of key-value pairs.""" 86 """Converts a list of strings to a list of key-value pairs."""
86 result = [] 87 result = []
87 for item in items: 88 for item in items:
88 tokens = item.split('=', 1) 89 tokens = item.split('=', 1)
89 # Some GYP variables have hyphens, which we don't support. 90 # Some GYP variables have hyphens, which we don't support.
90 key = FormatKeyForGN(tokens[0]) 91 key = FormatKeyForGN(tokens[0])
91 if len(tokens) == 2: 92 if len(tokens) == 2:
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 args.extend( 428 args.extend(
428 ['-I' + i for i in additional_include_files(supplemental_includes, args)]) 429 ['-I' + i for i in additional_include_files(supplemental_includes, args)])
429 430
430 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()]) 431 args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()])
431 432
432 print 'Updating projects from gyp files...' 433 print 'Updating projects from gyp files...'
433 sys.stdout.flush() 434 sys.stdout.flush()
434 435
435 # Off we go... 436 # Off we go...
436 sys.exit(gyp.main(args)) 437 sys.exit(gyp.main(args))
OLDNEW
« 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