blob: f3dd5c9013b7374999a856dcce08649b9ec1fa55 [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
Junxiao Shi38f4ce92016-08-04 10:01:52 +00007TOOLS_DEPENDENCY = 'core-objects NDN_CXX BOOST LIBRESOLV'
8
Alexander Afanasyev262203b2015-01-26 16:39:59 -08009def build(bld):
Junxiao Shi38f4ce92016-08-04 10:01:52 +000010 # 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 Afanasyev262203b2015-01-26 16:39:59 -080014 for i in bld.path.ant_glob(['*.cpp']):
15 name = str(i)[:-len(".cpp")]
Junxiao Shi38f4ce92016-08-04 10:01:52 +000016 bld(features='cxx cxxprogram',
Alexander Afanasyev262203b2015-01-26 16:39:59 -080017 target="../bin/%s" % name,
Junxiao Shi38f4ce92016-08-04 10:01:52 +000018 source=[i],
19 use=TOOLS_DEPENDENCY
Alexander Afanasyev262203b2015-01-26 16:39:59 -080020 )
21
Junxiao Shi38f4ce92016-08-04 10:01:52 +000022
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 Afanasyev262203b2015-01-26 16:39:59 -080028 for name in bld.path.ant_glob(['*'], dir=True, src=False):
Junxiao Shi38f4ce92016-08-04 10:01:52 +000029 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 Afanasyev262203b2015-01-26 16:39:59 -080033 if len(srcFiles) > 0:
Junxiao Shi38f4ce92016-08-04 10:01:52 +000034 srcObjects = 'tools-%s-objects' % name
35 bld(features='cxx',
36 name=srcObjects,
Alexander Afanasyev262203b2015-01-26 16:39:59 -080037 source=srcFiles,
Junxiao Shi38f4ce92016-08-04 10:01:52 +000038 use=TOOLS_DEPENDENCY,
Alexander Afanasyev262203b2015-01-26 16:39:59 -080039 includes='%s' % name,
40 )
Junxiao Shi38f4ce92016-08-04 10:01:52 +000041 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 Afanasyev262203b2015-01-26 16:39:59 -080060
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/*'))