blob: dea80b8ed394fe25d1fde10eb09a125fdf7dd01e [file] [log] [blame]
Obaid2ea377f2014-02-27 19:45:15 -06001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev80f06a52014-03-27 14:40:00 -07003from waflib import Logs, Configure
Obaid2ea377f2014-02-27 19:45:15 -06004
5def configure(conf):
Alexander Afanasyev80f06a52014-03-27 14:40:00 -07006 areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
Obaid2ea377f2014-02-27 19:45:15 -06007 if conf.options.debug:
Alexander Afanasyev80f06a52014-03-27 14:40:00 -07008 conf.define('_DEBUG', 1)
9 defaultFlags = ['-O0', '-g3',
10 '-Werror',
11 '-Wall',
12 '-fcolor-diagnostics', # only clang supports
Obaid2ea377f2014-02-27 19:45:15 -060013
Alexander Afanasyev80f06a52014-03-27 14:40:00 -070014 # # to disable known warnings
15 # '-Wno-unused-variable', # cryptopp
16 # '-Wno-unused-function',
17 # '-Wno-deprecated-declarations',
18 ]
Obaid2ea377f2014-02-27 19:45:15 -060019
Alexander Afanasyev80f06a52014-03-27 14:40:00 -070020 if areCustomCxxflagsPresent:
21 missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
22 if len(missingFlags) > 0:
23 Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
24 % " ".join(conf.env.CXXFLAGS))
25 Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
26 else:
27 conf.add_supported_cxxflags(cxxflags=defaultFlags)
Obaid2ea377f2014-02-27 19:45:15 -060028 else:
Alexander Afanasyev80f06a52014-03-27 14:40:00 -070029 defaultFlags = ['-O2', '-g', '-Wall',
30
31 # # to disable known warnings
32 # '-Wno-unused-variable', # cryptopp
33 # '-Wno-unused-function',
34 # '-Wno-deprecated-declarations',
35 ]
36 if not areCustomCxxflagsPresent:
37 conf.add_supported_cxxflags(cxxflags=defaultFlags)
Obaid2ea377f2014-02-27 19:45:15 -060038
39@Configure.conf
40def add_supported_cxxflags(self, cxxflags):
41 """
42 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
43 """
44 self.start_msg('Checking allowed flags for c++ compiler')
45
46 supportedFlags = []
47 for flag in cxxflags:
48 if self.check_cxx (cxxflags=[flag], mandatory=False):
49 supportedFlags += [flag]
50
51 self.end_msg (' '.join (supportedFlags))
52 self.env.CXXFLAGS += supportedFlags