OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 import copy | 3 import copy |
4 import gyp.input | 4 import gyp.input |
5 import optparse | 5 import optparse |
6 import os.path | 6 import os.path |
7 import re | 7 import re |
8 import shlex | 8 import shlex |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 extension = '.gyp' | 23 extension = '.gyp' |
24 files = os.listdir(os.getcwd()) | 24 files = os.listdir(os.getcwd()) |
25 build_files = [] | 25 build_files = [] |
26 for file in files: | 26 for file in files: |
27 if file[-len(extension):] == extension: | 27 if file[-len(extension):] == extension: |
28 build_files.append(file) | 28 build_files.append(file) |
29 return build_files | 29 return build_files |
30 | 30 |
31 | 31 |
32 def Load(build_files, format, default_variables={}, | 32 def Load(build_files, format, default_variables={}, |
33 includes=[], depth='.', params={}): | 33 includes=[], depth='.', params={}, check=False): |
34 """ | 34 """ |
35 Loads one or more specified build files. | 35 Loads one or more specified build files. |
36 default_variables and includes will be copied before use. | 36 default_variables and includes will be copied before use. |
37 Returns the generator for the specified format and the | 37 Returns the generator for the specified format and the |
38 data returned by loading the specified build files. | 38 data returned by loading the specified build files. |
39 """ | 39 """ |
40 default_variables = copy.copy(default_variables) | 40 default_variables = copy.copy(default_variables) |
41 | 41 |
42 # Default variables provided by this program and its modules should be | 42 # Default variables provided by this program and its modules should be |
43 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, | 43 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, |
(...skipping 22 matching lines...) Expand all Loading... |
66 'non_configuration_keys': | 66 'non_configuration_keys': |
67 getattr(generator, 'generator_additional_non_configuration_keys', []), | 67 getattr(generator, 'generator_additional_non_configuration_keys', []), |
68 'path_sections': | 68 'path_sections': |
69 getattr(generator, 'generator_additional_path_sections', []), | 69 getattr(generator, 'generator_additional_path_sections', []), |
70 'extra_sources_for_rules': | 70 'extra_sources_for_rules': |
71 getattr(generator, 'generator_extra_sources_for_rules', []), | 71 getattr(generator, 'generator_extra_sources_for_rules', []), |
72 } | 72 } |
73 | 73 |
74 # Process the input specific to this generator. | 74 # Process the input specific to this generator. |
75 result = gyp.input.Load(build_files, default_variables, includes[:], | 75 result = gyp.input.Load(build_files, default_variables, includes[:], |
76 depth, generator_input_info) | 76 depth, generator_input_info, check) |
77 return [generator] + result | 77 return [generator] + result |
78 | 78 |
79 def NameValueListToDict(name_value_list): | 79 def NameValueListToDict(name_value_list): |
80 """ | 80 """ |
81 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary | 81 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary |
82 of the pairs. If a string is simply NAME, then the value in the dictionary | 82 of the pairs. If a string is simply NAME, then the value in the dictionary |
83 is set to True. If VALUE can be converted to an integer, it is. | 83 is set to True. If VALUE can be converted to an integer, it is. |
84 """ | 84 """ |
85 result = { } | 85 result = { } |
86 for item in name_value_list: | 86 for item in name_value_list: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 action='append', default=[], help='turn on a debugging ' | 119 action='append', default=[], help='turn on a debugging ' |
120 'mode for debugging GYP. Supported modes are "variables" ' | 120 'mode for debugging GYP. Supported modes are "variables" ' |
121 'and "general"') | 121 'and "general"') |
122 parser.add_option('-S', '--suffix', dest='suffix', default='', | 122 parser.add_option('-S', '--suffix', dest='suffix', default='', |
123 help='suffix to add to generated files') | 123 help='suffix to add to generated files') |
124 parser.add_option('-G', dest='generator_flags', action='append', default=[], | 124 parser.add_option('-G', dest='generator_flags', action='append', default=[], |
125 metavar='FLAG=VAL', help='sets generator flag FLAG to VAL') | 125 metavar='FLAG=VAL', help='sets generator flag FLAG to VAL') |
126 parser.add_option('--generator-output', dest='generator_output', | 126 parser.add_option('--generator-output', dest='generator_output', |
127 action='store', default=None, metavar='DIR', | 127 action='store', default=None, metavar='DIR', |
128 help='puts generated build files under DIR') | 128 help='puts generated build files under DIR') |
| 129 parser.add_option('--check', dest='check', action='store_true', |
| 130 help='check format of gyp files') |
129 | 131 |
130 # We read a few things from ~/.gyp, so set up a var for that. | 132 # We read a few things from ~/.gyp, so set up a var for that. |
131 home_vars = ['HOME'] | 133 home_vars = ['HOME'] |
132 if sys.platform in ('cygwin', 'win32'): | 134 if sys.platform in ('cygwin', 'win32'): |
133 home_vars.append('USERPROFILE') | 135 home_vars.append('USERPROFILE') |
134 home = None | 136 home = None |
135 for home_var in home_vars: | 137 for home_var in home_vars: |
136 home = os.getenv(home_var) | 138 home = os.getenv(home_var) |
137 if home != None: | 139 if home != None: |
138 break | 140 break |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 for format in set(options.formats): | 264 for format in set(options.formats): |
263 params = {'options': options, | 265 params = {'options': options, |
264 'build_files': build_files, | 266 'build_files': build_files, |
265 'generator_flags': generator_flags, | 267 'generator_flags': generator_flags, |
266 'cwd': os.getcwd()} | 268 'cwd': os.getcwd()} |
267 | 269 |
268 # Start with the default variables from the command line. | 270 # Start with the default variables from the command line. |
269 [generator, flat_list, targets, data] = Load(build_files, format, | 271 [generator, flat_list, targets, data] = Load(build_files, format, |
270 cmdline_default_variables, | 272 cmdline_default_variables, |
271 includes, options.depth, | 273 includes, options.depth, |
272 params) | 274 params, options.check) |
273 | 275 |
274 # TODO(mark): Pass |data| for now because the generator needs a list of | 276 # TODO(mark): Pass |data| for now because the generator needs a list of |
275 # build files that came in. In the future, maybe it should just accept | 277 # build files that came in. In the future, maybe it should just accept |
276 # a list, and not the whole data dict. | 278 # a list, and not the whole data dict. |
277 # NOTE: flat_list is the flattened dependency graph specifying the order | 279 # NOTE: flat_list is the flattened dependency graph specifying the order |
278 # that targets may be built. Build systems that operate serially or that | 280 # that targets may be built. Build systems that operate serially or that |
279 # need to have dependencies defined before dependents reference them should | 281 # need to have dependencies defined before dependents reference them should |
280 # generate targets in the order specified in flat_list. | 282 # generate targets in the order specified in flat_list. |
281 generator.GenerateOutput(flat_list, targets, data, params) | 283 generator.GenerateOutput(flat_list, targets, data, params) |
282 | 284 |
283 # Done | 285 # Done |
284 return 0 | 286 return 0 |
285 | 287 |
286 | 288 |
287 if __name__ == '__main__': | 289 if __name__ == '__main__': |
288 sys.exit(main(sys.argv[1:])) | 290 sys.exit(main(sys.argv[1:])) |
OLD | NEW |