Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | from waflib import Utils, Context |
| 4 | |
| 5 | top = '..' |
| 6 | |
| 7 | def build(bld): |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 8 | TOOLS_DEPENDENCY = 'core-objects NDN_CXX BOOST LIBRESOLV' |
| 9 | |
| 10 | # Single object tools: |
| 11 | # tools/example-tool.cpp is a self-contained tool with a main() function |
| 12 | # and is built as build/bin/example-tool. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 13 | # These tools cannot be unit-tested. |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 14 | for i in bld.path.ant_glob(['*.cpp']): |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 15 | name = str(i)[:-len('.cpp')] |
| 16 | bld.program(target='../bin/%s' % name, |
| 17 | source=[i], |
| 18 | use=TOOLS_DEPENDENCY) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 19 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 20 | # Sub-directory tools: |
| 21 | # tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool. |
| 22 | # tools/example-tool/main.cpp must exist and must contain the main() function. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 23 | # All other objects are collected into 'tools-objects' and can be unit-tested. |
| 24 | testableObjects = [] |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 25 | for name in bld.path.ant_glob(['*'], dir=True, src=False): |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 26 | mainFile = bld.path.find_node(['%s/main.cpp' % name]) |
| 27 | if mainFile is None: |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 28 | continue # not a C++ tool |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 29 | srcFiles = bld.path.ant_glob(['%s/**/*.cpp' % name], excl=['%s/main.cpp' % name]) |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 30 | if srcFiles: |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 31 | srcObjects = 'tools-%s-objects' % name |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 32 | bld.objects(target=srcObjects, |
| 33 | source=srcFiles, |
| 34 | use=TOOLS_DEPENDENCY, |
| 35 | includes='%s' % name) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 36 | testableObjects.append(srcObjects) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 37 | else: |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 38 | srcObjects = '' |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 39 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 40 | bld.program(target='../bin/%s' % name, |
| 41 | source=[mainFile], |
| 42 | use=TOOLS_DEPENDENCY + ' ' + srcObjects, |
| 43 | includes='%s' % name) |
| 44 | |
| 45 | bld(target='tools-objects', |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 46 | export_includes='.', |
| 47 | use=testableObjects) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 48 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 49 | scripts = bld.path.ant_glob(['*.sh', '*.py']) |
| 50 | bld(features='subst', |
| 51 | name='scripts', |
| 52 | target=['../bin/%s' % node.change_ext('') for node in scripts], |
| 53 | source=scripts, |
| 54 | install_path='${BINDIR}', |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 55 | chmod=Utils.O755, |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 56 | VERSION=Context.g_module.VERSION) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 57 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame^] | 58 | bld.install_files('${DATAROOTDIR}/ndn', |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 59 | bld.path.ant_glob('nfd-status-http-server-files/*')) |