aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
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 /mesonbuild
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 'mesonbuild')
-rw-r--r--mesonbuild/compilers/c.py3
-rw-r--r--mesonbuild/compilers/compilers.py14
-rw-r--r--mesonbuild/interpreter.py7
3 files changed, 24 insertions, 0 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index a6ae4af..9b24e85 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -1543,6 +1543,9 @@ class VisualStudioCCompiler(CCompiler):
# false without compiling anything
return name in ['dllimport', 'dllexport']
+ def get_argument_syntax(self):
+ return 'msvc'
+
class ArmCCompiler(ArmCompiler, CCompiler):
def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs):
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):
"""
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index e724e6a..c2cfe5c 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -935,6 +935,7 @@ class CompilerHolder(InterpreterObject):
'first_supported_link_argument': self.first_supported_link_argument_method,
'unittest_args': self.unittest_args_method,
'symbols_have_underscore_prefix': self.symbols_have_underscore_prefix_method,
+ 'get_argument_syntax': self.get_argument_syntax_method,
})
def _dep_msg(self, deps, endl):
@@ -1532,6 +1533,12 @@ class CompilerHolder(InterpreterObject):
args = mesonlib.stringlistify(args)
return [a for a in args if self.has_func_attribute_method(a, kwargs)]
+ @FeatureNew('compiler.get_argument_syntax_method', '0.49.0')
+ @noPosargs
+ @noKwargs
+ def get_argument_syntax_method(self, args, kwargs):
+ return self.compiler.get_argument_syntax()
+
ModuleState = namedtuple('ModuleState', [
'build_to_src', 'subproject', 'subdir', 'current_lineno', 'environment',