diff options
author | Daniel Stone <daniels@collabora.com> | 2017-04-12 16:00:48 +0100 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2017-08-31 20:24:20 +0100 |
commit | e1ffae0580259343be7665c6b2f014fe71b8c05c (patch) | |
tree | 24462ab941900841b2d1e320e2c02fbef0dd992e /mesonbuild/compilers/compilers.py | |
parent | 7fb1973caca249e284ba6bec7e7a7b2439f9721f (diff) | |
download | meson-e1ffae0580259343be7665c6b2f014fe71b8c05c.zip meson-e1ffae0580259343be7665c6b2f014fe71b8c05c.tar.gz meson-e1ffae0580259343be7665c6b2f014fe71b8c05c.tar.bz2 |
Add Compiler.get_supported_arguments()
Add a helper for the common pattern of:
args_to_use = []
foreach arg : candidate_args
if cc.has_argument(arg)
args_to_use += arg
endif
endforeach
Replaced with:
args_to_use = cc.get_supported_arguments(candidate_args)
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r-- | mesonbuild/compilers/compilers.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 5077a6e..c431194 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -712,6 +712,13 @@ class Compiler: 'Language {} does not support has_multi_arguments.'.format( self.get_display_language())) + def get_supported_arguments(self, args, env): + supported_args = [] + for arg in args: + if self.has_argument(arg, env): + supported_args.append(arg) + return supported_args + def get_cross_extra_flags(self, environment, link): extra_flags = [] if self.is_cross and environment: |