build: Experimental support to build using precompiled headers
This type of build needs to be explicitly enabled using --with-pch
configure option.
Change-Id: I02dc304187d54c3cf40f1d51b1b11b21f868e225
diff --git a/src/common.cpp b/src/common.cpp
index c3dedd2..7665dc8 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -5,8 +5,8 @@
* See COPYING for copyright and distribution information.
*/
-#include <sstream>
#include "common.hpp"
+
#include "util/time.hpp"
using namespace std;
diff --git a/src/common.hpp b/src/common.hpp
index d8290bf..6398323 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -12,11 +12,28 @@
#include <stdint.h>
// TODO: Is stddef.h portable?
#include <stddef.h>
+#include <unistd.h>
+
+// Standard headers to precompile
#include <vector>
#include <list>
#include <set>
#include <algorithm>
+#include <map>
+#include <sstream>
+#include <fstream>
+#include <exception>
+#include <map>
+
+// Other useful headers to precompile
+#include <boost/lexical_cast.hpp>
+#include <boost/asio.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+
+#include <boost/iostreams/detail/ios.hpp>
+#include <boost/iostreams/categories.hpp>
+#include <boost/iostreams/stream.hpp>
#if NDN_CPP_HAVE_CXX11
diff --git a/src/data.cpp b/src/data.cpp
index 85d87a5..00a915c 100644
--- a/src/data.cpp
+++ b/src/data.cpp
@@ -6,6 +6,7 @@
*/
#include "common.hpp"
+
#include "data.hpp"
using namespace std;
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 5656b61..fbd5838 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -7,8 +7,10 @@
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
-#include "encoding/block.hpp"
-#include "encoding/tlv.hpp"
+#include "common.hpp"
+
+#include "block.hpp"
+#include "tlv.hpp"
namespace ndn {
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index f515727..b729bc2 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -12,14 +12,9 @@
#include "../common.hpp"
-#include <list>
-#include <exception>
-
#include "buffer.hpp"
#include "tlv.hpp"
-#include <boost/lexical_cast.hpp>
-
namespace ndn {
/**
diff --git a/src/encoding/buffer.hpp b/src/encoding/buffer.hpp
index 9742512..398817f 100644
--- a/src/encoding/buffer.hpp
+++ b/src/encoding/buffer.hpp
@@ -12,12 +12,6 @@
#include "../common.hpp"
-#include <boost/iostreams/detail/ios.hpp>
-#include <boost/iostreams/categories.hpp>
-#include <boost/iostreams/stream.hpp>
-
-#include <vector>
-
namespace ndn {
class Buffer;
diff --git a/src/encoding/oid.cpp b/src/encoding/oid.cpp
index d023f82..ae4e12d 100644
--- a/src/encoding/oid.cpp
+++ b/src/encoding/oid.cpp
@@ -5,10 +5,10 @@
* See COPYING for copyright and distribution information.
*/
-#include <stdlib.h>
-#include <sstream>
+#include "common.hpp"
-#include "encoding/oid.hpp"
+#include "oid.hpp"
+
#include <cryptopp/asn.h>
using namespace std;
diff --git a/src/encoding/oid.hpp b/src/encoding/oid.hpp
index e755c05..308da8e 100644
--- a/src/encoding/oid.hpp
+++ b/src/encoding/oid.hpp
@@ -9,8 +9,7 @@
#ifndef NDN_OID_HPP
#define NDN_OID_HPP
-#include <vector>
-#include <string>
+#include "../common.hpp"
namespace CryptoPP { class BufferedTransformation; }
diff --git a/src/exclude.cpp b/src/exclude.cpp
index 42fb843..264919b 100644
--- a/src/exclude.cpp
+++ b/src/exclude.cpp
@@ -8,6 +8,8 @@
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
+#include "common.hpp"
+
#include "exclude.hpp"
namespace ndn
diff --git a/src/exclude.hpp b/src/exclude.hpp
index e26ec31..62ce672 100644
--- a/src/exclude.hpp
+++ b/src/exclude.hpp
@@ -13,8 +13,6 @@
#include "name.hpp"
-#include <map>
-
namespace ndn {
/**
diff --git a/src/interest.cpp b/src/interest.cpp
index 6c030dc..da3cab6 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -6,6 +6,7 @@
*/
#include "common.hpp"
+
#include "interest.hpp"
#include "util/random.hpp"
diff --git a/src/interest.hpp b/src/interest.hpp
index 29ce962..e09cf2c 100644
--- a/src/interest.hpp
+++ b/src/interest.hpp
@@ -8,6 +8,7 @@
#ifndef NDN_INTEREST_HPP
#define NDN_INTEREST_HPP
+#include "common.hpp"
#include "name.hpp"
#include "exclude.hpp"
#include "encoding/block.hpp"
diff --git a/src/name-component.cpp b/src/name-component.cpp
index 3956e80..0fd7bd7 100644
--- a/src/name-component.cpp
+++ b/src/name-component.cpp
@@ -7,6 +7,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "name-component.hpp"
#include "util/time.hpp"
diff --git a/src/name.cpp b/src/name.cpp
index 5c267d7..a355e4a 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -6,6 +6,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "name.hpp"
#include <algorithm>
diff --git a/src/node.cpp b/src/node.cpp
index 23e3185..0c9c872 100644
--- a/src/node.cpp
+++ b/src/node.cpp
@@ -5,6 +5,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "node.hpp"
#include "forwarding-entry.hpp"
diff --git a/src/security/certificate-cache-ttl.cpp b/src/security/certificate-cache-ttl.cpp
index f5482a3..9538d95 100644
--- a/src/security/certificate-cache-ttl.cpp
+++ b/src/security/certificate-cache-ttl.cpp
@@ -5,13 +5,12 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "certificate-cache-ttl.hpp"
-#include <iostream>
-
#include "../util/logging.hpp"
-
INIT_LOGGER("CertificateCacheTtl")
using namespace std;
diff --git a/src/security/certificate-cache-ttl.hpp b/src/security/certificate-cache-ttl.hpp
index 6d5194b..8702c3a 100644
--- a/src/security/certificate-cache-ttl.hpp
+++ b/src/security/certificate-cache-ttl.hpp
@@ -8,15 +8,12 @@
#ifndef NDN_CERTIFICATE_CACHE_TTL_HPP
#define NDN_CERTIFICATE_CACHE_TTL_HPP
+#include "../common.hpp"
#include "certificate-cache.hpp"
#include "../util/scheduler.hpp"
#include "../util/time.hpp"
-#include <unistd.h>
-#include <map>
-
-namespace ndn
-{
+namespace ndn {
class CertificateCacheTtl : public CertificateCache
{
diff --git a/src/security/certificate-extension.cpp b/src/security/certificate-extension.cpp
index f876823..e3ceff6 100644
--- a/src/security/certificate-extension.cpp
+++ b/src/security/certificate-extension.cpp
@@ -6,7 +6,9 @@
* See COPYING for copyright and distribution information.
*/
-#include "security/certificate-extension.hpp"
+#include "common.hpp"
+
+#include "certificate-extension.hpp"
#include <cryptopp/asn.h>
using namespace std;
diff --git a/src/security/certificate-subject-description.cpp b/src/security/certificate-subject-description.cpp
index fc6156f..63e7b0b 100644
--- a/src/security/certificate-subject-description.cpp
+++ b/src/security/certificate-subject-description.cpp
@@ -6,7 +6,10 @@
* See COPYING for copyright and distribution information.
*/
-#include "security/certificate-subject-description.hpp"
+#include "common.hpp"
+
+#include "certificate-subject-description.hpp"
+
#include <cryptopp/asn.h>
using namespace std;
diff --git a/src/security/certificate.cpp b/src/security/certificate.cpp
index 3a3b224..3778a80 100644
--- a/src/security/certificate.cpp
+++ b/src/security/certificate.cpp
@@ -8,7 +8,7 @@
#include "common.hpp"
-#include "security/certificate.hpp"
+#include "certificate.hpp"
#include "../util/logging.hpp"
#include "../util/time.hpp"
diff --git a/src/security/certificate.hpp b/src/security/certificate.hpp
index 9871733..260638a 100644
--- a/src/security/certificate.hpp
+++ b/src/security/certificate.hpp
@@ -9,8 +9,8 @@
#ifndef NDN_CERTIFICATE_HPP
#define NDN_CERTIFICATE_HPP
-#include "../data.hpp"
#include "../common.hpp"
+#include "../data.hpp"
#include "certificate-subject-description.hpp"
#include "certificate-extension.hpp"
diff --git a/src/security/identity-certificate.cpp b/src/security/identity-certificate.cpp
index 334172e..44d6588 100644
--- a/src/security/identity-certificate.cpp
+++ b/src/security/identity-certificate.cpp
@@ -6,7 +6,9 @@
* See COPYING for copyright and distribution information.
*/
-#include "security/identity-certificate.hpp"
+#include "common.hpp"
+
+#include "identity-certificate.hpp"
using namespace std;
diff --git a/src/security/identity-certificate.hpp b/src/security/identity-certificate.hpp
index 65b07af..fa31966 100644
--- a/src/security/identity-certificate.hpp
+++ b/src/security/identity-certificate.hpp
@@ -9,6 +9,7 @@
#ifndef NDN_IDENTITY_CERTIFICATE_HPP
#define NDN_IDENTITY_CERTIFICATE_HPP
+#include "../common.hpp"
#include "certificate.hpp"
namespace ndn {
diff --git a/src/security/public-key.cpp b/src/security/public-key.cpp
index 27992ca..09222a4 100644
--- a/src/security/public-key.cpp
+++ b/src/security/public-key.cpp
@@ -7,7 +7,8 @@
*/
#include "common.hpp"
-#include "security/public-key.hpp"
+
+#include "public-key.hpp"
#include <cryptopp/rsa.h>
#include <cryptopp/base64.h>
diff --git a/src/security/public-key.hpp b/src/security/public-key.hpp
index 5a70e38..8fc5dab 100644
--- a/src/security/public-key.hpp
+++ b/src/security/public-key.hpp
@@ -9,7 +9,8 @@
#ifndef NDN_PUBLIC_KEY_HPP
#define NDN_PUBLIC_KEY_HPP
-#include <stdexcept>
+#include "../common.hpp"
+
#include "../encoding/oid.hpp"
#include "../encoding/buffer.hpp"
#include "security-common.hpp"
diff --git a/src/security/sec-public-info-memory.cpp b/src/security/sec-public-info-memory.cpp
index c6d7316..e9f93f2 100644
--- a/src/security/sec-public-info-memory.cpp
+++ b/src/security/sec-public-info-memory.cpp
@@ -5,10 +5,10 @@
* See COPYING for copyright and distribution information.
*/
-#include "security/sec-public-info-memory.hpp"
+#include "common.hpp"
-#include <algorithm>
-#include "security/identity-certificate.hpp"
+#include "sec-public-info-memory.hpp"
+#include "identity-certificate.hpp"
using namespace std;
diff --git a/src/security/sec-public-info-memory.hpp b/src/security/sec-public-info-memory.hpp
index eb747e9..e598ebf 100644
--- a/src/security/sec-public-info-memory.hpp
+++ b/src/security/sec-public-info-memory.hpp
@@ -8,8 +8,7 @@
#ifndef NDN_SEC_PUBLIC_INFO_MEMORY_HPP
#define NDN_SEC_PUBLIC_INFO_MEMORY_HPP
-#include <vector>
-#include <map>
+#include "../common.hpp"
#include "sec-public-info.hpp"
namespace ndn {
@@ -26,7 +25,7 @@
/**
* The virtual Destructor.
*/
- virtual
+ virtual
~SecPublicInfoMemory();
/**
@@ -34,7 +33,7 @@
* @param identityName The identity name.
* @return true if the identity exists, otherwise false.
*/
- virtual bool
+ virtual bool
doesIdentityExist(const Name& identityName);
/**
@@ -48,7 +47,7 @@
* Revoke the identity.
* @return true if the identity was revoked, false if not.
*/
- virtual bool
+ virtual bool
revokeIdentity();
/**
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 43dc641..b2315c6 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -6,19 +6,24 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
+#include "sec-public-info-sqlite3.hpp"
+#include "identity-certificate.hpp"
+#include "signature-sha256-with-rsa.hpp"
+
+#include "../util/logging.hpp"
+#include "../util/time.hpp"
+
+#include "../data.hpp"
+
#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <fstream>
#include <boost/filesystem.hpp>
-#include "../util/logging.hpp"
-#include "../util/time.hpp"
-#include "data.hpp"
-#include "security/identity-certificate.hpp"
-#include "security/sec-public-info-sqlite3.hpp"
-#include "security/signature-sha256-with-rsa.hpp"
INIT_LOGGER("BasicKeyMetaInfo");
diff --git a/src/security/sec-rule-relative.cpp b/src/security/sec-rule-relative.cpp
index 8da1bd1..cdfdeac 100644
--- a/src/security/sec-rule-relative.cpp
+++ b/src/security/sec-rule-relative.cpp
@@ -5,6 +5,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "sec-rule-relative.hpp"
#include "signature-sha256-with-rsa.hpp"
diff --git a/src/security/sec-rule-specific.cpp b/src/security/sec-rule-specific.cpp
index 1479b6d..b1973de 100644
--- a/src/security/sec-rule-specific.cpp
+++ b/src/security/sec-rule-specific.cpp
@@ -5,6 +5,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "sec-rule-specific.hpp"
#include "signature-sha256-with-rsa.hpp"
diff --git a/src/security/sec-rule-specific.hpp b/src/security/sec-rule-specific.hpp
index 21d00e6..2b7b355 100644
--- a/src/security/sec-rule-specific.hpp
+++ b/src/security/sec-rule-specific.hpp
@@ -8,6 +8,7 @@
#ifndef NDN_SEC_RULE_SPECIFIC_H
#define NDN_SEC_RULE_SPECIFIC_H
+#include "../common.hpp"
#include "sec-rule.hpp"
#include "../util/regex.hpp"
diff --git a/src/security/sec-rule.hpp b/src/security/sec-rule.hpp
index 1e2dbd0..c175863 100644
--- a/src/security/sec-rule.hpp
+++ b/src/security/sec-rule.hpp
@@ -8,6 +8,7 @@
#ifndef NDN_SEC_RULE_HPP
#define NDN_SEC_RULE_HPP
+#include "../common.hpp"
#include "../data.hpp"
namespace ndn
diff --git a/src/security/sec-tpm-file.cpp b/src/security/sec-tpm-file.cpp
index c8dab80..52f14ba 100644
--- a/src/security/sec-tpm-file.cpp
+++ b/src/security/sec-tpm-file.cpp
@@ -7,13 +7,9 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#endif
+#include "common.hpp"
-#include "security/sec-tpm-file.hpp"
-
-#include <string>
+#include "sec-tpm-file.hpp"
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
diff --git a/src/security/sec-tpm-memory.cpp b/src/security/sec-tpm-memory.cpp
index d4de6fc..a72e385 100644
--- a/src/security/sec-tpm-memory.cpp
+++ b/src/security/sec-tpm-memory.cpp
@@ -5,8 +5,11 @@
* See COPYING for copyright and distribution information.
*/
-#include "security/sec-tpm-memory.hpp"
-#include "security/public-key.hpp"
+#include "common.hpp"
+
+#include "sec-tpm-memory.hpp"
+#include "public-key.hpp"
+
#include <openssl/ssl.h>
#include <openssl/sha.h>
#include <openssl/rsa.h>
diff --git a/src/security/sec-tpm-memory.hpp b/src/security/sec-tpm-memory.hpp
index 110442e..38bc5ff 100644
--- a/src/security/sec-tpm-memory.hpp
+++ b/src/security/sec-tpm-memory.hpp
@@ -8,7 +8,7 @@
#ifndef NDN_SEC_TPM_MEMORY_HPP
#define NDN_SEC_TPM_MEMORY_HPP
-#include <map>
+#include "../common.hpp"
#include "sec-tpm.hpp"
struct rsa_st;
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index ba2464f..27039bf 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -5,13 +5,13 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "sec-tpm-osx.hpp"
#include "security/public-key.hpp"
#include "util/logging.hpp"
-#include <fstream>
-#include <sstream>
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
diff --git a/src/security/sec-tpm.hpp b/src/security/sec-tpm.hpp
index 3336a32..ec3334d 100644
--- a/src/security/sec-tpm.hpp
+++ b/src/security/sec-tpm.hpp
@@ -9,7 +9,7 @@
#ifndef NDN_SEC_TPM_HPP
#define NDN_SEC_TPM_HPP
-#include <string>
+#include "../common.hpp"
#include "security-common.hpp"
#include "../name.hpp"
#include "../data.hpp"
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index 63c49c4..18dc9bf 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -5,6 +5,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "validator-regex.hpp"
#include "signature-sha256-with-rsa.hpp"
#include "certificate-cache-ttl.hpp"
diff --git a/src/security/validator-regex.hpp b/src/security/validator-regex.hpp
index a06964c..6b44d13 100644
--- a/src/security/validator-regex.hpp
+++ b/src/security/validator-regex.hpp
@@ -14,9 +14,6 @@
#include "certificate-cache.hpp"
#include "../util/regex.hpp"
-#include <map>
-
-
namespace ndn {
class ValidatorRegex : public Validator
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 62289f5..ebb8b55 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -6,6 +6,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "validator.hpp"
#include "../util/logging.hpp"
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 4ba4c43..1d74aa2 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -9,6 +9,8 @@
#ifndef NDN_VALIDATOR_HPP
#define NDN_VALIDATOR_HPP
+#include "../common.hpp"
+
#include "../data.hpp"
#include "../face.hpp"
#include "public-key.hpp"
diff --git a/src/transport/tcp-transport.cpp b/src/transport/tcp-transport.cpp
index a12c223..3c773a8 100644
--- a/src/transport/tcp-transport.cpp
+++ b/src/transport/tcp-transport.cpp
@@ -5,13 +5,10 @@
* See COPYING for copyright and distribution information.
*/
-#include <stdexcept>
-#include <stdlib.h>
+#include "common.hpp"
-#include "face.hpp"
-#include "transport/tcp-transport.hpp"
+#include "tcp-transport.hpp"
-#include <boost/asio.hpp>
#if NDN_CPP_HAVE_CXX11
// In the std library, the placeholders are in a different namespace than boost.
using namespace ndn::func_lib::placeholders;
diff --git a/src/transport/tcp-transport.hpp b/src/transport/tcp-transport.hpp
index 00f3fef..c2ba56e 100644
--- a/src/transport/tcp-transport.hpp
+++ b/src/transport/tcp-transport.hpp
@@ -8,7 +8,7 @@
#ifndef NDN_TCP_TRANSPORT_HPP
#define NDN_TCP_TRANSPORT_HPP
-#include <string>
+#include "../common.hpp"
#include "transport.hpp"
namespace ndn {
diff --git a/src/transport/transport.hpp b/src/transport/transport.hpp
index 41861b4..3b62a21 100644
--- a/src/transport/transport.hpp
+++ b/src/transport/transport.hpp
@@ -9,10 +9,7 @@
#define NDN_TRANSPORT_HPP
#include "../common.hpp"
-
-#include <vector>
-#include <boost/asio.hpp>
-#include <boost/lexical_cast.hpp>
+#include "../encoding/block.hpp"
namespace ndn {
diff --git a/src/transport/unix-transport.cpp b/src/transport/unix-transport.cpp
index e258f11..4da0502 100644
--- a/src/transport/unix-transport.cpp
+++ b/src/transport/unix-transport.cpp
@@ -5,17 +5,11 @@
* See COPYING for copyright and distribution information.
*/
-#include <stdexcept>
-#include <stdlib.h>
+#include "common.hpp"
-#include "face.hpp"
-#include "transport/unix-transport.hpp"
+#include "unix-transport.hpp"
-#include <boost/asio.hpp>
-#if NDN_CPP_HAVE_CXX11
-// In the std library, the placeholders are in a different namespace than boost.
-using namespace ndn::func_lib::placeholders;
-#endif
+#include "../face.hpp"
using namespace std;
typedef boost::asio::local::stream_protocol protocol;
diff --git a/src/transport/unix-transport.hpp b/src/transport/unix-transport.hpp
index c2ee204..26621d7 100644
--- a/src/transport/unix-transport.hpp
+++ b/src/transport/unix-transport.hpp
@@ -8,7 +8,7 @@
#ifndef NDN_UDPTRANSPORT_HPP
#define NDN_UDPTRANSPORT_HPP
-#include <string>
+#include "../common.hpp"
#include "transport.hpp"
namespace ndn {
diff --git a/src/util/crypto.cpp b/src/util/crypto.cpp
index 490feb8..8967523 100644
--- a/src/util/crypto.cpp
+++ b/src/util/crypto.cpp
@@ -4,7 +4,9 @@
* See COPYING for copyright and distribution information.
*/
-#include "util/crypto.hpp"
+#include "common.hpp"
+
+#include "crypto.hpp"
namespace ndn {
diff --git a/src/util/logging.cpp b/src/util/logging.cpp
index 7147768..59c7b2a 100644
--- a/src/util/logging.cpp
+++ b/src/util/logging.cpp
@@ -6,6 +6,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "logging.hpp"
#ifdef NDN_CPP_HAVE_LOG4CXX
diff --git a/src/util/random.cpp b/src/util/random.cpp
index f1cb5b9..6bbe203 100644
--- a/src/util/random.cpp
+++ b/src/util/random.cpp
@@ -4,6 +4,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "random.hpp"
#include <cryptopp/osrng.h>
diff --git a/src/util/scheduler.cpp b/src/util/scheduler.cpp
index c13e070..388d5e7 100644
--- a/src/util/scheduler.cpp
+++ b/src/util/scheduler.cpp
@@ -4,6 +4,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "scheduler.hpp"
namespace ndn {
diff --git a/src/util/time.cpp b/src/util/time.cpp
index 97ac14c..07e7f34 100644
--- a/src/util/time.cpp
+++ b/src/util/time.cpp
@@ -4,6 +4,8 @@
* See COPYING for copyright and distribution information.
*/
+#include "common.hpp"
+
#include "time.hpp"
#include <time.h>
#include <stdexcept>
diff --git a/src/util/time.hpp b/src/util/time.hpp
index 9af95fc..5d729d9 100644
--- a/src/util/time.hpp
+++ b/src/util/time.hpp
@@ -9,7 +9,6 @@
#define NDN_TIME_HPP
#include "../common.hpp"
-#include <boost/date_time/posix_time/posix_time.hpp>
namespace ndn {
diff --git a/tests/wscript b/tests/wscript
index 877d24a..4fbfb4a 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -19,3 +19,7 @@
# In case we want to make it optional later
unittests.source += bld.path.ant_glob('**/*-sqlite3.cpp')
+
+ if bld.env['WITH_PCH']:
+ unittests.pch = "../src/common.hpp"
+
diff --git a/wscript b/wscript
index 079ceeb..7bc8a27 100644
--- a/wscript
+++ b/wscript
@@ -3,6 +3,7 @@
NAME="ndn-cpp-dev"
from waflib import Build, Logs, Utils, Task, TaskGen, Configure
+from waflib.Tools import c_preproc
def options(opt):
opt.load('compiler_c compiler_cxx gnu_dirs c_osx')
@@ -27,6 +28,8 @@
opt.add_option('--without-sqlite-locking', action='store_false', default=True, dest='with_sqlite_locking',
help='''Disable filesystem locking in sqlite3 database (use unix-dot locking mechanism instead). '''
'''This option may be necessary if home directory is hosted on NFS.''')
+ opt.add_option('--with-pch', action='store_true', default=False, dest='with_pch',
+ help='''Try to use precompiled header to speed up compilation (only gcc and clang)''')
def configure(conf):
conf.load("compiler_c compiler_cxx boost gnu_dirs c_osx openssl cryptopp")
@@ -111,6 +114,8 @@
if not conf.options.with_sqlite_locking:
conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
+ conf.env['WITH_PCH'] = conf.options.with_pch
+
conf.write_config_header('src/ndn-cpp-config.h', define_prefix='NDN_CPP_')
def build (bld):
@@ -122,11 +127,14 @@
source = bld.path.ant_glob('src/**/*.cpp',
excl = ['src/**/*-osx.cpp', 'src/**/*-sqlite3.cpp']),
use = 'BOOST OPENSSL LOG4CXX CRYPTOPP SQLITE3 RT PTHREAD',
- includes = "src",
+ includes = ". src",
export_includes = "src",
install_path = '${LIBDIR}',
)
+ if bld.env['WITH_PCH']:
+ libndn_cpp.pch = "src/common.hpp"
+
if Utils.unversioned_sys_platform () == "darwin":
libndn_cpp.source += bld.path.ant_glob('src/**/*-osx.cpp')
libndn_cpp.mac_app = True
@@ -222,3 +230,26 @@
bld (features="sphinx",
outdir = "doc/html",
source = "doc/source/conf.py")
+
+
+@TaskGen.feature('cxx')
+@TaskGen.before('process_source')
+def process_pch(self):
+ if getattr(self, 'pch', ''):
+ # for now support only gcc-compatible things
+ if self.env['COMPILER_CXX'] == 'g++':
+ nodes = self.to_nodes(self.pch, path=self.path)
+ for x in nodes:
+ z = self.create_task('gchx', x, x.change_ext('.hpp.gch'))
+ z.orig_self = self
+
+class gchx(Task.Task):
+ run_str = '${CXX} -x c++-header ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT}'
+ scan = c_preproc.scan
+ ext_out = ['.hpp']
+ color = 'BLUE'
+
+ def post_run(self):
+ super(gchx, self).post_run()
+ self.orig_self.env['CXXFLAGS'] = ['-include', self.inputs[0].relpath()] + self.env['CXXFLAGS']
+