diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-05-07 00:20:29 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-05-07 00:20:29 +0530 |
commit | b1df1a2bec053937ecb09f425248c1dbcee9237a (patch) | |
tree | f9581f6d3e8d5d1c81b3b9e7693138c67b783178 /mesonbuild/interpreter.py | |
parent | 11968382a3800f7dd6d04b3a94d4351f0950dd9a (diff) | |
download | meson-b1df1a2bec053937ecb09f425248c1dbcee9237a.zip meson-b1df1a2bec053937ecb09f425248c1dbcee9237a.tar.gz meson-b1df1a2bec053937ecb09f425248c1dbcee9237a.tar.bz2 |
run_command: accept built File objects too
The file will always exist by the time run_command() is invoked, so
there is no reason why we should forbid it. Also allow using File
objects as the command to run since strings are also allowed.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index d8f3b2b..2c6806a 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1469,28 +1469,33 @@ class Interpreter(InterpreterBase): raise InterpreterException('Not enough arguments') cmd = args[0] cargs = args[1:] + srcdir = self.environment.get_source_dir() + builddir = self.environment.get_build_dir() if isinstance(cmd, ExternalProgramHolder): cmd = cmd.get_command() elif isinstance(cmd, str): cmd = [cmd] + elif isinstance(cmd, mesonlib.File): + cmd = [cmd.absolute_path(srcdir, builddir)] else: - raise InterpreterException('First argument should be find_program() ' - 'or string, not {!r}'.format(cmd)) + m = 'First argument must be a string, or the output of ' \ + 'find_program(), files(), or configure_file(); not {!r}' + raise InterpreterException(m.format(cmd)) 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))) + expanded_args.append(a.absolute_path(srcdir, builddir)) else: - raise InterpreterException('Run_command arguments must be strings or the output of files().') + m = 'run_command() arguments must be strings, the output of ' \ + 'files(), or configure_file(); not {!r}' + raise InterpreterException(m.format(a)) args = cmd + expanded_args in_builddir = kwargs.get('in_builddir', False) if not isinstance(in_builddir, bool): raise InterpreterException('in_builddir must be boolean.') - return RunProcess(args, self.environment.source_dir, self.environment.build_dir, self.subdir, + return RunProcess(args, srcdir, builddir, self.subdir, get_meson_script(self.environment, 'mesonintrospect'), in_builddir) @stringArgs |