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 2470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2481 raise GypError("Target %s has an invalid target type '%s'. " | 2481 raise GypError("Target %s has an invalid target type '%s'. " |
2482 "Must be one of %s." % | 2482 "Must be one of %s." % |
2483 (target, target_type, '/'.join(VALID_TARGET_TYPES))) | 2483 (target, target_type, '/'.join(VALID_TARGET_TYPES))) |
2484 if (target_dict.get('standalone_static_library', 0) and | 2484 if (target_dict.get('standalone_static_library', 0) and |
2485 not target_type == 'static_library'): | 2485 not target_type == 'static_library'): |
2486 raise GypError('Target %s has type %s but standalone_static_library flag is' | 2486 raise GypError('Target %s has type %s but standalone_static_library flag is' |
2487 ' only valid for static_library type.' % (target, | 2487 ' only valid for static_library type.' % (target, |
2488 target_type)) | 2488 target_type)) |
2489 | 2489 |
2490 | 2490 |
2491 def ValidateSourcesInTarget(target, target_dict, build_file, | |
2492 duplicate_basename_check): | |
2493 if not duplicate_basename_check: | |
2494 return | |
2495 # TODO: Check if MSVC allows this for loadable_module targets. | |
2496 if target_dict.get('type', None) not in ('static_library', 'shared_library'): | |
Nico
2015/05/21 23:50:07
Maybe shared_library can be removed here?
scottmg
2015/05/21 23:59:18
That seems pretty weird now that I look at it. I d
| |
2497 return | |
2498 sources = target_dict.get('sources', []) | |
2499 basenames = {} | |
2500 for source in sources: | |
2501 name, ext = os.path.splitext(source) | |
2502 is_compiled_file = ext in [ | |
2503 '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S'] | |
2504 if not is_compiled_file: | |
2505 continue | |
2506 basename = os.path.basename(name) # Don't include extension. | |
2507 basenames.setdefault(basename, []).append(source) | |
2508 | |
2509 error = '' | |
2510 for basename, files in basenames.iteritems(): | |
2511 if len(files) > 1: | |
2512 error += ' %s: %s\n' % (basename, ' '.join(files)) | |
2513 | |
2514 if error: | |
2515 print('static library %s has several files with the same basename:\n' % | |
2516 target + error + 'Some build systems, e.g. MSVC08 and Make generator ' | |
Nico
2015/05/21 23:50:07
Maybe this should say "libtool on mac" now?
scottmg
2015/05/21 23:59:18
Done.
| |
2517 'for Mac, cannot handle that. Use --no-duplicate-basename-check to' | |
yukawa
2015/05/21 23:58:57
A white space between 'to' and 'disable'?
If this
scottmg
2015/05/22 00:00:46
I think I did this accidentally during reflowing.
| |
2518 'disable this validation.') | |
2519 raise GypError('Duplicate basenames in sources section, see list above') | |
2520 | |
2521 | |
2491 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): | 2522 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): |
2492 """Ensures that the rules sections in target_dict are valid and consistent, | 2523 """Ensures that the rules sections in target_dict are valid and consistent, |
2493 and determines which sources they apply to. | 2524 and determines which sources they apply to. |
2494 | 2525 |
2495 Arguments: | 2526 Arguments: |
2496 target: string, name of target. | 2527 target: string, name of target. |
2497 target_dict: dict, target spec containing "rules" and "sources" lists. | 2528 target_dict: dict, target spec containing "rules" and "sources" lists. |
2498 extra_sources_for_rules: a list of keys to scan for rule matches in | 2529 extra_sources_for_rules: a list of keys to scan for rule matches in |
2499 addition to 'sources'. | 2530 addition to 'sources'. |
2500 """ | 2531 """ |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2701 | 2732 |
2702 global multiple_toolsets | 2733 global multiple_toolsets |
2703 multiple_toolsets = generator_input_info[ | 2734 multiple_toolsets = generator_input_info[ |
2704 'generator_supports_multiple_toolsets'] | 2735 'generator_supports_multiple_toolsets'] |
2705 | 2736 |
2706 global generator_filelist_paths | 2737 global generator_filelist_paths |
2707 generator_filelist_paths = generator_input_info['generator_filelist_paths'] | 2738 generator_filelist_paths = generator_input_info['generator_filelist_paths'] |
2708 | 2739 |
2709 | 2740 |
2710 def Load(build_files, variables, includes, depth, generator_input_info, check, | 2741 def Load(build_files, variables, includes, depth, generator_input_info, check, |
2711 circular_check, parallel, root_targets): | 2742 circular_check, duplicate_basename_check, parallel, root_targets): |
2712 SetGeneratorGlobals(generator_input_info) | 2743 SetGeneratorGlobals(generator_input_info) |
2713 # A generator can have other lists (in addition to sources) be processed | 2744 # A generator can have other lists (in addition to sources) be processed |
2714 # for rules. | 2745 # for rules. |
2715 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] | 2746 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] |
2716 | 2747 |
2717 # Load build files. This loads every target-containing build file into | 2748 # Load build files. This loads every target-containing build file into |
2718 # the |data| dictionary such that the keys to |data| are build file names, | 2749 # the |data| dictionary such that the keys to |data| are build file names, |
2719 # and the values are the entire build file contents after "early" or "pre" | 2750 # and the values are the entire build file contents after "early" or "pre" |
2720 # processing has been done and includes have been resolved. | 2751 # processing has been done and includes have been resolved. |
2721 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as | 2752 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2825 target_dict = targets[target] | 2856 target_dict = targets[target] |
2826 ProcessListFiltersInDict(target, target_dict) | 2857 ProcessListFiltersInDict(target, target_dict) |
2827 | 2858 |
2828 # Apply "latelate" variable expansions and condition evaluations. | 2859 # Apply "latelate" variable expansions and condition evaluations. |
2829 for target in flat_list: | 2860 for target in flat_list: |
2830 target_dict = targets[target] | 2861 target_dict = targets[target] |
2831 build_file = gyp.common.BuildFile(target) | 2862 build_file = gyp.common.BuildFile(target) |
2832 ProcessVariablesAndConditionsInDict( | 2863 ProcessVariablesAndConditionsInDict( |
2833 target_dict, PHASE_LATELATE, variables, build_file) | 2864 target_dict, PHASE_LATELATE, variables, build_file) |
2834 | 2865 |
2866 # TODO(thakis): Get vpx_scale/arm/scalesystemdependent.c to be renamed to | |
2867 # scalesystemdependent_arm_additions.c or similar. | |
Nico
2015/05/21 23:50:07
If the shared_library above goes away, this may or
scottmg
2015/05/21 23:59:18
I'm feeling lucky. Done!
| |
2868 if 'arm' in variables.get('target_arch', ''): | |
2869 duplicate_basename_check = False | |
2870 | |
2835 # Make sure that the rules make sense, and build up rule_sources lists as | 2871 # Make sure that the rules make sense, and build up rule_sources lists as |
2836 # needed. Not all generators will need to use the rule_sources lists, but | 2872 # needed. Not all generators will need to use the rule_sources lists, but |
2837 # some may, and it seems best to build the list in a common spot. | 2873 # some may, and it seems best to build the list in a common spot. |
2838 # Also validate actions and run_as elements in targets. | 2874 # Also validate actions and run_as elements in targets. |
2839 for target in flat_list: | 2875 for target in flat_list: |
2840 target_dict = targets[target] | 2876 target_dict = targets[target] |
2841 build_file = gyp.common.BuildFile(target) | 2877 build_file = gyp.common.BuildFile(target) |
2842 ValidateTargetType(target, target_dict) | 2878 ValidateTargetType(target, target_dict) |
2879 ValidateSourcesInTarget(target, target_dict, build_file, | |
2880 duplicate_basename_check) | |
2843 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) | 2881 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) |
2844 ValidateRunAsInTarget(target, target_dict, build_file) | 2882 ValidateRunAsInTarget(target, target_dict, build_file) |
2845 ValidateActionsInTarget(target, target_dict, build_file) | 2883 ValidateActionsInTarget(target, target_dict, build_file) |
2846 | 2884 |
2847 # Generators might not expect ints. Turn them into strs. | 2885 # Generators might not expect ints. Turn them into strs. |
2848 TurnIntIntoStrInDict(data) | 2886 TurnIntIntoStrInDict(data) |
2849 | 2887 |
2850 # TODO(mark): Return |data| for now because the generator needs a list of | 2888 # TODO(mark): Return |data| for now because the generator needs a list of |
2851 # build files that came in. In the future, maybe it should just accept | 2889 # build files that came in. In the future, maybe it should just accept |
2852 # a list, and not the whole data dict. | 2890 # a list, and not the whole data dict. |
2853 return [flat_list, targets, data] | 2891 return [flat_list, targets, data] |
OLD | NEW |