mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-25 03:09:30 +01:00
Boost module enhancements and fixes
- Output detected version of boost in dot-form (e.g., 1.56.0, instead of 1_56) - Fix Boost.Log library detection: * when linking to shared library, BOOST_LOG_DYN_LINK needs to be defined * when linking to non-multithreaded version, BOOST_LOG_NO_THREADS needs to be defined (see http://www.boost.org/doc/libs/1_60_0/libs/log/doc/html/log/installation/config.html)
This commit is contained in:
parent
1ee5adc3b3
commit
b99a82ddfe
11
playground/boost_log/main.cpp
Normal file
11
playground/boost_log/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
int main(int, char*[])
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
|
||||
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
|
||||
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
|
||||
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
|
||||
BOOST_LOG_TRIVIAL(error) << "An error severity message";
|
||||
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
|
||||
}
|
16
playground/boost_log/wscript
Normal file
16
playground/boost_log/wscript
Normal file
@ -0,0 +1,16 @@
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx boost')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx boost')
|
||||
|
||||
if conf.options.boost_mt:
|
||||
conf.check_boost('system thread log log_setup')
|
||||
else:
|
||||
conf.check_boost('log log_setup')
|
||||
|
||||
def build(bld):
|
||||
bld.program(source='main.cpp', target='app', use='BOOST')
|
@ -61,7 +61,7 @@ BOOST_VERSION_FILE = 'boost/version.hpp'
|
||||
BOOST_VERSION_CODE = '''
|
||||
#include <iostream>
|
||||
#include <boost/version.hpp>
|
||||
int main() { std::cout << BOOST_LIB_VERSION << std::endl; }
|
||||
int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
|
||||
'''
|
||||
|
||||
BOOST_ERROR_CODE = '''
|
||||
@ -116,14 +116,15 @@ BOOST_TOOLSETS = {
|
||||
|
||||
|
||||
def options(opt):
|
||||
opt = opt.add_option_group('Boost Options')
|
||||
opt.add_option('--boost-includes', type='string',
|
||||
default='', dest='boost_includes',
|
||||
help='''path to the boost includes root (~boost root)
|
||||
e.g. /path/to/boost_1_47_0''')
|
||||
help='''path to the directory where the boost includes are,
|
||||
e.g., /path/to/boost_1_55_0/stage/include''')
|
||||
opt.add_option('--boost-libs', type='string',
|
||||
default='', dest='boost_libs',
|
||||
help='''path to the directory where the boost libs are
|
||||
e.g. /path/to/boost_1_47_0/stage/lib''')
|
||||
help='''path to the directory where the boost libs are,
|
||||
e.g., path/to/boost_1_55_0/stage/lib''')
|
||||
opt.add_option('--boost-mt', action='store_true',
|
||||
default=False, dest='boost_mt',
|
||||
help='select multi-threaded libraries')
|
||||
@ -162,11 +163,13 @@ def boost_get_version(self, d):
|
||||
except EnvironmentError:
|
||||
Logs.error("Could not read the file %r" % node.abspath())
|
||||
else:
|
||||
re_but = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.*)"', re.M)
|
||||
m = re_but.search(txt)
|
||||
if m:
|
||||
return m.group(1)
|
||||
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True)
|
||||
re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.+)"', re.M)
|
||||
m1 = re_but1.search(txt)
|
||||
re_but2 = re.compile('^#define\\s+BOOST_VERSION\\s+(\\d+)', re.M)
|
||||
m2 = re_but2.search(txt)
|
||||
if m1 and m2:
|
||||
return (m1.group(1), m2.group(1))
|
||||
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(":")
|
||||
|
||||
@conf
|
||||
def boost_get_includes(self, *k, **kw):
|
||||
@ -328,8 +331,12 @@ def check_boost(self, *k, **kw):
|
||||
|
||||
self.start_msg('Checking boost includes')
|
||||
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
|
||||
self.env.BOOST_VERSION = self.boost_get_version(inc)
|
||||
self.end_msg(self.env.BOOST_VERSION)
|
||||
versions = self.boost_get_version(inc)
|
||||
self.env.BOOST_VERSION = versions[0]
|
||||
self.env.BOOST_VERSION_NUMBER = int(versions[1])
|
||||
self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
|
||||
int(versions[1]) / 100 % 1000,
|
||||
int(versions[1]) % 100))
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
|
||||
|
||||
@ -357,8 +364,24 @@ def check_boost(self, *k, **kw):
|
||||
if (params['lib'] and 'thread' in params['lib']) or \
|
||||
params['stlib'] and 'thread' in params['stlib']:
|
||||
self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
|
||||
if (params['lib'] and 'log' in params['lib']) or \
|
||||
params['stlib'] and 'log' in params['stlib']:
|
||||
|
||||
def is_log_mt():
|
||||
'''Check if found boost_log library is multithread-safe'''
|
||||
for lib in libs:
|
||||
if lib.startswith('boost_log'):
|
||||
lib_log = lib
|
||||
break
|
||||
return '-mt' in lib_log
|
||||
|
||||
if params['lib'] and 'log' in params['lib']:
|
||||
self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
|
||||
if not is_log_mt():
|
||||
self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
|
||||
self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
|
||||
if params['stlib'] and 'log' in params['stlib']:
|
||||
# Static linking is assumed by default
|
||||
if not is_log_mt():
|
||||
self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
|
||||
self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
|
||||
|
||||
if params.get('linkage_autodetect', False):
|
||||
|
Loading…
Reference in New Issue
Block a user