diff options
author | Evgenii Shatokhin <eugene.shatokhin@rosalab.ru> | 2018-02-25 16:02:10 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-03-06 21:07:16 +0200 |
commit | 19718a8d9c5cb6d9ac2c2cbb5459178906a3a007 (patch) | |
tree | 60ae3fa4084c7ffe0f1b8c97d5ab58b80c2cf509 /mesonbuild/interpreter.py | |
parent | 048508c989081f8bcf54d76f5b13138cc3f47738 (diff) | |
download | meson-19718a8d9c5cb6d9ac2c2cbb5459178906a3a007.zip meson-19718a8d9c5cb6d9ac2c2cbb5459178906a3a007.tar.gz meson-19718a8d9c5cb6d9ac2c2cbb5459178906a3a007.tar.bz2 |
Allow passing a compiler object to run_command()
Sometimes it is needed to run the current compiler with specific options
not to compile a file but rather to obtain additional info. For example,
GCC has several -print-* options to query it about the paths to
different libraries and development files. One use case is to get the
location of development files for GCC plugins, which is not easily
obtainable by other means:
gcc -print-file-name=plugin
For this purpose, it would be convenient if the compiler object returned
by meson.get_compiler(lang) could be used in run_command() directly.
This commit implements it.
Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 7a76fad..71c9f4b 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1679,10 +1679,17 @@ external dependencies (including libraries) must go to "dependencies".''') cargs = args[1:] srcdir = self.environment.get_source_dir() builddir = self.environment.get_build_dir() - m = 'must be a string, or the output of find_program(), files(), or ' \ - 'configure_file(); not {!r}' + m = 'must be a string, or the output of find_program(), files() '\ + 'or configure_file(), or a compiler object; not {!r}' if isinstance(cmd, ExternalProgramHolder): cmd = cmd.held_object + elif isinstance(cmd, CompilerHolder): + cmd = cmd.compiler.get_exelist()[0] + prog = ExternalProgram(cmd, silent=True) + if not prog.found(): + raise InterpreterException('Program {!r} not found ' + 'or not executable'.format(cmd)) + cmd = prog else: if isinstance(cmd, mesonlib.File): cmd = cmd.absolute_path(srcdir, builddir) |