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 | |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 7 | TOOLS_DEPENDENCY = 'core-objects NDN_CXX BOOST LIBRESOLV' |
| 8 | |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 9 | def build(bld): |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 10 | # single object tools |
| 11 | # tools/example-tool.cpp should a self-contained tool with a main function |
| 12 | # and it's built into build/bin/example-tool. |
| 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']): |
| 15 | name = str(i)[:-len(".cpp")] |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 16 | bld(features='cxx cxxprogram', |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 17 | target="../bin/%s" % name, |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 18 | source=[i], |
| 19 | use=TOOLS_DEPENDENCY |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 20 | ) |
| 21 | |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 22 | |
| 23 | # sub-directory tools |
| 24 | # tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool |
| 25 | # tools/example-tool/main.cpp must exist and it should contain the main function. |
| 26 | # All other objects are collected into 'tools-objects' and can be unit-tested. |
| 27 | testableObjects = [] |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 28 | for name in bld.path.ant_glob(['*'], dir=True, src=False): |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 29 | mainFile = bld.path.find_node(['%s/main.cpp' % name]) |
| 30 | if mainFile is None: |
| 31 | continue # not a C++ tool |
| 32 | srcFiles = bld.path.ant_glob(['%s/**/*.cpp' % name], excl=['%s/main.cpp' % name]) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 33 | if len(srcFiles) > 0: |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 34 | srcObjects = 'tools-%s-objects' % name |
| 35 | bld(features='cxx', |
| 36 | name=srcObjects, |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 37 | source=srcFiles, |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 38 | use=TOOLS_DEPENDENCY, |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 39 | includes='%s' % name, |
| 40 | ) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame^] | 41 | testableObjects.append(srcObjects) |
| 42 | |
| 43 | bld(features='cxx cxxprogram', |
| 44 | target="../bin/%s" % name, |
| 45 | source=[mainFile], |
| 46 | use=TOOLS_DEPENDENCY + ' ' + srcObjects, |
| 47 | includes='%s' % name, |
| 48 | ) |
| 49 | else: |
| 50 | bld(features='cxx cxxprogram', |
| 51 | target="../bin/%s" % name, |
| 52 | source=[mainFile], |
| 53 | use=TOOLS_DEPENDENCY, |
| 54 | includes='%s' % name, |
| 55 | ) |
| 56 | |
| 57 | bld(name='tools-objects', |
| 58 | export_includes='.', |
| 59 | use=testableObjects) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 60 | |
| 61 | bld(features="subst", |
| 62 | source=bld.path.ant_glob(['*.sh', '*.py']), |
| 63 | target=['../bin/%s' % node.change_ext('') |
| 64 | for node in bld.path.ant_glob(['*.sh', '*.py'])], |
| 65 | install_path="${BINDIR}", |
| 66 | chmod=Utils.O755, |
| 67 | VERSION=Context.g_module.VERSION |
| 68 | ) |
| 69 | |
| 70 | bld.install_files("${DATAROOTDIR}/ndn", |
| 71 | bld.path.ant_glob('nfd-status-http-server-files/*')) |