From e1ffae0580259343be7665c6b2f014fe71b8c05c Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 12 Apr 2017 16:00:48 +0100 Subject: 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) --- mesonbuild/compilers/compilers.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mesonbuild/compilers/compilers.py') 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: -- cgit v1.1