From 63f4f9481ebc865b11a06aeecf0c624104d46afd Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 16 Oct 2018 10:03:13 -0700 Subject: 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). --- mesonbuild/compilers/compilers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 8adacef..a038abf 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1214,6 +1214,17 @@ class Compiler: m = 'Language {} does not support position-independent executable' raise EnvironmentException(m.format(self.get_display_language())) + def get_argument_syntax(self): + """Returns the argument family type. + + Compilers fall into families if they try to emulate the command line + interface of another compiler. For example, clang is in the GCC family + since it accepts most of the same arguments as GCC. ICL (ICC on + windows) is in the MSVC family since it accepts most of the same + arguments as MSVC. + """ + return 'other' + @enum.unique class CompilerType(enum.Enum): @@ -1449,6 +1460,9 @@ class GnuLikeCompiler(abc.ABC): # For other targets, discard the .def file. return [] + def get_argument_syntax(self): + return 'gcc' + class GnuCompiler(GnuLikeCompiler): """ -- cgit v1.1