diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-06-09 21:19:58 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-06-09 21:19:58 +0300 |
commit | d8d989d9b80fffe88372f6606d21cb7d5f57e2c2 (patch) | |
tree | 75cca57745585d1b31a3e7cf2ca03a0b72451e0c /mesonbuild/compilers.py | |
parent | 50609054ecfb18bbdaf1aa56fe2c801be95f31db (diff) | |
download | meson-d8d989d9b80fffe88372f6606d21cb7d5f57e2c2.zip meson-d8d989d9b80fffe88372f6606d21cb7d5f57e2c2.tar.gz meson-d8d989d9b80fffe88372f6606d21cb7d5f57e2c2.tar.bz2 |
Add a has_arg method to compiler to check whether it supports a given argument.
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r-- | mesonbuild/compilers.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 03ef9f9..325b611 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -293,6 +293,9 @@ class Compiler(): def get_library_dirs(self): return [] + def has_arg(self, arg): + raise EnvironmentException('Language {} does not support has_arg.'.format(self.language)) + class CCompiler(Compiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None): super().__init__(exelist, version) @@ -506,6 +509,8 @@ int main () {{ {1}; }}''' return p def compiles(self, code, extra_args = []): + if isinstance(extra_args, str): + extra_args = [extra_args] suflen = len(self.default_suffix) (fd, srcname) = tempfile.mkstemp(suffix='.'+self.default_suffix) os.close(fd) @@ -819,6 +824,9 @@ void bar() { def thread_link_flags(self): return ['-pthread'] + def has_arg(self, arg): + return self.compiles('int i;\n', extra_args=arg) + class CPPCompiler(CCompiler): def __init__(self, exelist, version, is_cross, exe_wrap): CCompiler.__init__(self, exelist, version, is_cross, exe_wrap) |