blob: 57066f0138bd6d12c75a8f6717499d77c49ce5b4 [file] [log] [blame]
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
Alexander Afanasyevfff47d62014-05-11 19:24:46 -07003from waflib import Utils
4
Alexander Afanasyeva1ae0a12014-01-28 15:21:02 -08005top = '..'
6
7def build(bld):
Alexander Afanasyev5560fd42018-03-07 17:03:03 -05008 # Single object tools:
9 # tools/example-tool.cpp is a self-contained tool with a main() function
10 # and is built as build/bin/example-tool.
11 # These tools cannot be unit-tested.
12 for tool in bld.path.ant_glob('*.cpp'):
13 name = tool.change_ext('').path_from(bld.path.get_bld())
Davide Pesavento19442812018-11-23 14:00:04 -050014 bld.program(name='tool-%s' % name,
Alexander Afanasyev5560fd42018-03-07 17:03:03 -050015 target='../bin/%s' % name,
16 source=[tool],
17 use='ndn-cxx')
Yingdi Yu8d7468f2014-02-21 14:49:45 -080018
Alexander Afanasyev5560fd42018-03-07 17:03:03 -050019 # Sub-directory tools:
20 # tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool.
21 # tools/example-tool/main.cpp must exist and must contain the main() function.
22 # All other objects are collected into 'tools-objects' and can be unit-tested.
23 testableObjects = []
24 for subdir in bld.path.ant_glob('*', dir=True, src=False):
25 mainFile = subdir.find_node('main.cpp')
26 if mainFile is None:
27 continue # not a C++ tool
Alexander Afanasyev28d0d942015-01-04 14:52:19 -080028
Alexander Afanasyev5560fd42018-03-07 17:03:03 -050029 name = subdir.path_from(bld.path)
30 srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
31 srcObjects = ''
32 if srcFiles:
Davide Pesavento19442812018-11-23 14:00:04 -050033 srcObjects = 'tool-%s-objects' % name
Alexander Afanasyev5560fd42018-03-07 17:03:03 -050034 bld.objects(target=srcObjects,
35 source=srcFiles,
36 use='ndn-cxx',
37 includes=name)
38 testableObjects.append(srcObjects)
39
Davide Pesavento19442812018-11-23 14:00:04 -050040 bld.program(name='tool-%s' % name,
Alexander Afanasyev5560fd42018-03-07 17:03:03 -050041 target='../bin/%s' % name,
42 source=[mainFile],
43 use='ndn-cxx ' + srcObjects,
44 includes=name)
45
46 bld.objects(target='tools-objects',
47 source=[],
48 export_includes='.',
49 use=testableObjects)
50
51 # Tool wrappers
52 wrapperFiles = bld.path.ant_glob('wrapper/*.sh')
Davide Pesavento19442812018-11-23 14:00:04 -050053 bld(name='tool-wrappers',
Alexander Afanasyev5560fd42018-03-07 17:03:03 -050054 features='subst',
55 source=wrapperFiles,
56 target=['../bin/%s' % node.change_ext('', '.sh').path_from(bld.path.find_dir('wrapper').get_bld())
57 for node in wrapperFiles],
58 install_path='${BINDIR}',
59 chmod=Utils.O755)