Can use files() in run_command.

pull/769/head
Jussi Pakkanen 8 years ago
parent b1e4b8e143
commit 6f2b29e0f7
  1. 15
      mesonbuild/interpreter.py
  2. 14
      test cases/common/38 run program/meson.build

@ -144,6 +144,7 @@ class RunProcess(InterpreterObject):
cwd = os.path.join(source_dir, subdir)
child_env = os.environ.copy()
child_env.update(env)
mlog.debug('Running command:', ' '.join(command_array))
try:
return subprocess.Popen(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=child_env, cwd=cwd)
@ -1385,9 +1386,19 @@ class Interpreter():
cmd = [cmd]
else:
raise InterpreterException('First argument is of incorrect type.')
check_stringlist(cargs, 'Run_command arguments must be strings.')
args = cmd + cargs
expanded_args = []
for a in mesonlib.flatten(cargs):
if isinstance(a, str):
expanded_args.append(a)
elif isinstance(a, mesonlib.File):
if a.is_built:
raise InterpreterException('Can not use generated files in run_command.')
expanded_args.append(os.path.join(self.environment.get_source_dir(), str(a)))
else:
raise InterpreterException('Run_command arguments must be strings or the output of files().')
args = cmd + expanded_args
in_builddir = kwargs.get('in_builddir', False)
mlog.debug('Running command:', ' '.join(args))
if not isinstance(in_builddir, bool):
raise InterpreterException('in_builddir must be boolean.')
return RunProcess(args, self.environment.source_dir, self.environment.build_dir,

@ -41,3 +41,17 @@ endif
if cs.stderr() != ''
error('Extra text in stderr (script).')
endif
# We should be able to have files() in argument
f = files('meson.build')
if build_machine.system() == 'windows'
c = run_command('cmd', '/c', 'echo', f)
else
c = run_command('echo', f)
endif
if c.returncode() != 0
error('Using files() in argument failed.')
endif

Loading…
Cancel
Save