Chromium Code Reviews| Index: pylib/gyp/generator/msvs.py |
| diff --git a/pylib/gyp/generator/msvs.py b/pylib/gyp/generator/msvs.py |
| index 47cbd36ec69c54d0229cf2ad299e7bdf29f30a25..f766988f95baff10556b60b467469683319e0654 100644 |
| --- a/pylib/gyp/generator/msvs.py |
| +++ b/pylib/gyp/generator/msvs.py |
| @@ -918,7 +918,7 @@ def _GenerateMSVSProject(project, options, version, generator_flags): |
| sources, excluded_sources, |
| actions_to_add) |
| list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
| - sources, excluded_sources, excluded_idl = ( |
| + sources, excluded_sources, excluded_custom_files = ( |
| _AdjustSourcesAndConvertToFilterHierarchy( |
| spec, options, project_dir, sources, excluded_sources, list_excluded)) |
| @@ -936,7 +936,7 @@ def _GenerateMSVSProject(project, options, version, generator_flags): |
| # Don't excluded sources with actions attached, or they won't run. |
| excluded_sources = _FilterActionsFromExcluded( |
| excluded_sources, actions_to_add) |
| - _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, |
| + _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_custom_files, |
| list_excluded) |
| _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) |
| @@ -1025,7 +1025,7 @@ def _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config): |
| for this configuration. |
| """ |
| # Get the information for this configuration |
| - include_dirs, resource_include_dirs = _GetIncludeDirs(config) |
| + include_dirs, resource_include_dirs, _ = _GetIncludeDirs(config) |
| libraries = _GetLibraries(spec) |
| out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False) |
| defines = _GetDefines(config) |
| @@ -1094,7 +1094,8 @@ def _GetIncludeDirs(config): |
| config: The dictionnary that defines the special processing to be done |
| for this configuration. |
| Returns: |
| - The list of directory paths. |
| + A triple of (C++ include directory paths, Resource Compiler include |
| + directory paths, MASM inclue directory paths) |
|
scottmg
2013/01/03 03:36:40
inclue
|
| """ |
| # TODO(bradnelson): include_dirs should really be flexible enough not to |
| # require this sort of thing. |
| @@ -1102,9 +1103,11 @@ def _GetIncludeDirs(config): |
| config.get('include_dirs', []) + |
| config.get('msvs_system_include_dirs', [])) |
| resource_include_dirs = config.get('resource_include_dirs', include_dirs) |
| + masm_include_dirs = config.get('masm_include_dirs', include_dirs) |
| include_dirs = _FixPaths(include_dirs) |
| resource_include_dirs = _FixPaths(resource_include_dirs) |
| - return include_dirs, resource_include_dirs |
| + masm_include_dirs = _FixPaths(masm_include_dirs) |
| + return include_dirs, resource_include_dirs, masm_include_dirs |
| def _GetLibraries(spec): |
| @@ -1337,7 +1340,7 @@ def _AdjustSourcesAndConvertToFilterHierarchy( |
| excluded_sources: A set of sources to be excluded for this project. |
| Returns: |
| A trio of (list of sources, list of excluded sources, |
| - path of excluded IDL file) |
| + path of excluded files being handled by non-MSVS-native rules) |
| """ |
| # Exclude excluded sources coming into the generator. |
| excluded_sources.update(set(spec.get('sources_excluded', []))) |
| @@ -1350,7 +1353,7 @@ def _AdjustSourcesAndConvertToFilterHierarchy( |
| # Convert to proper windows form. |
| excluded_sources = _FixPaths(excluded_sources) |
| - excluded_idl = _IdlFilesHandledNonNatively(spec, sources) |
| + excluded_custom_files = _FilesHandledNonNatively(spec, sources) |
| precompiled_related = _GetPrecompileRelatedFiles(spec) |
| # Find the excluded ones, minus the precompiled header related ones. |
| @@ -1361,22 +1364,24 @@ def _AdjustSourcesAndConvertToFilterHierarchy( |
| sources = _ConvertSourcesToFilterHierarchy(sources, excluded=fully_excluded, |
| list_excluded=list_excluded) |
| - return sources, excluded_sources, excluded_idl |
| + return sources, excluded_sources, excluded_custom_files |
| -def _IdlFilesHandledNonNatively(spec, sources): |
| - # If any non-native rules use 'idl' as an extension exclude idl files. |
| +def _FilesHandledNonNatively(spec, sources): |
| + # If any non-native rules exist for extensions normally handled by MSVS, such |
| + # as .idl or .asm, then exclude files with those extensions. |
| # Gather a list here to use later. |
| - using_idl = False |
| - for rule in spec.get('rules', []): |
| - if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): |
| - using_idl = True |
| - break |
| - if using_idl: |
| - excluded_idl = [i for i in sources if i.endswith('.idl')] |
| - else: |
| - excluded_idl = [] |
| - return excluded_idl |
| + excluded_files = [] |
| + for extension in ['idl', 'asm']: |
| + using_custom_rule = False |
| + for rule in spec.get('rules', []): |
| + if (rule['extension'] == extension and |
| + int(rule.get('msvs_external_rule', 0))): |
| + using_custom_rule = True |
| + break |
| + if using_custom_rule: |
| + excluded_files.extend([i for i in sources if i.endswith('.' + extension)]) |
| + return excluded_files |
| def _GetPrecompileRelatedFiles(spec): |
| @@ -1390,9 +1395,10 @@ def _GetPrecompileRelatedFiles(spec): |
| return precompiled_related |
| -def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, |
| - list_excluded): |
| - exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) |
| +def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, |
| + excluded_custom_files, list_excluded): |
| + exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, |
| + excluded_custom_files) |
| for file_name, excluded_configs in exclusions.iteritems(): |
| if (not list_excluded and |
| len(excluded_configs) == len(spec['configurations'])): |
| @@ -1405,7 +1411,7 @@ def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, |
| {'ExcludedFromBuild': 'true'}) |
| -def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl): |
| +def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_custom_files): |
| exclusions = {} |
| # Exclude excluded sources from being built. |
| for f in excluded_sources: |
| @@ -1418,7 +1424,7 @@ def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl): |
| exclusions[f] = excluded_configs |
| # If any non-native rules use 'idl' as an extension exclude idl files. |
| # Exclude them now. |
| - for f in excluded_idl: |
| + for f in excluded_custom_files: |
| excluded_configs = [] |
| for config_name, config in spec['configurations'].iteritems(): |
| excluded_configs.append((config_name, config)) |
| @@ -1971,6 +1977,9 @@ def _MapFileToMsBuildSourceType(source, extension_to_rule_name): |
| elif ext == '.idl': |
| group = 'midl' |
| element = 'Midl' |
| + elif ext == '.asm': |
| + group = 'masm' |
| + element = 'MASM' |
| else: |
| group = 'none' |
| element = 'None' |
| @@ -2778,7 +2787,8 @@ def _FinalizeMSBuildSettings(spec, configuration): |
| converted = True |
| msvs_settings = configuration.get('msvs_settings', {}) |
| msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) |
| - include_dirs, resource_include_dirs = _GetIncludeDirs(configuration) |
| + include_dirs, resource_include_dirs, masm_include_dirs = \ |
| + _GetIncludeDirs(configuration) |
| libraries = _GetLibraries(spec) |
| out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) |
| defines = _GetDefines(configuration) |
| @@ -2809,6 +2819,8 @@ def _FinalizeMSBuildSettings(spec, configuration): |
| 'AdditionalIncludeDirectories', include_dirs) |
| _ToolAppend(msbuild_settings, 'ResourceCompile', |
| 'AdditionalIncludeDirectories', resource_include_dirs) |
| + _ToolAppend(msbuild_settings, 'MASM', |
| + 'AdditionalIncludeDirectories', masm_include_dirs) |
| # Add in libraries. |
| _ToolAppend(msbuild_settings, 'Link', 'AdditionalDependencies', libraries) |
| if out_file: |
| @@ -2819,6 +2831,8 @@ def _FinalizeMSBuildSettings(spec, configuration): |
| 'PreprocessorDefinitions', defines) |
| _ToolAppend(msbuild_settings, 'ResourceCompile', |
| 'PreprocessorDefinitions', defines) |
| + _ToolAppend(msbuild_settings, 'MASM', |
| + 'PreprocessorDefinitions', defines) |
| # Add disabled warnings. |
| _ToolAppend(msbuild_settings, 'ClCompile', |
| 'DisableSpecificWarnings', disabled_warnings) |
| @@ -2896,7 +2910,7 @@ def _VerifySourcesExist(sources, root_dir): |
| def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, |
| actions_spec, sources_handled_by_action, list_excluded): |
| - groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule'] |
| + groups = ['none', 'midl', 'masm', 'include', 'compile', 'resource', 'rule'] |
| grouped_sources = {} |
| for g in groups: |
| grouped_sources[g] = [] |
| @@ -3014,7 +3028,7 @@ def _GenerateMSBuildProject(project, options, version, generator_flags): |
| sources, excluded_sources, |
| props_files_of_rules, targets_files_of_rules, |
| actions_to_add, extension_to_rule_name) |
| - sources, excluded_sources, excluded_idl = ( |
| + sources, excluded_sources, excluded_custom_files = ( |
| _AdjustSourcesAndConvertToFilterHierarchy(spec, options, |
| project_dir, sources, |
| excluded_sources, |
| @@ -3027,7 +3041,8 @@ def _GenerateMSBuildProject(project, options, version, generator_flags): |
| excluded_sources = _FilterActionsFromExcluded( |
| excluded_sources, actions_to_add) |
| - exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) |
| + exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, |
| + excluded_custom_files) |
| actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( |
| spec, actions_to_add) |
| @@ -3086,6 +3101,9 @@ def _GetMSBuildExtensions(props_files_of_rules): |
| extensions = ['ImportGroup', {'Label': 'ExtensionSettings'}] |
| for props_file in props_files_of_rules: |
| extensions.append(['Import', {'Project': props_file}]) |
| + extensions.append( |
| + ['Import', {'Project': |
| + r'$(VCTargetsPath)\BuildCustomizations\masm.props'}]) |
| return [extensions] |
| @@ -3093,6 +3111,9 @@ def _GetMSBuildExtensionTargets(targets_files_of_rules): |
| targets_node = ['ImportGroup', {'Label': 'ExtensionTargets'}] |
| for targets_file in sorted(targets_files_of_rules): |
| targets_node.append(['Import', {'Project': targets_file}]) |
| + targets_node.append( |
| + ['Import', {'Project': |
| + r'$(VCTargetsPath)\BuildCustomizations\masm.targets'}]) |
| return [targets_node] |