forked from mrzechonek/tut-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwscript
More file actions
130 lines (99 loc) · 4.64 KB
/
wscript
File metadata and controls
130 lines (99 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
APPNAME='tut'
VERSION='2016-04-01'
srcdir = '.'
blddir = 'build'
from waflib import Options, Scripting, Utils, Build
import glob
import os
def options(opt):
opt.load('compiler_cxx')
opt.load('tut gcov', tooldir='waftools')
gr = opt.add_option_group('build options')
gr.add_option('--debug', action='store_true', help='Build debug variant', default=False)
gr.add_option('--with-rtti', action='store_true', help='Enable RTTI (autodetect by default)', default=None)
gr.add_option('--without-rtti', action='store_false', dest='with_rtti')
gr.add_option('--with-seh', action='store_true', help='Build with SEH extensions for win32 (off by default)', default=False)
gr.add_option('--without-seh', action='store_false', dest='with_seh')
gr.add_option('--with-posix', action='store_true', help='Build with POSIX extensions (autodetect by default)', default=None)
gr.add_option('--without-posix', action='store_false', dest='with_posix')
def configure(cnf):
cnf.start_msg('Set installation prefix to')
cnf.end_msg(cnf.env.PREFIX)
cnf.load('compiler_cxx')
cnf.load('tut gcov', tooldir='waftools')
cnf.env.PLATFORM = Utils.unversioned_sys_platform()
if cnf.env.COMPILER_CXX == 'g++':
cnf.env.CPPFLAGS += [ '-O2', '-Wall', '-Wextra', '-Weffc++', '-ftemplate-depth-100' ]
if cnf.options.debug:
cnf.env.CPPFLAGS += [ '-O0', '-g' ]
if cnf.env.COMPILER_CXX == 'msvc':
if cnf.options.coverage:
raise WafError('Self-test coverage is not available under msvc, sorry!')
cnf.options.debug = True
cnf.env.CPPFLAGS += [ '/DNOMINMAX' ]
if cnf.options.with_posix is None:
cnf.options.with_posix = cnf.check_cxx(fragment='#include <unistd.h>\nint main() { fork(); }',
msg='Checking for fork()', mandatory=False)
if cnf.options.with_rtti is None:
cnf.options.with_rtti = cnf.check_cxx(fragment='#include <typeinfo>\nint main() { typeid(int).name(); }',
msg='Checking for typeid()', mandatory=False)
if cnf.options.with_posix:
cnf.define_cond('TUT_USE_POSIX', 1)
if cnf.options.with_seh:
cnf.define_cond('TUT_USE_SEH', 1)
if cnf.options.with_rtti:
cnf.define_cond('TUT_USE_RTTI', 1)
cnf.start_msg('Platform')
cnf.end_msg(Utils.unversioned_sys_platform())
def enabled_msg(msg, enabled):
cnf.start_msg(msg)
if enabled:
cnf.end_msg('enabled')
else:
cnf.end_msg('disabled', color='YELLOW')
enabled_msg('POSIX extensions', cnf.is_defined('TUT_USE_POSIX'))
enabled_msg('Win32 structured exception handling', cnf.is_defined('TUT_USE_SEH'))
enabled_msg('C++ run-time type identification', cnf.is_defined('TUT_USE_RTTI'))
cnf.write_config_header( os.path.join('include', 'tut', 'tut_config.hpp') )
def build(bld):
bld(features='cxx',
includes='include',
export_includes = 'include',
target='tut')
bld.install_files( os.path.join('${PREFIX}', 'include', 'tut'),
glob.glob(os.path.join('include', 'tut', '*.hpp')) )
bld.install_files( os.path.join('${PREFIX}', 'include', 'tut'),
bld.env[Build.CFG_FILES])
bld(features='cxx cprogram tut gcov',
target='self_test',
use='tut',
source=glob.glob('selftest/*.cpp'),
install_path=None)
def write_pkgconfig(task):
with open(task.outputs[0].abspath(), 'w') as f:
f.write(
'# tut.pc -- pkg-config data for Template Unit Test framework\n'
'prefix=%(prefix)s\n'
'INSTALL_BIN=${prefix}/bin\n'
'INSTALL_INC=${prefix}/include\n'
'INSTALL_LIB=${prefix}/lib\n'
'exec_prefix=${prefix}\n'
'libdir=${exec_prefix}/lib\n'
'includedir=${prefix}/include\n'
'Name: TUT\n'
'Description: Template Unit Test framework\n'
'Version: %(version)s\n'
'Requires:\n'
'Cflags: -I${includedir}\n' % dict(prefix=bld.options.destdir, version=VERSION))
bld(target='tut.pc',
rule=write_pkgconfig,
install_path=os.path.join('${PREFIX}', 'lib', 'pkgconfig'))
for example in ('simple', 'basic', 'shared_ptr', 'restartable'):
bld(features='cxx cprogram',
target='example_%s' % example,
use='tut',
source=glob.glob('examples/%s/*.cpp' % example),
install_path=None)
def test(tst):
Options.options.test = True
Scripting.run_command('build')