aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/vs2010backend.py
diff options
context:
space:
mode:
authorNicolas Schneider <nioncode+git@gmail.com>2017-03-19 23:28:05 +0100
committerNicolas Schneider <nioncode+git@gmail.com>2017-03-20 14:33:44 +0100
commitb434fcd12b59f10f7623d27eafa8ac48c7d051f3 (patch)
tree6a7b3b1def4e44b688814b49fbfab231ade30bff /mesonbuild/backend/vs2010backend.py
parent59984f501412cb2c8b8643a6b5ee4933c891d99e (diff)
downloadmeson-b434fcd12b59f10f7623d27eafa8ac48c7d051f3.zip
meson-b434fcd12b59f10f7623d27eafa8ac48c7d051f3.tar.gz
meson-b434fcd12b59f10f7623d27eafa8ac48c7d051f3.tar.bz2
vs: support Generator outputs as CustomTarget inputs
This changes how generated files are added to the VS project. Previously, they were all added as a single CustomBuildStep with all generator commands, inputs and outputs merged together. Now, each input file is added separately to the project and is given a CustomBuild command. This adds all generator input files to the files list in the VS gui and allows to run only some of the generator commands if only some of the input files have changed.
Diffstat (limited to 'mesonbuild/backend/vs2010backend.py')
-rw-r--r--mesonbuild/backend/vs2010backend.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 547889c..48958cd 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -93,9 +93,6 @@ class Vs2010Backend(backends.Backend):
def generate_custom_generator_commands(self, target, parent_node):
generator_output_files = []
- commands = []
- inputs = []
- outputs = []
custom_target_include_dirs = []
custom_target_output_files = []
target_private_dir = self.relpath(self.get_target_private_dir(target), self.get_target_dir(target))
@@ -116,6 +113,7 @@ class Vs2010Backend(backends.Backend):
outfilelist = genlist.get_outputs()
exe_arr = self.exe_object_to_cmd_array(exe)
base_args = generator.get_arglist()
+ idgroup = ET.SubElement(parent_node, 'ItemGroup')
for i in range(len(infilelist)):
if len(infilelist) == len(outfilelist):
sole_output = os.path.join(target_private_dir, outfilelist[i])
@@ -132,18 +130,10 @@ class Vs2010Backend(backends.Backend):
args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir()).replace("@BUILD_DIR@", target_private_dir)
for x in args]
fullcmd = exe_arr + self.replace_extra_args(args, genlist)
- commands.append(' '.join(self.special_quote(fullcmd)))
- inputs.append(infilename)
- outputs.extend(outfiles)
- if len(commands) > 0:
- idgroup = ET.SubElement(parent_node, 'ItemDefinitionGroup')
- cbs = ET.SubElement(idgroup, 'CustomBuildStep')
- ET.SubElement(cbs, 'Command').text = '\r\n'.join(commands)
- ET.SubElement(cbs, 'Inputs').text = ";".join(inputs)
- ET.SubElement(cbs, 'Outputs').text = ';'.join(outputs)
- ET.SubElement(cbs, 'Message').text = 'Generating custom sources.'
- pg = ET.SubElement(parent_node, 'PropertyGroup')
- ET.SubElement(pg, 'CustomBuildBeforeTargets').text = 'ClCompile'
+ command = ' '.join(self.special_quote(fullcmd))
+ cbs = ET.SubElement(idgroup, 'CustomBuild', Include=infilename)
+ ET.SubElement(cbs, 'Command').text = command
+ ET.SubElement(cbs, 'Outputs').text = ';'.join(outfiles)
return generator_output_files, custom_target_output_files, custom_target_include_dirs
def generate(self, interp):
@@ -205,8 +195,7 @@ class Vs2010Backend(backends.Backend):
for d in [target.command] + target.args:
if isinstance(d, (build.BuildTarget, build.CustomTarget)):
all_deps[d.get_id()] = d
- # BuildTarget
- else:
+ elif isinstance(target, build.BuildTarget):
for ldep in target.link_targets:
all_deps[ldep.get_id()] = ldep
for obj_id, objdep in self.get_obj_target_deps(target.objects):
@@ -218,6 +207,8 @@ class Vs2010Backend(backends.Backend):
gen_exe = gendep.generator.get_exe()
if isinstance(gen_exe, build.Executable):
all_deps[gen_exe.get_id()] = gen_exe
+ else:
+ raise MesonException('Unknown target type for target %s' % target)
if not t or not recursive:
return all_deps
ret = self.get_target_deps(all_deps, recursive)
@@ -418,6 +409,7 @@ class Vs2010Backend(backends.Backend):
ET.SubElement(customstep, 'Outputs').text = ';'.join(ofilenames)
ET.SubElement(customstep, 'Inputs').text = ';'.join(srcs)
ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets')
+ self.generate_custom_generator_commands(target, root)
tree = ET.ElementTree(root)
tree.write(ofname, encoding='utf-8', xml_declaration=True)