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>pull/3191/head
parent
048508c989
commit
19718a8d9c
5 changed files with 44 additions and 5 deletions
@ -0,0 +1,10 @@ |
||||
## Compiler object can now be passed to run_command() |
||||
|
||||
This can be used to run the current compiler with the specified arguments |
||||
to obtain additional information from it. |
||||
One of the use cases is to get the location of development files for the |
||||
GCC plugins: |
||||
|
||||
cc = meson.get_compiler('c') |
||||
result = run_command(cc, '-print-file-name=plugin') |
||||
plugin_dev_path = result.stdout().strip() |
@ -0,0 +1,10 @@ |
||||
project('compiler_object_in_run_command', 'c') |
||||
cc = meson.get_compiler('c') |
||||
|
||||
# This test only checks that the compiler object can be passed to |
||||
# run_command(). If the compiler has been launched, it is expected |
||||
# to output something either to stdout or to stderr. |
||||
result = run_command(cc, '--version') |
||||
if result.stdout() == '' and result.stderr() == '' |
||||
error('No output in stdout and stderr. Did the compiler run at all?') |
||||
endif |
Loading…
Reference in new issue