forked from jimporter/mettle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bfg
91 lines (77 loc) · 2.79 KB
/
build.bfg
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
# -*- python -*-
from os.path import splitext
bfg9000_required_version('>=0.2.0')
project('mettle', version='1.0pre')
if env.builder('c++').flavor == 'msvc':
global_options(['/EHsc'], lang='c++')
else:
global_options(['-pthread', '-std=c++14'], lang='c++')
if env.platform.name != 'darwin':
global_link_options(['-pthread'])
includes = header_directory('include', include='*.hpp')
boost = boost_package(version='>=1.55')
iostreams = boost_package('iostreams', version='>=1.55')
prog_opts = boost_package('program_options', version='>=1.55')
libmettle = shared_library(
'mettle',
files=find_files('src/libmettle', '*.cpp', extra='*.hpp'),
include=includes,
packages=[iostreams, prog_opts],
)
mettle_objs = object_files(
files=find_files('src/mettle', '*.cpp', extra='*.hpp'),
include=includes,
packages=boost,
)
mettle = executable(
'mettle',
files=mettle_objs,
libs=[libmettle],
packages=[iostreams, prog_opts],
)
install(mettle, libmettle, includes)
extra_files = {
'test/driver/test_test_file.cpp': ['src/mettle/test_file.cpp'],
'test/driver/test_run_test_files.cpp': [
'src/mettle/run_test_files.cpp', 'src/mettle/test_file.cpp'
] + find_files('src/mettle', 'run_test_file.cpp'),
}
extra_pkgs = {
'test/driver/test_cmd_line.cpp': [prog_opts],
'test/driver/test_test_file.cpp': [prog_opts],
'test/driver/test_run_test_files.cpp': [iostreams, prog_opts],
}
driver = test_driver(
mettle,
options=['--output=verbose'],
environment={'TEST_DATA': 'test_data'},
)
for src in find_files('test', '*.cpp', extra='*.hpp'):
test(executable(
splitext(src)[0],
files=[src] + [mettle_objs[i] for i in extra_files.get(src, [])],
include=includes,
libs=libmettle,
packages=[boost] + extra_pkgs.get(src, []),
), driver=driver)
test_data = alias('test-data', [
executable(splitext(src)[0], files=src, include=includes, libs=libmettle,
packages=boost)
for src in find_files('test_data', '*.cpp', extra='*.hpp')
])
test_deps(test_data)
header_only_examples = ['examples/test_02_header_only.cpp']
alias('examples', [
executable(splitext(src)[0], files=src, include=includes,
libs=None if src in header_only_examples else libmettle,
packages=boost)
for src in find_files('examples', '*.cpp', extra='*.hpp')
])
# XXX: Don't cd once MkDocs supports building from other dirs.
cd = ['cd', directory('.')]
command('doc', cmds=[cd, ['mkdocs', 'build', '--clean']])
command('doc-serve', cmds=[cd, ['mkdocs', 'serve', '--dev-addr=0.0.0.0:8000']])
command('doc-deploy', cmds=[cd, ['mkdocs', 'gh-deploy', '--clean']])
# Extra files to be packaged in the source dist.
extra_dist(files=['README.md', 'LICENSE', 'mkdocs.yml'],
dirs=['doc', 'scripts'])