aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-10-16 10:03:13 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2018-11-03 18:10:36 +0200
commit63f4f9481ebc865b11a06aeecf0c624104d46afd (patch)
tree13ff86bcf410ae872ebc1c33cac851104d21ecf0 /docs/markdown
parent8cd7f7871bc99e5ed709d4f0ec54997047f3e335 (diff)
downloadmeson-63f4f9481ebc865b11a06aeecf0c624104d46afd.zip
meson-63f4f9481ebc865b11a06aeecf0c624104d46afd.tar.gz
meson-63f4f9481ebc865b11a06aeecf0c624104d46afd.tar.bz2
Add new compiler.get_argument_syntax method
Some compilers try very had to pretend they're another compiler (ICC pretends to be GCC and Linux and MacOS, and MSVC on windows), Clang behaves much like GCC, but now also has clang-cl, which behaves like MSVC. This method provides an easy way to determine whether testing for MSVC like arguments `/w1234` or gcc like arguments `-Wfoo` are likely to succeed, without having to check for dozens of compilers and the host operating system, (as you would otherwise have to do with ICC).
Diffstat (limited to 'docs/markdown')
-rw-r--r--docs/markdown/Compiler-properties.md14
-rw-r--r--docs/markdown/Reference-manual.md7
-rw-r--r--docs/markdown/Reference-tables.md45
-rw-r--r--docs/markdown/snippets/compiler_argument_syntax.md22
4 files changed, 63 insertions, 25 deletions
diff --git a/docs/markdown/Compiler-properties.md b/docs/markdown/Compiler-properties.md
index 1228f42..4f5ebdb 100644
--- a/docs/markdown/Compiler-properties.md
+++ b/docs/markdown/Compiler-properties.md
@@ -29,9 +29,17 @@ Compiler id
==
The compiler object has a method called `get_id`, which returns a
-lower case string describing the "family" of the compiler. See
-[reference tables](Reference-tables.md) for a list of supported
-compiler ids.
+lower case string describing the "family" of the compiler.
+
+The compiler object also has a method `get_argument_syntax` which
+returns a lower case string of `gcc`, `msvc`, or another undefined string
+value; identifying whether the compiler arguments use the same syntax as
+either `gcc` or `msvc`, or that its arguments are not like either. This should
+only be used to select the syntax of the arguments, such as those to test
+with `has_argument`.
+
+See [reference tables](Reference-tables.md#compiler-ids) for a list of supported compiler
+ids and their argument type.
Does code compile?
==
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index f43f1f6..72e9609 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -1702,6 +1702,13 @@ the following methods:
- `get_id()` returns a string identifying the compiler. For example,
`gcc`, `msvc`, [and more](Reference-tables.md#compiler-ids).
+- `get_argument_syntax()` *(new in 0.49.0)* returns a string identifying the type
+ of arguments the compiler takes. Can be one of `gcc`, `msvc`, or an undefined
+ string value. This method is useful for identifying compilers that are not
+ gcc or msvc, but use the same argument syntax as one of those two compilers
+ such as clang or icc, especially when they use different syntax on different
+ operating systems.
+
- `get_supported_arguments(list_of_string)` *(added 0.43.0)* returns
an array containing only the arguments supported by the compiler,
as if `has_argument` were called on them individually.
diff --git a/docs/markdown/Reference-tables.md b/docs/markdown/Reference-tables.md
index ef5d24b..72dce4b 100644
--- a/docs/markdown/Reference-tables.md
+++ b/docs/markdown/Reference-tables.md
@@ -2,28 +2,29 @@
## Compiler ids
-These are return values of the `get_id` method in a compiler object.
-
-| Value | Compiler family |
-| ----- | ---------------- |
-| gcc | The GNU Compiler Collection |
-| clang | The Clang compiler |
-| msvc | Microsoft Visual Studio |
-| intel | Intel compiler |
-| llvm | LLVM-based compiler (Swift, D) |
-| mono | Xamarin C# compiler |
-| dmd | D lang reference compiler |
-| rustc | Rust compiler |
-| valac | Vala compiler |
-| pathscale | The Pathscale Fortran compiler |
-| pgi | The Portland Fortran compiler |
-| sun | Sun Fortran compiler |
-| g95 | The G95 Fortran compiler |
-| open64 | The Open64 Fortran Compiler |
-| nagfor | The NAG Fortran compiler |
-| lcc | Elbrus C/C++/Fortran Compiler |
-| arm | ARM compiler |
-| armclang | ARMCLANG compiler |
+These are return values of the `get_id` (Compiler family) and
+`get_argument_syntax` (Argument syntax) method in a compiler object.
+
+| Value | Compiler family | Argument syntax |
+| ----- | ---------------- | -------------------------------|
+| gcc | The GNU Compiler Collection | gcc |
+| clang | The Clang compiler | gcc |
+| msvc | Microsoft Visual Studio | msvc |
+| intel | Intel compiler | msvc on windows, otherwise gcc |
+| llvm | LLVM-based compiler (Swift, D) | |
+| mono | Xamarin C# compiler | |
+| dmd | D lang reference compiler | |
+| rustc | Rust compiler | |
+| valac | Vala compiler | |
+| pathscale | The Pathscale Fortran compiler | |
+| pgi | The Portland Fortran compiler | |
+| sun | Sun Fortran compiler | |
+| g95 | The G95 Fortran compiler | |
+| open64 | The Open64 Fortran Compiler | |
+| nagfor | The NAG Fortran compiler | |
+| lcc | Elbrus C/C++/Fortran Compiler | |
+| arm | ARM compiler | |
+| armclang | ARMCLANG compiler | |
## Script environment variables
diff --git a/docs/markdown/snippets/compiler_argument_syntax.md b/docs/markdown/snippets/compiler_argument_syntax.md
new file mode 100644
index 0000000..6ae32d4
--- /dev/null
+++ b/docs/markdown/snippets/compiler_argument_syntax.md
@@ -0,0 +1,22 @@
+## new compiler method `get_argument_syntax`
+
+The compiler object now has `get_argument_syntax` method, which returns a
+string value of `gcc`, `msvc`, or an undefined value string value. This can be
+used to determine if a compiler uses gcc syntax (`-Wfoo`), msvc syntax
+(`/w1234`), or some other kind of arguments.
+
+```meson
+cc = meson.get_compiler('c')
+
+if cc.get_argument_syntax() == 'msvc'
+ if cc.has_argument('/w1235')
+ add_project_arguments('/w1235', language : ['c'])
+ endif
+elif cc.get_argument_syntax() == 'gcc'
+ if cc.has_argument('-Wfoo')
+ add_project_arguments('-Wfoo', language : ['c'])
+ endif
+elif cc.get_id() == 'some other compiler'
+ add_project_arguments('--error-on-foo', language : ['c'])
+endif
+```