blob: 7f4ff7f6b7d00c5b2f7b90648f70f2bd944180ee [file] [log] [blame]
Alexander Afanasyev262203b2015-01-26 16:39:59 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Davide Pesavento0064c1d2018-03-03 18:43:53 -05002"""
3Copyright (c) 2014-2018, Regents of the University of California,
4 Arizona Board of Regents,
5 Colorado State University,
6 University Pierre & Marie Curie, Sorbonne University,
7 Washington University in St. Louis,
8 Beijing Institute of Technology,
9 The University of Memphis.
Alexander Afanasyev262203b2015-01-26 16:39:59 -080010
Davide Pesavento0064c1d2018-03-03 18:43:53 -050011This file is part of NFD (Named Data Networking Forwarding Daemon).
12See AUTHORS.md for complete list of NFD authors and contributors.
13
14NFD is free software: you can redistribute it and/or modify it under the terms
15of the GNU General Public License as published by the Free Software Foundation,
16either version 3 of the License, or (at your option) any later version.
17
18NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20PURPOSE. See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along with
23NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24"""
Alexander Afanasyev262203b2015-01-26 16:39:59 -080025
26top = '..'
27
Davide Pesavento0064c1d2018-03-03 18:43:53 -050028from waflib import Context, Utils
29
Alexander Afanasyev262203b2015-01-26 16:39:59 -080030def build(bld):
Davide Pesavento0064c1d2018-03-03 18:43:53 -050031 commonDeps = 'core-objects NDN_CXX BOOST LIBRESOLV'
Davide Pesavento56a741f2018-02-10 16:30:59 -050032
33 # Single object tools:
34 # tools/example-tool.cpp is a self-contained tool with a main() function
35 # and is built as build/bin/example-tool.
Junxiao Shi38f4ce92016-08-04 10:01:52 +000036 # These tools cannot be unit-tested.
Davide Pesavento0064c1d2018-03-03 18:43:53 -050037 for tool in bld.path.ant_glob('*.cpp'):
38 name = tool.change_ext('').path_from(bld.path.get_bld())
39 bld.program(name=name,
40 target='../bin/%s' % name,
41 source=[tool],
42 use=commonDeps)
Alexander Afanasyev262203b2015-01-26 16:39:59 -080043
Davide Pesavento56a741f2018-02-10 16:30:59 -050044 # Sub-directory tools:
45 # tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool.
46 # tools/example-tool/main.cpp must exist and must contain the main() function.
Junxiao Shi38f4ce92016-08-04 10:01:52 +000047 # All other objects are collected into 'tools-objects' and can be unit-tested.
48 testableObjects = []
Davide Pesavento0064c1d2018-03-03 18:43:53 -050049 for subdir in bld.path.ant_glob('*', dir=True, src=False):
50 mainFile = subdir.find_node('main.cpp')
Junxiao Shi38f4ce92016-08-04 10:01:52 +000051 if mainFile is None:
Davide Pesavento56a741f2018-02-10 16:30:59 -050052 continue # not a C++ tool
Davide Pesavento0064c1d2018-03-03 18:43:53 -050053
54 name = subdir.path_from(bld.path)
55 srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
56 srcObjects = ''
Davide Pesavento56a741f2018-02-10 16:30:59 -050057 if srcFiles:
Junxiao Shi38f4ce92016-08-04 10:01:52 +000058 srcObjects = 'tools-%s-objects' % name
Davide Pesavento56a741f2018-02-10 16:30:59 -050059 bld.objects(target=srcObjects,
60 source=srcFiles,
Davide Pesavento0064c1d2018-03-03 18:43:53 -050061 use=commonDeps,
62 includes=name)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000063 testableObjects.append(srcObjects)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000064
Davide Pesavento0064c1d2018-03-03 18:43:53 -050065 bld.program(name=name,
66 target='../bin/%s' % name,
Davide Pesavento56a741f2018-02-10 16:30:59 -050067 source=[mainFile],
Davide Pesavento0064c1d2018-03-03 18:43:53 -050068 use=commonDeps + ' ' + srcObjects,
69 includes=name)
Davide Pesavento56a741f2018-02-10 16:30:59 -050070
Davide Pesavento0064c1d2018-03-03 18:43:53 -050071 bld.objects(target='tools-objects',
72 source=[],
73 export_includes='.',
74 use=testableObjects)
Alexander Afanasyev262203b2015-01-26 16:39:59 -080075
Davide Pesavento0064c1d2018-03-03 18:43:53 -050076 # Scripts
77 for script in bld.path.ant_glob(['*.sh', '*.py']):
78 name = script.change_ext('').path_from(bld.path.get_bld())
79 bld(features='subst',
80 name=name,
81 target='../bin/%s' % name,
82 source=[script],
83 install_path='${BINDIR}',
84 chmod=Utils.O755,
85 VERSION=Context.g_module.VERSION)
Alexander Afanasyev262203b2015-01-26 16:39:59 -080086
Davide Pesavento56a741f2018-02-10 16:30:59 -050087 bld.install_files('${DATAROOTDIR}/ndn',
Alexander Afanasyev262203b2015-01-26 16:39:59 -080088 bld.path.ant_glob('nfd-status-http-server-files/*'))