diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-09-01 18:32:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-01 18:32:27 +0300 |
commit | 437fc04da1a6961cc27510d58d2f0a38b71eb526 (patch) | |
tree | 5553eba398fda7b96f47cb1896c86fbc2915cbe4 /docs/markdown | |
parent | 7fb1973caca249e284ba6bec7e7a7b2439f9721f (diff) | |
parent | 552c15b978434456780f9efea1e7f05b21b1208f (diff) | |
download | meson-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')
-rw-r--r-- | docs/markdown/Reference-manual.md | 14 | ||||
-rw-r--r-- | docs/markdown/snippets/get-supported-arguments.md | 23 |
2 files changed, 32 insertions, 5 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 91f7edd..3f25e80 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1260,6 +1260,12 @@ the following methods: the positional argument, you can specify external dependencies to use with `dependencies` keyword argument. +- `compiles(code)` returns true if the code fragment given in the + positional argument compiles, you can specify external dependencies + to use with `dependencies` keyword argument, `code` can be either a + string containing source code or a `file` object pointing to the + source code. + - `compute_int(expr, ...')` computes the value of the given expression (as an example `1 + 2`). When cross compiling this is evaluated with an iterative algorithm, you can specify keyword arguments `low` @@ -1286,11 +1292,9 @@ the following methods: - `get_id()` returns a string identifying the compiler. For example, `gcc`, `msvc`, [and more](Compiler-properties.md#compiler-id). -- `compiles(code)` returns true if the code fragment given in the - positional argument compiles, you can specify external dependencies - to use with `dependencies` keyword argument, `code` can be either a - string containing source code or a `file` object pointing to the - source code. +- `get_supported_arguments(list_of_string)` returns an array + containing only the arguments supported by the compiler, as if + `has_argument` were called on them individually. - `has_argument(argument_name)` returns true if the compiler accepts the specified command line argument, that is, can compile code 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) |