@@ -1030,45 +1030,6 @@ def _GenerateProject(project, options, version, generator_flags, spec):
1030
1030
return _GenerateMSVSProject (project , options , version , generator_flags )
1031
1031
1032
1032
1033
- # TODO: Avoid code duplication with _ValidateSourcesForOSX in make.py.
1034
- def _ValidateSourcesForMSVSProject (spec , version ):
1035
- """Makes sure if duplicate basenames are not specified in the source list.
1036
-
1037
- Arguments:
1038
- spec: The target dictionary containing the properties of the target.
1039
- version: The VisualStudioVersion object.
1040
- """
1041
- # This validation should not be applied to MSVC2010 and later.
1042
- assert not version .UsesVcxproj ()
1043
-
1044
- # TODO: Check if MSVC allows this for loadable_module targets.
1045
- if spec .get ("type" , None ) not in ("static_library" , "shared_library" ):
1046
- return
1047
- sources = spec .get ("sources" , [])
1048
- basenames = {}
1049
- for source in sources :
1050
- name , ext = os .path .splitext (source )
1051
- is_compiled_file = ext in [".c" , ".cc" , ".cpp" , ".cxx" , ".m" , ".mm" , ".s" , ".S" ]
1052
- if not is_compiled_file :
1053
- continue
1054
- basename = os .path .basename (name ) # Don't include extension.
1055
- basenames .setdefault (basename , []).append (source )
1056
-
1057
- error = ""
1058
- for basename , files in basenames .items ():
1059
- if len (files ) > 1 :
1060
- error += " %s: %s\n " % (basename , " " .join (files ))
1061
-
1062
- if error :
1063
- print (
1064
- "static library %s has several files with the same basename:\n "
1065
- % spec ["target_name" ]
1066
- + error
1067
- + "MSVC08 cannot handle that."
1068
- )
1069
- raise GypError ("Duplicate basenames in sources section, see list above" )
1070
-
1071
-
1072
1033
def _GenerateMSVSProject (project , options , version , generator_flags ):
1073
1034
"""Generates a .vcproj file. It may create .rules and .user files too.
1074
1035
@@ -1095,11 +1056,6 @@ def _GenerateMSVSProject(project, options, version, generator_flags):
1095
1056
for config_name , config in spec ["configurations" ].items ():
1096
1057
_AddConfigurationToMSVSProject (p , spec , config_type , config_name , config )
1097
1058
1098
- # MSVC08 and prior version cannot handle duplicate basenames in the same
1099
- # target.
1100
- # TODO: Take excluded sources into consideration if possible.
1101
- _ValidateSourcesForMSVSProject (spec , version )
1102
-
1103
1059
# Prepare list of sources and excluded sources.
1104
1060
gyp_file = os .path .split (project .build_file )[1 ]
1105
1061
sources , excluded_sources = _PrepareListOfSources (spec , generator_flags , gyp_file )
@@ -3659,6 +3615,15 @@ def _AddSources2(
3659
3615
extension_to_rule_name ,
3660
3616
_GetUniquePlatforms (spec ),
3661
3617
)
3618
+ if group == "compile" :
3619
+ # Always add an <ObjectFileName> value to support duplicate
3620
+ # source file basenames.
3621
+ file_name = source
3622
+ if (file_name .startswith ("..\\ " )):
3623
+ file_name = re .sub (r"^(\.\.\\)+" , "" , file_name )
3624
+ elif (file_name .startswith ("$(" )):
3625
+ file_name = re .sub (r"^\$\([^)]+\)\\" , "" , file_name )
3626
+ detail .append (["ObjectFileName" , "$(IntDir)\\ " + file_name ])
3662
3627
grouped_sources [group ].append ([element , {"Include" : source }] + detail )
3663
3628
3664
3629
0 commit comments