This repository has been archived by the owner on Jan 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwscript
107 lines (85 loc) · 3.2 KB
/
wscript
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
VERSION='0.1'
APPNAME='carepo'
import waflib
def options(opt):
opt.load('compiler_c')
opt.load('ndnx', tooldir='.')
opt.load('cunit', tooldir='.')
opt.add_option('--optimize',action='store_true',default=False,dest='optimize',help='optimize object code')
opt.add_option('--unit',action='store_true',default=False,dest='unit',help='build unit tests')
opt.add_option('--markdown',action='store_true',default=False,dest='markdown',help='build Markdown into HTML')
opt.add_option('--ndnxsrc',type='string',default='',dest='ndnxsrc_dir',help='''path to NDNx source code''')
def configure(conf):
conf.load('compiler_c')
conf.load('ndnx', tooldir='.')
conf.load('cunit', tooldir='.')
conf.check_ndnx(path=conf.options.ndnx_dir)
conf.define('_GNU_SOURCE', 1)
conf.env.append_unique('CFLAGS', ['-Wall', '-Werror', '-Wpointer-arith', '-fPIC', '-Wstrict-prototypes', '-std=c99'])
if conf.options.optimize:
conf.env.append_unique('CFLAGS', ['-O3', '-g1'])
else:
conf.env.append_unique('CFLAGS', ['-O0', '-g3'])
if conf.options.unit:
conf.env.UNIT = 1
conf.check_cunit(path=conf.options.cunit_dir)
if conf.options.markdown:
conf.env.MARKDOWN = 1
conf.find_program('pandoc', var='PANDOC')
if conf.options.ndnxsrc_dir:
conf.env.ndnxsrc_dir = conf.options.ndnxsrc_dir
else:
conf.env.ndnxsrc_dir = '../ndnx'
def build(bld):
source_subdirs = ['rabin','segment']
bld.objects(target='objs',
source=bld.path.ant_glob([subdir+'/*.c' for subdir in source_subdirs], excl=['**/*_test*.c']),
includes='.',
export_includes='.',
use='NDNX',
)
bld.program(target='rabinseg',
source=bld.path.ant_glob(['command/rabinseg.c']),
use='objs',
install_path=None,
)
bld.program(target='caput',
source=bld.path.ant_glob(['command/caput.c']),
use='objs',
install_path=None,
)
bld.program(target='caget',
source=bld.path.ant_glob(['command/caget.c']),
use='objs',
install_path=None,
)
bld.program(target='car',
source=bld.path.ant_glob(['repo/*.c']),
includes=['.',bld.env.ndnxsrc_dir+'/csrc/'],
lib='ndnsync',
use='objs',
install_path=None,
)
if bld.env.UNIT:
bld.program(target='unittest',
source=bld.path.ant_glob([subdir+'/*_test*.c' for subdir in source_subdirs] + ['command/unittest.c']),
use='objs CUNIT',
install_path=None,
)
if bld.env.MARKDOWN:
waflib.TaskGen.declare_chain(name='markdown2html',
rule='${PANDOC} -f markdown -t html -o ${TGT} ${SRC}',
shell=False,
ext_in='.md',
ext_out='.htm',
reentrant=False,
install_path=None,
)
bld(source=bld.path.ant_glob(['**/*.md']))
def check(ctx):
unittest_node=ctx.root.find_node(waflib.Context.out_dir+'/unittest')
if unittest_node is None:
ctx.fatal('unittest is not built; configure with --unit and build')
else:
import subprocess
subprocess.call(unittest_node.abspath())