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
diff --git a/daemon/common/global.hpp b/daemon/common/global.hpp
index ccc5160..25102f9 100644
--- a/daemon/common/global.hpp
+++ b/daemon/common/global.hpp
@@ -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.
diff --git a/daemon/face/ethernet-channel.hpp b/daemon/face/ethernet-channel.hpp
index 2096585..bc9b141 100644
--- a/daemon/face/ethernet-channel.hpp
+++ b/daemon/face/ethernet-channel.hpp
@@ -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 {
diff --git a/daemon/face/ethernet-transport.hpp b/daemon/face/ethernet-transport.hpp
index 951d56a..8fa7a6a 100644
--- a/daemon/face/ethernet-transport.hpp
+++ b/daemon/face/ethernet-transport.hpp
@@ -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 {
diff --git a/daemon/face/multicast-udp-transport.cpp b/daemon/face/multicast-udp-transport.cpp
index bb373fd..e0b7ac5 100644
--- a/daemon/face/multicast-udp-transport.cpp
+++ b/daemon/face/multicast-udp-transport.cpp
@@ -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__
diff --git a/daemon/face/multicast-udp-transport.hpp b/daemon/face/multicast-udp-transport.hpp
index b881e81..5a19a0c 100644
--- a/daemon/face/multicast-udp-transport.hpp
+++ b/daemon/face/multicast-udp-transport.hpp
@@ -28,6 +28,7 @@
#include "datagram-transport.hpp"
+#include <boost/asio/ip/udp.hpp>
#include <ndn-cxx/net/network-interface.hpp>
namespace nfd::face {
diff --git a/daemon/face/network-predicate.cpp b/daemon/face/network-predicate.cpp
index a13d886..340ef82 100644
--- a/daemon/face/network-predicate.cpp
+++ b/daemon/face/network-predicate.cpp
@@ -29,6 +29,8 @@
#include <fnmatch.h>
+#include <boost/lexical_cast.hpp>
+
namespace nfd::face {
NetworkPredicateBase::NetworkPredicateBase()
diff --git a/daemon/face/network-predicate.hpp b/daemon/face/network-predicate.hpp
index 2ea79d6..5a758da 100644
--- a/daemon/face/network-predicate.hpp
+++ b/daemon/face/network-predicate.hpp
@@ -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 {
diff --git a/daemon/face/stream-transport.hpp b/daemon/face/stream-transport.hpp
index ec33b26..b6ad18b 100644
--- a/daemon/face/stream-transport.hpp
+++ b/daemon/face/stream-transport.hpp
@@ -32,6 +32,8 @@
#include <queue>
+#include <boost/asio/write.hpp>
+
namespace nfd::face {
/** \brief Implements Transport for stream-based protocols.
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index be029d0..e3c9910 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -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);
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index 7193851..811ee5e 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -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
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 8ff04cc..1d25419 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -25,6 +25,8 @@
#include "tcp-factory.hpp"
+#include <boost/lexical_cast.hpp>
+
namespace nfd::face {
namespace ip = boost::asio::ip;
diff --git a/daemon/face/tcp-transport.hpp b/daemon/face/tcp-transport.hpp
index 595e574..ed147fe 100644
--- a/daemon/face/tcp-transport.hpp
+++ b/daemon/face/tcp-transport.hpp
@@ -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>);
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index 4e91045..80c6878 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -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);
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 4feec76..331174d 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -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>
diff --git a/daemon/face/udp-protocol.hpp b/daemon/face/udp-protocol.hpp
index ebd3dad..1b6e363 100644
--- a/daemon/face/udp-protocol.hpp
+++ b/daemon/face/udp-protocol.hpp
@@ -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
*/
diff --git a/daemon/face/unicast-udp-transport.hpp b/daemon/face/unicast-udp-transport.hpp
index 7c96fef..82982fc 100644
--- a/daemon/face/unicast-udp-transport.hpp
+++ b/daemon/face/unicast-udp-transport.hpp
@@ -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>));
diff --git a/daemon/face/unix-stream-channel.hpp b/daemon/face/unix-stream-channel.hpp
index 0c2eb2e..b0fdf2c 100644
--- a/daemon/face/unix-stream-channel.hpp
+++ b/daemon/face/unix-stream-channel.hpp
@@ -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
diff --git a/daemon/face/unix-stream-transport.hpp b/daemon/face/unix-stream-transport.hpp
index 8ad8a46..47b6a7e 100644
--- a/daemon/face/unix-stream-transport.hpp
+++ b/daemon/face/unix-stream-transport.hpp
@@ -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
diff --git a/daemon/fw/self-learning-strategy.hpp b/daemon/fw/self-learning-strategy.hpp
index 118fe3d..59cf98b 100644
--- a/daemon/fw/self-learning-strategy.hpp
+++ b/daemon/fw/self-learning-strategy.hpp
@@ -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 {
diff --git a/daemon/fw/strategy.hpp b/daemon/fw/strategy.hpp
index 4c9a2e5..ce8ba23 100644
--- a/daemon/fw/strategy.hpp
+++ b/daemon/fw/strategy.hpp
@@ -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;
diff --git a/daemon/main.cpp b/daemon/main.cpp
index 6d29646..60a589a 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -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>
diff --git a/daemon/mgmt/command-authenticator.cpp b/daemon/mgmt/command-authenticator.cpp
index ebf7991..d9dfba0 100644
--- a/daemon/mgmt/command-authenticator.cpp
+++ b/daemon/mgmt/command-authenticator.cpp
@@ -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>
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index ea0c056..fa18856 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -30,6 +30,8 @@
#include <ndn-cxx/mgmt/nfd/strategy-choice.hpp>
+#include <boost/lexical_cast.hpp>
+
namespace nfd {
NFD_LOG_INIT(StrategyChoiceManager);
diff --git a/daemon/nfd-pch.hpp b/daemon/nfd-pch.hpp
new file mode 100644
index 0000000..1692179
--- /dev/null
+++ b/daemon/nfd-pch.hpp
@@ -0,0 +1,40 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2022, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * 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/>.
+ */
+
+#ifndef NFD_DAEMON_NFD_PCH_HPP
+#define NFD_DAEMON_NFD_PCH_HPP
+
+#include "core/common.hpp"
+
+#include <boost/lexical_cast.hpp>
+#include <boost/property_tree/ptree.hpp>
+
+#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
diff --git a/daemon/table/name-tree-iterator.hpp b/daemon/table/name-tree-iterator.hpp
index fc04fb6..4a76a53 100644
--- a/daemon/table/name-tree-iterator.hpp
+++ b/daemon/table/name-tree-iterator.hpp
@@ -28,6 +28,8 @@
#include "name-tree-hashtable.hpp"
+#include <boost/range/iterator_range_core.hpp>
+
namespace nfd::name_tree {
class NameTree;