aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/snippets
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-09-01 18:32:27 +0300
committerGitHub <noreply@github.com>2017-09-01 18:32:27 +0300
commit437fc04da1a6961cc27510d58d2f0a38b71eb526 (patch)
tree5553eba398fda7b96f47cb1896c86fbc2915cbe4 /docs/markdown/snippets
parent7fb1973caca249e284ba6bec7e7a7b2439f9721f (diff)
parent552c15b978434456780f9efea1e7f05b21b1208f (diff)
downloadmeson-437fc04da1a6961cc27510d58d2f0a38b71eb526.zip
meson-437fc04da1a6961cc27510d58d2f0a38b71eb526.tar.gz
meson-437fc04da1a6961cc27510d58d2f0a38b71eb526.tar.bz2
Merge pull request #1614 from fooishbar/cc-filter-args
Add Compiler.filter_arguments()
Diffstat (limited to 'docs/markdown/snippets')
-rw-r--r--docs/markdown/snippets/get-supported-arguments.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/markdown/snippets/get-supported-arguments.md b/docs/markdown/snippets/get-supported-arguments.md
new file mode 100644
index 0000000..c0cc9bf
--- /dev/null
+++ b/docs/markdown/snippets/get-supported-arguments.md
@@ -0,0 +1,23 @@
+# Easier handling of supported compiler arguments
+
+A common pattern for handling multiple desired compiler arguments, was to
+test their presence and add them to an array one-by-one, e.g.:
+
+ warning_flags_maybe = [
+ '-Wsomething',
+ '-Wanother-thing',
+ '-Wno-the-other-thing',
+ ]
+ warning_flags = []
+ foreach flag : warning_flags_maybe
+ if cc.has_argument(flag)
+ warning_flags += flag
+ endif
+ endforeach
+ cc.add_project_argument(warning_flags)
+
+A helper has been added for the foreach/has_argument pattern, so you can
+now simply do:
+
+ warning_flags = [ ... ]
+ flags = cc.get_supported_flags(warning_flags)