2011-09-10 20:02:12 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
#
|
|
|
|
# partially based on boost.py written by Gernot Vormayr
|
|
|
|
# written by Ruediger Sonderfeld <ruediger@c-plusplus.de>, 2008
|
|
|
|
# modified by Bjoern Michaelsen, 2008
|
|
|
|
# modified by Luca Fossati, 2008
|
|
|
|
# rewritten for waf 1.5.1, Thomas Nagy, 2008
|
|
|
|
# rewritten for waf 1.6.2, Sylvain Rouquette, 2011
|
|
|
|
|
|
|
|
'''
|
2011-11-08 08:13:00 +01:00
|
|
|
|
|
|
|
This is an extra tool, not bundled with the default waf binary.
|
2011-09-10 20:02:12 +02:00
|
|
|
To add the boost tool to the waf file:
|
|
|
|
$ ./waf-light --tools=compat15,boost
|
|
|
|
or, if you have waf >= 1.6.2
|
|
|
|
$ ./waf update --files=boost
|
|
|
|
|
2011-11-08 08:13:00 +01:00
|
|
|
When using this tool, the wscript will look like:
|
2011-09-10 20:02:12 +02:00
|
|
|
|
2011-11-08 08:13:00 +01:00
|
|
|
def options(opt):
|
|
|
|
opt.load('compiler_cxx boost')
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
conf.load('compiler_cxx boost')
|
|
|
|
conf.check_boost(lib='system filesystem')
|
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
bld(source='main.cpp', target='app', use='BOOST')
|
2011-09-10 20:02:12 +02:00
|
|
|
|
2011-11-08 08:13:00 +01:00
|
|
|
Options are generated, in order to specify the location of boost includes/libraries.
|
|
|
|
The `check_boost` configuration function allows to specify the used boost libraries.
|
2014-06-17 20:29:26 +02:00
|
|
|
It can also provide default arguments to the --boost-mt command-line arguments.
|
2011-11-08 08:13:00 +01:00
|
|
|
Everything will be packaged together in a BOOST component that you can use.
|
|
|
|
|
|
|
|
When using MSVC, a lot of compilation flags need to match your BOOST build configuration:
|
|
|
|
- you may have to add /EHsc to your CXXFLAGS or define boost::throw_exception if BOOST_NO_EXCEPTIONS is defined.
|
|
|
|
Errors: C4530
|
|
|
|
- boost libraries will try to be smart and use the (pretty but often not useful) auto-linking feature of MSVC
|
2014-02-24 20:35:38 +01:00
|
|
|
So before calling `conf.check_boost` you might want to disabling by adding
|
|
|
|
conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
|
2014-02-15 11:09:37 +01:00
|
|
|
Errors:
|
2011-11-08 08:13:00 +01:00
|
|
|
- boost might also be compiled with /MT, which links the runtime statically.
|
2014-02-15 11:09:37 +01:00
|
|
|
If you have problems with redefined symbols,
|
2011-11-08 08:13:00 +01:00
|
|
|
self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
|
|
|
|
self.env['CXXFLAGS_%s' % var] += ['/MD', '/EHsc']
|
|
|
|
Passing `--boost-linkage_autodetect` might help ensuring having a correct linkage in some basic cases.
|
2011-09-10 20:02:12 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import re
|
2011-11-08 08:13:00 +01:00
|
|
|
from waflib import Utils, Logs, Errors
|
2011-09-10 20:02:12 +02:00
|
|
|
from waflib.Configure import conf
|
2014-07-06 16:35:52 +02:00
|
|
|
from waflib.TaskGen import feature, after_method
|
2011-09-10 20:02:12 +02:00
|
|
|
|
2014-02-01 18:24:16 +01:00
|
|
|
BOOST_LIBS = ['/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu',
|
2014-02-24 20:35:38 +01:00
|
|
|
'/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
|
2011-09-10 20:02:12 +02:00
|
|
|
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include']
|
|
|
|
BOOST_VERSION_FILE = 'boost/version.hpp'
|
|
|
|
BOOST_VERSION_CODE = '''
|
|
|
|
#include <iostream>
|
|
|
|
#include <boost/version.hpp>
|
|
|
|
int main() { std::cout << BOOST_LIB_VERSION << std::endl; }
|
|
|
|
'''
|
|
|
|
|
2014-04-10 07:43:28 +02:00
|
|
|
BOOST_ERROR_CODE = '''
|
|
|
|
#include <boost/system/error_code.hpp>
|
|
|
|
int main() { boost::system::error_code c; }
|
|
|
|
'''
|
|
|
|
|
|
|
|
BOOST_THREAD_CODE = '''
|
|
|
|
#include <boost/thread.hpp>
|
|
|
|
int main() { boost::thread t; }
|
|
|
|
'''
|
|
|
|
|
2011-09-10 20:02:12 +02:00
|
|
|
# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
|
|
|
|
PLATFORM = Utils.unversioned_sys_platform()
|
|
|
|
detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
|
|
|
|
detect_clang = lambda env: (PLATFORM == 'darwin') and 'clang-darwin' or 'clang'
|
|
|
|
detect_mingw = lambda env: (re.search('MinGW', env.CXX[0])) and 'mgw' or 'gcc'
|
|
|
|
BOOST_TOOLSETS = {
|
|
|
|
'borland': 'bcb',
|
|
|
|
'clang': detect_clang,
|
|
|
|
'como': 'como',
|
|
|
|
'cw': 'cw',
|
|
|
|
'darwin': 'xgcc',
|
|
|
|
'edg': 'edg',
|
|
|
|
'g++': detect_mingw,
|
|
|
|
'gcc': detect_mingw,
|
|
|
|
'icpc': detect_intel,
|
|
|
|
'intel': detect_intel,
|
|
|
|
'kcc': 'kcc',
|
|
|
|
'kylix': 'bck',
|
|
|
|
'mipspro': 'mp',
|
|
|
|
'mingw': 'mgw',
|
|
|
|
'msvc': 'vc',
|
|
|
|
'qcc': 'qcc',
|
|
|
|
'sun': 'sw',
|
|
|
|
'sunc++': 'sw',
|
|
|
|
'tru64cxx': 'tru',
|
|
|
|
'vacpp': 'xlc'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def options(opt):
|
|
|
|
opt.add_option('--boost-includes', type='string',
|
|
|
|
default='', dest='boost_includes',
|
2011-11-08 08:13:00 +01:00
|
|
|
help='''path to the boost includes root (~boost root)
|
|
|
|
e.g. /path/to/boost_1_47_0''')
|
2011-09-10 20:02:12 +02:00
|
|
|
opt.add_option('--boost-libs', type='string',
|
|
|
|
default='', dest='boost_libs',
|
|
|
|
help='''path to the directory where the boost libs are
|
2011-11-08 08:13:00 +01:00
|
|
|
e.g. /path/to/boost_1_47_0/stage/lib''')
|
2014-06-17 20:29:26 +02:00
|
|
|
opt.add_option('--boost-mt', action='store_true',
|
|
|
|
default=False, dest='boost_mt',
|
|
|
|
help='select multi-threaded libraries')
|
2011-09-10 20:02:12 +02:00
|
|
|
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
|
2014-06-17 20:29:26 +02:00
|
|
|
help='''select libraries with tags (gd for debug, static is automatically added),
|
2011-09-10 20:02:12 +02:00
|
|
|
see doc Boost, Getting Started, chapter 6.1''')
|
2011-11-08 08:13:00 +01:00
|
|
|
opt.add_option('--boost-linkage_autodetect', action="store_true", dest='boost_linkage_autodetect',
|
|
|
|
help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
|
2011-09-10 20:02:12 +02:00
|
|
|
opt.add_option('--boost-toolset', type='string',
|
|
|
|
default='', dest='boost_toolset',
|
|
|
|
help='force a toolset e.g. msvc, vc90, \
|
|
|
|
gcc, mingw, mgw45 (default: auto)')
|
|
|
|
py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
|
|
|
|
opt.add_option('--boost-python', type='string',
|
|
|
|
default=py_version, dest='boost_python',
|
|
|
|
help='select the lib python with this version \
|
|
|
|
(default: %s)' % py_version)
|
|
|
|
|
|
|
|
|
|
|
|
@conf
|
2013-06-05 00:03:21 +02:00
|
|
|
def __boost_get_version_file(self, d):
|
2014-02-24 20:36:36 +01:00
|
|
|
if not d:
|
|
|
|
return None
|
2013-06-05 00:03:21 +02:00
|
|
|
dnode = self.root.find_dir(d)
|
|
|
|
if dnode:
|
|
|
|
return dnode.find_node(BOOST_VERSION_FILE)
|
|
|
|
return None
|
2011-09-10 20:02:12 +02:00
|
|
|
|
|
|
|
@conf
|
2013-06-05 00:03:21 +02:00
|
|
|
def boost_get_version(self, d):
|
2011-09-10 20:02:12 +02:00
|
|
|
"""silently retrieve the boost version number"""
|
2013-06-05 00:03:21 +02:00
|
|
|
node = self.__boost_get_version_file(d)
|
|
|
|
if node:
|
|
|
|
try:
|
|
|
|
txt = node.read()
|
|
|
|
except (OSError, IOError):
|
|
|
|
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)
|
2013-06-05 21:42:49 +02:00
|
|
|
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True)
|
2011-09-10 20:02:12 +02:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def boost_get_includes(self, *k, **kw):
|
|
|
|
includes = k and k[0] or kw.get('includes', None)
|
|
|
|
if includes and self.__boost_get_version_file(includes):
|
|
|
|
return includes
|
2014-02-15 11:09:37 +01:00
|
|
|
for d in self.environ.get('INCLUDE', '').split(';') + BOOST_INCLUDES:
|
2014-02-24 20:36:36 +01:00
|
|
|
if self.__boost_get_version_file(d):
|
2013-05-19 08:34:51 +02:00
|
|
|
return d
|
2011-09-10 20:02:12 +02:00
|
|
|
if includes:
|
2013-03-12 14:10:12 +01:00
|
|
|
self.end_msg('headers not found in %s' % includes)
|
|
|
|
self.fatal('The configuration failed')
|
2011-09-10 20:02:12 +02:00
|
|
|
else:
|
2013-03-12 14:10:12 +01:00
|
|
|
self.end_msg('headers not found, please provide a --boost-includes argument (see help)')
|
|
|
|
self.fatal('The configuration failed')
|
2011-09-10 20:02:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def boost_get_toolset(self, cc):
|
|
|
|
toolset = cc
|
|
|
|
if not cc:
|
|
|
|
build_platform = Utils.unversioned_sys_platform()
|
|
|
|
if build_platform in BOOST_TOOLSETS:
|
|
|
|
cc = build_platform
|
|
|
|
else:
|
|
|
|
cc = self.env.CXX_NAME
|
|
|
|
if cc in BOOST_TOOLSETS:
|
|
|
|
toolset = BOOST_TOOLSETS[cc]
|
|
|
|
return isinstance(toolset, str) and toolset or toolset(self.env)
|
|
|
|
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def __boost_get_libs_path(self, *k, **kw):
|
|
|
|
''' return the lib path and all the files in it '''
|
|
|
|
if 'files' in kw:
|
|
|
|
return self.root.find_dir('.'), Utils.to_list(kw['files'])
|
|
|
|
libs = k and k[0] or kw.get('libs', None)
|
|
|
|
if libs:
|
|
|
|
path = self.root.find_dir(libs)
|
|
|
|
files = path.ant_glob('*boost_*')
|
|
|
|
if not libs or not files:
|
2014-02-15 11:09:37 +01:00
|
|
|
for d in self.environ.get('LIB', '').split(';') + BOOST_LIBS:
|
2014-02-24 20:35:38 +01:00
|
|
|
if not d:
|
|
|
|
continue
|
2013-06-05 00:03:21 +02:00
|
|
|
path = self.root.find_dir(d)
|
|
|
|
if path:
|
2011-09-10 20:02:12 +02:00
|
|
|
files = path.ant_glob('*boost_*')
|
|
|
|
if files:
|
|
|
|
break
|
2013-06-05 00:03:21 +02:00
|
|
|
path = self.root.find_dir(d + '64')
|
|
|
|
if path:
|
2011-09-10 20:02:12 +02:00
|
|
|
files = path.ant_glob('*boost_*')
|
|
|
|
if files:
|
|
|
|
break
|
|
|
|
if not path:
|
|
|
|
if libs:
|
2013-03-12 14:10:12 +01:00
|
|
|
self.end_msg('libs not found in %s' % libs)
|
|
|
|
self.fatal('The configuration failed')
|
2011-09-10 20:02:12 +02:00
|
|
|
else:
|
2013-03-12 14:10:12 +01:00
|
|
|
self.end_msg('libs not found, please provide a --boost-libs argument (see help)')
|
|
|
|
self.fatal('The configuration failed')
|
2011-09-10 20:02:12 +02:00
|
|
|
|
2011-09-10 20:46:24 +02:00
|
|
|
self.to_log('Found the boost path in %r with the libraries:' % path)
|
|
|
|
for x in files:
|
|
|
|
self.to_log(' %r' % x)
|
|
|
|
return path, files
|
2011-09-10 20:02:12 +02:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def boost_get_libs(self, *k, **kw):
|
|
|
|
'''
|
|
|
|
return the lib path and the required libs
|
|
|
|
according to the parameters
|
|
|
|
'''
|
|
|
|
path, files = self.__boost_get_libs_path(**kw)
|
2014-09-01 23:14:10 +02:00
|
|
|
files = sorted(files, key=lambda f: len(f.name), reverse=True)
|
2011-11-08 08:13:00 +01:00
|
|
|
toolset = self.boost_get_toolset(kw.get('toolset', ''))
|
2014-06-17 23:40:21 +02:00
|
|
|
toolset_pat = '(-%s[0-9]{0,3})' % toolset
|
2014-09-03 00:23:19 +02:00
|
|
|
version = '-%s' % self.env.BOOST_VERSION
|
2011-09-10 20:02:12 +02:00
|
|
|
|
|
|
|
def find_lib(re_lib, files):
|
|
|
|
for file in files:
|
2014-09-03 00:23:19 +02:00
|
|
|
if re_lib.search(file.name):
|
2011-09-10 20:46:24 +02:00
|
|
|
self.to_log('Found boost lib %s' % file)
|
2011-09-10 20:02:12 +02:00
|
|
|
return file
|
|
|
|
return None
|
|
|
|
|
|
|
|
def format_lib_name(name):
|
2012-09-15 08:30:51 +02:00
|
|
|
if name.startswith('lib') and self.env.CC_NAME != 'msvc':
|
2011-09-10 20:02:12 +02:00
|
|
|
name = name[3:]
|
2012-10-05 00:21:27 +02:00
|
|
|
return name[:name.rfind('.')]
|
2011-09-10 20:02:12 +02:00
|
|
|
|
2014-06-17 20:29:26 +02:00
|
|
|
def match_libs(lib_names, is_static):
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
libs = []
|
|
|
|
lib_names = Utils.to_list(lib_names)
|
|
|
|
if not lib_names:
|
|
|
|
return libs
|
2014-06-17 20:29:26 +02:00
|
|
|
t = []
|
2014-06-17 23:40:21 +02:00
|
|
|
if kw.get('mt', False):
|
2014-09-03 00:23:19 +02:00
|
|
|
t.append('-mt')
|
2014-06-17 20:29:26 +02:00
|
|
|
if kw.get('abi', None):
|
2014-09-03 00:23:19 +02:00
|
|
|
t.append('%s%s' % (is_static and '-s' or '-', kw['abi']))
|
2014-06-17 23:40:21 +02:00
|
|
|
elif is_static:
|
2014-09-03 00:23:19 +02:00
|
|
|
t.append('-s')
|
2014-06-18 00:12:30 +02:00
|
|
|
tags_pat = t and ''.join(t) or ''
|
2014-09-03 00:23:19 +02:00
|
|
|
ext = is_static and self.env.cxxstlib_PATTERN or self.env.cxxshlib_PATTERN
|
|
|
|
ext = ext % '' # remove %s from PATTERN
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
for lib in lib_names:
|
2014-06-17 23:40:21 +02:00
|
|
|
if lib == 'python':
|
2014-09-01 23:17:52 +02:00
|
|
|
# for instance, with python='27',
|
|
|
|
# accepts '-py27', '-py2', '27' and '2'
|
|
|
|
# but will reject '-py3', '-py26', '26' and '3'
|
2014-09-01 23:14:10 +02:00
|
|
|
tags = '({0})?((-py{2})|(-py{1}(?=[^0-9]))|({2})|({1}(?=[^0-9]))|(?=[^0-9])(?!-py))'.format(tags_pat, kw['python'][0], kw['python'])
|
2014-06-18 00:12:30 +02:00
|
|
|
else:
|
|
|
|
tags = tags_pat
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
# Trying libraries, from most strict match to least one
|
2014-09-03 00:23:19 +02:00
|
|
|
for pattern in ['boost_%s%s%s%s%s$' % (lib, toolset_pat, tags, version, ext),
|
|
|
|
'boost_%s%s%s%s$' % (lib, tags, version, ext),
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
# Give up trying to find the right version
|
2014-09-03 00:23:19 +02:00
|
|
|
'boost_%s%s%s%s$' % (lib, toolset_pat, tags, ext),
|
|
|
|
'boost_%s%s%s$' % (lib, tags, ext),
|
2014-06-17 23:40:21 +02:00
|
|
|
'boost_%s' % lib]:
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
self.to_log('Trying pattern %s' % pattern)
|
|
|
|
file = find_lib(re.compile(pattern), files)
|
|
|
|
if file:
|
|
|
|
libs.append(format_lib_name(file.name))
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
|
|
|
|
self.fatal('The configuration failed')
|
|
|
|
return libs
|
2011-09-10 20:02:12 +02:00
|
|
|
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
return path.abspath(), \
|
2014-06-17 20:29:26 +02:00
|
|
|
match_libs(kw.get('lib', None), False), \
|
|
|
|
match_libs(kw.get('stlib', None), True)
|
2011-09-10 20:02:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def check_boost(self, *k, **kw):
|
|
|
|
"""
|
2011-11-08 08:13:00 +01:00
|
|
|
Initialize boost libraries to be used.
|
2011-09-10 20:02:12 +02:00
|
|
|
|
2011-11-08 08:13:00 +01:00
|
|
|
Keywords: you can pass the same parameters as with the command line (without "--boost-").
|
|
|
|
Note that the command line has the priority, and should preferably be used.
|
2011-09-10 20:02:12 +02:00
|
|
|
"""
|
|
|
|
if not self.env['CXX']:
|
|
|
|
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
|
|
|
|
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
params = {
|
|
|
|
'lib': k and k[0] or kw.get('lib', None),
|
|
|
|
'stlib': kw.get('stlib', None)
|
|
|
|
}
|
2011-09-10 20:02:12 +02:00
|
|
|
for key, value in self.options.__dict__.items():
|
|
|
|
if not key.startswith('boost_'):
|
|
|
|
continue
|
|
|
|
key = key[len('boost_'):]
|
|
|
|
params[key] = value and value or kw.get(key, '')
|
|
|
|
|
|
|
|
var = kw.get('uselib_store', 'BOOST')
|
|
|
|
|
|
|
|
self.start_msg('Checking boost includes')
|
2011-11-08 08:13:00 +01:00
|
|
|
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
|
|
|
|
self.env.BOOST_VERSION = self.boost_get_version(inc)
|
2011-09-10 20:02:12 +02:00
|
|
|
self.end_msg(self.env.BOOST_VERSION)
|
|
|
|
if Logs.verbose:
|
|
|
|
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
|
|
|
|
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
if not params['lib'] and not params['stlib']:
|
2011-09-10 20:02:12 +02:00
|
|
|
return
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
if 'static' in kw or 'static' in params:
|
|
|
|
Logs.warn('boost: static parameter is deprecated, use stlib instead.')
|
2011-09-10 20:02:12 +02:00
|
|
|
self.start_msg('Checking boost libs')
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
path, libs, stlibs = self.boost_get_libs(**params)
|
|
|
|
self.env['LIBPATH_%s' % var] = [path]
|
|
|
|
self.env['STLIBPATH_%s' % var] = [path]
|
|
|
|
self.env['LIB_%s' % var] = libs
|
|
|
|
self.env['STLIB_%s' % var] = stlibs
|
2011-09-10 20:02:12 +02:00
|
|
|
self.end_msg('ok')
|
|
|
|
if Logs.verbose:
|
|
|
|
Logs.pprint('CYAN', ' path : %s' % path)
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
Logs.pprint('CYAN', ' shared libs : %s' % libs)
|
|
|
|
Logs.pprint('CYAN', ' static libs : %s' % stlibs)
|
2011-09-10 20:02:12 +02:00
|
|
|
|
2011-11-08 08:13:00 +01:00
|
|
|
|
|
|
|
def try_link():
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
if (params['lib'] and 'system' in params['lib']) or \
|
|
|
|
params['stlib'] and 'system' in params['stlib']:
|
2014-04-10 07:43:28 +02:00
|
|
|
self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
|
WARNING: I broke the compatibility with previous boost.py
- removed "static" parameter, now use stlib to specify static libs (added a warning if you were using it)
- removed "mt" parameter, now specify it as part of the abi (see help)
- added "stlib" parameter, to specify which lib will be linked statically. "lib" is used to link shared libs.
explanation:
After struggling to link Boost.Log, the problem lies into which libs can/must be linked statically and dynamically.
I built a small test with only system, locale, log_setup, log and thread, and could link it as static.
But after adding boost_filesystem, I couldn't link everything as static anymore and would fail on a dependency in "locale" (icu, nconv).
Linking everything as shared would failed aswell (log). But linking only "locale" as shared, and the rest as static would work.
Hence the change.
Since I broke everything, I figured I would rework the "mt" parameter, since it's kinda part of the abi on windows.
2014-06-15 17:28:26 +02:00
|
|
|
if (params['lib'] and 'thread' in params['lib']) or \
|
|
|
|
params['stlib'] and 'thread' in params['stlib']:
|
2014-04-10 07:43:28 +02:00
|
|
|
self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
|
2011-11-08 08:13:00 +01:00
|
|
|
|
|
|
|
if params.get('linkage_autodetect', False):
|
|
|
|
self.start_msg("Attempting to detect boost linkage flags")
|
|
|
|
toolset = self.boost_get_toolset(kw.get('toolset', ''))
|
2014-01-05 22:27:06 +01:00
|
|
|
if toolset in ('vc',):
|
2011-11-08 08:13:00 +01:00
|
|
|
# disable auto-linking feature, causing error LNK1181
|
|
|
|
# because the code wants to be linked against
|
|
|
|
self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
|
|
|
|
|
|
|
|
# if no dlls are present, we guess the .lib files are not stubs
|
|
|
|
has_dlls = False
|
|
|
|
for x in Utils.listdir(path):
|
|
|
|
if x.endswith(self.env.cxxshlib_PATTERN % ''):
|
|
|
|
has_dlls = True
|
|
|
|
break
|
|
|
|
if not has_dlls:
|
|
|
|
self.env['STLIBPATH_%s' % var] = [path]
|
|
|
|
self.env['STLIB_%s' % var] = libs
|
|
|
|
del self.env['LIB_%s' % var]
|
|
|
|
del self.env['LIBPATH_%s' % var]
|
|
|
|
|
|
|
|
# we attempt to play with some known-to-work CXXFLAGS combinations
|
|
|
|
for cxxflags in (['/MD', '/EHsc'], []):
|
|
|
|
self.env.stash()
|
|
|
|
self.env["CXXFLAGS_%s" % var] += cxxflags
|
|
|
|
try:
|
|
|
|
try_link()
|
|
|
|
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
|
2013-10-20 19:39:11 +02:00
|
|
|
exc = None
|
2011-11-08 08:13:00 +01:00
|
|
|
break
|
2013-10-20 19:39:11 +02:00
|
|
|
except Errors.ConfigurationError as e:
|
2011-11-08 08:13:00 +01:00
|
|
|
self.env.revert()
|
2013-10-20 19:39:11 +02:00
|
|
|
exc = e
|
2011-11-08 08:13:00 +01:00
|
|
|
|
2013-10-20 19:39:11 +02:00
|
|
|
if exc is not None:
|
|
|
|
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=exc)
|
2013-03-12 14:10:12 +01:00
|
|
|
self.fatal('The configuration failed')
|
2011-11-08 08:13:00 +01:00
|
|
|
else:
|
2013-03-12 14:10:12 +01:00
|
|
|
self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
|
|
|
|
self.fatal('The configuration failed')
|
2011-11-08 08:13:00 +01:00
|
|
|
else:
|
|
|
|
self.start_msg('Checking for boost linkage')
|
|
|
|
try:
|
|
|
|
try_link()
|
|
|
|
except Errors.ConfigurationError as e:
|
2013-03-12 14:10:12 +01:00
|
|
|
self.end_msg("Could not link against boost libraries using supplied options")
|
|
|
|
self.fatal('The configuration failed')
|
2011-11-08 08:13:00 +01:00
|
|
|
self.end_msg('ok')
|
|
|
|
|
2014-07-06 16:35:52 +02:00
|
|
|
|
|
|
|
@feature('cxx')
|
|
|
|
@after_method('apply_link')
|
|
|
|
def install_boost(self):
|
|
|
|
if install_boost.done or not Utils.is_win32 or not self.bld.cmd.startswith('install'):
|
|
|
|
return
|
|
|
|
install_boost.done = True
|
|
|
|
inst_to = getattr(self, 'install_path', '${BINDIR}')
|
|
|
|
for lib in self.env.LIB_BOOST:
|
2014-07-06 17:30:14 +02:00
|
|
|
try:
|
|
|
|
file = self.bld.find_file(self.env.cxxshlib_PATTERN % lib, self.env.LIBPATH_BOOST)
|
|
|
|
self.bld.install_files(inst_to, self.bld.root.find_node(file))
|
|
|
|
except:
|
2014-07-06 16:35:52 +02:00
|
|
|
continue
|
|
|
|
install_boost.done = False
|