Specify build flags per build type.

pull/15/head
Jussi Pakkanen 11 years ago
parent ac2d7e3440
commit b626d017a2
  1. 3
      backends.py
  2. 35
      environment.py
  3. 2
      meson.py
  4. 3
      mesongui.py

@ -306,8 +306,7 @@ class Backend():
if self.environment.coredata.buildtype != 'plain':
commands += compiler.get_debug_flags()
commands += compiler.get_std_warn_flags()
if self.environment.coredata.buildtype == 'optimized':
commands += compiler.get_std_opt_flags()
commands += compiler.get_buildtype_flags(self.environment.coredata.buildtype)
if self.environment.coredata.coverage:
commands += compiler.get_coverage_flags()
if isinstance(target, build.SharedLibrary):

@ -35,6 +35,12 @@ class RunResult():
self.stdout = stdout
self.stderr = stderr
gnulike_buildtype_flags = {'plain' : [],
'debug' : ['-g'],
'debugoptimized' : ['-O2', '-g'],
'release' : ['-O3'],
}
class CCompiler():
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
if type(exelist) == type(''):
@ -645,7 +651,6 @@ def get_gcc_soname_flags(gcc_type, shlib_name, path):
class GnuCCompiler(CCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2']
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
@ -658,8 +663,8 @@ class GnuCCompiler(CCompiler):
def get_std_warn_flags(self):
return GnuCCompiler.std_warn_flags
def get_std_opt_flags(self):
return GnuCCompiler.std_opt_flags
def get_buildtype_flags(self, buildtype):
return gnulike_buildtype_flags[buildtype]
def get_pch_suffix(self):
return 'gch'
@ -677,7 +682,6 @@ class GnuCCompiler(CCompiler):
class GnuObjCCompiler(ObjCCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2']
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
@ -686,8 +690,8 @@ class GnuObjCCompiler(ObjCCompiler):
def get_std_warn_flags(self):
return GnuObjCCompiler.std_warn_flags
def get_std_opt_flags(self):
return GnuObjCCompiler.std_opt_flags
def get_buildtype_flags(self, buildtype):
return gnulike_buildtype_flags[buildtype]
def get_pch_suffix(self):
return 'gch'
@ -711,8 +715,8 @@ class GnuObjCPPCompiler(ObjCPPCompiler):
def get_std_warn_flags(self):
return GnuObjCPPCompiler.std_warn_flags
def get_std_opt_flags(self):
return GnuObjCPPCompiler.std_opt_flags
def get_buildtype_flags(self, buildtype):
return gnulike_buildtype_flags[buildtype]
def get_pch_suffix(self):
return 'gch'
@ -737,7 +741,6 @@ class ClangObjCPPCompiler(GnuObjCPPCompiler):
class ClangCCompiler(CCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2']
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
@ -746,8 +749,8 @@ class ClangCCompiler(CCompiler):
def get_std_warn_flags(self):
return ClangCCompiler.std_warn_flags
def get_std_opt_flags(self):
return ClangCCompiler.std_opt_flags
def get_buildtype_flags(self, buildtype):
return gnulike_buildtype_flags[buildtype]
def get_pch_suffix(self):
return 'pch'
@ -759,7 +762,6 @@ class ClangCCompiler(CCompiler):
class GnuCPPCompiler(CPPCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2']
# may need to separate the latter to extra_debug_flags or something
std_debug_flags = ['-g']
@ -777,8 +779,8 @@ class GnuCPPCompiler(CPPCompiler):
def get_std_warn_flags(self):
return GnuCPPCompiler.std_warn_flags
def get_std_opt_flags(self):
return GnuCPPCompiler.std_opt_flags
def get_buildtype_flags(self, buildtype):
return gnulike_buildtype_flags[buildtype]
def get_pch_suffix(self):
return 'gch'
@ -793,7 +795,6 @@ class GnuCPPCompiler(CPPCompiler):
class ClangCPPCompiler(CPPCompiler):
std_warn_flags = ['-Wall', '-Winvalid-pch']
std_opt_flags = ['-O2']
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)
@ -802,8 +803,8 @@ class ClangCPPCompiler(CPPCompiler):
def get_std_warn_flags(self):
return ClangCPPCompiler.std_warn_flags
def get_std_opt_flags(self):
return ClangCPPCompiler.std_opt_flags
def get_buildtype_flags(self, buildtype):
return gnulike_buildtype_flags[buildtype]
def get_pch_suffix(self):
return 'pch'

@ -27,7 +27,7 @@ usage_info = '%prog [options] source_dir build_dir'
parser = OptionParser(usage=usage_info, version=coredata.version)
build_types = ['plain', 'debug', 'optimized']
build_types = ['plain', 'debug', 'debugoptimized', 'release']
buildtype_help = 'build type, one of: %s' % ', '.join(build_types)
buildtype_help += ' (default: %default)'

@ -238,7 +238,8 @@ class OptionForm:
combo = QComboBox()
combo.addItem('plain')
combo.addItem('debug')
combo.addItem('optimized')
combo.addItem('debugoptimized')
combo.addItem('release')
combo.setCurrentText(self.coredata.buildtype)
combo.currentTextChanged.connect(self.build_type_changed)
self.form.addRow('Build type', combo)

Loading…
Cancel
Save