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 import copy | 5 import copy |
6 import ntpath | 6 import ntpath |
7 import os | 7 import os |
8 import posixpath | 8 import posixpath |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))] | 810 rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))] |
811 | 811 |
812 # Handle rules that use a native rules file. | 812 # Handle rules that use a native rules file. |
813 if rules_native: | 813 if rules_native: |
814 _GenerateNativeRulesForMSVS(p, rules_native, output_dir, spec, options) | 814 _GenerateNativeRulesForMSVS(p, rules_native, output_dir, spec, options) |
815 | 815 |
816 # Handle external rules (non-native rules). | 816 # Handle external rules (non-native rules). |
817 if rules_external: | 817 if rules_external: |
818 _GenerateExternalRules(rules_external, output_dir, spec, | 818 _GenerateExternalRules(rules_external, output_dir, spec, |
819 sources, options, actions_to_add) | 819 sources, options, actions_to_add) |
820 _AdjustSourcesForRules(spec, rules, sources, excluded_sources) | 820 _AdjustSourcesForRules(rules, sources, excluded_sources, False) |
821 | 821 |
822 | 822 |
823 def _AdjustSourcesForRules(spec, rules, sources, excluded_sources): | 823 def _AdjustSourcesForRules(rules, sources, excluded_sources, is_msbuild): |
824 # Add outputs generated by each rule (if applicable). | 824 # Add outputs generated by each rule (if applicable). |
825 for rule in rules: | 825 for rule in rules: |
826 # Add in the outputs from this rule. | 826 # Add in the outputs from this rule. |
827 trigger_files = _FindRuleTriggerFiles(rule, sources) | 827 trigger_files = _FindRuleTriggerFiles(rule, sources) |
828 for trigger_file in trigger_files: | 828 for trigger_file in trigger_files: |
829 # Remove trigger_file from excluded_sources to let the rule be triggered | 829 # Remove trigger_file from excluded_sources to let the rule be triggered |
830 # (e.g. rule trigger ax_enums.idl is added to excluded_sources | 830 # (e.g. rule trigger ax_enums.idl is added to excluded_sources |
831 # because it's also in an action's inputs in the same project) | 831 # because it's also in an action's inputs in the same project) |
832 excluded_sources.discard(_FixPath(trigger_file)) | 832 excluded_sources.discard(_FixPath(trigger_file)) |
833 # Done if not processing outputs as sources. | 833 # Done if not processing outputs as sources. |
834 if int(rule.get('process_outputs_as_sources', False)): | 834 if int(rule.get('process_outputs_as_sources', False)): |
835 inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file) | 835 inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file) |
836 inputs = OrderedSet(_FixPaths(inputs)) | 836 inputs = OrderedSet(_FixPaths(inputs)) |
837 outputs = OrderedSet(_FixPaths(outputs)) | 837 outputs = OrderedSet(_FixPaths(outputs)) |
838 inputs.remove(_FixPath(trigger_file)) | 838 inputs.remove(_FixPath(trigger_file)) |
839 sources.update(inputs) | 839 sources.update(inputs) |
840 if not spec.get('msvs_external_builder'): | 840 if not is_msbuild: |
841 excluded_sources.update(inputs) | 841 excluded_sources.update(inputs) |
842 sources.update(outputs) | 842 sources.update(outputs) |
843 | 843 |
844 | 844 |
845 def _FilterActionsFromExcluded(excluded_sources, actions_to_add): | 845 def _FilterActionsFromExcluded(excluded_sources, actions_to_add): |
846 """Take inputs with actions attached out of the list of exclusions. | 846 """Take inputs with actions attached out of the list of exclusions. |
847 | 847 |
848 Arguments: | 848 Arguments: |
849 excluded_sources: list of source files not to be built. | 849 excluded_sources: list of source files not to be built. |
850 actions_to_add: dict of actions keyed on source file they're attached to. | 850 actions_to_add: dict of actions keyed on source file they're attached to. |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 if missing_sources: | 2006 if missing_sources: |
2007 error_message = "Missing input files:\n" + \ | 2007 error_message = "Missing input files:\n" + \ |
2008 '\n'.join(set(missing_sources)) | 2008 '\n'.join(set(missing_sources)) |
2009 if generator_flags.get('msvs_error_on_missing_sources', False): | 2009 if generator_flags.get('msvs_error_on_missing_sources', False): |
2010 raise GypError(error_message) | 2010 raise GypError(error_message) |
2011 else: | 2011 else: |
2012 print >> sys.stdout, "Warning: " + error_message | 2012 print >> sys.stdout, "Warning: " + error_message |
2013 | 2013 |
2014 | 2014 |
2015 def _GenerateMSBuildFiltersFile(filters_path, source_files, | 2015 def _GenerateMSBuildFiltersFile(filters_path, source_files, |
2016 extension_to_rule_name): | 2016 rule_dependencies, extension_to_rule_name): |
2017 """Generate the filters file. | 2017 """Generate the filters file. |
2018 | 2018 |
2019 This file is used by Visual Studio to organize the presentation of source | 2019 This file is used by Visual Studio to organize the presentation of source |
2020 files into folders. | 2020 files into folders. |
2021 | 2021 |
2022 Arguments: | 2022 Arguments: |
2023 filters_path: The path of the file to be created. | 2023 filters_path: The path of the file to be created. |
2024 source_files: The hierarchical structure of all the sources. | 2024 source_files: The hierarchical structure of all the sources. |
2025 extension_to_rule_name: A dictionary mapping file extensions to rules. | 2025 extension_to_rule_name: A dictionary mapping file extensions to rules. |
2026 """ | 2026 """ |
2027 filter_group = [] | 2027 filter_group = [] |
2028 source_group = [] | 2028 source_group = [] |
2029 _AppendFiltersForMSBuild('', source_files, extension_to_rule_name, | 2029 _AppendFiltersForMSBuild('', source_files, rule_dependencies, |
2030 filter_group, source_group) | 2030 extension_to_rule_name, filter_group, source_group) |
2031 if filter_group: | 2031 if filter_group: |
2032 content = ['Project', | 2032 content = ['Project', |
2033 {'ToolsVersion': '4.0', | 2033 {'ToolsVersion': '4.0', |
2034 'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003' | 2034 'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003' |
2035 }, | 2035 }, |
2036 ['ItemGroup'] + filter_group, | 2036 ['ItemGroup'] + filter_group, |
2037 ['ItemGroup'] + source_group | 2037 ['ItemGroup'] + source_group |
2038 ] | 2038 ] |
2039 easy_xml.WriteXmlIfChanged(content, filters_path, pretty=True, win32=True) | 2039 easy_xml.WriteXmlIfChanged(content, filters_path, pretty=True, win32=True) |
2040 elif os.path.exists(filters_path): | 2040 elif os.path.exists(filters_path): |
2041 # We don't need this filter anymore. Delete the old filter file. | 2041 # We don't need this filter anymore. Delete the old filter file. |
2042 os.unlink(filters_path) | 2042 os.unlink(filters_path) |
2043 | 2043 |
2044 | 2044 |
2045 def _AppendFiltersForMSBuild(parent_filter_name, sources, | 2045 def _AppendFiltersForMSBuild(parent_filter_name, sources, rule_dependencies, |
2046 extension_to_rule_name, | 2046 extension_to_rule_name, |
2047 filter_group, source_group): | 2047 filter_group, source_group): |
2048 """Creates the list of filters and sources to be added in the filter file. | 2048 """Creates the list of filters and sources to be added in the filter file. |
2049 | 2049 |
2050 Args: | 2050 Args: |
2051 parent_filter_name: The name of the filter under which the sources are | 2051 parent_filter_name: The name of the filter under which the sources are |
2052 found. | 2052 found. |
2053 sources: The hierarchy of filters and sources to process. | 2053 sources: The hierarchy of filters and sources to process. |
2054 extension_to_rule_name: A dictionary mapping file extensions to rules. | 2054 extension_to_rule_name: A dictionary mapping file extensions to rules. |
2055 filter_group: The list to which filter entries will be appended. | 2055 filter_group: The list to which filter entries will be appended. |
2056 source_group: The list to which source entries will be appeneded. | 2056 source_group: The list to which source entries will be appeneded. |
2057 """ | 2057 """ |
2058 for source in sources: | 2058 for source in sources: |
2059 if isinstance(source, MSVSProject.Filter): | 2059 if isinstance(source, MSVSProject.Filter): |
2060 # We have a sub-filter. Create the name of that sub-filter. | 2060 # We have a sub-filter. Create the name of that sub-filter. |
2061 if not parent_filter_name: | 2061 if not parent_filter_name: |
2062 filter_name = source.name | 2062 filter_name = source.name |
2063 else: | 2063 else: |
2064 filter_name = '%s\\%s' % (parent_filter_name, source.name) | 2064 filter_name = '%s\\%s' % (parent_filter_name, source.name) |
2065 # Add the filter to the group. | 2065 # Add the filter to the group. |
2066 filter_group.append( | 2066 filter_group.append( |
2067 ['Filter', {'Include': filter_name}, | 2067 ['Filter', {'Include': filter_name}, |
2068 ['UniqueIdentifier', MSVSNew.MakeGuid(source.name)]]) | 2068 ['UniqueIdentifier', MSVSNew.MakeGuid(source.name)]]) |
2069 # Recurse and add its dependents. | 2069 # Recurse and add its dependents. |
2070 _AppendFiltersForMSBuild(filter_name, source.contents, | 2070 _AppendFiltersForMSBuild(filter_name, source.contents, |
2071 extension_to_rule_name, | 2071 rule_dependencies, extension_to_rule_name, |
2072 filter_group, source_group) | 2072 filter_group, source_group) |
2073 else: | 2073 else: |
2074 # It's a source. Create a source entry. | 2074 # It's a source. Create a source entry. |
2075 _, element = _MapFileToMsBuildSourceType(source, extension_to_rule_name) | 2075 _, element = _MapFileToMsBuildSourceType(source, rule_dependencies, |
| 2076 extension_to_rule_name) |
2076 source_entry = [element, {'Include': source}] | 2077 source_entry = [element, {'Include': source}] |
2077 # Specify the filter it is part of, if any. | 2078 # Specify the filter it is part of, if any. |
2078 if parent_filter_name: | 2079 if parent_filter_name: |
2079 source_entry.append(['Filter', parent_filter_name]) | 2080 source_entry.append(['Filter', parent_filter_name]) |
2080 source_group.append(source_entry) | 2081 source_group.append(source_entry) |
2081 | 2082 |
2082 | 2083 |
2083 def _MapFileToMsBuildSourceType(source, extension_to_rule_name): | 2084 def _MapFileToMsBuildSourceType(source, rule_dependencies, |
| 2085 extension_to_rule_name): |
2084 """Returns the group and element type of the source file. | 2086 """Returns the group and element type of the source file. |
2085 | 2087 |
2086 Arguments: | 2088 Arguments: |
2087 source: The source file name. | 2089 source: The source file name. |
2088 extension_to_rule_name: A dictionary mapping file extensions to rules. | 2090 extension_to_rule_name: A dictionary mapping file extensions to rules. |
2089 | 2091 |
2090 Returns: | 2092 Returns: |
2091 A pair of (group this file should be part of, the label of element) | 2093 A pair of (group this file should be part of, the label of element) |
2092 """ | 2094 """ |
2093 _, ext = os.path.splitext(source) | 2095 _, ext = os.path.splitext(source) |
2094 if ext in extension_to_rule_name: | 2096 if ext in extension_to_rule_name: |
2095 group = 'rule' | 2097 group = 'rule' |
2096 element = extension_to_rule_name[ext] | 2098 element = extension_to_rule_name[ext] |
2097 elif ext in ['.cc', '.cpp', '.c', '.cxx']: | 2099 elif ext in ['.cc', '.cpp', '.c', '.cxx']: |
2098 group = 'compile' | 2100 group = 'compile' |
2099 element = 'ClCompile' | 2101 element = 'ClCompile' |
2100 elif ext in ['.h', '.hxx']: | 2102 elif ext in ['.h', '.hxx']: |
2101 group = 'include' | 2103 group = 'include' |
2102 element = 'ClInclude' | 2104 element = 'ClInclude' |
2103 elif ext == '.rc': | 2105 elif ext == '.rc': |
2104 group = 'resource' | 2106 group = 'resource' |
2105 element = 'ResourceCompile' | 2107 element = 'ResourceCompile' |
2106 elif ext == '.idl': | 2108 elif ext == '.idl': |
2107 group = 'midl' | 2109 group = 'midl' |
2108 element = 'Midl' | 2110 element = 'Midl' |
| 2111 elif source in rule_dependencies: |
| 2112 group = 'rule_dependency' |
| 2113 element = 'CustomBuild' |
2109 else: | 2114 else: |
2110 group = 'none' | 2115 group = 'none' |
2111 element = 'None' | 2116 element = 'None' |
2112 return (group, element) | 2117 return (group, element) |
2113 | 2118 |
2114 | 2119 |
2115 def _GenerateRulesForMSBuild(output_dir, options, spec, | 2120 def _GenerateRulesForMSBuild(output_dir, options, spec, |
2116 sources, excluded_sources, | 2121 sources, excluded_sources, |
2117 props_files_of_rules, targets_files_of_rules, | 2122 props_files_of_rules, targets_files_of_rules, |
2118 actions_to_add, extension_to_rule_name): | 2123 actions_to_add, rule_dependencies, |
| 2124 extension_to_rule_name): |
2119 # MSBuild rules are implemented using three files: an XML file, a .targets | 2125 # MSBuild rules are implemented using three files: an XML file, a .targets |
2120 # file and a .props file. | 2126 # file and a .props file. |
2121 # See http://blogs.msdn.com/b/vcblog/archive/2010/04/21/quick-help-on-vs2010-c
ustom-build-rule.aspx | 2127 # See http://blogs.msdn.com/b/vcblog/archive/2010/04/21/quick-help-on-vs2010-c
ustom-build-rule.aspx |
2122 # for more details. | 2128 # for more details. |
2123 rules = spec.get('rules', []) | 2129 rules = spec.get('rules', []) |
2124 rules_native = [r for r in rules if not int(r.get('msvs_external_rule', 0))] | 2130 rules_native = [r for r in rules if not int(r.get('msvs_external_rule', 0))] |
2125 rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))] | 2131 rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))] |
2126 | 2132 |
2127 msbuild_rules = [] | 2133 msbuild_rules = [] |
2128 for rule in rules_native: | 2134 for rule in rules_native: |
2129 # Skip a rule with no action and no inputs. | 2135 # Skip a rule with no action and no inputs. |
2130 if 'action' not in rule and not rule.get('rule_sources', []): | 2136 if 'action' not in rule and not rule.get('rule_sources', []): |
2131 continue | 2137 continue |
2132 msbuild_rule = MSBuildRule(rule, spec) | 2138 msbuild_rule = MSBuildRule(rule, spec) |
2133 msbuild_rules.append(msbuild_rule) | 2139 msbuild_rules.append(msbuild_rule) |
| 2140 rule_dependencies.update(msbuild_rule.additional_dependencies.split(';')) |
2134 extension_to_rule_name[msbuild_rule.extension] = msbuild_rule.rule_name | 2141 extension_to_rule_name[msbuild_rule.extension] = msbuild_rule.rule_name |
2135 if msbuild_rules: | 2142 if msbuild_rules: |
2136 base = spec['target_name'] + options.suffix | 2143 base = spec['target_name'] + options.suffix |
2137 props_name = base + '.props' | 2144 props_name = base + '.props' |
2138 targets_name = base + '.targets' | 2145 targets_name = base + '.targets' |
2139 xml_name = base + '.xml' | 2146 xml_name = base + '.xml' |
2140 | 2147 |
2141 props_files_of_rules.add(props_name) | 2148 props_files_of_rules.add(props_name) |
2142 targets_files_of_rules.add(targets_name) | 2149 targets_files_of_rules.add(targets_name) |
2143 | 2150 |
2144 props_path = os.path.join(output_dir, props_name) | 2151 props_path = os.path.join(output_dir, props_name) |
2145 targets_path = os.path.join(output_dir, targets_name) | 2152 targets_path = os.path.join(output_dir, targets_name) |
2146 xml_path = os.path.join(output_dir, xml_name) | 2153 xml_path = os.path.join(output_dir, xml_name) |
2147 | 2154 |
2148 _GenerateMSBuildRulePropsFile(props_path, msbuild_rules) | 2155 _GenerateMSBuildRulePropsFile(props_path, msbuild_rules) |
2149 _GenerateMSBuildRuleTargetsFile(targets_path, msbuild_rules) | 2156 _GenerateMSBuildRuleTargetsFile(targets_path, msbuild_rules) |
2150 _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules) | 2157 _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules) |
2151 | 2158 |
2152 if rules_external: | 2159 if rules_external: |
2153 _GenerateExternalRules(rules_external, output_dir, spec, | 2160 _GenerateExternalRules(rules_external, output_dir, spec, |
2154 sources, options, actions_to_add) | 2161 sources, options, actions_to_add) |
2155 _AdjustSourcesForRules(spec, rules, sources, excluded_sources) | 2162 _AdjustSourcesForRules(rules, sources, excluded_sources, True) |
2156 | 2163 |
2157 | 2164 |
2158 class MSBuildRule(object): | 2165 class MSBuildRule(object): |
2159 """Used to store information used to generate an MSBuild rule. | 2166 """Used to store information used to generate an MSBuild rule. |
2160 | 2167 |
2161 Attributes: | 2168 Attributes: |
2162 rule_name: The rule name, sanitized to use in XML. | 2169 rule_name: The rule name, sanitized to use in XML. |
2163 target_name: The name of the target. | 2170 target_name: The name of the target. |
2164 after_targets: The name of the AfterTargets element. | 2171 after_targets: The name of the AfterTargets element. |
2165 before_targets: The name of the BeforeTargets element. | 2172 before_targets: The name of the BeforeTargets element. |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3066 if isinstance(source, MSVSProject.Filter): | 3073 if isinstance(source, MSVSProject.Filter): |
3067 missing_sources.extend(_VerifySourcesExist(source.contents, root_dir)) | 3074 missing_sources.extend(_VerifySourcesExist(source.contents, root_dir)) |
3068 else: | 3075 else: |
3069 if '$' not in source: | 3076 if '$' not in source: |
3070 full_path = os.path.join(root_dir, source) | 3077 full_path = os.path.join(root_dir, source) |
3071 if not os.path.exists(full_path): | 3078 if not os.path.exists(full_path): |
3072 missing_sources.append(full_path) | 3079 missing_sources.append(full_path) |
3073 return missing_sources | 3080 return missing_sources |
3074 | 3081 |
3075 | 3082 |
3076 def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, | 3083 def _GetMSBuildSources(spec, sources, exclusions, rule_dependencies, |
3077 actions_spec, sources_handled_by_action, list_excluded): | 3084 extension_to_rule_name, actions_spec, |
3078 groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule'] | 3085 sources_handled_by_action, list_excluded): |
| 3086 groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule', |
| 3087 'rule_dependency'] |
3079 grouped_sources = {} | 3088 grouped_sources = {} |
3080 for g in groups: | 3089 for g in groups: |
3081 grouped_sources[g] = [] | 3090 grouped_sources[g] = [] |
3082 | 3091 |
3083 _AddSources2(spec, sources, exclusions, grouped_sources, | 3092 _AddSources2(spec, sources, exclusions, grouped_sources, |
3084 extension_to_rule_name, sources_handled_by_action, list_excluded) | 3093 rule_dependencies, extension_to_rule_name, |
| 3094 sources_handled_by_action, list_excluded) |
3085 sources = [] | 3095 sources = [] |
3086 for g in groups: | 3096 for g in groups: |
3087 if grouped_sources[g]: | 3097 if grouped_sources[g]: |
3088 sources.append(['ItemGroup'] + grouped_sources[g]) | 3098 sources.append(['ItemGroup'] + grouped_sources[g]) |
3089 if actions_spec: | 3099 if actions_spec: |
3090 sources.append(['ItemGroup'] + actions_spec) | 3100 sources.append(['ItemGroup'] + actions_spec) |
3091 return sources | 3101 return sources |
3092 | 3102 |
3093 | 3103 |
3094 def _AddSources2(spec, sources, exclusions, grouped_sources, | 3104 def _AddSources2(spec, sources, exclusions, grouped_sources, |
3095 extension_to_rule_name, sources_handled_by_action, | 3105 rule_dependencies, extension_to_rule_name, |
| 3106 sources_handled_by_action, |
3096 list_excluded): | 3107 list_excluded): |
3097 extensions_excluded_from_precompile = [] | 3108 extensions_excluded_from_precompile = [] |
3098 for source in sources: | 3109 for source in sources: |
3099 if isinstance(source, MSVSProject.Filter): | 3110 if isinstance(source, MSVSProject.Filter): |
3100 _AddSources2(spec, source.contents, exclusions, grouped_sources, | 3111 _AddSources2(spec, source.contents, exclusions, grouped_sources, |
3101 extension_to_rule_name, sources_handled_by_action, | 3112 rule_dependencies, extension_to_rule_name, |
| 3113 sources_handled_by_action, |
3102 list_excluded) | 3114 list_excluded) |
3103 else: | 3115 else: |
3104 if not source in sources_handled_by_action: | 3116 if not source in sources_handled_by_action: |
3105 detail = [] | 3117 detail = [] |
3106 excluded_configurations = exclusions.get(source, []) | 3118 excluded_configurations = exclusions.get(source, []) |
3107 if len(excluded_configurations) == len(spec['configurations']): | 3119 if len(excluded_configurations) == len(spec['configurations']): |
3108 detail.append(['ExcludedFromBuild', 'true']) | 3120 detail.append(['ExcludedFromBuild', 'true']) |
3109 else: | 3121 else: |
3110 for config_name, configuration in sorted(excluded_configurations): | 3122 for config_name, configuration in sorted(excluded_configurations): |
3111 condition = _GetConfigurationCondition(config_name, configuration) | 3123 condition = _GetConfigurationCondition(config_name, configuration) |
(...skipping 22 matching lines...) Expand all Loading... |
3134 ]) | 3146 ]) |
3135 else: | 3147 else: |
3136 # Turn off precompiled header usage for source files of a | 3148 # Turn off precompiled header usage for source files of a |
3137 # different type than the file that generated the | 3149 # different type than the file that generated the |
3138 # precompiled header. | 3150 # precompiled header. |
3139 for extension in extensions_excluded_from_precompile: | 3151 for extension in extensions_excluded_from_precompile: |
3140 if source.endswith(extension): | 3152 if source.endswith(extension): |
3141 detail.append(['PrecompiledHeader', '']) | 3153 detail.append(['PrecompiledHeader', '']) |
3142 detail.append(['ForcedIncludeFiles', '']) | 3154 detail.append(['ForcedIncludeFiles', '']) |
3143 | 3155 |
3144 group, element = _MapFileToMsBuildSourceType(source, | 3156 group, element = _MapFileToMsBuildSourceType(source, rule_dependencies, |
3145 extension_to_rule_name) | 3157 extension_to_rule_name) |
3146 grouped_sources[group].append([element, {'Include': source}] + detail) | 3158 grouped_sources[group].append([element, {'Include': source}] + detail) |
3147 | 3159 |
3148 | 3160 |
3149 def _GetMSBuildProjectReferences(project): | 3161 def _GetMSBuildProjectReferences(project): |
3150 references = [] | 3162 references = [] |
3151 if project.dependencies: | 3163 if project.dependencies: |
3152 group = ['ItemGroup'] | 3164 group = ['ItemGroup'] |
3153 for dependency in project.dependencies: | 3165 for dependency in project.dependencies: |
3154 guid = dependency.guid | 3166 guid = dependency.guid |
(...skipping 23 matching lines...) Expand all Loading... |
3178 gyp_path = _NormalizedSource(project.build_file) | 3190 gyp_path = _NormalizedSource(project.build_file) |
3179 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir) | 3191 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir) |
3180 | 3192 |
3181 gyp_file = os.path.split(project.build_file)[1] | 3193 gyp_file = os.path.split(project.build_file)[1] |
3182 sources, excluded_sources = _PrepareListOfSources(spec, generator_flags, | 3194 sources, excluded_sources = _PrepareListOfSources(spec, generator_flags, |
3183 gyp_file) | 3195 gyp_file) |
3184 # Add rules. | 3196 # Add rules. |
3185 actions_to_add = {} | 3197 actions_to_add = {} |
3186 props_files_of_rules = set() | 3198 props_files_of_rules = set() |
3187 targets_files_of_rules = set() | 3199 targets_files_of_rules = set() |
| 3200 rule_dependencies = set() |
3188 extension_to_rule_name = {} | 3201 extension_to_rule_name = {} |
3189 list_excluded = generator_flags.get('msvs_list_excluded_files', True) | 3202 list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
3190 | 3203 |
3191 # Don't generate rules if we are using an external builder like ninja. | 3204 # Don't generate rules if we are using an external builder like ninja. |
3192 if not spec.get('msvs_external_builder'): | 3205 if not spec.get('msvs_external_builder'): |
3193 _GenerateRulesForMSBuild(project_dir, options, spec, | 3206 _GenerateRulesForMSBuild(project_dir, options, spec, |
3194 sources, excluded_sources, | 3207 sources, excluded_sources, |
3195 props_files_of_rules, targets_files_of_rules, | 3208 props_files_of_rules, targets_files_of_rules, |
3196 actions_to_add, extension_to_rule_name) | 3209 actions_to_add, rule_dependencies, |
| 3210 extension_to_rule_name) |
3197 else: | 3211 else: |
3198 rules = spec.get('rules', []) | 3212 rules = spec.get('rules', []) |
3199 _AdjustSourcesForRules(spec, rules, sources, excluded_sources) | 3213 _AdjustSourcesForRules(rules, sources, excluded_sources, True) |
3200 | 3214 |
3201 sources, excluded_sources, excluded_idl = ( | 3215 sources, excluded_sources, excluded_idl = ( |
3202 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, | 3216 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, |
3203 project_dir, sources, | 3217 project_dir, sources, |
3204 excluded_sources, | 3218 excluded_sources, |
3205 list_excluded, version)) | 3219 list_excluded, version)) |
3206 | 3220 |
3207 # Don't add actions if we are using an external builder like ninja. | 3221 # Don't add actions if we are using an external builder like ninja. |
3208 if not spec.get('msvs_external_builder'): | 3222 if not spec.get('msvs_external_builder'): |
3209 _AddActions(actions_to_add, spec, project.build_file) | 3223 _AddActions(actions_to_add, spec, project.build_file) |
3210 _AddCopies(actions_to_add, spec) | 3224 _AddCopies(actions_to_add, spec) |
3211 | 3225 |
3212 # NOTE: this stanza must appear after all actions have been decided. | 3226 # NOTE: this stanza must appear after all actions have been decided. |
3213 # Don't excluded sources with actions attached, or they won't run. | 3227 # Don't excluded sources with actions attached, or they won't run. |
3214 excluded_sources = _FilterActionsFromExcluded( | 3228 excluded_sources = _FilterActionsFromExcluded( |
3215 excluded_sources, actions_to_add) | 3229 excluded_sources, actions_to_add) |
3216 | 3230 |
3217 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) | 3231 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) |
3218 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( | 3232 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( |
3219 spec, actions_to_add) | 3233 spec, actions_to_add) |
3220 | 3234 |
3221 _GenerateMSBuildFiltersFile(project.path + '.filters', sources, | 3235 _GenerateMSBuildFiltersFile(project.path + '.filters', sources, |
| 3236 rule_dependencies, |
3222 extension_to_rule_name) | 3237 extension_to_rule_name) |
3223 missing_sources = _VerifySourcesExist(sources, project_dir) | 3238 missing_sources = _VerifySourcesExist(sources, project_dir) |
3224 | 3239 |
3225 for configuration in configurations.itervalues(): | 3240 for configuration in configurations.itervalues(): |
3226 _FinalizeMSBuildSettings(spec, configuration) | 3241 _FinalizeMSBuildSettings(spec, configuration) |
3227 | 3242 |
3228 # Add attributes to root element | 3243 # Add attributes to root element |
3229 | 3244 |
3230 import_default_section = [ | 3245 import_default_section = [ |
3231 ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.Default.props'}]] | 3246 ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.Default.props'}]] |
(...skipping 19 matching lines...) Expand all Loading... |
3251 else: | 3266 else: |
3252 content += _GetMSBuildLocalProperties(project.msbuild_toolset) | 3267 content += _GetMSBuildLocalProperties(project.msbuild_toolset) |
3253 content += import_cpp_props_section | 3268 content += import_cpp_props_section |
3254 content += _GetMSBuildExtensions(props_files_of_rules) | 3269 content += _GetMSBuildExtensions(props_files_of_rules) |
3255 content += _GetMSBuildPropertySheets(configurations) | 3270 content += _GetMSBuildPropertySheets(configurations) |
3256 content += macro_section | 3271 content += macro_section |
3257 content += _GetMSBuildConfigurationGlobalProperties(spec, configurations, | 3272 content += _GetMSBuildConfigurationGlobalProperties(spec, configurations, |
3258 project.build_file) | 3273 project.build_file) |
3259 content += _GetMSBuildToolSettingsSections(spec, configurations) | 3274 content += _GetMSBuildToolSettingsSections(spec, configurations) |
3260 content += _GetMSBuildSources( | 3275 content += _GetMSBuildSources( |
3261 spec, sources, exclusions, extension_to_rule_name, actions_spec, | 3276 spec, sources, exclusions, rule_dependencies, extension_to_rule_name, |
3262 sources_handled_by_action, list_excluded) | 3277 actions_spec, sources_handled_by_action, list_excluded) |
3263 content += _GetMSBuildProjectReferences(project) | 3278 content += _GetMSBuildProjectReferences(project) |
3264 content += import_cpp_targets_section | 3279 content += import_cpp_targets_section |
3265 content += _GetMSBuildExtensionTargets(targets_files_of_rules) | 3280 content += _GetMSBuildExtensionTargets(targets_files_of_rules) |
3266 | 3281 |
3267 if spec.get('msvs_external_builder'): | 3282 if spec.get('msvs_external_builder'): |
3268 content += _GetMSBuildExternalBuilderTargets(spec) | 3283 content += _GetMSBuildExternalBuilderTargets(spec) |
3269 | 3284 |
3270 # TODO(jeanluc) File a bug to get rid of runas. We had in MSVS: | 3285 # TODO(jeanluc) File a bug to get rid of runas. We had in MSVS: |
3271 # has_run_as = _WriteMSVSUserFile(project.path, version, spec) | 3286 # has_run_as = _WriteMSVSUserFile(project.path, version, spec) |
3272 | 3287 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3390 action_spec.extend( | 3405 action_spec.extend( |
3391 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3406 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3392 [['FileType', 'Document'], | 3407 [['FileType', 'Document'], |
3393 ['Command', command], | 3408 ['Command', command], |
3394 ['Message', description], | 3409 ['Message', description], |
3395 ['Outputs', outputs] | 3410 ['Outputs', outputs] |
3396 ]) | 3411 ]) |
3397 if additional_inputs: | 3412 if additional_inputs: |
3398 action_spec.append(['AdditionalInputs', additional_inputs]) | 3413 action_spec.append(['AdditionalInputs', additional_inputs]) |
3399 actions_spec.append(action_spec) | 3414 actions_spec.append(action_spec) |
OLD | NEW |