blob: de4cb78cc96cebe2e6a88904906306912b8fd9bc [file] [log] [blame]
Alexander Afanasyev262203b2015-01-26 16:39:59 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3from waflib import Utils, Context
4
5top = '..'
6
7def build(bld):
Davide Pesavento56a741f2018-02-10 16:30:59 -05008 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 Shi38f4ce92016-08-04 10:01:52 +000013 # These tools cannot be unit-tested.
Alexander Afanasyev262203b2015-01-26 16:39:59 -080014 for i in bld.path.ant_glob(['*.cpp']):
Davide Pesavento56a741f2018-02-10 16:30:59 -050015 name = str(i)[:-len('.cpp')]
16 bld.program(target='../bin/%s' % name,
17 source=[i],
18 use=TOOLS_DEPENDENCY)
Alexander Afanasyev262203b2015-01-26 16:39:59 -080019
Davide Pesavento56a741f2018-02-10 16:30:59 -050020 # 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 Shi38f4ce92016-08-04 10:01:52 +000023 # All other objects are collected into 'tools-objects' and can be unit-tested.
24 testableObjects = []
Alexander Afanasyev262203b2015-01-26 16:39:59 -080025 for name in bld.path.ant_glob(['*'], dir=True, src=False):
Junxiao Shi38f4ce92016-08-04 10:01:52 +000026 mainFile = bld.path.find_node(['%s/main.cpp' % name])
27 if mainFile is None:
Davide Pesavento56a741f2018-02-10 16:30:59 -050028 continue # not a C++ tool
Junxiao Shi38f4ce92016-08-04 10:01:52 +000029 srcFiles = bld.path.ant_glob(['%s/**/*.cpp' % name], excl=['%s/main.cpp' % name])
Davide Pesavento56a741f2018-02-10 16:30:59 -050030 if srcFiles:
Junxiao Shi38f4ce92016-08-04 10:01:52 +000031 srcObjects = 'tools-%s-objects' % name
Davide Pesavento56a741f2018-02-10 16:30:59 -050032 bld.objects(target=srcObjects,
33 source=srcFiles,
34 use=TOOLS_DEPENDENCY,
35 includes='%s' % name)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000036 testableObjects.append(srcObjects)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000037 else:
Davide Pesavento56a741f2018-02-10 16:30:59 -050038 srcObjects = ''
Junxiao Shi38f4ce92016-08-04 10:01:52 +000039
Davide Pesavento56a741f2018-02-10 16:30:59 -050040 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 Shi38f4ce92016-08-04 10:01:52 +000046 export_includes='.',
47 use=testableObjects)
Alexander Afanasyev262203b2015-01-26 16:39:59 -080048
Davide Pesavento56a741f2018-02-10 16:30:59 -050049 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 Afanasyev262203b2015-01-26 16:39:59 -080055 chmod=Utils.O755,
Davide Pesavento56a741f2018-02-10 16:30:59 -050056 VERSION=Context.g_module.VERSION)
Alexander Afanasyev262203b2015-01-26 16:39:59 -080057
Davide Pesavento56a741f2018-02-10 16:30:59 -050058 bld.install_files('${DATAROOTDIR}/ndn',
Alexander Afanasyev262203b2015-01-26 16:39:59 -080059 bld.path.ant_glob('nfd-status-http-server-files/*'))