diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-02-20 11:47:03 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-02-20 11:47:03 +0100 |
commit | 4af673e161138fbed287a8e00cf7b2b0aafdd8b3 (patch) | |
tree | 90fb82bb98fdbcbb0c86c446e029c13bf999c8b0 /tools/gyp/pylib/gyp/generator/msvs.py | |
parent | 7ae0d473a6b6ac8cb3e55d665528667566cd8e60 (diff) | |
download | android-node-v8-4af673e161138fbed287a8e00cf7b2b0aafdd8b3.tar.gz android-node-v8-4af673e161138fbed287a8e00cf7b2b0aafdd8b3.tar.bz2 android-node-v8-4af673e161138fbed287a8e00cf7b2b0aafdd8b3.zip |
gyp: update to r1214
Diffstat (limited to 'tools/gyp/pylib/gyp/generator/msvs.py')
-rw-r--r-- | tools/gyp/pylib/gyp/generator/msvs.py | 101 |
1 files changed, 59 insertions, 42 deletions
diff --git a/tools/gyp/pylib/gyp/generator/msvs.py b/tools/gyp/pylib/gyp/generator/msvs.py index e9ead80d6a..a4c6efd1a4 100644 --- a/tools/gyp/pylib/gyp/generator/msvs.py +++ b/tools/gyp/pylib/gyp/generator/msvs.py @@ -1,4 +1,4 @@ -# Copyright (c) 2011 Google Inc. All rights reserved. +# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -162,7 +162,8 @@ def _FixPaths(paths): return [_FixPath(i) for i in paths] -def _ConvertSourcesToFilterHierarchy(sources, prefix=None, excluded=None): +def _ConvertSourcesToFilterHierarchy(sources, prefix=None, excluded=None, + list_excluded=True): """Converts a list split source file paths into a vcproj folder hierarchy. Arguments: @@ -197,14 +198,15 @@ def _ConvertSourcesToFilterHierarchy(sources, prefix=None, excluded=None): folders[s[0]] = [] folders[s[0]].append(s[1:]) # Add a folder for excluded files. - if excluded_result: + if excluded_result and list_excluded: excluded_folder = MSVSProject.Filter('_excluded_files', contents=excluded_result) result.append(excluded_folder) # Populate all the folders. for f in folders: contents = _ConvertSourcesToFilterHierarchy(folders[f], prefix=prefix + [f], - excluded=excluded) + excluded=excluded, + list_excluded=list_excluded) contents = MSVSProject.Filter(f, contents=contents) result.append(contents) @@ -831,13 +833,14 @@ def _GetGuidOfProject(proj_path, spec): return guid -def _GenerateProject(project, options, version): +def _GenerateProject(project, options, version, generator_flags): """Generates a vcproj file. Arguments: project: the MSVSProject object. options: global generator options. version: the MSVSVersion object. + generator_flags: dict of generator-specific flags. """ default_config = _GetDefaultConfiguration(project.spec) @@ -846,18 +849,19 @@ def _GenerateProject(project, options, version): return if version.UsesVcxproj(): - _GenerateMSBuildProject(project, options, version) + _GenerateMSBuildProject(project, options, version, generator_flags) else: - _GenerateMSVSProject(project, options, version) + _GenerateMSVSProject(project, options, version, generator_flags) -def _GenerateMSVSProject(project, options, version): +def _GenerateMSVSProject(project, options, version, generator_flags): """Generates a .vcproj file. It may create .rules and .user files too. Arguments: project: The project object we will generate the file for. options: Global options passed to the generator. version: The VisualStudioVersion object. + generator_flags: dict of generator-specific flags. """ spec = project.spec vcproj_dir = os.path.dirname(project.path) @@ -886,9 +890,10 @@ def _GenerateMSVSProject(project, options, version): _GenerateRulesForMSVS(p, project_dir, options, spec, sources, excluded_sources, actions_to_add) + list_excluded = generator_flags.get('msvs_list_excluded_files', True) sources, excluded_sources, excluded_idl = ( _AdjustSourcesAndConvertToFilterHierarchy( - spec, options, project_dir, sources, excluded_sources)) + spec, options, project_dir, sources, excluded_sources, list_excluded)) # Add in files. _VerifySourcesExist(sources, project_dir) @@ -904,7 +909,8 @@ def _GenerateMSVSProject(project, options, version): # 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_idl, + list_excluded) _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) # Write it out. @@ -963,7 +969,6 @@ def _GetMSVSConfigurationType(spec, build_file): 'loadable_module': '2', # .dll 'static_library': '4', # .lib 'none': '10', # Utility type - 'dummy_executable': '1', # .exe }[spec['type']] except KeyError: if spec.get('type'): @@ -1120,7 +1125,6 @@ def _GetOutputFilePathAndTool(spec): # VisualStudio 2010, we will have to change the value of $(OutDir) # to contain the \lib suffix, rather than doing it as below. 'static_library': ('VCLibrarianTool', 'Lib', '$(OutDir)\\lib\\', '.lib'), - 'dummy_executable': ('VCLinkerTool', 'Link', '$(IntDir)\\', '.junk'), } output_file_props = output_file_map.get(spec['type']) if output_file_props and int(spec.get('msvs_auto_output_file', 1)): @@ -1287,7 +1291,7 @@ def _PrepareListOfSources(spec, gyp_file): def _AdjustSourcesAndConvertToFilterHierarchy( - spec, options, gyp_dir, sources, excluded_sources): + spec, options, gyp_dir, sources, excluded_sources, list_excluded): """Adjusts the list of sources and excluded sources. Also converts the sets to lists. @@ -1321,13 +1325,8 @@ def _AdjustSourcesAndConvertToFilterHierarchy( # Convert to folders and the right slashes. sources = [i.split('\\') for i in sources] - sources = _ConvertSourcesToFilterHierarchy(sources, excluded=fully_excluded) - # Add in dummy file for type none. - if spec['type'] == 'dummy_executable': - # Pull in a dummy main so it can link successfully. - dummy_relpath = gyp.common.RelativePath( - options.depth + '\\tools\\gyp\\gyp_dummy.c', gyp_dir) - sources.append(dummy_relpath) + sources = _ConvertSourcesToFilterHierarchy(sources, excluded=fully_excluded, + list_excluded=list_excluded) return sources, excluded_sources, excluded_idl @@ -1358,12 +1357,19 @@ def _GetPrecompileRelatedFiles(spec): return precompiled_related -def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl): +def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, + list_excluded): exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) for file_name, excluded_configs in exclusions.iteritems(): - for config_name, config in excluded_configs: - p.AddFileConfig(file_name, _ConfigFullName(config_name, config), - {'ExcludedFromBuild': 'true'}) + if (not list_excluded and + len(excluded_configs) == len(spec['configurations'])): + # If we're not listing excluded files, then they won't appear in the + # project, so don't try to configure them to be excluded. + pass + else: + for config_name, config in excluded_configs: + p.AddFileConfig(file_name, _ConfigFullName(config_name, config), + {'ExcludedFromBuild': 'true'}) def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl): @@ -1751,6 +1757,8 @@ def GenerateOutput(target_list, target_dicts, data, params): # GeneratorCalculatedVariables. msvs_version = params['msvs_version'] + generator_flags = params.get('generator_flags', {}) + # Optionally shard targets marked with 'msvs_shard': SHARD_COUNT. (target_list, target_dicts) = _ShardTargets(target_list, target_dicts) @@ -1769,7 +1777,7 @@ def GenerateOutput(target_list, target_dicts, data, params): # Generate each project. for project in project_objects.values(): fixpath_prefix = project.fixpath_prefix - _GenerateProject(project, options, msvs_version) + _GenerateProject(project, options, msvs_version, generator_flags) fixpath_prefix = None for build_file in data: @@ -1873,7 +1881,10 @@ def _MapFileToMsBuildSourceType(source, extension_to_rule_name): A pair of (group this file should be part of, the label of element) """ _, ext = os.path.splitext(source) - if ext in ['.cc', '.cpp', '.c', '.cxx']: + if ext in extension_to_rule_name: + group = 'rule' + element = extension_to_rule_name[ext] + elif ext in ['.cc', '.cpp', '.c', '.cxx']: group = 'compile' element = 'ClCompile' elif ext in ['.h', '.hxx']: @@ -1885,9 +1896,6 @@ def _MapFileToMsBuildSourceType(source, extension_to_rule_name): elif ext == '.idl': group = 'midl' element = 'Midl' - elif ext in extension_to_rule_name: - group = 'rule' - element = extension_to_rule_name[ext] else: group = 'none' element = 'None' @@ -2663,14 +2671,14 @@ def _VerifySourcesExist(sources, root_dir): def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, - actions_spec, sources_handled_by_action): + actions_spec, sources_handled_by_action, list_excluded): groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule'] grouped_sources = {} for g in groups: grouped_sources[g] = [] _AddSources2(spec, sources, exclusions, grouped_sources, - extension_to_rule_name, sources_handled_by_action) + extension_to_rule_name, sources_handled_by_action, list_excluded) sources = [] for g in groups: if grouped_sources[g]: @@ -2681,12 +2689,14 @@ def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, def _AddSources2(spec, sources, exclusions, grouped_sources, - extension_to_rule_name, sources_handled_by_action): + extension_to_rule_name, sources_handled_by_action, + list_excluded): extensions_excluded_from_precompile = [] for source in sources: if isinstance(source, MSVSProject.Filter): _AddSources2(spec, source.contents, exclusions, grouped_sources, - extension_to_rule_name, sources_handled_by_action) + extension_to_rule_name, sources_handled_by_action, + list_excluded) else: if not source in sources_handled_by_action: detail = [] @@ -2741,17 +2751,22 @@ def _GetMSBuildProjectReferences(project): guid = dependency.guid project_dir = os.path.split(project.path)[0] relative_path = gyp.common.RelativePath(dependency.path, project_dir) - group.append( - ['ProjectReference', - {'Include': relative_path}, - ['Project', guid], - ['ReferenceOutputAssembly', 'false'] - ]) + project_ref = ['ProjectReference', + {'Include': relative_path}, + ['Project', guid], + ['ReferenceOutputAssembly', 'false'] + ] + for config in dependency.spec.get('configurations', {}).itervalues(): + # If it's disabled in any config, turn it off in the reference. + if config.get('msvs_2010_disable_uldi_when_referenced', 0): + project_ref.append(['UseLibraryDependencyInputs', 'false']) + break + group.append(project_ref) references.append(group) return references -def _GenerateMSBuildProject(project, options, version): +def _GenerateMSBuildProject(project, options, version, generator_flags): spec = project.spec configurations = spec['configurations'] project_dir, project_file_name = os.path.split(project.path) @@ -2769,6 +2784,7 @@ def _GenerateMSBuildProject(project, options, version): props_files_of_rules = set() targets_files_of_rules = set() extension_to_rule_name = {} + list_excluded = generator_flags.get('msvs_list_excluded_files', True) _GenerateRulesForMSBuild(project_dir, options, spec, sources, excluded_sources, props_files_of_rules, targets_files_of_rules, @@ -2776,7 +2792,8 @@ def _GenerateMSBuildProject(project, options, version): sources, excluded_sources, excluded_idl = ( _AdjustSourcesAndConvertToFilterHierarchy(spec, options, project_dir, sources, - excluded_sources)) + excluded_sources, + list_excluded)) _AddActions(actions_to_add, spec, project.build_file) _AddCopies(actions_to_add, spec) @@ -2826,7 +2843,7 @@ def _GenerateMSBuildProject(project, options, version): content += _GetMSBuildToolSettingsSections(spec, configurations) content += _GetMSBuildSources( spec, sources, exclusions, extension_to_rule_name, actions_spec, - sources_handled_by_action) + sources_handled_by_action, list_excluded) content += _GetMSBuildProjectReferences(project) content += import_cpp_targets_section content += _GetMSBuildExtensionTargets(targets_files_of_rules) |