mirror of
https://gitlab.com/ita1024/waf.git
synced 2025-01-24 09:20:00 +01:00
use lists instead of tuples for constants and convert to unix format all .py files
This commit is contained in:
parent
48a8a30fd5
commit
c41ca4b821
@ -1,269 +1,267 @@
|
||||
#!/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
|
||||
|
||||
'''
|
||||
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
|
||||
|
||||
The wscript will look like:
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx boost')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx boost')
|
||||
conf.check_boost(lib='system filesystem', mt=True, static=True)
|
||||
|
||||
def build(bld):
|
||||
bld(source='main.cpp', target='app', use='BOOST')
|
||||
'''
|
||||
|
||||
import sys
|
||||
import re
|
||||
from waflib import Utils, Logs
|
||||
from waflib.Configure import conf
|
||||
|
||||
BOOST_LIBS = ('/usr/lib', '/usr/local/lib',
|
||||
'/opt/local/lib', '/sw/lib', '/lib')
|
||||
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; }
|
||||
'''
|
||||
|
||||
# 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',
|
||||
help='''path to the boost directory where the includes are
|
||||
e.g. /boost_1_45_0/include''')
|
||||
opt.add_option('--boost-libs', type='string',
|
||||
default='', dest='boost_libs',
|
||||
help='''path to the directory where the boost libs are
|
||||
e.g. /boost_1_45_0/stage/lib''')
|
||||
opt.add_option('--boost-static', action='store_true',
|
||||
default=False, dest='boost_static',
|
||||
help='link static libraries')
|
||||
opt.add_option('--boost-mt', action='store_true',
|
||||
default=False, dest='boost_mt',
|
||||
help='select multi-threaded libraries')
|
||||
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
|
||||
help='''select libraries with tags (dgsyp, d for debug),
|
||||
see doc Boost, Getting Started, chapter 6.1''')
|
||||
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
|
||||
def __boost_get_version_file(self, dir):
|
||||
try:
|
||||
return self.root.find_dir(dir).find_node(BOOST_VERSION_FILE)
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
@conf
|
||||
def boost_get_version(self, dir):
|
||||
"""silently retrieve the boost version number"""
|
||||
re_but = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.*)"$', re.M)
|
||||
try:
|
||||
val = re_but.search(self.__boost_get_version_file(dir).read()).group(1)
|
||||
except:
|
||||
val = self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[dir],
|
||||
execute=True, define_ret=True)
|
||||
return val
|
||||
|
||||
|
||||
@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
|
||||
for dir in BOOST_INCLUDES:
|
||||
if self.__boost_get_version_file(dir):
|
||||
return dir
|
||||
if includes:
|
||||
self.fatal('headers not found in %s' % includes)
|
||||
else:
|
||||
self.fatal('headers not found, use --boost-includes=/path/to/boost')
|
||||
|
||||
|
||||
@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:
|
||||
for dir in BOOST_LIBS:
|
||||
try:
|
||||
path = self.root.find_dir(dir)
|
||||
files = path.ant_glob('*boost_*')
|
||||
if files:
|
||||
break
|
||||
path = self.root.find_dir(dir + '64')
|
||||
files = path.ant_glob('*boost_*')
|
||||
if files:
|
||||
break
|
||||
except:
|
||||
path = None
|
||||
if not path:
|
||||
if libs:
|
||||
self.fatal('libs not found in %s' % libs)
|
||||
else:
|
||||
self.fatal('libs not found, \
|
||||
use --boost-includes=/path/to/boost/lib')
|
||||
return path, files
|
||||
|
||||
|
||||
@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)
|
||||
t = []
|
||||
if kw.get('mt', False):
|
||||
t.append('mt')
|
||||
if kw.get('abi', None):
|
||||
t.append(kw['abi'])
|
||||
tags = t and '(-%s)+' % '-'.join(t) or ''
|
||||
toolset = '(-%s[0-9]{0,3})+' % self.boost_get_toolset(kw.get('toolset', ''))
|
||||
version = '(-%s)+' % self.env.BOOST_VERSION
|
||||
|
||||
def find_lib(re_lib, files):
|
||||
for file in files:
|
||||
if re_lib.search(file.name):
|
||||
return file
|
||||
return None
|
||||
|
||||
def format_lib_name(name):
|
||||
if name.startswith('lib'):
|
||||
name = name[3:]
|
||||
return name.split('.')[0]
|
||||
|
||||
libs = []
|
||||
for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
|
||||
py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
|
||||
# Trying libraries, from most strict match to least one
|
||||
for pattern in ['boost_%s%s%s%s%s' % (lib, toolset, tags, py, version),
|
||||
'boost_%s%s%s%s' % (lib, tags, py, version),
|
||||
'boost_%s%s%s' % (lib, tags, version),
|
||||
# Give up trying to find the right version
|
||||
'boost_%s%s%s%s' % (lib, toolset, tags, py),
|
||||
'boost_%s%s%s' % (lib, tags, py),
|
||||
'boost_%s%s' % (lib, tags)]:
|
||||
file = find_lib(re.compile(pattern), files)
|
||||
if file:
|
||||
libs.append(format_lib_name(file.name))
|
||||
break
|
||||
else:
|
||||
self.fatal('lib %s not found in %s' % (lib, path))
|
||||
|
||||
return path.abspath(), libs
|
||||
|
||||
|
||||
@conf
|
||||
def check_boost(self, *k, **kw):
|
||||
"""
|
||||
initialize boost
|
||||
|
||||
You can pass the same parameters as the command line (without "--boost-"),
|
||||
but the command line has the priority.
|
||||
"""
|
||||
if not self.env['CXX']:
|
||||
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
|
||||
|
||||
params = {'lib': k and k[0] or kw.get('lib', None)}
|
||||
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')
|
||||
self.env['INCLUDES_%s' % var] = self.boost_get_includes(**params)
|
||||
self.env.BOOST_VERSION = self.boost_get_version(self.env['INCLUDES_%s' % var])
|
||||
self.end_msg(self.env.BOOST_VERSION)
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
|
||||
|
||||
if not params['lib']:
|
||||
return
|
||||
self.start_msg('Checking boost libs')
|
||||
suffix = params.get('static', 'ST') or ''
|
||||
path, libs = self.boost_get_libs(**params)
|
||||
self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
|
||||
self.env['%sLIB_%s' % (suffix, var)] = libs
|
||||
self.end_msg('ok')
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % path)
|
||||
Logs.pprint('CYAN', ' libs : %s' % libs)
|
||||
|
||||
#!/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
|
||||
|
||||
'''
|
||||
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
|
||||
|
||||
The wscript will look like:
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx boost')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx boost')
|
||||
conf.check_boost(lib='system filesystem', mt=True, static=True)
|
||||
|
||||
def build(bld):
|
||||
bld(source='main.cpp', target='app', use='BOOST')
|
||||
'''
|
||||
|
||||
import sys
|
||||
import re
|
||||
from waflib import Utils, Logs
|
||||
from waflib.Configure import conf
|
||||
|
||||
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
|
||||
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; }
|
||||
'''
|
||||
|
||||
# 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',
|
||||
help='''path to the boost directory where the includes are
|
||||
e.g. /boost_1_45_0/include''')
|
||||
opt.add_option('--boost-libs', type='string',
|
||||
default='', dest='boost_libs',
|
||||
help='''path to the directory where the boost libs are
|
||||
e.g. /boost_1_45_0/stage/lib''')
|
||||
opt.add_option('--boost-static', action='store_true',
|
||||
default=False, dest='boost_static',
|
||||
help='link static libraries')
|
||||
opt.add_option('--boost-mt', action='store_true',
|
||||
default=False, dest='boost_mt',
|
||||
help='select multi-threaded libraries')
|
||||
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
|
||||
help='''select libraries with tags (dgsyp, d for debug),
|
||||
see doc Boost, Getting Started, chapter 6.1''')
|
||||
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
|
||||
def __boost_get_version_file(self, dir):
|
||||
try:
|
||||
return self.root.find_dir(dir).find_node(BOOST_VERSION_FILE)
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
@conf
|
||||
def boost_get_version(self, dir):
|
||||
"""silently retrieve the boost version number"""
|
||||
re_but = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.*)"$', re.M)
|
||||
try:
|
||||
val = re_but.search(self.__boost_get_version_file(dir).read()).group(1)
|
||||
except:
|
||||
val = self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[dir],
|
||||
execute=True, define_ret=True)
|
||||
return val
|
||||
|
||||
|
||||
@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
|
||||
for dir in BOOST_INCLUDES:
|
||||
if self.__boost_get_version_file(dir):
|
||||
return dir
|
||||
if includes:
|
||||
self.fatal('headers not found in %s' % includes)
|
||||
else:
|
||||
self.fatal('headers not found, use --boost-includes=/path/to/boost')
|
||||
|
||||
|
||||
@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:
|
||||
for dir in BOOST_LIBS:
|
||||
try:
|
||||
path = self.root.find_dir(dir)
|
||||
files = path.ant_glob('*boost_*')
|
||||
if files:
|
||||
break
|
||||
path = self.root.find_dir(dir + '64')
|
||||
files = path.ant_glob('*boost_*')
|
||||
if files:
|
||||
break
|
||||
except:
|
||||
path = None
|
||||
if not path:
|
||||
if libs:
|
||||
self.fatal('libs not found in %s' % libs)
|
||||
else:
|
||||
self.fatal('libs not found, \
|
||||
use --boost-includes=/path/to/boost/lib')
|
||||
return path, files
|
||||
|
||||
|
||||
@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)
|
||||
t = []
|
||||
if kw.get('mt', False):
|
||||
t.append('mt')
|
||||
if kw.get('abi', None):
|
||||
t.append(kw['abi'])
|
||||
tags = t and '(-%s)+' % '-'.join(t) or ''
|
||||
toolset = '(-%s[0-9]{0,3})+' % self.boost_get_toolset(kw.get('toolset', ''))
|
||||
version = '(-%s)+' % self.env.BOOST_VERSION
|
||||
|
||||
def find_lib(re_lib, files):
|
||||
for file in files:
|
||||
if re_lib.search(file.name):
|
||||
return file
|
||||
return None
|
||||
|
||||
def format_lib_name(name):
|
||||
if name.startswith('lib'):
|
||||
name = name[3:]
|
||||
return name.split('.')[0]
|
||||
|
||||
libs = []
|
||||
for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
|
||||
py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
|
||||
# Trying libraries, from most strict match to least one
|
||||
for pattern in ['boost_%s%s%s%s%s' % (lib, toolset, tags, py, version),
|
||||
'boost_%s%s%s%s' % (lib, tags, py, version),
|
||||
'boost_%s%s%s' % (lib, tags, version),
|
||||
# Give up trying to find the right version
|
||||
'boost_%s%s%s%s' % (lib, toolset, tags, py),
|
||||
'boost_%s%s%s' % (lib, tags, py),
|
||||
'boost_%s%s' % (lib, tags)]:
|
||||
file = find_lib(re.compile(pattern), files)
|
||||
if file:
|
||||
libs.append(format_lib_name(file.name))
|
||||
break
|
||||
else:
|
||||
self.fatal('lib %s not found in %s' % (lib, path))
|
||||
|
||||
return path.abspath(), libs
|
||||
|
||||
|
||||
@conf
|
||||
def check_boost(self, *k, **kw):
|
||||
"""
|
||||
initialize boost
|
||||
|
||||
You can pass the same parameters as the command line (without "--boost-"),
|
||||
but the command line has the priority.
|
||||
"""
|
||||
if not self.env['CXX']:
|
||||
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
|
||||
|
||||
params = {'lib': k and k[0] or kw.get('lib', None)}
|
||||
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')
|
||||
self.env['INCLUDES_%s' % var] = self.boost_get_includes(**params)
|
||||
self.env.BOOST_VERSION = self.boost_get_version(self.env['INCLUDES_%s' % var])
|
||||
self.end_msg(self.env.BOOST_VERSION)
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
|
||||
|
||||
if not params['lib']:
|
||||
return
|
||||
self.start_msg('Checking boost libs')
|
||||
suffix = params.get('static', 'ST') or ''
|
||||
path, libs = self.boost_get_libs(**params)
|
||||
self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
|
||||
self.env['%sLIB_%s' % (suffix, var)] = libs
|
||||
self.end_msg('ok')
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % path)
|
||||
Logs.pprint('CYAN', ' libs : %s' % libs)
|
||||
|
||||
|
@ -1,74 +1,74 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
#
|
||||
# written by Sylvain Rouquette, 2011
|
||||
|
||||
'''
|
||||
To add the freeimage tool to the waf file:
|
||||
$ ./waf-light --tools=compat15,freeimage
|
||||
or, if you have waf >= 1.6.2
|
||||
$ ./waf update --files=freeimage
|
||||
|
||||
The wscript will look like:
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx freeimage')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx freeimage')
|
||||
|
||||
# you can call check_freeimage with some parameters.
|
||||
# It's optional on Linux, it's 'mandatory' on Windows if
|
||||
# you didn't use --fi-path on the command-line
|
||||
|
||||
# conf.check_freeimage(path='FreeImage/Dist', fip=True)
|
||||
|
||||
def build(bld):
|
||||
bld(source='main.cpp', target='app', use='FREEIMAGE')
|
||||
'''
|
||||
|
||||
from waflib import Utils
|
||||
from waflib.Configure import conf
|
||||
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--fi-path', type='string', default='', dest='fi_path',
|
||||
help='''path to the FreeImage directory \
|
||||
where the files are e.g. /FreeImage/Dist''')
|
||||
opt.add_option('--fip', action='store_true', default=False, dest='fip',
|
||||
help='link with FreeImagePlus')
|
||||
opt.add_option('--fi-static', action='store_true',
|
||||
default=False, dest='fi_static',
|
||||
help="link as shared libraries")
|
||||
|
||||
|
||||
@conf
|
||||
def check_freeimage(self, path=None, fip=False):
|
||||
self.start_msg('Checking FreeImage')
|
||||
if not self.env['CXX']:
|
||||
self.fatal('you must load compiler_cxx before loading freeimage')
|
||||
prefix = self.options.fi_static and 'ST' or ''
|
||||
platform = Utils.unversioned_sys_platform()
|
||||
if platform == 'win32':
|
||||
if not path:
|
||||
self.fatal('you must specify the path to FreeImage. \
|
||||
use --fi-path=/FreeImage/Dist')
|
||||
else:
|
||||
self.env['INCLUDES_FREEIMAGE'] = path
|
||||
self.env['%sLIBPATH_FREEIMAGE' % prefix] = path
|
||||
libs = ['FreeImage']
|
||||
if self.options.fip:
|
||||
libs.append('FreeImagePlus')
|
||||
if platform == 'win32':
|
||||
self.env['%sLIB_FREEIMAGE' % prefix] = libs
|
||||
else:
|
||||
self.env['%sLIB_FREEIMAGE' % prefix] = [i.lower() for i in libs]
|
||||
self.end_msg('ok')
|
||||
|
||||
|
||||
def configure(conf):
|
||||
platform = Utils.unversioned_sys_platform()
|
||||
if platform == 'win32' and not conf.options.fi_path:
|
||||
return
|
||||
conf.check_freeimage(conf.options.fi_path, conf.options.fip)
|
||||
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
#
|
||||
# written by Sylvain Rouquette, 2011
|
||||
|
||||
'''
|
||||
To add the freeimage tool to the waf file:
|
||||
$ ./waf-light --tools=compat15,freeimage
|
||||
or, if you have waf >= 1.6.2
|
||||
$ ./waf update --files=freeimage
|
||||
|
||||
The wscript will look like:
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx freeimage')
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx freeimage')
|
||||
|
||||
# you can call check_freeimage with some parameters.
|
||||
# It's optional on Linux, it's 'mandatory' on Windows if
|
||||
# you didn't use --fi-path on the command-line
|
||||
|
||||
# conf.check_freeimage(path='FreeImage/Dist', fip=True)
|
||||
|
||||
def build(bld):
|
||||
bld(source='main.cpp', target='app', use='FREEIMAGE')
|
||||
'''
|
||||
|
||||
from waflib import Utils
|
||||
from waflib.Configure import conf
|
||||
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--fi-path', type='string', default='', dest='fi_path',
|
||||
help='''path to the FreeImage directory \
|
||||
where the files are e.g. /FreeImage/Dist''')
|
||||
opt.add_option('--fip', action='store_true', default=False, dest='fip',
|
||||
help='link with FreeImagePlus')
|
||||
opt.add_option('--fi-static', action='store_true',
|
||||
default=False, dest='fi_static',
|
||||
help="link as shared libraries")
|
||||
|
||||
|
||||
@conf
|
||||
def check_freeimage(self, path=None, fip=False):
|
||||
self.start_msg('Checking FreeImage')
|
||||
if not self.env['CXX']:
|
||||
self.fatal('you must load compiler_cxx before loading freeimage')
|
||||
prefix = self.options.fi_static and 'ST' or ''
|
||||
platform = Utils.unversioned_sys_platform()
|
||||
if platform == 'win32':
|
||||
if not path:
|
||||
self.fatal('you must specify the path to FreeImage. \
|
||||
use --fi-path=/FreeImage/Dist')
|
||||
else:
|
||||
self.env['INCLUDES_FREEIMAGE'] = path
|
||||
self.env['%sLIBPATH_FREEIMAGE' % prefix] = path
|
||||
libs = ['FreeImage']
|
||||
if self.options.fip:
|
||||
libs.append('FreeImagePlus')
|
||||
if platform == 'win32':
|
||||
self.env['%sLIB_FREEIMAGE' % prefix] = libs
|
||||
else:
|
||||
self.env['%sLIB_FREEIMAGE' % prefix] = [i.lower() for i in libs]
|
||||
self.end_msg('ok')
|
||||
|
||||
|
||||
def configure(conf):
|
||||
platform = Utils.unversioned_sys_platform()
|
||||
if platform == 'win32' and not conf.options.fi_path:
|
||||
return
|
||||
conf.check_freeimage(conf.options.fi_path, conf.options.fip)
|
||||
|
||||
|
@ -1,106 +1,106 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
#
|
||||
# written by Sylvain Rouquette, 2011
|
||||
|
||||
'''
|
||||
Install pep8 module:
|
||||
$ easy_install pep8
|
||||
or
|
||||
$ pip install pep8
|
||||
|
||||
To add the boost tool to the waf file:
|
||||
$ ./waf-light --tools=compat15,pep8
|
||||
or, if you have waf >= 1.6.2
|
||||
$ ./waf update --files=pep8
|
||||
|
||||
|
||||
Then add this to your wscript:
|
||||
|
||||
[at]extension('.py', 'wscript')
|
||||
def run_pep8(self, node):
|
||||
self.create_task('Pep8', node)
|
||||
|
||||
'''
|
||||
|
||||
import threading
|
||||
from waflib import TaskGen, Task, Options
|
||||
|
||||
pep8 = __import__('pep8')
|
||||
|
||||
|
||||
class Pep8(Task.Task):
|
||||
color = 'PINK'
|
||||
lock = threading.Lock()
|
||||
|
||||
def check_options(self):
|
||||
if pep8.options:
|
||||
return
|
||||
pep8.options = Options.options
|
||||
pep8.options.prog = 'pep8'
|
||||
excl = pep8.options.exclude.split(',')
|
||||
pep8.options.exclude = [s.rstrip('/') for s in excl]
|
||||
if pep8.options.filename:
|
||||
pep8.options.filename = pep8.options.filename.split(',')
|
||||
if pep8.options.select:
|
||||
pep8.options.select = pep8.options.select.split(',')
|
||||
else:
|
||||
pep8.options.select = []
|
||||
if pep8.options.ignore:
|
||||
pep8.options.ignore = pep8.options.ignore.split(',')
|
||||
elif pep8.options.select:
|
||||
# Ignore all checks which are not explicitly selected
|
||||
pep8.options.ignore = ['']
|
||||
elif pep8.options.testsuite or pep8.options.doctest:
|
||||
# For doctest and testsuite, all checks are required
|
||||
pep8.options.ignore = []
|
||||
else:
|
||||
# The default choice: ignore controversial checks
|
||||
pep8.options.ignore = pep8.DEFAULT_IGNORE.split(',')
|
||||
pep8.options.physical_checks = pep8.find_checks('physical_line')
|
||||
pep8.options.logical_checks = pep8.find_checks('logical_line')
|
||||
pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
|
||||
pep8.options.messages = {}
|
||||
|
||||
def run(self):
|
||||
with Pep8.lock:
|
||||
self.check_options()
|
||||
pep8.input_file(self.inputs[0].abspath())
|
||||
return 0 if not pep8.get_count() else -1
|
||||
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('-q', '--quiet', default=0, action='count',
|
||||
help="report only file names, or nothing with -qq")
|
||||
opt.add_option('-r', '--repeat', action='store_true',
|
||||
help="show all occurrences of the same error")
|
||||
opt.add_option('--exclude', metavar='patterns',
|
||||
default=pep8.DEFAULT_EXCLUDE,
|
||||
help="exclude files or directories which match these "
|
||||
"comma separated patterns (default: %s)" %
|
||||
pep8.DEFAULT_EXCLUDE,
|
||||
dest='exclude')
|
||||
opt.add_option('--filename', metavar='patterns', default='*.py',
|
||||
help="when parsing directories, only check filenames "
|
||||
"matching these comma separated patterns (default: "
|
||||
"*.py)")
|
||||
opt.add_option('--select', metavar='errors', default='',
|
||||
help="select errors and warnings (e.g. E,W6)")
|
||||
opt.add_option('--ignore', metavar='errors', default='',
|
||||
help="skip errors and warnings (e.g. E4,W)")
|
||||
opt.add_option('--show-source', action='store_true',
|
||||
help="show source code for each error")
|
||||
opt.add_option('--show-pep8', action='store_true',
|
||||
help="show text of PEP 8 for each error")
|
||||
opt.add_option('--statistics', action='store_true',
|
||||
help="count errors and warnings")
|
||||
opt.add_option('--count', action='store_true',
|
||||
help="print total number of errors and warnings "
|
||||
"to standard error and set exit code to 1 if "
|
||||
"total is not null")
|
||||
opt.add_option('--benchmark', action='store_true',
|
||||
help="measure processing speed")
|
||||
opt.add_option('--testsuite', metavar='dir',
|
||||
help="run regression tests from dir")
|
||||
opt.add_option('--doctest', action='store_true',
|
||||
help="run doctest on myself")
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
#
|
||||
# written by Sylvain Rouquette, 2011
|
||||
|
||||
'''
|
||||
Install pep8 module:
|
||||
$ easy_install pep8
|
||||
or
|
||||
$ pip install pep8
|
||||
|
||||
To add the boost tool to the waf file:
|
||||
$ ./waf-light --tools=compat15,pep8
|
||||
or, if you have waf >= 1.6.2
|
||||
$ ./waf update --files=pep8
|
||||
|
||||
|
||||
Then add this to your wscript:
|
||||
|
||||
[at]extension('.py', 'wscript')
|
||||
def run_pep8(self, node):
|
||||
self.create_task('Pep8', node)
|
||||
|
||||
'''
|
||||
|
||||
import threading
|
||||
from waflib import TaskGen, Task, Options
|
||||
|
||||
pep8 = __import__('pep8')
|
||||
|
||||
|
||||
class Pep8(Task.Task):
|
||||
color = 'PINK'
|
||||
lock = threading.Lock()
|
||||
|
||||
def check_options(self):
|
||||
if pep8.options:
|
||||
return
|
||||
pep8.options = Options.options
|
||||
pep8.options.prog = 'pep8'
|
||||
excl = pep8.options.exclude.split(',')
|
||||
pep8.options.exclude = [s.rstrip('/') for s in excl]
|
||||
if pep8.options.filename:
|
||||
pep8.options.filename = pep8.options.filename.split(',')
|
||||
if pep8.options.select:
|
||||
pep8.options.select = pep8.options.select.split(',')
|
||||
else:
|
||||
pep8.options.select = []
|
||||
if pep8.options.ignore:
|
||||
pep8.options.ignore = pep8.options.ignore.split(',')
|
||||
elif pep8.options.select:
|
||||
# Ignore all checks which are not explicitly selected
|
||||
pep8.options.ignore = ['']
|
||||
elif pep8.options.testsuite or pep8.options.doctest:
|
||||
# For doctest and testsuite, all checks are required
|
||||
pep8.options.ignore = []
|
||||
else:
|
||||
# The default choice: ignore controversial checks
|
||||
pep8.options.ignore = pep8.DEFAULT_IGNORE.split(',')
|
||||
pep8.options.physical_checks = pep8.find_checks('physical_line')
|
||||
pep8.options.logical_checks = pep8.find_checks('logical_line')
|
||||
pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
|
||||
pep8.options.messages = {}
|
||||
|
||||
def run(self):
|
||||
with Pep8.lock:
|
||||
self.check_options()
|
||||
pep8.input_file(self.inputs[0].abspath())
|
||||
return 0 if not pep8.get_count() else -1
|
||||
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('-q', '--quiet', default=0, action='count',
|
||||
help="report only file names, or nothing with -qq")
|
||||
opt.add_option('-r', '--repeat', action='store_true',
|
||||
help="show all occurrences of the same error")
|
||||
opt.add_option('--exclude', metavar='patterns',
|
||||
default=pep8.DEFAULT_EXCLUDE,
|
||||
help="exclude files or directories which match these "
|
||||
"comma separated patterns (default: %s)" %
|
||||
pep8.DEFAULT_EXCLUDE,
|
||||
dest='exclude')
|
||||
opt.add_option('--filename', metavar='patterns', default='*.py',
|
||||
help="when parsing directories, only check filenames "
|
||||
"matching these comma separated patterns (default: "
|
||||
"*.py)")
|
||||
opt.add_option('--select', metavar='errors', default='',
|
||||
help="select errors and warnings (e.g. E,W6)")
|
||||
opt.add_option('--ignore', metavar='errors', default='',
|
||||
help="skip errors and warnings (e.g. E4,W)")
|
||||
opt.add_option('--show-source', action='store_true',
|
||||
help="show source code for each error")
|
||||
opt.add_option('--show-pep8', action='store_true',
|
||||
help="show text of PEP 8 for each error")
|
||||
opt.add_option('--statistics', action='store_true',
|
||||
help="count errors and warnings")
|
||||
opt.add_option('--count', action='store_true',
|
||||
help="print total number of errors and warnings "
|
||||
"to standard error and set exit code to 1 if "
|
||||
"total is not null")
|
||||
opt.add_option('--benchmark', action='store_true',
|
||||
help="measure processing speed")
|
||||
opt.add_option('--testsuite', metavar='dir',
|
||||
help="run regression tests from dir")
|
||||
opt.add_option('--doctest', action='store_true',
|
||||
help="run doctest on myself")
|
||||
|
@ -1,71 +1,71 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
this tool supports the export_symbols_regex to export the symbols in a shared library.
|
||||
by default, all symbols are exported by gcc, and nothing by msvc.
|
||||
to use the tool, do something like:
|
||||
|
||||
def build(ctx):
|
||||
ctx(features='c cshlib syms', source='a.c b.c', export_symbols_regex='mylib_.*', target='testlib')
|
||||
|
||||
only the symbols starting with 'mylib_' will be exported.
|
||||
"""
|
||||
|
||||
import re
|
||||
from waflib.Context import STDOUT
|
||||
from waflib.Task import Task
|
||||
from waflib.Errors import WafError
|
||||
from waflib.TaskGen import feature, after_method
|
||||
|
||||
class gen_sym(Task):
|
||||
def run(self):
|
||||
obj = self.inputs[0]
|
||||
if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME):
|
||||
re_nm = re.compile(r'External\s+\|\s+_(' + self.generator.export_symbols_regex + r')\b')
|
||||
cmd = ['dumpbin', '/symbols', obj.abspath()]
|
||||
else:
|
||||
if self.env.DEST_BINFMT == 'pe': #gcc uses nm, and has a preceding _ on windows
|
||||
re_nm = re.compile(r'T\s+_(' + self.generator.export_symbols_regex + r')\b')
|
||||
else:
|
||||
re_nm = re.compile(r'T\s+(' + self.generator.export_symbols_regex + r')\b')
|
||||
cmd = ['nm', '-g', obj.abspath()]
|
||||
syms = re_nm.findall(self.generator.bld.cmd_and_log(cmd, quiet=STDOUT))
|
||||
self.outputs[0].write('%r' % syms)
|
||||
|
||||
class compile_sym(Task):
|
||||
def run(self):
|
||||
syms = {}
|
||||
for x in self.inputs:
|
||||
slist = eval(x.read())
|
||||
for s in slist:
|
||||
syms[s] = 1
|
||||
lsyms = syms.keys()
|
||||
lsyms.sort()
|
||||
if self.env.DEST_BINFMT == 'pe':
|
||||
self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms))
|
||||
elif self.env.DEST_BINFMT == 'elf':
|
||||
self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n")
|
||||
else:
|
||||
raise WafError('NotImplemented')
|
||||
|
||||
@feature('syms')
|
||||
@after_method('process_source', 'process_use', 'apply_link', 'process_uselib_local')
|
||||
def do_the_symbol_stuff(self):
|
||||
ins = [x.outputs[0] for x in self.compiled_tasks]
|
||||
self.gen_sym_tasks = [self.create_task('gen_sym', x, x.change_ext('.%d.sym' % self.idx)) for x in ins]
|
||||
|
||||
tsk = self.create_task('compile_sym',
|
||||
[x.outputs[0] for x in self.gen_sym_tasks],
|
||||
self.path.find_or_declare(getattr(self, 'sym_filename', self.target + '.def')))
|
||||
self.link_task.set_run_after(tsk)
|
||||
self.link_task.dep_nodes = [tsk.outputs[0]]
|
||||
if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME):
|
||||
self.link_task.env.append_value('LINKFLAGS', ['/def:' + tsk.outputs[0].bldpath()])
|
||||
elif self.env.DEST_BINFMT == 'pe': #gcc on windows takes *.def as an additional input
|
||||
self.link_task.inputs.append(tsk.outputs[0])
|
||||
elif self.env.DEST_BINFMT == 'elf':
|
||||
self.link_task.env.append_value('LINKFLAGS', ['-Wl,-version-script', '-Wl,' + tsk.outputs[0].bldpath()])
|
||||
else:
|
||||
raise WafError('NotImplemented')
|
||||
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""
|
||||
this tool supports the export_symbols_regex to export the symbols in a shared library.
|
||||
by default, all symbols are exported by gcc, and nothing by msvc.
|
||||
to use the tool, do something like:
|
||||
|
||||
def build(ctx):
|
||||
ctx(features='c cshlib syms', source='a.c b.c', export_symbols_regex='mylib_.*', target='testlib')
|
||||
|
||||
only the symbols starting with 'mylib_' will be exported.
|
||||
"""
|
||||
|
||||
import re
|
||||
from waflib.Context import STDOUT
|
||||
from waflib.Task import Task
|
||||
from waflib.Errors import WafError
|
||||
from waflib.TaskGen import feature, after_method
|
||||
|
||||
class gen_sym(Task):
|
||||
def run(self):
|
||||
obj = self.inputs[0]
|
||||
if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME):
|
||||
re_nm = re.compile(r'External\s+\|\s+_(' + self.generator.export_symbols_regex + r')\b')
|
||||
cmd = ['dumpbin', '/symbols', obj.abspath()]
|
||||
else:
|
||||
if self.env.DEST_BINFMT == 'pe': #gcc uses nm, and has a preceding _ on windows
|
||||
re_nm = re.compile(r'T\s+_(' + self.generator.export_symbols_regex + r')\b')
|
||||
else:
|
||||
re_nm = re.compile(r'T\s+(' + self.generator.export_symbols_regex + r')\b')
|
||||
cmd = ['nm', '-g', obj.abspath()]
|
||||
syms = re_nm.findall(self.generator.bld.cmd_and_log(cmd, quiet=STDOUT))
|
||||
self.outputs[0].write('%r' % syms)
|
||||
|
||||
class compile_sym(Task):
|
||||
def run(self):
|
||||
syms = {}
|
||||
for x in self.inputs:
|
||||
slist = eval(x.read())
|
||||
for s in slist:
|
||||
syms[s] = 1
|
||||
lsyms = syms.keys()
|
||||
lsyms.sort()
|
||||
if self.env.DEST_BINFMT == 'pe':
|
||||
self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms))
|
||||
elif self.env.DEST_BINFMT == 'elf':
|
||||
self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n")
|
||||
else:
|
||||
raise WafError('NotImplemented')
|
||||
|
||||
@feature('syms')
|
||||
@after_method('process_source', 'process_use', 'apply_link', 'process_uselib_local')
|
||||
def do_the_symbol_stuff(self):
|
||||
ins = [x.outputs[0] for x in self.compiled_tasks]
|
||||
self.gen_sym_tasks = [self.create_task('gen_sym', x, x.change_ext('.%d.sym' % self.idx)) for x in ins]
|
||||
|
||||
tsk = self.create_task('compile_sym',
|
||||
[x.outputs[0] for x in self.gen_sym_tasks],
|
||||
self.path.find_or_declare(getattr(self, 'sym_filename', self.target + '.def')))
|
||||
self.link_task.set_run_after(tsk)
|
||||
self.link_task.dep_nodes = [tsk.outputs[0]]
|
||||
if 'msvc' in (self.env.CC_NAME, self.env.CXX_NAME):
|
||||
self.link_task.env.append_value('LINKFLAGS', ['/def:' + tsk.outputs[0].bldpath()])
|
||||
elif self.env.DEST_BINFMT == 'pe': #gcc on windows takes *.def as an additional input
|
||||
self.link_task.inputs.append(tsk.outputs[0])
|
||||
elif self.env.DEST_BINFMT == 'elf':
|
||||
self.link_task.env.append_value('LINKFLAGS', ['-Wl,-version-script', '-Wl,' + tsk.outputs[0].bldpath()])
|
||||
else:
|
||||
raise WafError('NotImplemented')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user