OLD | NEW |
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 Loading... |
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 Loading... |
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)) |
OLD | NEW |