diff options
-rw-r--r-- | mesonbuild/interpreter.py | 15 | ||||
-rw-r--r-- | test cases/common/38 run program/meson.build | 14 |
2 files changed, 27 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 361e0aa..1ef4133 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -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, diff --git a/test cases/common/38 run program/meson.build b/test cases/common/38 run program/meson.build index 20a8107..1563dec 100644 --- a/test cases/common/38 run program/meson.build +++ b/test cases/common/38 run program/meson.build @@ -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 + |