Permit use of file objects in run targets.

pull/768/head
Jussi Pakkanen 9 years ago
parent 3f62fb788b
commit 9235fd4ec1
  1. 2
      mesonbuild/backend/ninjabackend.py
  2. 4
      mesonbuild/interpreter.py
  3. 3
      test cases/common/58 run target/meson.build

@ -424,6 +424,8 @@ int dummy;
elif isinstance(i, (build.BuildTarget, build.CustomTarget)):
relfname = self.get_target_filename(i)
arg_strings.append(os.path.join(self.environment.get_build_dir(), relfname))
elif isinstance(i, mesonlib.File):
arg_strings.append(i.rel_to_builddir(self.build_to_src))
else:
mlog.debug(str(i))
raise MesonException('Unreachable code in generate_run_target.')

@ -1873,12 +1873,12 @@ class Interpreter():
raise InterpreterException('Run_target needs at least one positional argument.')
cleaned_args = []
for i in all_args:
for i in mesonlib.flatten(all_args):
try:
i = i.held_object
except AttributeError:
pass
if not isinstance(i, (str, build.BuildTarget, build.CustomTarget, dependencies.ExternalProgram)):
if not isinstance(i, (str, build.BuildTarget, build.CustomTarget, dependencies.ExternalProgram, mesonlib.File)):
mlog.debug('Wrong type:', str(i))
raise InterpreterException('Invalid argument to run_target.')
cleaned_args.append(i)

@ -34,3 +34,6 @@ run_target('upload2',
python3 = find_program('python3')
run_target('py3hi',
command : [python3, '-c', 'print("I am Python3.")'])
run_target('ct_in_arg',
command : ['echo', hex, files('helloprinter.c')])

Loading…
Cancel
Save