| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009 Google Inc. All rights reserved. | 3 # Copyright (c) 2009 Google Inc. 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 import copy | 7 import copy |
| 8 import gyp.input | 8 import gyp.input |
| 9 import optparse | 9 import optparse |
| 10 import os.path | 10 import os.path |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 extension = '.gyp' | 28 extension = '.gyp' |
| 29 files = os.listdir(os.getcwd()) | 29 files = os.listdir(os.getcwd()) |
| 30 build_files = [] | 30 build_files = [] |
| 31 for file in files: | 31 for file in files: |
| 32 if file[-len(extension):] == extension: | 32 if file[-len(extension):] == extension: |
| 33 build_files.append(file) | 33 build_files.append(file) |
| 34 return build_files | 34 return build_files |
| 35 | 35 |
| 36 | 36 |
| 37 def Load(build_files, format, default_variables={}, | 37 def Load(build_files, format, default_variables={}, |
| 38 includes=[], depth='.', params={}, check=False): | 38 includes=[], depth='.', params={}, check=False, circular_check=True): |
| 39 """ | 39 """ |
| 40 Loads one or more specified build files. | 40 Loads one or more specified build files. |
| 41 default_variables and includes will be copied before use. | 41 default_variables and includes will be copied before use. |
| 42 Returns the generator for the specified format and the | 42 Returns the generator for the specified format and the |
| 43 data returned by loading the specified build files. | 43 data returned by loading the specified build files. |
| 44 """ | 44 """ |
| 45 default_variables = copy.copy(default_variables) | 45 default_variables = copy.copy(default_variables) |
| 46 | 46 |
| 47 # Default variables provided by this program and its modules should be | 47 # Default variables provided by this program and its modules should be |
| 48 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, | 48 # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 73 'path_sections': | 73 'path_sections': |
| 74 getattr(generator, 'generator_additional_path_sections', []), | 74 getattr(generator, 'generator_additional_path_sections', []), |
| 75 'extra_sources_for_rules': | 75 'extra_sources_for_rules': |
| 76 getattr(generator, 'generator_extra_sources_for_rules', []), | 76 getattr(generator, 'generator_extra_sources_for_rules', []), |
| 77 'generator_supports_multiple_toolsets': | 77 'generator_supports_multiple_toolsets': |
| 78 getattr(generator, 'generator_supports_multiple_toolsets', False), | 78 getattr(generator, 'generator_supports_multiple_toolsets', False), |
| 79 } | 79 } |
| 80 | 80 |
| 81 # Process the input specific to this generator. | 81 # Process the input specific to this generator. |
| 82 result = gyp.input.Load(build_files, default_variables, includes[:], | 82 result = gyp.input.Load(build_files, default_variables, includes[:], |
| 83 depth, generator_input_info, check) | 83 depth, generator_input_info, check, circular_check) |
| 84 return [generator] + result | 84 return [generator] + result |
| 85 | 85 |
| 86 def NameValueListToDict(name_value_list): | 86 def NameValueListToDict(name_value_list): |
| 87 """ | 87 """ |
| 88 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary | 88 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary |
| 89 of the pairs. If a string is simply NAME, then the value in the dictionary | 89 of the pairs. If a string is simply NAME, then the value in the dictionary |
| 90 is set to True. If VALUE can be converted to an integer, it is. | 90 is set to True. If VALUE can be converted to an integer, it is. |
| 91 """ | 91 """ |
| 92 result = { } | 92 result = { } |
| 93 for item in name_value_list: | 93 for item in name_value_list: |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 help='sets generator flag FLAG to VAL') | 257 help='sets generator flag FLAG to VAL') |
| 258 parser.add_option('--generator-output', dest='generator_output', | 258 parser.add_option('--generator-output', dest='generator_output', |
| 259 action='store', default=None, metavar='DIR', type='path', | 259 action='store', default=None, metavar='DIR', type='path', |
| 260 env_name='GYP_GENERATOR_OUTPUT', | 260 env_name='GYP_GENERATOR_OUTPUT', |
| 261 help='puts generated build files under DIR') | 261 help='puts generated build files under DIR') |
| 262 parser.add_option('--ignore-environment', dest='use_environment', | 262 parser.add_option('--ignore-environment', dest='use_environment', |
| 263 action='store_false', default=True, regenerate=False, | 263 action='store_false', default=True, regenerate=False, |
| 264 help='do not read options from environment variables') | 264 help='do not read options from environment variables') |
| 265 parser.add_option('--check', dest='check', action='store_true', | 265 parser.add_option('--check', dest='check', action='store_true', |
| 266 help='check format of gyp files') | 266 help='check format of gyp files') |
| 267 # --no-circular-check disables the check for circular relationships between |
| 268 # .gyp files. These relationships should not exist, but they've only been |
| 269 # observed to be harmful with the Xcode generator. Chromium's .gyp files |
| 270 # currently have some circular relationships on non-Mac platforms, so this |
| 271 # option allows the strict behavior to be used on Macs and the lenient |
| 272 # behavior to be used elsewhere. |
| 273 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. |
| 274 parser.add_option('--no-circular-check', dest='circular_check', |
| 275 action='store_false', default=True, regenerate=False, |
| 276 help="don't check for circular relationships between files") |
| 267 | 277 |
| 268 # We read a few things from ~/.gyp, so set up a var for that. | 278 # We read a few things from ~/.gyp, so set up a var for that. |
| 269 home_vars = ['HOME'] | 279 home_vars = ['HOME'] |
| 270 if sys.platform in ('cygwin', 'win32'): | 280 if sys.platform in ('cygwin', 'win32'): |
| 271 home_vars.append('USERPROFILE') | 281 home_vars.append('USERPROFILE') |
| 272 home = None | 282 home = None |
| 273 for home_var in home_vars: | 283 for home_var in home_vars: |
| 274 home = os.getenv(home_var) | 284 home = os.getenv(home_var) |
| 275 if home != None: | 285 if home != None: |
| 276 break | 286 break |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 'generator_flags': generator_flags, | 423 'generator_flags': generator_flags, |
| 414 'cwd': os.getcwd(), | 424 'cwd': os.getcwd(), |
| 415 'build_files_arg': build_files_arg, | 425 'build_files_arg': build_files_arg, |
| 416 'gyp_binary': sys.argv[0], | 426 'gyp_binary': sys.argv[0], |
| 417 'home_dot_gyp': home_dot_gyp} | 427 'home_dot_gyp': home_dot_gyp} |
| 418 | 428 |
| 419 # Start with the default variables from the command line. | 429 # Start with the default variables from the command line. |
| 420 [generator, flat_list, targets, data] = Load(build_files, format, | 430 [generator, flat_list, targets, data] = Load(build_files, format, |
| 421 cmdline_default_variables, | 431 cmdline_default_variables, |
| 422 includes, options.depth, | 432 includes, options.depth, |
| 423 params, options.check) | 433 params, options.check, |
| 434 options.circular_check) |
| 424 | 435 |
| 425 # TODO(mark): Pass |data| for now because the generator needs a list of | 436 # TODO(mark): Pass |data| for now because the generator needs a list of |
| 426 # build files that came in. In the future, maybe it should just accept | 437 # build files that came in. In the future, maybe it should just accept |
| 427 # a list, and not the whole data dict. | 438 # a list, and not the whole data dict. |
| 428 # NOTE: flat_list is the flattened dependency graph specifying the order | 439 # NOTE: flat_list is the flattened dependency graph specifying the order |
| 429 # that targets may be built. Build systems that operate serially or that | 440 # that targets may be built. Build systems that operate serially or that |
| 430 # need to have dependencies defined before dependents reference them should | 441 # need to have dependencies defined before dependents reference them should |
| 431 # generate targets in the order specified in flat_list. | 442 # generate targets in the order specified in flat_list. |
| 432 generator.GenerateOutput(flat_list, targets, data, params) | 443 generator.GenerateOutput(flat_list, targets, data, params) |
| 433 | 444 |
| 434 # Done | 445 # Done |
| 435 return 0 | 446 return 0 |
| 436 | 447 |
| 437 | 448 |
| 438 if __name__ == '__main__': | 449 if __name__ == '__main__': |
| 439 sys.exit(main(sys.argv[1:])) | 450 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |