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; -*- |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 2 | """ |
| 3 | Copyright (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 Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 10 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 11 | This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | |
| 14 | NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | of the GNU General Public License as published by the Free Software Foundation, |
| 16 | either version 3 of the License, or (at your option) any later version. |
| 17 | |
| 18 | NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | PURPOSE. See the GNU General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License along with |
| 23 | NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | """ |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 25 | |
| 26 | top = '..' |
| 27 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 28 | from waflib import Context, Utils |
| 29 | |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 30 | def build(bld): |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 31 | commonDeps = 'core-objects NDN_CXX BOOST LIBRESOLV' |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 32 | |
| 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 Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 36 | # These tools cannot be unit-tested. |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 37 | 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 Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 43 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 44 | # 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 Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 47 | # All other objects are collected into 'tools-objects' and can be unit-tested. |
| 48 | testableObjects = [] |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 49 | for subdir in bld.path.ant_glob('*', dir=True, src=False): |
| 50 | mainFile = subdir.find_node('main.cpp') |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 51 | if mainFile is None: |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 52 | continue # not a C++ tool |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 53 | |
| 54 | name = subdir.path_from(bld.path) |
| 55 | srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp']) |
| 56 | srcObjects = '' |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 57 | if srcFiles: |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 58 | srcObjects = 'tools-%s-objects' % name |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 59 | bld.objects(target=srcObjects, |
| 60 | source=srcFiles, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 61 | use=commonDeps, |
| 62 | includes=name) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 63 | testableObjects.append(srcObjects) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 64 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 65 | bld.program(name=name, |
| 66 | target='../bin/%s' % name, |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 67 | source=[mainFile], |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 68 | use=commonDeps + ' ' + srcObjects, |
| 69 | includes=name) |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 70 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 71 | bld.objects(target='tools-objects', |
| 72 | source=[], |
| 73 | export_includes='.', |
| 74 | use=testableObjects) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 75 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame^] | 76 | # 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 Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 86 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 87 | bld.install_files('${DATAROOTDIR}/ndn', |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 88 | bld.path.ant_glob('nfd-status-http-server-files/*')) |