aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-09-10 17:00:00 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2016-09-10 17:00:00 +0300
commit85c2f670795f97dfc3f7474971457ef604ef0be3 (patch)
treec9b03e016039391f2ef96ab6e571d1b421529f0f /mesonbuild/compilers.py
parent2336624f4a42d459dda077634140b3c1def255db (diff)
downloadmeson-85c2f670795f97dfc3f7474971457ef604ef0be3.zip
meson-85c2f670795f97dfc3f7474971457ef604ef0be3.tar.gz
meson-85c2f670795f97dfc3f7474971457ef604ef0be3.tar.bz2
Made C++ compiler use GNU class.
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r--mesonbuild/compilers.py129
1 files changed, 51 insertions, 78 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index c51d3ac..ff3e26a 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -1939,14 +1939,6 @@ class GnuCompiler:
def __init__(self, gcc_type):
self.id = 'gcc'
self.gcc_type = gcc_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',
- 'b_colorout']
- if self.gcc_type != GCC_OSX:
- self.base_options.append('b_lundef')
- self.base_options.append('b_asneeded')
def get_colorout_args(self, colortype):
if mesonlib.version_compare(self.version, '>=4.9.0'):
@@ -1980,6 +1972,14 @@ class GnuCCompiler(GnuCompiler, CCompiler):
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
GnuCompiler.__init__(self, gcc_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',
+ 'b_colorout']
+ if self.gcc_type != GCC_OSX:
+ self.base_options.append('b_lundef')
+ self.base_options.append('b_asneeded')
def can_compile(self, filename):
return super().can_compile(filename) or filename.split('.')[-1].lower() == 's' # Gcc can do asm, too.
@@ -2007,6 +2007,49 @@ class GnuCCompiler(GnuCompiler, CCompiler):
return options['c_winlibs'].value
return []
+class GnuCPPCompiler(GnuCompiler, CPPCompiler):
+
+ def __init__(self, exelist, version, gcc_type, is_cross, exe_wrap):
+ CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
+ GnuCompiler.__init__(self, gcc_type)
+ self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'],
+ '2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'],
+ '3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']}
+ self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
+ 'b_colorout']
+ if self.gcc_type != GCC_OSX:
+ self.base_options.append('b_lundef')
+ self.base_options.append('b_asneeded')
+
+ def get_options(self):
+ opts = {'cpp_std' : coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+ ['none', 'c++03', 'c++11', 'c++14', 'c++1z',
+ 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++1z'],
+ 'none'),
+ 'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
+ 'STL debug mode',
+ False)}
+ if self.gcc_type == GCC_MINGW:
+ opts.update({
+ 'cpp_winlibs': coredata.UserStringArrayOption('c_winlibs', 'Standard Win libraries to link against',
+ gnu_winlibs),
+ })
+ return opts
+
+ def get_option_compile_args(self, options):
+ args = []
+ std = options['cpp_std']
+ if std.value != 'none':
+ args.append('-std=' + std.value)
+ if options['cpp_debugstl'].value:
+ args.append('-D_GLIBCXX_DEBUG=1')
+ return args
+
+ def get_option_link_args(self, options):
+ if self.gcc_type == GCC_MINGW:
+ return options['cpp_winlibs'].value
+ return []
+
class GnuObjCCompiler(ObjCCompiler):
std_opt_args = ['-O2']
@@ -2134,76 +2177,6 @@ class ClangCCompiler(CCompiler):
def has_argument(self, arg, env):
return super().has_argument(['-Werror=unknown-warning-option', arg], env)
-class GnuCPPCompiler(CPPCompiler):
- # may need to separate the latter to extra_debug_args or something
- std_debug_args = ['-g']
-
- def __init__(self, exelist, version, gcc_type, is_cross, exe_wrap):
- CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
- self.id = 'gcc'
- self.gcc_type = gcc_type
- self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'],
- '2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'],
- '3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']}
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
- 'b_colorout']
- if self.gcc_type != GCC_OSX:
- self.base_options.append('b_lundef')
- self.base_options.append('b_asneeded')
-
- def get_colorout_args(self, colortype):
- if mesonlib.version_compare(self.version, '>=4.9.0'):
- return gnu_color_args[colortype][:]
- return []
-
- def get_pic_args(self):
- if self.gcc_type == GCC_MINGW:
- return [] # On Window gcc defaults to fpic being always on.
- return ['-fPIC']
-
- def get_always_args(self):
- return ['-pipe']
-
- 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 'gch'
-
- def get_soname_args(self, shlib_name, path, soversion):
- return get_gcc_soname_args(self.gcc_type, shlib_name, path, soversion)
-
- def get_options(self):
- opts = {'cpp_std' : coredata.UserComboOption('cpp_std', 'C++ language standard to use',
- ['none', 'c++03', 'c++11', 'c++14', 'c++1z',
- 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++1z'],
- 'none'),
- 'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
- 'STL debug mode',
- False)}
- if self.gcc_type == GCC_MINGW:
- opts.update({
- 'cpp_winlibs': coredata.UserStringArrayOption('c_winlibs', 'Standard Win libraries to link against',
- gnu_winlibs),
- })
- return opts
-
- def get_option_compile_args(self, options):
- args = []
- std = options['cpp_std']
- if std.value != 'none':
- args.append('-std=' + std.value)
- if options['cpp_debugstl'].value:
- args.append('-D_GLIBCXX_DEBUG=1')
- return args
-
- def get_option_link_args(self, options):
- if self.gcc_type == GCC_MINGW:
- return options['cpp_winlibs'].value
- return []
class ClangCPPCompiler(CPPCompiler):
def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None):