aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-09-10 17:19:51 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2016-09-10 17:19:51 +0300
commit20083c06943f1fe3e7f8db09f4d9b74ba96a51a7 (patch)
tree9c0fbd04576234b42b81c6bdad92d115d93ce040 /mesonbuild/compilers.py
parent26f9adf6a6b184def445dae1c9c2f8587cdd3320 (diff)
downloadmeson-20083c06943f1fe3e7f8db09f4d9b74ba96a51a7.zip
meson-20083c06943f1fe3e7f8db09f4d9b74ba96a51a7.tar.gz
meson-20083c06943f1fe3e7f8db09f4d9b74ba96a51a7.tar.bz2
Factored Clang common stuff in its own class.
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r--mesonbuild/compilers.py60
1 files changed, 32 insertions, 28 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 99e1a41..ba95ba1 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -2067,6 +2067,36 @@ class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler):
'2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']}
+class ClangCompiler():
+ def __init__(self, clang_type):
+ self.id = 'clang'
+ self.clang_type = clang_type
+ self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
+ if self.clang_type != CLANG_OSX:
+ self.base_options.append('b_lundef')
+ self.base_options.append('b_asneeded')
+
+ def get_buildtype_args(self, buildtype):
+ return gnulike_buildtype_args[buildtype]
+
+ def get_buildtype_linker_args(self, buildtype):
+ return gnulike_buildtype_linker_args[buildtype]
+
+ def get_pch_suffix(self):
+ return 'pch'
+
+ def can_compile(self, filename):
+ return super().can_compile(filename) or filename.split('.')[-1].lower() == 's' # Clang can do asm, too.
+
+ def get_pch_use_args(self, pch_dir, header):
+ # Workaround for Clang bug http://llvm.org/bugs/show_bug.cgi?id=15136
+ # This flag is internal to Clang (or at least not documented on the man page)
+ # so it might change semantics at any time.
+ return ['-include-pch', os.path.join (pch_dir, self.get_pch_name (header))]
+
+ def has_argument(self, arg, env):
+ return super().has_argument(['-Werror=unknown-warning-option', arg], env)
+
class ClangObjCCompiler(GnuObjCCompiler):
def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None):
super().__init__(exelist, version, is_cross, exe_wrapper)
@@ -2087,36 +2117,13 @@ class ClangObjCPPCompiler(GnuObjCPPCompiler):
self.base_options.append('b_lundef')
self.base_options.append('b_asneeded')
-class ClangCCompiler(CCompiler):
+class ClangCCompiler(ClangCompiler, CCompiler):
def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
- self.id = 'clang'
- self.clang_type = clang_type
+ ClangCompiler.__init__(self, clang_type)
self.warn_args = {'1': ['-Wall', '-Winvalid-pch'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch'],
'3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']}
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
- if self.clang_type != CLANG_OSX:
- self.base_options.append('b_lundef')
- self.base_options.append('b_asneeded')
-
- def get_buildtype_args(self, buildtype):
- return gnulike_buildtype_args[buildtype]
-
- def get_buildtype_linker_args(self, buildtype):
- return gnulike_buildtype_linker_args[buildtype]
-
- def get_pch_suffix(self):
- return 'pch'
-
- def can_compile(self, filename):
- return super().can_compile(filename) or filename.split('.')[-1].lower() == 's' # Clang can do asm, too.
-
- def get_pch_use_args(self, pch_dir, header):
- # Workaround for Clang bug http://llvm.org/bugs/show_bug.cgi?id=15136
- # This flag is internal to Clang (or at least not documented on the man page)
- # so it might change semantics at any time.
- return ['-include-pch', os.path.join (pch_dir, self.get_pch_name (header))]
def get_options(self):
return {'c_std' : coredata.UserComboOption('c_std', 'C language standard to use',
@@ -2133,9 +2140,6 @@ class ClangCCompiler(CCompiler):
def get_option_link_args(self, options):
return []
- def has_argument(self, arg, env):
- return super().has_argument(['-Werror=unknown-warning-option', arg], env)
-
class ClangCPPCompiler(CPPCompiler):
def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None):