Fix exe wrapper detection for run targets.

pull/8313/head
Jussi Pakkanen 4 years ago
parent 398df56298
commit 71784e1002
  1. 12
      mesonbuild/backend/backends.py
  2. 2
      mesonbuild/backend/ninjabackend.py
  3. 2
      mesonbuild/backend/vs2010backend.py
  4. 3
      run_unittests.py
  5. 9
      test cases/common/52 run target/meson.build

@ -397,9 +397,17 @@ class Backend:
if isinstance(exe, dependencies.ExternalProgram):
exe_cmd = exe.get_command()
exe_for_machine = exe.for_machine
elif isinstance(exe, (build.BuildTarget, build.CustomTarget)):
elif isinstance(exe, build.BuildTarget):
exe_cmd = [self.get_target_filename_abs(exe)]
exe_for_machine = exe.for_machine
elif isinstance(exe, build.CustomTarget):
# The output of a custom target can either be directly runnable
# or not, that is, a script, a native binary or a cross compiled
# binary when exe wrapper is available and when it is not.
# This implementation is not exhaustive but it works in the
# common cases.
exe_cmd = [self.get_target_filename_abs(exe)]
exe_for_machine = MachineChoice.BUILD
else:
exe_cmd = [exe]
exe_for_machine = MachineChoice.BUILD
@ -470,6 +478,8 @@ class Backend:
if isinstance(exe, (dependencies.ExternalProgram,
build.BuildTarget, build.CustomTarget)):
basename = exe.name
elif isinstance(exe, mesonlib.File):
basename = os.path.basename(exe.fname)
else:
basename = os.path.basename(exe)

@ -995,7 +995,7 @@ int dummy;
target_env = self.get_run_target_env(target)
_, _, cmd = self.eval_custom_target_command(target)
desc = 'Running external command {}{}'
meson_exe_cmd, reason = self.as_meson_exe_cmdline(target_name, cmd[0], cmd[1:],
meson_exe_cmd, reason = self.as_meson_exe_cmdline(target_name, target.command[0], cmd[1:],
force_serialize=True, env=target_env,
verbose=True)
cmd_type = ' (wrapped by meson {})'.format(reason)

@ -536,7 +536,7 @@ class Vs2010Backend(backends.Backend):
_, _, cmd_raw = self.eval_custom_target_command(target)
depend_files = self.get_custom_target_depend_files(target)
target_env = self.get_run_target_env(target)
wrapper_cmd, _ = self.as_meson_exe_cmdline(target.name, cmd_raw[0], cmd_raw[1:],
wrapper_cmd, _ = self.as_meson_exe_cmdline(target.name, 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)),

@ -7881,7 +7881,6 @@ class LinuxCrossMingwTests(BaseLinuxCrossTests):
# Force tracebacks so we can detect them properly
env = {'MESON_FORCE_BACKTRACE': '1'}
error_message = "An exe_wrapper is needed but was not found. Please define one in cross file and check the command and/or add it to PATH."
error_message2 = "The exe_wrapper 'broken' defined in the cross file is needed by run target 'run-prog', but was not found. Please check the command and/or add it to PATH."
with self.assertRaises(MesonException) as cm:
# Must run in-process or we'll get a generic CalledProcessError
@ -7895,7 +7894,7 @@ class LinuxCrossMingwTests(BaseLinuxCrossTests):
self.init(testdir, extra_args='-Dcustom-target=false',
inprocess=True,
override_envvars=env)
self.assertEqual(str(cm.exception), error_message2)
self.assertEqual(str(cm.exception), error_message)
self.init(testdir, extra_args=['-Dcustom-target=false', '-Drun-target=false'],
override_envvars=env)

@ -4,8 +4,11 @@ project('run target', 'c')
# In cross builds exe_wrapper should be added if it exists.
exe = executable('helloprinter', 'helloprinter.c')
run_target('runhello',
command : [exe, 'argument'])
if not meson.is_cross_build() or meson.can_run_host_binaries()
run_target('runhello',
command : [exe, 'argument'])
endif
converter = find_program('converter.py')
@ -62,10 +65,12 @@ conf = configure_file(
configuration: configuration_data()
)
run_target('configure_script',
command : conf
)
# Target names that clash with potential builtin functionality.
run_target('ctags',
command : converter)

Loading…
Cancel
Save