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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 files = os.listdir(os.getcwd()) | 42 files = os.listdir(os.getcwd()) |
43 build_files = [] | 43 build_files = [] |
44 for file in files: | 44 for file in files: |
45 if file.endswith(extension): | 45 if file.endswith(extension): |
46 build_files.append(file) | 46 build_files.append(file) |
47 return build_files | 47 return build_files |
48 | 48 |
49 | 49 |
50 def Load(build_files, format, default_variables={}, | 50 def Load(build_files, format, default_variables={}, |
51 includes=[], depth='.', params=None, check=False, | 51 includes=[], depth='.', params=None, check=False, |
52 circular_check=True, duplicate_basename_check=True): | 52 circular_check=True): |
53 """ | 53 """ |
54 Loads one or more specified build files. | 54 Loads one or more specified build files. |
55 default_variables and includes will be copied before use. | 55 default_variables and includes will be copied before use. |
56 Returns the generator for the specified format and the | 56 Returns the generator for the specified format and the |
57 data returned by loading the specified build files. | 57 data returned by loading the specified build files. |
58 """ | 58 """ |
59 if params is None: | 59 if params is None: |
60 params = {} | 60 params = {} |
61 | 61 |
62 flavor = None | 62 flavor = None |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 'generator_wants_static_library_dependencies_adjusted', True), | 119 'generator_wants_static_library_dependencies_adjusted', True), |
120 'generator_wants_sorted_dependencies': | 120 'generator_wants_sorted_dependencies': |
121 getattr(generator, 'generator_wants_sorted_dependencies', False), | 121 getattr(generator, 'generator_wants_sorted_dependencies', False), |
122 'generator_filelist_paths': | 122 'generator_filelist_paths': |
123 getattr(generator, 'generator_filelist_paths', None), | 123 getattr(generator, 'generator_filelist_paths', None), |
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 duplicate_basename_check, | |
130 params['parallel'], params['root_targets']) | 129 params['parallel'], params['root_targets']) |
131 return [generator] + result | 130 return [generator] + result |
132 | 131 |
133 def NameValueListToDict(name_value_list): | 132 def NameValueListToDict(name_value_list): |
134 """ | 133 """ |
135 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 |
136 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 |
137 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. |
138 """ | 137 """ |
139 result = { } | 138 result = { } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 # --no-circular-check disables the check for circular relationships between | 317 # --no-circular-check disables the check for circular relationships between |
319 # .gyp files. These relationships should not exist, but they've only been | 318 # .gyp files. These relationships should not exist, but they've only been |
320 # observed to be harmful with the Xcode generator. Chromium's .gyp files | 319 # observed to be harmful with the Xcode generator. Chromium's .gyp files |
321 # currently have some circular relationships on non-Mac platforms, so this | 320 # currently have some circular relationships on non-Mac platforms, so this |
322 # option allows the strict behavior to be used on Macs and the lenient | 321 # option allows the strict behavior to be used on Macs and the lenient |
323 # behavior to be used elsewhere. | 322 # behavior to be used elsewhere. |
324 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. | 323 # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. |
325 parser.add_option('--no-circular-check', dest='circular_check', | 324 parser.add_option('--no-circular-check', dest='circular_check', |
326 action='store_false', default=True, regenerate=False, | 325 action='store_false', default=True, regenerate=False, |
327 help="don't check for circular relationships between files") | 326 help="don't check for circular relationships between files") |
328 # --no-duplicate-basename-check disables the check for duplicate basenames | |
329 # in a static_library/shared_library project. Visual C++ 2008 generator | |
330 # doesn't support this configuration. Libtool on Mac also generates warnings | |
331 # when duplicate basenames are passed into Make generator on Mac. | |
332 # TODO(yukawa): Remove this option when these legacy generators are | |
333 # deprecated. | |
334 parser.add_option('--no-duplicate-basename-check', | |
335 dest='duplicate_basename_check', action='store_false', | |
336 default=True, regenerate=False, | |
337 help="don't check for duplicate basenames") | |
338 parser.add_option('--no-parallel', action='store_true', default=False, | 327 parser.add_option('--no-parallel', action='store_true', default=False, |
339 help='Disable multiprocessing') | 328 help='Disable multiprocessing') |
340 parser.add_option('-S', '--suffix', dest='suffix', default='', | 329 parser.add_option('-S', '--suffix', dest='suffix', default='', |
341 help='suffix to add to generated files') | 330 help='suffix to add to generated files') |
342 parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store', | 331 parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store', |
343 default=None, metavar='DIR', type='path', | 332 default=None, metavar='DIR', type='path', |
344 help='directory to use as the root of the source tree') | 333 help='directory to use as the root of the source tree') |
345 parser.add_option('-R', '--root-target', dest='root_targets', | 334 parser.add_option('-R', '--root-target', dest='root_targets', |
346 action='append', metavar='TARGET', | 335 action='append', metavar='TARGET', |
347 help='include only TARGET and its deep dependencies') | 336 help='include only TARGET and its deep dependencies') |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 'cwd': os.getcwd(), | 491 'cwd': os.getcwd(), |
503 'build_files_arg': build_files_arg, | 492 'build_files_arg': build_files_arg, |
504 'gyp_binary': sys.argv[0], | 493 'gyp_binary': sys.argv[0], |
505 'home_dot_gyp': home_dot_gyp, | 494 'home_dot_gyp': home_dot_gyp, |
506 'parallel': options.parallel, | 495 'parallel': options.parallel, |
507 'root_targets': options.root_targets} | 496 'root_targets': options.root_targets} |
508 | 497 |
509 # Start with the default variables from the command line. | 498 # Start with the default variables from the command line. |
510 [generator, flat_list, targets, data] = Load( | 499 [generator, flat_list, targets, data] = Load( |
511 build_files, format, cmdline_default_variables, includes, options.depth, | 500 build_files, format, cmdline_default_variables, includes, options.depth, |
512 params, options.check, options.circular_check, | 501 params, options.check, options.circular_check) |
513 options.duplicate_basename_check) | |
514 | 502 |
515 # TODO(mark): Pass |data| for now because the generator needs a list of | 503 # TODO(mark): Pass |data| for now because the generator needs a list of |
516 # build files that came in. In the future, maybe it should just accept | 504 # build files that came in. In the future, maybe it should just accept |
517 # a list, and not the whole data dict. | 505 # a list, and not the whole data dict. |
518 # NOTE: flat_list is the flattened dependency graph specifying the order | 506 # NOTE: flat_list is the flattened dependency graph specifying the order |
519 # that targets may be built. Build systems that operate serially or that | 507 # that targets may be built. Build systems that operate serially or that |
520 # need to have dependencies defined before dependents reference them should | 508 # need to have dependencies defined before dependents reference them should |
521 # generate targets in the order specified in flat_list. | 509 # generate targets in the order specified in flat_list. |
522 generator.GenerateOutput(flat_list, targets, data, params) | 510 generator.GenerateOutput(flat_list, targets, data, params) |
523 | 511 |
(...skipping 14 matching lines...) Expand all Loading... |
538 except GypError, e: | 526 except GypError, e: |
539 sys.stderr.write("gyp: %s\n" % e) | 527 sys.stderr.write("gyp: %s\n" % e) |
540 return 1 | 528 return 1 |
541 | 529 |
542 # NOTE: setuptools generated console_scripts calls function with no arguments | 530 # NOTE: setuptools generated console_scripts calls function with no arguments |
543 def script_main(): | 531 def script_main(): |
544 return main(sys.argv[1:]) | 532 return main(sys.argv[1:]) |
545 | 533 |
546 if __name__ == '__main__': | 534 if __name__ == '__main__': |
547 sys.exit(script_main()) | 535 sys.exit(script_main()) |
OLD | NEW |