blob: 07de0e920f623c406af996f93a64329d503bc2e9 [file] [log] [blame]
Alexander Afanasyev2b57aeb2018-06-15 18:32:28 -04001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyev2b57aeb2018-06-15 18:32:28 -04003top = '..'
4
5def build(bld):
6 # Single object tools:
7 # tools/example-tool.cpp is a self-contained tool with a main() function
8 # and is built as build/bin/example-tool.
9 # These tools cannot be unit-tested.
10 for tool in bld.path.ant_glob('*.cpp'):
11 name = tool.change_ext('').path_from(bld.path.get_bld())
12 bld.program(name=name,
13 target='../bin/%s' % name,
14 source=[tool],
15 use='NDN_CXX libndn-nac')
16
17 # Sub-directory tools:
18 # tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool.
19 # tools/example-tool/main.cpp must exist and must contain the main() function.
20 # All other objects are collected into 'tools-objects' and can be unit-tested.
21 testableObjects = []
22 for subdir in bld.path.ant_glob('*', dir=True, src=False):
23 mainFile = subdir.find_node('main.cpp')
24 if mainFile is None:
25 continue # not a C++ tool
26
27 name = subdir.path_from(bld.path)
28 srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
29 srcObjects = ''
30 if srcFiles:
31 srcObjects = 'tools-%s-objects' % name
32 bld.objects(target=srcObjects,
33 source=srcFiles,
34 use='NDN_CXX libndn-nac',
35 includes=name)
36 testableObjects.append(srcObjects)
37
38 bld.program(name=name,
39 target='../bin/%s' % name,
40 source=[mainFile],
41 use='NDN_CXX libndn-nac ' + srcObjects,
42 includes=name)
43
44 bld.objects(target='tools-objects',
45 source=[],
46 export_includes='.',
47 use=testableObjects)