Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: pylib/gyp/generator/msvs.py

Issue 344573002: Introduce '--no-duplicate-basename-check' option to disable the check of duplicate basenames (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: Rebase with r1946 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pylib/gyp/generator/make.py ('k') | pylib/gyp/input.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 # Skip emitting anything if told to with msvs_existing_vcproj option. 914 # Skip emitting anything if told to with msvs_existing_vcproj option.
915 if default_config.get('msvs_existing_vcproj'): 915 if default_config.get('msvs_existing_vcproj'):
916 return [] 916 return []
917 917
918 if version.UsesVcxproj(): 918 if version.UsesVcxproj():
919 return _GenerateMSBuildProject(project, options, version, generator_flags) 919 return _GenerateMSBuildProject(project, options, version, generator_flags)
920 else: 920 else:
921 return _GenerateMSVSProject(project, options, version, generator_flags) 921 return _GenerateMSVSProject(project, options, version, generator_flags)
922 922
923 923
924 # TODO: Avoid code duplication with _ValidateSourcesForOSX in make.py.
925 def _ValidateSourcesForMSVSProject(spec, version):
926 """Makes sure if duplicate basenames are not specified in the source list.
927
928 Arguments:
929 spec: The target dictionary containing the properties of the target.
930 version: The VisualStudioVersion object.
931 """
932 # This validation should not be applied to MSVC2010 and later.
933 assert not version.UsesVcxproj()
934
935 # TODO: Check if MSVC allows this for loadable_module targets.
936 if spec.get('type', None) not in ('static_library', 'shared_library'):
937 return
938 sources = spec.get('sources', [])
939 basenames = {}
940 for source in sources:
941 name, ext = os.path.splitext(source)
942 is_compiled_file = ext in [
943 '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S']
944 if not is_compiled_file:
945 continue
946 basename = os.path.basename(name) # Don't include extension.
947 basenames.setdefault(basename, []).append(source)
948
949 error = ''
950 for basename, files in basenames.iteritems():
951 if len(files) > 1:
952 error += ' %s: %s\n' % (basename, ' '.join(files))
953
954 if error:
955 print('static library %s has several files with the same basename:\n' %
956 spec['target_name'] + error + 'MSVC08 cannot handle that.')
957 raise GypError('Duplicate basenames in sources section, see list above')
958
959
924 def _GenerateMSVSProject(project, options, version, generator_flags): 960 def _GenerateMSVSProject(project, options, version, generator_flags):
925 """Generates a .vcproj file. It may create .rules and .user files too. 961 """Generates a .vcproj file. It may create .rules and .user files too.
926 962
927 Arguments: 963 Arguments:
928 project: The project object we will generate the file for. 964 project: The project object we will generate the file for.
929 options: Global options passed to the generator. 965 options: Global options passed to the generator.
930 version: The VisualStudioVersion object. 966 version: The VisualStudioVersion object.
931 generator_flags: dict of generator-specific flags. 967 generator_flags: dict of generator-specific flags.
932 """ 968 """
933 spec = project.spec 969 spec = project.spec
934 gyp.common.EnsureDirExists(project.path) 970 gyp.common.EnsureDirExists(project.path)
935 971
936 platforms = _GetUniquePlatforms(spec) 972 platforms = _GetUniquePlatforms(spec)
937 p = MSVSProject.Writer(project.path, version, spec['target_name'], 973 p = MSVSProject.Writer(project.path, version, spec['target_name'],
938 project.guid, platforms) 974 project.guid, platforms)
939 975
940 # Get directory project file is in. 976 # Get directory project file is in.
941 project_dir = os.path.split(project.path)[0] 977 project_dir = os.path.split(project.path)[0]
942 gyp_path = _NormalizedSource(project.build_file) 978 gyp_path = _NormalizedSource(project.build_file)
943 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir) 979 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir)
944 980
945 config_type = _GetMSVSConfigurationType(spec, project.build_file) 981 config_type = _GetMSVSConfigurationType(spec, project.build_file)
946 for config_name, config in spec['configurations'].iteritems(): 982 for config_name, config in spec['configurations'].iteritems():
947 _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config) 983 _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config)
948 984
985 # MSVC08 and prior version cannot handle duplicate basenames in the same
986 # target.
987 # TODO: Take excluded sources into consideration if possible.
988 _ValidateSourcesForMSVSProject(spec, version)
989
949 # Prepare list of sources and excluded sources. 990 # Prepare list of sources and excluded sources.
950 gyp_file = os.path.split(project.build_file)[1] 991 gyp_file = os.path.split(project.build_file)[1]
951 sources, excluded_sources = _PrepareListOfSources(spec, generator_flags, 992 sources, excluded_sources = _PrepareListOfSources(spec, generator_flags,
952 gyp_file) 993 gyp_file)
953 994
954 # Add rules. 995 # Add rules.
955 actions_to_add = {} 996 actions_to_add = {}
956 _GenerateRulesForMSVS(p, project_dir, options, spec, 997 _GenerateRulesForMSVS(p, project_dir, options, spec,
957 sources, excluded_sources, 998 sources, excluded_sources,
958 actions_to_add) 999 actions_to_add)
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 action_spec.extend( 3355 action_spec.extend(
3315 # TODO(jeanluc) 'Document' for all or just if as_sources? 3356 # TODO(jeanluc) 'Document' for all or just if as_sources?
3316 [['FileType', 'Document'], 3357 [['FileType', 'Document'],
3317 ['Command', command], 3358 ['Command', command],
3318 ['Message', description], 3359 ['Message', description],
3319 ['Outputs', outputs] 3360 ['Outputs', outputs]
3320 ]) 3361 ])
3321 if additional_inputs: 3362 if additional_inputs:
3322 action_spec.append(['AdditionalInputs', additional_inputs]) 3363 action_spec.append(['AdditionalInputs', additional_inputs])
3323 actions_spec.append(action_spec) 3364 actions_spec.append(action_spec)
OLDNEW
« no previous file with comments | « pylib/gyp/generator/make.py ('k') | pylib/gyp/input.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698