OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Converts a given gypi file to a python scope and writes the result to stdout. | 5 """Converts a given gypi file to a python scope and writes the result to stdout. |
6 | 6 |
| 7 USING THIS SCRIPT IN CHROMIUM |
| 8 |
| 9 Forking Python to run this script in the middle of GN is slow, especially on |
| 10 Windows, and it makes both the GYP and GN files harder to follow. You can't |
| 11 use "git grep" to find files in the GN build any more, and tracking everything |
| 12 in GYP down requires a level of indirection. Any calls will have to be removed |
| 13 and cleaned up once the GYP-to-GN transition is complete. |
| 14 |
| 15 As a result, we only use this script when the list of files is large and |
| 16 frequently-changing. In these cases, having one canonical list outweights the |
| 17 downsides. |
| 18 |
| 19 As of this writing, the GN build is basically complete. It's likely that all |
| 20 large and frequently changing targets where this is appropriate use this |
| 21 mechanism already. And since we hope to turn down the GYP build soon, the time |
| 22 horizon is also relatively short. As a result, it is likely that no additional |
| 23 uses of this script should every be added to the build. During this later part |
| 24 of the transition period, we should be focusing more and more on the absolute |
| 25 readability of the GN build. |
| 26 |
| 27 |
| 28 HOW TO USE |
| 29 |
7 It is assumed that the file contains a toplevel dictionary, and this script | 30 It is assumed that the file contains a toplevel dictionary, and this script |
8 will return that dictionary as a GN "scope" (see example below). This script | 31 will return that dictionary as a GN "scope" (see example below). This script |
9 does not know anything about GYP and it will not expand variables or execute | 32 does not know anything about GYP and it will not expand variables or execute |
10 conditions. | 33 conditions. |
11 | 34 |
12 It will strip conditions blocks. | 35 It will strip conditions blocks. |
13 | 36 |
14 A variables block at the top level will be flattened so that the variables | 37 A variables block at the top level will be flattened so that the variables |
15 appear in the root dictionary. This way they can be returned to the GN code. | 38 appear in the root dictionary. This way they can be returned to the GN code. |
16 | 39 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 del data[key] | 182 del data[key] |
160 | 183 |
161 print gn_helpers.ToGNString(data) | 184 print gn_helpers.ToGNString(data) |
162 | 185 |
163 if __name__ == '__main__': | 186 if __name__ == '__main__': |
164 try: | 187 try: |
165 main() | 188 main() |
166 except Exception, e: | 189 except Exception, e: |
167 print str(e) | 190 print str(e) |
168 sys.exit(1) | 191 sys.exit(1) |
OLD | NEW |