vs2010: support same source file names in different subdirs

pull/474/head
Nicolas Schneider 9 years ago
parent 7019daaab0
commit 0c4aab6eed
  1. 5
      mesonbuild/backend/vs2010backend.py
  2. 11
      mesonbuild/build.py

@ -566,6 +566,11 @@ class Vs2010Backend(backends.Backend):
inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath)
self.add_pch(inc_cl, proj_to_src_dir, pch_sources, s)
self.add_additional_options(s, inc_cl, extra_args, additional_options_set)
basename = os.path.basename(s.fname)
if basename in target.sources_conflicts:
obj_name = '.'.join(s.split('.')[:-1]).replace('/', '_')\
+ '.' + self.environment.get_object_suffix()
ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + obj_name
for s in gen_src:
relpath = self.relpath(s, target.subdir)
inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath)

@ -184,6 +184,7 @@ class BuildTarget():
self.subproject = subproject # Can not be calculated from subdir as subproject dirname can be changed per project.
self.is_cross = is_cross
self.sources = []
self.sources_conflicts = {}
self.objects = []
self.external_deps = []
self.include_dirs = []
@ -244,6 +245,7 @@ class BuildTarget():
if not isinstance(sources, list):
sources = [sources]
added_sources = {} # If the same source is defined multiple times, use it only once.
conflicts = {} # We must resolve conflicts if multiple source files from different subdirs have the same name.
for s in sources:
# Holder unpacking. Ugly.
if hasattr(s, 'held_object'):
@ -252,10 +254,19 @@ class BuildTarget():
if not s in added_sources:
self.sources.append(s)
added_sources[s] = True
basename = os.path.basename(s.fname)
conflicting_sources = conflicts.get(basename, None)
if conflicting_sources is None:
conflicting_sources = []
conflicting_sources.append(s)
conflicts[basename] = conflicting_sources
elif isinstance(s, GeneratedList) or isinstance(s, CustomTarget):
self.generated.append(s)
else:
raise InvalidArguments('Bad source in target %s.' % self.name)
for basename, conflicting_sources in conflicts.items():
if len(conflicting_sources) > 1:
self.sources_conflicts[basename] = conflicting_sources
def validate_sources(self):
if len(self.sources) > 0:

Loading…
Cancel
Save