backends/vs: Do not emit dummy command for alias_command().

Alias commands did not work with the vs backend, due to trying to access
target.command[0] with an empty command. Fix this by just not emitting a
CustomBuild node for alias targets - the project references are enough to
trigger the necessary actions.

Fixes: #9247
pull/9256/head
Andres Freund 3 years ago committed by Xavier Claessens
parent 214d03568f
commit fddf88ba08
  1. 20
      mesonbuild/backend/vs2010backend.py
  2. 3
      unittests/allplatformstests.py

@ -27,7 +27,7 @@ from .. import mlog
from .. import compilers
from ..interpreter import Interpreter
from ..mesonlib import (
File, MesonException, python_command, replace_if_different, OptionKey, version_compare, MachineChoice
File, MesonException, replace_if_different, OptionKey, version_compare, MachineChoice
)
from ..environment import Environment, build_filename
@ -550,19 +550,27 @@ class Vs2010Backend(backends.Backend):
def gen_run_target_vcxproj(self, target, ofname, guid):
root = self.create_basic_crap(target, guid)
depend_files = self.get_custom_target_depend_files(target)
if not target.command:
# FIXME: This is an alias target that doesn't run any command, there
# is probably a better way than running a this dummy command.
cmd_raw = python_command + ['-c', 'exit']
# This is an alias target and thus doesn't run any command. It's
# enough to emit the references to the other projects for them to
# be built/run/..., if necessary.
assert isinstance(target, build.AliasTarget)
assert len(depend_files) == 0
else:
_, _, cmd_raw = self.eval_custom_target_command(target)
depend_files = self.get_custom_target_depend_files(target)
assert not isinstance(target, build.AliasTarget)
target_env = self.get_run_target_env(target)
_, _, cmd_raw = self.eval_custom_target_command(target)
wrapper_cmd, _ = self.as_meson_exe_cmdline(target.command[0], cmd_raw[1:],
force_serialize=True, env=target_env,
verbose=True)
self.add_custom_build(root, 'run_target', ' '.join(self.quote_arguments(wrapper_cmd)),
deps=depend_files)
# The import is needed even for alias targets, otherwise the build
# target isn't defined
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
self.add_regen_dependency(root)
self.add_target_deps(root, target)

@ -3066,9 +3066,6 @@ class AllPlatformTests(BasePlatformTests):
self.init(testdir, extra_args=['-Dcmake_prefix_path=' + os.path.join(testdir, 'prefix')])
def test_alias_target(self):
if self.backend is Backend.vs:
# FIXME: This unit test is broken with vs backend, needs investigation
raise SkipTest(f'Skipping alias_target test with {self.backend.name} backend')
testdir = os.path.join(self.unit_test_dir, '65 alias target')
self.init(testdir)
self.build()

Loading…
Cancel
Save