Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 | 45 |
| 46 | 46 |
| 47 class GypError(Exception): | 47 class GypError(Exception): |
| 48 """Error class representing an error, which is to be presented | 48 """Error class representing an error, which is to be presented |
| 49 to the user. The main entry point will catch and display this. | 49 to the user. The main entry point will catch and display this. |
| 50 """ | 50 """ |
| 51 pass | 51 pass |
| 52 | 52 |
| 53 | 53 |
| 54 def Load(build_files, format, default_variables={}, | 54 def Load(build_files, format, default_variables={}, |
| 55 includes=[], depth='.', params=None, check=False, circular_check=True): | 55 includes=[], depth='.', params=None, check=False, |
| 56 circular_check=True, parallel=False): | |
| 56 """ | 57 """ |
| 57 Loads one or more specified build files. | 58 Loads one or more specified build files. |
| 58 default_variables and includes will be copied before use. | 59 default_variables and includes will be copied before use. |
| 59 Returns the generator for the specified format and the | 60 Returns the generator for the specified format and the |
| 60 data returned by loading the specified build files. | 61 data returned by loading the specified build files. |
| 61 """ | 62 """ |
| 62 if params is None: | 63 if params is None: |
| 63 params = {} | 64 params = {} |
| 64 | 65 |
| 65 flavor = None | 66 flavor = None |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 getattr(generator, 'generator_supports_multiple_toolsets', False), | 124 getattr(generator, 'generator_supports_multiple_toolsets', False), |
| 124 'generator_wants_static_library_dependencies_adjusted': | 125 'generator_wants_static_library_dependencies_adjusted': |
| 125 getattr(generator, | 126 getattr(generator, |
| 126 'generator_wants_static_library_dependencies_adjusted', True), | 127 'generator_wants_static_library_dependencies_adjusted', True), |
| 127 'generator_wants_sorted_dependencies': | 128 'generator_wants_sorted_dependencies': |
| 128 getattr(generator, 'generator_wants_sorted_dependencies', False), | 129 getattr(generator, 'generator_wants_sorted_dependencies', False), |
| 129 } | 130 } |
| 130 | 131 |
| 131 # Process the input specific to this generator. | 132 # Process the input specific to this generator. |
| 132 result = gyp.input.Load(build_files, default_variables, includes[:], | 133 result = gyp.input.Load(build_files, default_variables, includes[:], |
| 133 depth, generator_input_info, check, circular_check) | 134 depth, generator_input_info, check, circular_check, |
| 135 parallel) | |
| 134 return [generator] + result | 136 return [generator] + result |
| 135 | 137 |
| 136 def NameValueListToDict(name_value_list): | 138 def NameValueListToDict(name_value_list): |
| 137 """ | 139 """ |
| 138 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary | 140 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary |
| 139 of the pairs. If a string is simply NAME, then the value in the dictionary | 141 of the pairs. If a string is simply NAME, then the value in the dictionary |
| 140 is set to True. If VALUE can be converted to an integer, it is. | 142 is set to True. If VALUE can be converted to an integer, it is. |
| 141 """ | 143 """ |
| 142 result = { } | 144 result = { } |
| 143 for item in name_value_list: | 145 for item in name_value_list: |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 help='sets generator flag FLAG to VAL') | 312 help='sets generator flag FLAG to VAL') |
| 311 parser.add_option('--generator-output', dest='generator_output', | 313 parser.add_option('--generator-output', dest='generator_output', |
| 312 action='store', default=None, metavar='DIR', type='path', | 314 action='store', default=None, metavar='DIR', type='path', |
| 313 env_name='GYP_GENERATOR_OUTPUT', | 315 env_name='GYP_GENERATOR_OUTPUT', |
| 314 help='puts generated build files under DIR') | 316 help='puts generated build files under DIR') |
| 315 parser.add_option('--ignore-environment', dest='use_environment', | 317 parser.add_option('--ignore-environment', dest='use_environment', |
| 316 action='store_false', default=True, regenerate=False, | 318 action='store_false', default=True, regenerate=False, |
| 317 help='do not read options from environment variables') | 319 help='do not read options from environment variables') |
| 318 parser.add_option('--check', dest='check', action='store_true', | 320 parser.add_option('--check', dest='check', action='store_true', |
| 319 help='check format of gyp files') | 321 help='check format of gyp files') |
| 322 parser.add_option('--parallel', dest='parallel', action='store_true', | |
|
M-A Ruel
2012/09/18 19:42:18
Remove parameter dest='parallel'
it's not needed.
dmazzoni
2012/09/19 21:14:52
Done.
| |
| 323 env_name='GYP_PARALLEL', | |
| 324 regenerate=False, | |
|
M-A Ruel
2012/09/18 19:42:18
What's regenerate?
dmazzoni
2012/09/19 21:14:52
Looks like this isn't needed if 'dest' isn't used.
| |
| 325 help='Use multiprocessing for speed (experimental)') | |
| 320 parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store', | 326 parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store', |
| 321 default=None, metavar='DIR', type='path', | 327 default=None, metavar='DIR', type='path', |
| 322 help='directory to use as the root of the source tree') | 328 help='directory to use as the root of the source tree') |
| 323 # --no-circular-check disables the check for circular relationships between | 329 # --no-circular-check disables the check for circular relationships between |
| 324 # .gyp files. These relationships should not exist, but they've only been | 330 # .gyp files. These relationships should not exist, but they've only been |
| 325 # observed to be harmful with the Xcode generator. Chromium's .gyp files | 331 # observed to be harmful with the Xcode generator. Chromium's .gyp files |
| 326 # currently have some circular relationships on non-Mac platforms, so this | 332 # currently have some circular relationships on non-Mac platforms, so this |
| 327 # option allows the strict behavior to be used on Macs and the lenient | 333 # option allows the strict behavior to be used on Macs and the lenient |
| 328 # behavior to be used elsewhere. | 334 # behavior to be used elsewhere. |
| 329 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. | 335 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 elif sys.platform in ('win32', 'cygwin'): | 373 elif sys.platform in ('win32', 'cygwin'): |
| 368 options.formats = ['msvs'] | 374 options.formats = ['msvs'] |
| 369 else: | 375 else: |
| 370 options.formats = ['make'] | 376 options.formats = ['make'] |
| 371 | 377 |
| 372 if not options.generator_output and options.use_environment: | 378 if not options.generator_output and options.use_environment: |
| 373 g_o = os.environ.get('GYP_GENERATOR_OUTPUT') | 379 g_o = os.environ.get('GYP_GENERATOR_OUTPUT') |
| 374 if g_o: | 380 if g_o: |
| 375 options.generator_output = g_o | 381 options.generator_output = g_o |
| 376 | 382 |
| 383 if not options.parallel and options.use_environment: | |
| 384 parallel = os.environ.get('GYP_PARALLEL') | |
|
M-A Ruel
2012/09/18 19:42:18
options.parallel = bool(os.environ.get('GYP_PARALL
dmazzoni
2012/09/19 21:14:52
Done.
| |
| 385 if parallel: | |
| 386 options.parallel = True | |
| 387 | |
| 377 for mode in options.debug: | 388 for mode in options.debug: |
| 378 gyp.debug[mode] = 1 | 389 gyp.debug[mode] = 1 |
| 379 | 390 |
| 380 # Do an extra check to avoid work when we're not debugging. | 391 # Do an extra check to avoid work when we're not debugging. |
| 381 if DEBUG_GENERAL in gyp.debug.keys(): | 392 if DEBUG_GENERAL in gyp.debug.keys(): |
| 382 DebugOutput(DEBUG_GENERAL, 'running with these options:') | 393 DebugOutput(DEBUG_GENERAL, 'running with these options:') |
| 383 for option, value in sorted(options.__dict__.items()): | 394 for option, value in sorted(options.__dict__.items()): |
| 384 if option[0] == '_': | 395 if option[0] == '_': |
| 385 continue | 396 continue |
| 386 if isinstance(value, basestring): | 397 if isinstance(value, basestring): |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 'cwd': os.getcwd(), | 495 'cwd': os.getcwd(), |
| 485 'build_files_arg': build_files_arg, | 496 'build_files_arg': build_files_arg, |
| 486 'gyp_binary': sys.argv[0], | 497 'gyp_binary': sys.argv[0], |
| 487 'home_dot_gyp': home_dot_gyp} | 498 'home_dot_gyp': home_dot_gyp} |
| 488 | 499 |
| 489 # Start with the default variables from the command line. | 500 # Start with the default variables from the command line. |
| 490 [generator, flat_list, targets, data] = Load(build_files, format, | 501 [generator, flat_list, targets, data] = Load(build_files, format, |
| 491 cmdline_default_variables, | 502 cmdline_default_variables, |
| 492 includes, options.depth, | 503 includes, options.depth, |
| 493 params, options.check, | 504 params, options.check, |
| 494 options.circular_check) | 505 options.circular_check, |
| 506 options.parallel) | |
| 495 | 507 |
| 496 # TODO(mark): Pass |data| for now because the generator needs a list of | 508 # TODO(mark): Pass |data| for now because the generator needs a list of |
| 497 # build files that came in. In the future, maybe it should just accept | 509 # build files that came in. In the future, maybe it should just accept |
| 498 # a list, and not the whole data dict. | 510 # a list, and not the whole data dict. |
| 499 # NOTE: flat_list is the flattened dependency graph specifying the order | 511 # NOTE: flat_list is the flattened dependency graph specifying the order |
| 500 # that targets may be built. Build systems that operate serially or that | 512 # that targets may be built. Build systems that operate serially or that |
| 501 # need to have dependencies defined before dependents reference them should | 513 # need to have dependencies defined before dependents reference them should |
| 502 # generate targets in the order specified in flat_list. | 514 # generate targets in the order specified in flat_list. |
| 503 generator.GenerateOutput(flat_list, targets, data, params) | 515 generator.GenerateOutput(flat_list, targets, data, params) |
| 504 | 516 |
| 505 # Done | 517 # Done |
| 506 return 0 | 518 return 0 |
| 507 | 519 |
| 508 | 520 |
| 509 def main(args): | 521 def main(args): |
| 510 try: | 522 try: |
| 511 return gyp_main(args) | 523 return gyp_main(args) |
| 512 except GypError, e: | 524 except GypError, e: |
| 513 sys.stderr.write("gyp: %s\n" % e) | 525 sys.stderr.write("gyp: %s\n" % e) |
| 514 return 1 | 526 return 1 |
| 515 | 527 |
| 516 if __name__ == '__main__': | 528 if __name__ == '__main__': |
| 517 sys.exit(main(sys.argv[1:])) | 529 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |