OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from compiler.ast import Const | 5 from compiler.ast import Const |
6 from compiler.ast import Dict | 6 from compiler.ast import Dict |
7 from compiler.ast import Discard | 7 from compiler.ast import Discard |
8 from compiler.ast import List | 8 from compiler.ast import List |
9 from compiler.ast import Module | 9 from compiler.ast import Module |
10 from compiler.ast import Node | 10 from compiler.ast import Node |
(...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2456 raise GypError("Target %s has an invalid target type '%s'. " | 2456 raise GypError("Target %s has an invalid target type '%s'. " |
2457 "Must be one of %s." % | 2457 "Must be one of %s." % |
2458 (target, target_type, '/'.join(VALID_TARGET_TYPES))) | 2458 (target, target_type, '/'.join(VALID_TARGET_TYPES))) |
2459 if (target_dict.get('standalone_static_library', 0) and | 2459 if (target_dict.get('standalone_static_library', 0) and |
2460 not target_type == 'static_library'): | 2460 not target_type == 'static_library'): |
2461 raise GypError('Target %s has type %s but standalone_static_library flag is' | 2461 raise GypError('Target %s has type %s but standalone_static_library flag is' |
2462 ' only valid for static_library type.' % (target, | 2462 ' only valid for static_library type.' % (target, |
2463 target_type)) | 2463 target_type)) |
2464 | 2464 |
2465 | 2465 |
2466 def ValidateSourcesInTarget(target, target_dict, build_file): | 2466 def ValidateSourcesInTarget(target, target_dict, build_file, |
| 2467 duplicate_basename_check): |
| 2468 if not duplicate_basename_check: |
| 2469 return |
2467 # TODO: Check if MSVC allows this for loadable_module targets. | 2470 # TODO: Check if MSVC allows this for loadable_module targets. |
2468 if target_dict.get('type', None) not in ('static_library', 'shared_library'): | 2471 if target_dict.get('type', None) not in ('static_library', 'shared_library'): |
2469 return | 2472 return |
2470 sources = target_dict.get('sources', []) | 2473 sources = target_dict.get('sources', []) |
2471 basenames = {} | 2474 basenames = {} |
2472 for source in sources: | 2475 for source in sources: |
2473 name, ext = os.path.splitext(source) | 2476 name, ext = os.path.splitext(source) |
2474 is_compiled_file = ext in [ | 2477 is_compiled_file = ext in [ |
2475 '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S'] | 2478 '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S'] |
2476 if not is_compiled_file: | 2479 if not is_compiled_file: |
2477 continue | 2480 continue |
2478 basename = os.path.basename(name) # Don't include extension. | 2481 basename = os.path.basename(name) # Don't include extension. |
2479 basenames.setdefault(basename, []).append(source) | 2482 basenames.setdefault(basename, []).append(source) |
2480 | 2483 |
2481 error = '' | 2484 error = '' |
2482 for basename, files in basenames.iteritems(): | 2485 for basename, files in basenames.iteritems(): |
2483 if len(files) > 1: | 2486 if len(files) > 1: |
2484 error += ' %s: %s\n' % (basename, ' '.join(files)) | 2487 error += ' %s: %s\n' % (basename, ' '.join(files)) |
2485 | 2488 |
2486 if error: | 2489 if error: |
2487 print('static library %s has several files with the same basename:\n' % | 2490 print('static library %s has several files with the same basename:\n' % |
2488 target + error + 'Some build systems, e.g. MSVC08, ' | 2491 target + error + 'Some build systems, e.g. MSVC08 and Make generator ' |
2489 'cannot handle that.') | 2492 'for Mac, cannot handle that. Use --no-duplicate-basename-check to' |
| 2493 'disable this validation.') |
2490 raise GypError('Duplicate basenames in sources section, see list above') | 2494 raise GypError('Duplicate basenames in sources section, see list above') |
2491 | 2495 |
2492 | 2496 |
2493 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): | 2497 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): |
2494 """Ensures that the rules sections in target_dict are valid and consistent, | 2498 """Ensures that the rules sections in target_dict are valid and consistent, |
2495 and determines which sources they apply to. | 2499 and determines which sources they apply to. |
2496 | 2500 |
2497 Arguments: | 2501 Arguments: |
2498 target: string, name of target. | 2502 target: string, name of target. |
2499 target_dict: dict, target spec containing "rules" and "sources" lists. | 2503 target_dict: dict, target spec containing "rules" and "sources" lists. |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2703 | 2707 |
2704 global multiple_toolsets | 2708 global multiple_toolsets |
2705 multiple_toolsets = generator_input_info[ | 2709 multiple_toolsets = generator_input_info[ |
2706 'generator_supports_multiple_toolsets'] | 2710 'generator_supports_multiple_toolsets'] |
2707 | 2711 |
2708 global generator_filelist_paths | 2712 global generator_filelist_paths |
2709 generator_filelist_paths = generator_input_info['generator_filelist_paths'] | 2713 generator_filelist_paths = generator_input_info['generator_filelist_paths'] |
2710 | 2714 |
2711 | 2715 |
2712 def Load(build_files, variables, includes, depth, generator_input_info, check, | 2716 def Load(build_files, variables, includes, depth, generator_input_info, check, |
2713 circular_check, parallel, root_targets): | 2717 circular_check, duplicate_basename_check, parallel, root_targets): |
2714 SetGeneratorGlobals(generator_input_info) | 2718 SetGeneratorGlobals(generator_input_info) |
2715 # A generator can have other lists (in addition to sources) be processed | 2719 # A generator can have other lists (in addition to sources) be processed |
2716 # for rules. | 2720 # for rules. |
2717 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] | 2721 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] |
2718 | 2722 |
2719 # Load build files. This loads every target-containing build file into | 2723 # Load build files. This loads every target-containing build file into |
2720 # the |data| dictionary such that the keys to |data| are build file names, | 2724 # the |data| dictionary such that the keys to |data| are build file names, |
2721 # and the values are the entire build file contents after "early" or "pre" | 2725 # and the values are the entire build file contents after "early" or "pre" |
2722 # processing has been done and includes have been resolved. | 2726 # processing has been done and includes have been resolved. |
2723 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as | 2727 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 target_dict = targets[target] | 2832 target_dict = targets[target] |
2829 ProcessListFiltersInDict(target, target_dict) | 2833 ProcessListFiltersInDict(target, target_dict) |
2830 | 2834 |
2831 # Apply "latelate" variable expansions and condition evaluations. | 2835 # Apply "latelate" variable expansions and condition evaluations. |
2832 for target in flat_list: | 2836 for target in flat_list: |
2833 target_dict = targets[target] | 2837 target_dict = targets[target] |
2834 build_file = gyp.common.BuildFile(target) | 2838 build_file = gyp.common.BuildFile(target) |
2835 ProcessVariablesAndConditionsInDict( | 2839 ProcessVariablesAndConditionsInDict( |
2836 target_dict, PHASE_LATELATE, variables, build_file) | 2840 target_dict, PHASE_LATELATE, variables, build_file) |
2837 | 2841 |
| 2842 # TODO(thakis): Get vpx_scale/arm/scalesystemdependent.c to be renamed to |
| 2843 # scalesystemdependent_arm_additions.c or similar. |
| 2844 if 'arm' in variables.get('target_arch', ''): |
| 2845 duplicate_basename_check = False |
| 2846 |
2838 # Make sure that the rules make sense, and build up rule_sources lists as | 2847 # Make sure that the rules make sense, and build up rule_sources lists as |
2839 # needed. Not all generators will need to use the rule_sources lists, but | 2848 # needed. Not all generators will need to use the rule_sources lists, but |
2840 # some may, and it seems best to build the list in a common spot. | 2849 # some may, and it seems best to build the list in a common spot. |
2841 # Also validate actions and run_as elements in targets. | 2850 # Also validate actions and run_as elements in targets. |
2842 for target in flat_list: | 2851 for target in flat_list: |
2843 target_dict = targets[target] | 2852 target_dict = targets[target] |
2844 build_file = gyp.common.BuildFile(target) | 2853 build_file = gyp.common.BuildFile(target) |
2845 ValidateTargetType(target, target_dict) | 2854 ValidateTargetType(target, target_dict) |
2846 # TODO(thakis): Get vpx_scale/arm/scalesystemdependent.c to be renamed to | 2855 ValidateSourcesInTarget(target, target_dict, build_file, |
2847 # scalesystemdependent_arm_additions.c or similar. | 2856 duplicate_basename_check) |
2848 if 'arm' not in variables.get('target_arch', ''): | |
2849 ValidateSourcesInTarget(target, target_dict, build_file) | |
2850 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) | 2857 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) |
2851 ValidateRunAsInTarget(target, target_dict, build_file) | 2858 ValidateRunAsInTarget(target, target_dict, build_file) |
2852 ValidateActionsInTarget(target, target_dict, build_file) | 2859 ValidateActionsInTarget(target, target_dict, build_file) |
2853 | 2860 |
2854 # Generators might not expect ints. Turn them into strs. | 2861 # Generators might not expect ints. Turn them into strs. |
2855 TurnIntIntoStrInDict(data) | 2862 TurnIntIntoStrInDict(data) |
2856 | 2863 |
2857 # TODO(mark): Return |data| for now because the generator needs a list of | 2864 # TODO(mark): Return |data| for now because the generator needs a list of |
2858 # build files that came in. In the future, maybe it should just accept | 2865 # build files that came in. In the future, maybe it should just accept |
2859 # a list, and not the whole data dict. | 2866 # a list, and not the whole data dict. |
2860 return [flat_list, targets, data] | 2867 return [flat_list, targets, data] |
OLD | NEW |