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 | """ |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame^] | 3 | Copyright (c) 2014-2023, Regents of the University of California, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 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 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 26 | from waflib import Context, Utils |
| 27 | |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame^] | 28 | top = '..' |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 29 | |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 30 | def build(bld): |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 31 | # Single object tools: |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 32 | # tools/foo.cpp is a self-contained tool with a main() function |
| 33 | # and is built as build/bin/foo. These tools cannot be unit-tested. |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 34 | for tool in bld.path.ant_glob('*.cpp'): |
| 35 | name = tool.change_ext('').path_from(bld.path.get_bld()) |
| 36 | bld.program(name=name, |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame^] | 37 | target=f'{top}/bin/{name}', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 38 | source=[tool], |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 39 | use='core-objects') |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 40 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 41 | # Sub-directory tools: |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 42 | # tools/foo/**/*.cpp are compiled and linked into build/bin/foo. |
| 43 | # tools/foo/main.cpp must exist and must contain the main() function. |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 44 | # All other objects are collected into 'tools-objects' and can be unit-tested. |
| 45 | testableObjects = [] |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 46 | for subdir in bld.path.ant_glob('*', dir=True, src=False): |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 47 | name = subdir.path_from(bld.path) |
| 48 | subWscript = subdir.find_node('wscript') |
| 49 | if subWscript: |
| 50 | # if the subdir has a wscript, delegate to it |
| 51 | bld.recurse(name) |
| 52 | continue |
| 53 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 54 | mainFile = subdir.find_node('main.cpp') |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 55 | if mainFile is None: |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 56 | # not a C++ tool, skip the subdir |
| 57 | continue |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 58 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 59 | srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp']) |
| 60 | srcObjects = '' |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 61 | if srcFiles: |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame^] | 62 | srcObjects = f'tools-{name}-objects' |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 63 | bld.objects(target=srcObjects, |
| 64 | source=srcFiles, |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 65 | features='pch', |
| 66 | headers=subdir.find_node(name + '-pch.hpp'), |
| 67 | use='core-objects LIBRESOLV', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 68 | includes=name) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 69 | testableObjects.append(srcObjects) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 70 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 71 | bld.program(name=name, |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame^] | 72 | target=f'{top}/bin/{name}', |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 73 | source=[mainFile], |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 74 | use='core-objects ' + srcObjects, |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 75 | includes=name) |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 76 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 77 | bld.objects(target='tools-objects', |
| 78 | source=[], |
| 79 | export_includes='.', |
| 80 | use=testableObjects) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 81 | |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 82 | # Scripts |
| 83 | for script in bld.path.ant_glob(['*.sh', '*.py']): |
| 84 | name = script.change_ext('').path_from(bld.path.get_bld()) |
| 85 | bld(features='subst', |
| 86 | name=name, |
Davide Pesavento | 910232f | 2023-09-08 14:20:02 -0400 | [diff] [blame^] | 87 | target=f'{top}/bin/{name}', |
Davide Pesavento | 0064c1d | 2018-03-03 18:43:53 -0500 | [diff] [blame] | 88 | source=[script], |
| 89 | install_path='${BINDIR}', |
| 90 | chmod=Utils.O755, |
| 91 | VERSION=Context.g_module.VERSION) |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 92 | |
Davide Pesavento | 56a741f | 2018-02-10 16:30:59 -0500 | [diff] [blame] | 93 | bld.install_files('${DATAROOTDIR}/ndn', |
Alexander Afanasyev | 262203b | 2015-01-26 16:39:59 -0800 | [diff] [blame] | 94 | bld.path.ant_glob('nfd-status-http-server-files/*')) |