build: make precompiled headers more useful

This can reduce the compilation time of a release
build (without tests) by more than 40%

Refs: #5212
Change-Id: I977aff0c0c7becbfee8a8b55605b81d0c014829b
This commit is contained in:
Davide Pesavento committed 2022-06-13 16:30:11 -04:00
1 parent 9a28c3f752
commit a9b09b6994
48 files changed
+143 -62

No files matched your search

-3
View File
@@ -71,11 +71,8 @@
#include <ndn-cxx/util/span.hpp>
#include <ndn-cxx/util/time.hpp>
#include <boost/asio.hpp>
#include <boost/assert.hpp>
#include <boost/core/noncopyable.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/ptree.hpp>
namespace nfd {
+4
View File
@@ -25,9 +25,13 @@
#include "network.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/utility/value_init.hpp>
#include <algorithm>
#include <cctype>
#include <istream>
#include <ostream>
namespace nfd {
+2 -1
View File
@@ -26,7 +26,8 @@
#ifndef NFD_CORE_NETWORK_HPP
#define NFD_CORE_NETWORK_HPP
#include "common.hpp"
#include <boost/asio/ip/address.hpp>
#include <string_view>
namespace nfd {
+3 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021 Regents of the University of California,
* Copyright (c) 2014-2022 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,6 +27,8 @@
#include "core/common.hpp"
#include <boost/asio/io_service.hpp>
namespace nfd {
/** \brief Returns the global io_service instance for the calling thread.
+1
View File
@@ -30,6 +30,7 @@
#include "ethernet-protocol.hpp"
#include "pcap-helper.hpp"
#include <boost/asio/posix/stream_descriptor.hpp>
#include <ndn-cxx/net/network-interface.hpp>
namespace nfd::face {
+1
View File
@@ -30,6 +30,7 @@
#include "pcap-helper.hpp"
#include "transport.hpp"
#include <boost/asio/posix/stream_descriptor.hpp>
#include <ndn-cxx/net/network-interface.hpp>
namespace nfd::face {
+2
View File
@@ -29,6 +29,8 @@
#include "common/privilege-helper.hpp"
#include <boost/asio/ip/multicast.hpp>
#include <boost/asio/ip/v6_only.hpp>
#include <boost/functional/hash.hpp>
#ifdef __linux__
+1
View File
@@ -28,6 +28,7 @@
#include "datagram-transport.hpp"
#include <boost/asio/ip/udp.hpp>
#include <ndn-cxx/net/network-interface.hpp>
namespace nfd::face {
+2
View File
@@ -29,6 +29,8 @@
#include <fnmatch.h>
#include <boost/lexical_cast.hpp>
namespace nfd::face {
NetworkPredicateBase::NetworkPredicateBase()
+1
View File
@@ -28,6 +28,7 @@
#include "core/common.hpp"
#include <boost/property_tree/ptree_fwd.hpp>
#include <ndn-cxx/net/network-interface.hpp>
namespace nfd::face {
+2
View File
@@ -32,6 +32,8 @@
#include <queue>
#include <boost/asio/write.hpp>
namespace nfd::face {
/** \brief Implements Transport for stream-based protocols.
+2
View File
@@ -29,6 +29,8 @@
#include "tcp-transport.hpp"
#include "common/global.hpp"
#include <boost/asio/ip/v6_only.hpp>
namespace nfd::face {
NFD_LOG_INIT(TcpChannel);
+2
View File
@@ -28,6 +28,8 @@
#include "channel.hpp"
#include <boost/asio/ip/tcp.hpp>
namespace nfd::tcp {
using Endpoint = boost::asio::ip::tcp::endpoint;
} // namespace nfd::tcp
+2
View File
@@ -25,6 +25,8 @@
#include "tcp-factory.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::face {
namespace ip = boost::asio::ip;
+2
View File
@@ -28,6 +28,8 @@
#include "stream-transport.hpp"
#include <boost/asio/ip/tcp.hpp>
namespace nfd::face {
NFD_LOG_MEMBER_DECL_SPECIALIZED(StreamTransport<boost::asio::ip::tcp>);
+2
View File
@@ -29,6 +29,8 @@
#include "unicast-udp-transport.hpp"
#include "common/global.hpp"
#include <boost/asio/ip/v6_only.hpp>
namespace nfd::face {
NFD_LOG_INIT(UdpChannel);
+1
View File
@@ -28,6 +28,7 @@
#include "multicast-udp-transport.hpp"
#include "common/global.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
+3 -1
View File
@@ -28,9 +28,11 @@
#include "core/common.hpp"
#include <boost/asio/ip/udp.hpp>
namespace nfd::udp {
typedef boost::asio::ip::udp::endpoint Endpoint;
using Endpoint = boost::asio::ip::udp::endpoint;
/** \brief computes maximum payload size in a UDP packet
*/
+2
View File
@@ -28,6 +28,8 @@
#include "datagram-transport.hpp"
#include <boost/asio/ip/udp.hpp>
namespace nfd::face {
NFD_LOG_MEMBER_DECL_SPECIALIZED((DatagramTransport<boost::asio::ip::udp, Unicast>));
+2
View File
@@ -28,6 +28,8 @@
#include "channel.hpp"
#include <boost/asio/local/stream_protocol.hpp>
namespace nfd::unix_stream {
using Endpoint = boost::asio::local::stream_protocol::endpoint;
} // namespace nfd::unix_stream
+2
View File
@@ -28,6 +28,8 @@
#include "stream-transport.hpp"
#include <boost/asio/local/stream_protocol.hpp>
#ifndef NFD_HAVE_UNIX_SOCKETS
#error "Cannot include this file when UNIX sockets are not available"
#endif
+1 -1
View File
@@ -28,7 +28,7 @@
#include "fw/strategy.hpp"
#include <ndn-cxx/lp/prefix-announcement-header.hpp>
#include <ndn-cxx/prefix-announcement.hpp>
namespace nfd::fw {
+2
View File
@@ -29,6 +29,8 @@
#include "forwarder.hpp"
#include "table/measurements-accessor.hpp"
#include <boost/lexical_cast/try_lexical_convert.hpp>
namespace nfd::fw {
class StrategyParameters;
+2 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -33,6 +33,7 @@
#include <string.h> // for strsignal()
#include <boost/asio/signal_set.hpp>
#include <boost/config.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/filesystem.hpp>
-1
View File
@@ -32,7 +32,6 @@
#include <ndn-cxx/security/validation-policy.hpp>
#include <ndn-cxx/security/validation-policy-accept-all.hpp>
#include <ndn-cxx/security/validation-policy-command-interest.hpp>
#include <ndn-cxx/security/validator.hpp>
#include <ndn-cxx/util/io.hpp>
#include <boost/filesystem.hpp>
+2
View File
@@ -30,6 +30,8 @@
#include <ndn-cxx/mgmt/nfd/strategy-choice.hpp>
#include <boost/lexical_cast.hpp>
namespace nfd {
NFD_LOG_INIT(StrategyChoiceManager);
@@ -23,23 +23,18 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "available-commands.hpp"
#include "cs-module.hpp"
#include "face-module.hpp"
#include "rib-module.hpp"
#include "status.hpp"
#include "strategy-choice-module.hpp"
#ifndef NFD_DAEMON_NFD_PCH_HPP
#define NFD_DAEMON_NFD_PCH_HPP
namespace nfd::tools::nfdc {
#include "core/common.hpp"
void
registerCommands(CommandParser& parser)
{
registerStatusCommands(parser);
FaceModule::registerCommands(parser);
RibModule::registerCommands(parser);
CsModule::registerCommands(parser);
StrategyChoiceModule::registerCommands(parser);
}
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/ptree.hpp>
} // namespace nfd::tools::nfdc
#include <ndn-cxx/lp/packet.hpp>
#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/security/validator.hpp>
#include <ndn-cxx/util/logger.hpp>
#endif // NFD_DAEMON_NFD_PCH_HPP
+2
View File
@@ -28,6 +28,8 @@
#include "name-tree-hashtable.hpp"
#include <boost/range/iterator_range_core.hpp>
namespace nfd::name_tree {
class NameTree;
+2
View File
@@ -27,6 +27,8 @@
#include "tests/test-common.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::tests {
BOOST_AUTO_TEST_SUITE(TestNetwork)
+1
View File
@@ -28,6 +28,7 @@
#include "transport-test-common.hpp"
#include <boost/asio/read.hpp>
#include <boost/mpl/vector.hpp>
namespace nfd::tests {
+2
View File
@@ -29,6 +29,8 @@
#include "factory-test-common.hpp"
#include "tests/daemon/limited-io.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::tests {
using face::TcpChannel;
@@ -28,6 +28,8 @@
#include "face-system-fixture.hpp"
#include "factory-test-common.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::tests {
using face::WebSocketChannel;
+2
View File
@@ -29,6 +29,8 @@
#include "tests/daemon/global-io-fixture.hpp"
#include "tests/daemon/rib/create-route.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::tests {
using rib::Route;
+2
View File
@@ -28,6 +28,8 @@
#include "tests/test-common.hpp"
#include "tests/daemon/global-io-fixture.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::tests {
using rib::Route;
+2
View File
@@ -28,7 +28,9 @@
#include "face/tcp-channel.hpp"
#include "face/udp-channel.hpp"
#include <boost/asio/signal_set.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/lexical_cast.hpp>
#include <fstream>
#include <iostream>
@@ -28,6 +28,8 @@
#include "tests/test-common.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::tools::nfdc::tests {
BOOST_AUTO_TEST_SUITE(Nfdc)
+2
View File
@@ -27,6 +27,8 @@
#include "tests/test-common.hpp"
#include <boost/lexical_cast.hpp>
namespace nfd::tools::nfdc::tests {
BOOST_AUTO_TEST_SUITE(Nfdc)
+1 -1
View File
@@ -27,7 +27,7 @@
#define NFD_TESTS_TOOLS_NFDC_EXECUTE_COMMAND_FIXTURE_HPP
#include "mock-nfd-mgmt-fixture.hpp"
#include "nfdc/available-commands.hpp"
#include "nfdc/command-parser.hpp"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
+1
View File
@@ -29,6 +29,7 @@
#include <signal.h>
#include <string.h>
#include <boost/asio/signal_set.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
+5 -1
View File
@@ -33,6 +33,7 @@
#include <ndn-cxx/net/face-uri.hpp>
#include <ndn-cxx/security/key-chain.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
@@ -42,6 +43,9 @@
namespace nfd::tools::autoreg {
using ndn::FaceUri;
using ndn::Name;
class AutoregServer : boost::noncopyable
{
public:
@@ -101,7 +105,7 @@ public:
.setFaceId(faceId)
.setOrigin(ndn::nfd::ROUTE_ORIGIN_AUTOREG)
.setCost(m_cost)
.setExpirationPeriod(time::milliseconds::max()),
.setExpirationPeriod(ndn::time::milliseconds::max()),
[=] (auto&&...) { onRegisterCommandSuccess(faceId, prefix); },
[=] (const auto& response) { onRegisterCommandFailure(faceId, prefix, response); });
}
+1
View File
@@ -26,6 +26,7 @@
#include "command-definition.hpp"
#include "status-report.hpp"
#include <boost/lexical_cast.hpp>
#include <ndn-cxx/util/logger.hpp>
namespace nfd::tools::nfdc {
+16 -1
View File
@@ -24,7 +24,12 @@
*/
#include "command-parser.hpp"
#include "format-helpers.hpp"
#include "cs-module.hpp"
#include "face-module.hpp"
#include "rib-module.hpp"
#include "status.hpp"
#include "strategy-choice-module.hpp"
#include <ndn-cxx/util/logger.hpp>
@@ -127,4 +132,14 @@ CommandParser::parse(const std::vector<std::string>& tokens, ParseMode mode) con
return {def.getNoun(), def.getVerb(), def.parse(tokens, nConsumed), i->second->execute};
}
void
registerCommands(CommandParser& parser)
{
registerStatusCommands(parser);
FaceModule::registerCommands(parser);
RibModule::registerCommands(parser);
CsModule::registerCommands(parser);
StrategyChoiceModule::registerCommands(parser);
}
} // namespace nfd::tools::nfdc
+3
View File
@@ -123,6 +123,9 @@ private:
std::vector<CommandContainer::const_iterator> m_commandOrder;
};
void
registerCommands(CommandParser& parser);
} // namespace nfd::tools::nfdc
#endif // NFD_TOOLS_NFDC_COMMAND_PARSER_HPP
+2
View File
@@ -27,6 +27,8 @@
#include "canonizer.hpp"
#include "find-face.hpp"
#include <boost/lexical_cast/try_lexical_convert.hpp>
namespace nfd::tools::nfdc {
void
+3 -2
View File
@@ -23,10 +23,11 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "available-commands.hpp"
#include "core/version.hpp"
#include "command-parser.hpp"
#include "help.hpp"
#include "core/version.hpp"
#include <boost/tokenizer.hpp>
#include <fstream>
#include <iostream>
@@ -23,16 +23,13 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_TOOLS_NFDC_AVAILABLE_COMMANDS_HPP
#define NFD_TOOLS_NFDC_AVAILABLE_COMMANDS_HPP
#ifndef NFD_TOOLS_NFDC_NFDC_PCH_HPP
#define NFD_TOOLS_NFDC_NFDC_PCH_HPP
#include "command-parser.hpp"
#include "core/common.hpp"
namespace nfd::tools::nfdc {
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/security/validator-null.hpp>
#include <ndn-cxx/util/logger.hpp>
void
registerCommands(CommandParser& parser);
} // namespace nfd::tools::nfdc
#endif // NFD_TOOLS_NFDC_AVAILABLE_COMMANDS_HPP
#endif // NFD_TOOLS_NFDC_NFDC_PCH_HPP
+24 -18
View File
@@ -1,6 +1,6 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
"""
Copyright (c) 2014-2018, Regents of the University of California,
Copyright (c) 2014-2022, Regents of the University of California,
Arizona Board of Regents,
Colorado State University,
University Pierre & Marie Curie, Sorbonne University,
@@ -23,49 +23,55 @@ You should have received a copy of the GNU General Public License along with
NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
"""
top = '..'
from waflib import Context, Utils
def build(bld):
commonDeps = 'core-objects NDN_CXX BOOST LIBRESOLV'
top = '../'
def build(bld):
# Single object tools:
# tools/example-tool.cpp is a self-contained tool with a main() function
# and is built as build/bin/example-tool.
# These tools cannot be unit-tested.
# tools/foo.cpp is a self-contained tool with a main() function
# and is built as build/bin/foo. These tools cannot be unit-tested.
for tool in bld.path.ant_glob('*.cpp'):
name = tool.change_ext('').path_from(bld.path.get_bld())
bld.program(name=name,
target='../bin/%s' % name,
target=top + 'bin/%s' % name,
source=[tool],
use=commonDeps)
use='core-objects')
# Sub-directory tools:
# tools/example-tool/**/*.cpp is compiled and linked into build/bin/example-tool.
# tools/example-tool/main.cpp must exist and must contain the main() function.
# tools/foo/**/*.cpp are compiled and linked into build/bin/foo.
# tools/foo/main.cpp must exist and must contain the main() function.
# All other objects are collected into 'tools-objects' and can be unit-tested.
testableObjects = []
for subdir in bld.path.ant_glob('*', dir=True, src=False):
name = subdir.path_from(bld.path)
subWscript = subdir.find_node('wscript')
if subWscript:
# if the subdir has a wscript, delegate to it
bld.recurse(name)
continue
mainFile = subdir.find_node('main.cpp')
if mainFile is None:
continue # not a C++ tool
# not a C++ tool, skip the subdir
continue
name = subdir.path_from(bld.path)
srcFiles = subdir.ant_glob('**/*.cpp', excl=['main.cpp'])
srcObjects = ''
if srcFiles:
srcObjects = 'tools-%s-objects' % name
bld.objects(target=srcObjects,
source=srcFiles,
use=commonDeps,
features='pch',
headers=subdir.find_node(name + '-pch.hpp'),
use='core-objects LIBRESOLV',
includes=name)
testableObjects.append(srcObjects)
bld.program(name=name,
target='../bin/%s' % name,
target=top + 'bin/%s' % name,
source=[mainFile],
use=commonDeps + ' ' + srcObjects,
use='core-objects ' + srcObjects,
includes=name)
bld.objects(target='tools-objects',
@@ -78,7 +84,7 @@ def build(bld):
name = script.change_ext('').path_from(bld.path.get_bld())
bld(features='subst',
name=name,
target='../bin/%s' % name,
target=top + 'bin/%s' % name,
source=[script],
install_path='${BINDIR}',
chmod=Utils.O755,
+3 -3
View File
@@ -155,12 +155,10 @@ def build(bld):
bld.objects(
target='core-objects',
features='pch',
source=bld.path.find_node('core').ant_glob('*.cpp') + ['core/version.cpp'],
use='version.cpp version.hpp NDN_CXX BOOST LIBRT',
includes='.',
export_includes='.',
headers='core/common.hpp')
export_includes='.')
nfd_objects = bld.objects(
target='daemon-objects',
@@ -170,6 +168,8 @@ def build(bld):
'daemon/face/unix*.cpp',
'daemon/face/websocket*.cpp',
'daemon/main.cpp']),
features='pch',
headers='daemon/nfd-pch.hpp',
use='core-objects',
includes='daemon',
export_includes='daemon')