vs2010: add object files from custom_target to project

Object files from a custom_target are like external objects and must be
added to the project.
Object files from a generator are automatically used by MSBuild, since they
are part of the CustomBuildStep and thus part of the same project as the
current build target.
pull/522/head
Nicolas Schneider 9 years ago
parent 060f195fe0
commit 985ea50944
  1. 17
      mesonbuild/backend/vs2010backend.py

@ -69,14 +69,15 @@ class Vs2010Backend(backends.Backend):
if len(src_conflicts) > 1} if len(src_conflicts) > 1}
def generate_custom_generator_commands(self, target, parent_node): def generate_custom_generator_commands(self, target, parent_node):
all_output_files = [] generator_output_files = []
commands = [] commands = []
inputs = [] inputs = []
outputs = [] outputs = []
custom_target_include_dirs = [] custom_target_include_dirs = []
custom_target_output_files = []
for genlist in target.get_generated_sources(): for genlist in target.get_generated_sources():
if isinstance(genlist, build.CustomTarget): if isinstance(genlist, build.CustomTarget):
all_output_files += [os.path.join(self.get_target_dir(genlist), i) for i in genlist.output] custom_target_output_files += [os.path.join(self.get_target_dir(genlist), i) for i in genlist.output]
idir = self.relpath(self.get_target_dir(genlist), self.get_target_dir(target)) idir = self.relpath(self.get_target_dir(genlist), self.get_target_dir(target))
if idir not in custom_target_include_dirs: if idir not in custom_target_include_dirs:
custom_target_include_dirs.append(idir) custom_target_include_dirs.append(idir)
@ -97,7 +98,7 @@ class Vs2010Backend(backends.Backend):
infilename = os.path.join(self.environment.get_source_dir(), curfile) infilename = os.path.join(self.environment.get_source_dir(), curfile)
outfiles = genlist.get_outputs_for(curfile) outfiles = genlist.get_outputs_for(curfile)
outfiles = [os.path.join(target_private_dir, of) for of in outfiles] outfiles = [os.path.join(target_private_dir, of) for of in outfiles]
all_output_files += outfiles generator_output_files += outfiles
args = [x.replace("@INPUT@", infilename).replace('@OUTPUT@', sole_output)\ args = [x.replace("@INPUT@", infilename).replace('@OUTPUT@', sole_output)\
for x in base_args] for x in base_args]
args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", target_private_dir) args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", target_private_dir)
@ -115,7 +116,7 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(cbs, 'Message').text = 'Generating custom sources.' ET.SubElement(cbs, 'Message').text = 'Generating custom sources.'
pg = ET.SubElement(parent_node, 'PropertyGroup') pg = ET.SubElement(parent_node, 'PropertyGroup')
ET.SubElement(pg, 'CustomBuildBeforeTargets').text = 'ClCompile' ET.SubElement(pg, 'CustomBuildBeforeTargets').text = 'ClCompile'
return all_output_files, custom_target_include_dirs return generator_output_files, custom_target_output_files, custom_target_include_dirs
def generate(self, interp): def generate(self, interp):
self.resolve_source_conflicts() self.resolve_source_conflicts()
@ -442,8 +443,12 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(type_config, 'WholeProgramOptimization').text = 'false' ET.SubElement(type_config, 'WholeProgramOptimization').text = 'false'
ET.SubElement(type_config, 'UseDebugLibraries').text = 'true' ET.SubElement(type_config, 'UseDebugLibraries').text = 'true'
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props') ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props')
generated_files, generated_files_include_dirs = self.generate_custom_generator_commands(target, root) generated_files, custom_target_output_files, generated_files_include_dirs = self.generate_custom_generator_commands(target, root)
(gen_src, gen_hdrs, gen_objs, gen_langs) = self.split_sources(generated_files) (gen_src, gen_hdrs, gen_objs, gen_langs) = self.split_sources(generated_files)
(custom_src, custom_hdrs, custom_objs, custom_langs) = self.split_sources(custom_target_output_files)
gen_src += custom_src
gen_hdrs += custom_hdrs
gen_langs += custom_langs
direlem = ET.SubElement(root, 'PropertyGroup') direlem = ET.SubElement(root, 'PropertyGroup')
fver = ET.SubElement(direlem, '_ProjectFileVersion') fver = ET.SubElement(direlem, '_ProjectFileVersion')
fver.text = self.project_file_version fver.text = self.project_file_version
@ -573,6 +578,8 @@ class Vs2010Backend(backends.Backend):
for o in self.flatten_object_list(target, down): for o in self.flatten_object_list(target, down):
assert(isinstance(o, str)) assert(isinstance(o, str))
additional_objects.append(o) additional_objects.append(o)
for o in custom_objs:
additional_objects.append(self.relpath(o, self.get_target_dir(target)))
if len(additional_links) > 0: if len(additional_links) > 0:
additional_links.append('%(AdditionalDependencies)') additional_links.append('%(AdditionalDependencies)')
ET.SubElement(link, 'AdditionalDependencies').text = ';'.join(additional_links) ET.SubElement(link, 'AdditionalDependencies').text = ';'.join(additional_links)

Loading…
Cancel
Save