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 29 matching lines...) Expand all Loading... |
40 files = os.listdir(os.getcwd()) | 40 files = os.listdir(os.getcwd()) |
41 build_files = [] | 41 build_files = [] |
42 for file in files: | 42 for file in files: |
43 if file.endswith(extension): | 43 if file.endswith(extension): |
44 build_files.append(file) | 44 build_files.append(file) |
45 return build_files | 45 return build_files |
46 | 46 |
47 | 47 |
48 def Load(build_files, format, default_variables={}, | 48 def Load(build_files, format, default_variables={}, |
49 includes=[], depth='.', params=None, check=False, | 49 includes=[], depth='.', params=None, check=False, |
50 circular_check=True, parallel=False): | 50 circular_check=True): |
51 """ | 51 """ |
52 Loads one or more specified build files. | 52 Loads one or more specified build files. |
53 default_variables and includes will be copied before use. | 53 default_variables and includes will be copied before use. |
54 Returns the generator for the specified format and the | 54 Returns the generator for the specified format and the |
55 data returned by loading the specified build files. | 55 data returned by loading the specified build files. |
56 """ | 56 """ |
57 if params is None: | 57 if params is None: |
58 params = {} | 58 params = {} |
59 | 59 |
60 flavor = None | 60 flavor = None |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 'generator_wants_static_library_dependencies_adjusted': | 119 'generator_wants_static_library_dependencies_adjusted': |
120 getattr(generator, | 120 getattr(generator, |
121 'generator_wants_static_library_dependencies_adjusted', True), | 121 'generator_wants_static_library_dependencies_adjusted', True), |
122 'generator_wants_sorted_dependencies': | 122 'generator_wants_sorted_dependencies': |
123 getattr(generator, 'generator_wants_sorted_dependencies', False), | 123 getattr(generator, 'generator_wants_sorted_dependencies', False), |
124 } | 124 } |
125 | 125 |
126 # Process the input specific to this generator. | 126 # Process the input specific to this generator. |
127 result = gyp.input.Load(build_files, default_variables, includes[:], | 127 result = gyp.input.Load(build_files, default_variables, includes[:], |
128 depth, generator_input_info, check, circular_check, | 128 depth, generator_input_info, check, circular_check, |
129 parallel) | 129 params['parallel']) |
130 return [generator] + result | 130 return [generator] + result |
131 | 131 |
132 def NameValueListToDict(name_value_list): | 132 def NameValueListToDict(name_value_list): |
133 """ | 133 """ |
134 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary | 134 Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary |
135 of the pairs. If a string is simply NAME, then the value in the dictionary | 135 of the pairs. If a string is simply NAME, then the value in the dictionary |
136 is set to True. If VALUE can be converted to an integer, it is. | 136 is set to True. If VALUE can be converted to an integer, it is. |
137 """ | 137 """ |
138 result = { } | 138 result = { } |
139 for item in name_value_list: | 139 for item in name_value_list: |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 481 |
482 # Generate all requested formats (use a set in case we got one format request | 482 # Generate all requested formats (use a set in case we got one format request |
483 # twice) | 483 # twice) |
484 for format in set(options.formats): | 484 for format in set(options.formats): |
485 params = {'options': options, | 485 params = {'options': options, |
486 'build_files': build_files, | 486 'build_files': build_files, |
487 'generator_flags': generator_flags, | 487 'generator_flags': generator_flags, |
488 'cwd': os.getcwd(), | 488 'cwd': os.getcwd(), |
489 'build_files_arg': build_files_arg, | 489 'build_files_arg': build_files_arg, |
490 'gyp_binary': sys.argv[0], | 490 'gyp_binary': sys.argv[0], |
491 'home_dot_gyp': home_dot_gyp} | 491 'home_dot_gyp': home_dot_gyp, |
| 492 'parallel': options.parallel} |
492 | 493 |
493 # Start with the default variables from the command line. | 494 # Start with the default variables from the command line. |
494 [generator, flat_list, targets, data] = Load(build_files, format, | 495 [generator, flat_list, targets, data] = Load(build_files, format, |
495 cmdline_default_variables, | 496 cmdline_default_variables, |
496 includes, options.depth, | 497 includes, options.depth, |
497 params, options.check, | 498 params, options.check, |
498 options.circular_check, | 499 options.circular_check) |
499 options.parallel) | |
500 | 500 |
501 # TODO(mark): Pass |data| for now because the generator needs a list of | 501 # TODO(mark): Pass |data| for now because the generator needs a list of |
502 # build files that came in. In the future, maybe it should just accept | 502 # build files that came in. In the future, maybe it should just accept |
503 # a list, and not the whole data dict. | 503 # a list, and not the whole data dict. |
504 # NOTE: flat_list is the flattened dependency graph specifying the order | 504 # NOTE: flat_list is the flattened dependency graph specifying the order |
505 # that targets may be built. Build systems that operate serially or that | 505 # that targets may be built. Build systems that operate serially or that |
506 # need to have dependencies defined before dependents reference them should | 506 # need to have dependencies defined before dependents reference them should |
507 # generate targets in the order specified in flat_list. | 507 # generate targets in the order specified in flat_list. |
508 generator.GenerateOutput(flat_list, targets, data, params) | 508 generator.GenerateOutput(flat_list, targets, data, params) |
509 | 509 |
(...skipping 10 matching lines...) Expand all Loading... |
520 | 520 |
521 def main(args): | 521 def main(args): |
522 try: | 522 try: |
523 return gyp_main(args) | 523 return gyp_main(args) |
524 except GypError, e: | 524 except GypError, e: |
525 sys.stderr.write("gyp: %s\n" % e) | 525 sys.stderr.write("gyp: %s\n" % e) |
526 return 1 | 526 return 1 |
527 | 527 |
528 if __name__ == '__main__': | 528 if __name__ == '__main__': |
529 sys.exit(main(sys.argv[1:])) | 529 sys.exit(main(sys.argv[1:])) |
OLD | NEW |