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 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2469 raise GypError("Target %s has an invalid target type '%s'. " | 2469 raise GypError("Target %s has an invalid target type '%s'. " |
2470 "Must be one of %s." % | 2470 "Must be one of %s." % |
2471 (target, target_type, '/'.join(VALID_TARGET_TYPES))) | 2471 (target, target_type, '/'.join(VALID_TARGET_TYPES))) |
2472 if (target_dict.get('standalone_static_library', 0) and | 2472 if (target_dict.get('standalone_static_library', 0) and |
2473 not target_type == 'static_library'): | 2473 not target_type == 'static_library'): |
2474 raise GypError('Target %s has type %s but standalone_static_library flag is' | 2474 raise GypError('Target %s has type %s but standalone_static_library flag is' |
2475 ' only valid for static_library type.' % (target, | 2475 ' only valid for static_library type.' % (target, |
2476 target_type)) | 2476 target_type)) |
2477 | 2477 |
2478 | 2478 |
2479 def ValidateSourcesInTarget(target, target_dict, build_file, | |
2480 duplicate_basename_check): | |
2481 if not duplicate_basename_check: | |
2482 return | |
2483 # TODO: Check if MSVC allows this for loadable_module targets. | |
2484 if target_dict.get('type', None) not in ('static_library', 'shared_library'): | |
2485 return | |
2486 sources = target_dict.get('sources', []) | |
2487 basenames = {} | |
2488 for source in sources: | |
2489 name, ext = os.path.splitext(source) | |
2490 is_compiled_file = ext in [ | |
2491 '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S'] | |
2492 if not is_compiled_file: | |
2493 continue | |
2494 basename = os.path.basename(name) # Don't include extension. | |
2495 basenames.setdefault(basename, []).append(source) | |
2496 | |
2497 error = '' | |
2498 for basename, files in basenames.iteritems(): | |
2499 if len(files) > 1: | |
2500 error += ' %s: %s\n' % (basename, ' '.join(files)) | |
2501 | |
2502 if error: | |
2503 print('static library %s has several files with the same basename:\n' % | |
2504 target + error + 'Some build systems, e.g. MSVC08 and Make generator ' | |
2505 'for Mac, cannot handle that. Use --no-duplicate-basename-check to' | |
2506 'disable this validation.') | |
2507 raise GypError('Duplicate basenames in sources section, see list above') | |
2508 | |
2509 | |
2510 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): | 2479 def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): |
2511 """Ensures that the rules sections in target_dict are valid and consistent, | 2480 """Ensures that the rules sections in target_dict are valid and consistent, |
2512 and determines which sources they apply to. | 2481 and determines which sources they apply to. |
2513 | 2482 |
2514 Arguments: | 2483 Arguments: |
2515 target: string, name of target. | 2484 target: string, name of target. |
2516 target_dict: dict, target spec containing "rules" and "sources" lists. | 2485 target_dict: dict, target spec containing "rules" and "sources" lists. |
2517 extra_sources_for_rules: a list of keys to scan for rule matches in | 2486 extra_sources_for_rules: a list of keys to scan for rule matches in |
2518 addition to 'sources'. | 2487 addition to 'sources'. |
2519 """ | 2488 """ |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 | 2689 |
2721 global multiple_toolsets | 2690 global multiple_toolsets |
2722 multiple_toolsets = generator_input_info[ | 2691 multiple_toolsets = generator_input_info[ |
2723 'generator_supports_multiple_toolsets'] | 2692 'generator_supports_multiple_toolsets'] |
2724 | 2693 |
2725 global generator_filelist_paths | 2694 global generator_filelist_paths |
2726 generator_filelist_paths = generator_input_info['generator_filelist_paths'] | 2695 generator_filelist_paths = generator_input_info['generator_filelist_paths'] |
2727 | 2696 |
2728 | 2697 |
2729 def Load(build_files, variables, includes, depth, generator_input_info, check, | 2698 def Load(build_files, variables, includes, depth, generator_input_info, check, |
2730 circular_check, duplicate_basename_check, parallel, root_targets): | 2699 circular_check, parallel, root_targets): |
2731 SetGeneratorGlobals(generator_input_info) | 2700 SetGeneratorGlobals(generator_input_info) |
2732 # A generator can have other lists (in addition to sources) be processed | 2701 # A generator can have other lists (in addition to sources) be processed |
2733 # for rules. | 2702 # for rules. |
2734 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] | 2703 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] |
2735 | 2704 |
2736 # Load build files. This loads every target-containing build file into | 2705 # Load build files. This loads every target-containing build file into |
2737 # the |data| dictionary such that the keys to |data| are build file names, | 2706 # the |data| dictionary such that the keys to |data| are build file names, |
2738 # and the values are the entire build file contents after "early" or "pre" | 2707 # and the values are the entire build file contents after "early" or "pre" |
2739 # processing has been done and includes have been resolved. | 2708 # processing has been done and includes have been resolved. |
2740 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as | 2709 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2845 target_dict = targets[target] | 2814 target_dict = targets[target] |
2846 ProcessListFiltersInDict(target, target_dict) | 2815 ProcessListFiltersInDict(target, target_dict) |
2847 | 2816 |
2848 # Apply "latelate" variable expansions and condition evaluations. | 2817 # Apply "latelate" variable expansions and condition evaluations. |
2849 for target in flat_list: | 2818 for target in flat_list: |
2850 target_dict = targets[target] | 2819 target_dict = targets[target] |
2851 build_file = gyp.common.BuildFile(target) | 2820 build_file = gyp.common.BuildFile(target) |
2852 ProcessVariablesAndConditionsInDict( | 2821 ProcessVariablesAndConditionsInDict( |
2853 target_dict, PHASE_LATELATE, variables, build_file) | 2822 target_dict, PHASE_LATELATE, variables, build_file) |
2854 | 2823 |
2855 # TODO(thakis): Get vpx_scale/arm/scalesystemdependent.c to be renamed to | |
2856 # scalesystemdependent_arm_additions.c or similar. | |
2857 if 'arm' in variables.get('target_arch', ''): | |
2858 duplicate_basename_check = False | |
2859 | |
2860 # Make sure that the rules make sense, and build up rule_sources lists as | 2824 # Make sure that the rules make sense, and build up rule_sources lists as |
2861 # needed. Not all generators will need to use the rule_sources lists, but | 2825 # needed. Not all generators will need to use the rule_sources lists, but |
2862 # some may, and it seems best to build the list in a common spot. | 2826 # some may, and it seems best to build the list in a common spot. |
2863 # Also validate actions and run_as elements in targets. | 2827 # Also validate actions and run_as elements in targets. |
2864 for target in flat_list: | 2828 for target in flat_list: |
2865 target_dict = targets[target] | 2829 target_dict = targets[target] |
2866 build_file = gyp.common.BuildFile(target) | 2830 build_file = gyp.common.BuildFile(target) |
2867 ValidateTargetType(target, target_dict) | 2831 ValidateTargetType(target, target_dict) |
2868 ValidateSourcesInTarget(target, target_dict, build_file, | |
2869 duplicate_basename_check) | |
2870 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) | 2832 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) |
2871 ValidateRunAsInTarget(target, target_dict, build_file) | 2833 ValidateRunAsInTarget(target, target_dict, build_file) |
2872 ValidateActionsInTarget(target, target_dict, build_file) | 2834 ValidateActionsInTarget(target, target_dict, build_file) |
2873 | 2835 |
2874 # Generators might not expect ints. Turn them into strs. | 2836 # Generators might not expect ints. Turn them into strs. |
2875 TurnIntIntoStrInDict(data) | 2837 TurnIntIntoStrInDict(data) |
2876 | 2838 |
2877 # TODO(mark): Return |data| for now because the generator needs a list of | 2839 # TODO(mark): Return |data| for now because the generator needs a list of |
2878 # build files that came in. In the future, maybe it should just accept | 2840 # build files that came in. In the future, maybe it should just accept |
2879 # a list, and not the whole data dict. | 2841 # a list, and not the whole data dict. |
2880 return [flat_list, targets, data] | 2842 return [flat_list, targets, data] |
OLD | NEW |