build: Always build in C++11 mode.
This commit also embeds CI build scripts and includes waf script update
Change-Id: Ib89dd8040b5e438866315425293b02694b8d85fe
Refs: #1930
diff --git a/.gitignore b/.gitignore
index 444b8db..b78202c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
.DS*
+.waf3-1*
.waf-1*
.lock*
**/*.pyc
build/
-
diff --git a/.jenkins b/.jenkins
new file mode 100755
index 0000000..4daa40f
--- /dev/null
+++ b/.jenkins
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+set -e
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+for i in `find "$DIR/.jenkins.d" -type f -perm +111 | sort`; do
+ echo "Run: $i"
+ $i
+done
diff --git a/.jenkins.d/10-ndn-cxx.sh b/.jenkins.d/10-ndn-cxx.sh
new file mode 100755
index 0000000..951e3f9
--- /dev/null
+++ b/.jenkins.d/10-ndn-cxx.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+cd /tmp
+BUILD="no"
+if [ ! -d ndn-cxx ]; then
+ git clone --depth 1 git://github.com/named-data/ndn-cxx
+ cd ndn-cxx
+ BUILD="yes"
+else
+ cd ndn-cxx
+ INSTALLED_VERSION=`git rev-parse HEAD || echo NONE`
+ sudo rm -Rf latest-version
+ git clone --depth 1 git://github.com/named-data/ndn-cxx latest-version
+ cd latest-version
+ LATEST_VERSION=`git rev-parse HEAD || echo UNKNOWN`
+ cd ..
+ rm -Rf latest-version
+ if [ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]; then
+ cd ..
+ sudo rm -Rf ndn-cxx
+ git clone --depth 1 git://github.com/named-data/ndn-cxx
+ cd ndn-cxx
+ BUILD="yes"
+ fi
+fi
+
+sudo rm -Rf /usr/local/include/ndn-cxx
+sudo rm -f /usr/local/lib/libndn-cxx*
+sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
+
+if [ "$BUILD" = "yes" ]; then
+ sudo ./waf distclean -j1 --color=yes
+fi
+
+./waf configure -j1 --color=yes --without-osx-keychain
+./waf -j1 --color=yes
+sudo ./waf install -j1 --color=yes
diff --git a/.jenkins.d/20-build.sh b/.jenkins.d/20-build.sh
new file mode 100755
index 0000000..dc8af29
--- /dev/null
+++ b/.jenkins.d/20-build.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+sudo ./waf distclean -j1 --color=yes
+./waf configure -j1 --color=yes
+./waf -j1 --color=yes
+sudo ./waf install -j1 --color=yes
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
new file mode 100644
index 0000000..458677e
--- /dev/null
+++ b/.waf-tools/default-compiler-flags.py
@@ -0,0 +1,70 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+from waflib import Logs, Configure
+
+def options(opt):
+ opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
+ help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
+
+def configure(conf):
+ areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
+ defaultFlags = ['-std=c++0x', '-std=c++11',
+ '-stdlib=libc++', # clang on OSX < 10.9 by default uses gcc's
+ # libstdc++, which is not C++11 compatible
+ '-pedantic', '-Wall']
+
+ if conf.options.debug:
+ conf.define('_DEBUG', 1)
+ defaultFlags += ['-O0',
+ '-Og', # gcc >= 4.8
+ '-g3',
+ '-fcolor-diagnostics', # clang
+ '-fdiagnostics-color', # gcc >= 4.9
+ '-Werror',
+ '-Wno-error=maybe-uninitialized',
+ ]
+ if areCustomCxxflagsPresent:
+ missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
+ if len(missingFlags) > 0:
+ Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
+ % " ".join(conf.env.CXXFLAGS))
+ Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
+ else:
+ conf.add_supported_cxxflags(defaultFlags)
+ else:
+ defaultFlags += ['-O2', '-g']
+ if not areCustomCxxflagsPresent:
+ conf.add_supported_cxxflags(defaultFlags)
+
+ # clang on OSX < 10.9 by default uses gcc's libstdc++, which is not C++11 compatible
+ conf.add_supported_linkflags(['-stdlib=libc++'])
+
+@Configure.conf
+def add_supported_cxxflags(self, cxxflags):
+ """
+ Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
+ """
+ self.start_msg('Checking supported CXXFLAGS')
+
+ supportedFlags = []
+ for flag in cxxflags:
+ if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
+ supportedFlags += [flag]
+
+ self.end_msg(' '.join(supportedFlags))
+ self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
+
+@Configure.conf
+def add_supported_linkflags(self, linkflags):
+ """
+ Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
+ """
+ self.start_msg('Checking supported LINKFLAGS')
+
+ supportedFlags = []
+ for flag in linkflags:
+ if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
+ supportedFlags += [flag]
+
+ self.end_msg(' '.join(supportedFlags))
+ self.env.LINKFLAGS = supportedFlags + self.env.LINKFLAGS
diff --git a/src/ndn-traffic-client.cpp b/src/ndn-traffic-client.cpp
index 80a79da..2e1b910 100644
--- a/src/ndn-traffic-client.cpp
+++ b/src/ndn-traffic-client.cpp
@@ -36,9 +36,9 @@
, m_logger("NdnTrafficClient")
, m_hasError(false)
, m_hasQuietLogging(false)
- , m_face(m_ioService)
, m_interestInterval(getDefaultInterestInterval())
, m_nMaximumInterests(-1)
+ , m_face(m_ioService)
, m_nInterestsSent(0)
, m_nInterestsReceived(0)
, m_nContentInconsistencies(0)
@@ -777,12 +777,12 @@
private:
std::string m_programName;
+ Logger m_logger;
std::string m_instanceId;
bool m_hasError;
bool m_hasQuietLogging;
time::milliseconds m_interestInterval;
int m_nMaximumInterests;
- Logger m_logger;
std::string m_configurationFile;
boost::asio::io_service m_ioService;
Face m_face;
diff --git a/src/ndn-traffic-server.cpp b/src/ndn-traffic-server.cpp
index 4bf50cc..2c78dba 100644
--- a/src/ndn-traffic-server.cpp
+++ b/src/ndn-traffic-server.cpp
@@ -414,7 +414,7 @@
run()
{
boost::asio::signal_set signalSet(m_ioService, SIGINT, SIGTERM);
- signalSet.async_wait(boost::bind(&NdnTrafficServer::signalHandler, this));
+ signalSet.async_wait(bind(&NdnTrafficServer::signalHandler, this));
m_logger.initializeLog(m_instanceId);
initializeTrafficConfiguration();
if (m_nMaximumInterests == 0)
@@ -448,19 +448,20 @@
private:
KeyChain m_keyChain;
+ Logger m_logger;
std::string m_programName;
bool m_hasError;
bool m_hasQuietLogging;
- std::string m_instanceId;
- time::milliseconds m_contentDelay;
int m_nRegistrationsFailed;
- Logger m_logger;
+ int m_nMaximumInterests;
+ int m_nInterestsReceived;
+ time::milliseconds m_contentDelay;
+ std::string m_instanceId;
std::string m_configurationFile;
+
boost::asio::io_service m_ioService;
Face m_face;
std::vector<DataTrafficConfiguration> m_trafficPatterns;
- int m_nMaximumInterests;
- int m_nInterestsReceived;
};
} // namespace ndn
diff --git a/waf b/waf
index 78a44f3..ef9df38 100755
--- a/waf
+++ b/waf
Binary files differ
diff --git a/wscript b/wscript
index c421719..0a09375 100644
--- a/wscript
+++ b/wscript
@@ -3,10 +3,12 @@
APPNAME="ndn-traffic-generator"
def options(opt):
- opt.load('compiler_cxx gnu_dirs')
+ opt.load(['compiler_cxx', 'gnu_dirs'])
+ opt.load(['default-compiler-flags'], tooldir=['.waf-tools'])
def configure(conf):
- conf.load("compiler_cxx gnu_dirs")
+ conf.load(['compiler_cxx', 'gnu_dirs',
+ 'default-compiler-flags'])
conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
uselib_store='NDN_CXX', mandatory=True)