build: Always build in C++11 mode.

This commit also includes update of websocketpp submodule, as the
previous version has compilation problems on OSX with XCode 6.1

Change-Id: I8c9670d0026d840838d77e610e50679ee5ede7a5
Refs: #1930, #2082
This commit is contained in:
Davide Pesavento
2014-10-21 22:45:33 +02:00
committed by Alexander Afanasyev
parent 35eefdfa1a
commit ab1e8f2497
16 changed files with 149 additions and 99 deletions
+21 -8
View File
@@ -6,17 +6,30 @@ git submodule init
git submodule sync
git submodule update
# Cleanup
sudo ./waf distclean -j1 --color=yes
# Configure
COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
CXXFLAGS="-std=c++03 -pedantic -Wall -Wno-long-long -O2 -g -Werror" \
./waf configure -j1 --color=yes --with-tests --without-pch $COVERAGE
# Cleanup
sudo ./waf -j1 --color=yes distclean
# Build
./waf --color=yes -j1
# Configure/build in debug mode
./waf -j1 --color=yes configure --with-tests --without-pch --debug
./waf -j1 --color=yes build
# Cleanup
sudo ./waf -j1 --color=yes distclean
# Configure/build in optimized mode without tests with precompiled headers
./waf -j1 --color=yes configure
./waf -j1 --color=yes build
# Cleanup
sudo ./waf -j1 --color=yes distclean
# Configure/build in optimized mode
./waf -j1 --color=yes configure --with-tests --without-pch $COVERAGE
./waf -j1 --color=yes build
# (tests will be run against optimized version)
# Install
sudo ./waf -j1 --color=yes install
+25 -12
View File
@@ -8,20 +8,14 @@ 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 all optimizations (-O0)''')
opt.add_option('--with-c++11', action='store_true', default=False, dest='use_cxx11',
help='''Enable C++11 mode (experimental, may not work)''')
help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
def configure(conf):
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
defaultFlags = []
if conf.options.use_cxx11:
defaultFlags += ['-std=c++0x', '-std=c++11']
else:
defaultFlags += ['-std=c++03', '-Wno-variadic-macros', '-Wno-c99-extensions']
defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long', '-Wno-unneeded-internal-declaration']
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)
@@ -32,6 +26,7 @@ def configure(conf):
'-fdiagnostics-color', # gcc >= 4.9
'-Werror',
'-Wno-error=maybe-uninitialized', # Bug #1560
'-Wno-error=unneeded-internal-declaration', # Bug #1588
]
if areCustomCxxflagsPresent:
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
@@ -46,12 +41,15 @@ def configure(conf):
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 allowed flags for c++ compiler')
self.start_msg('Checking supported CXXFLAGS')
supportedFlags = []
for flag in cxxflags:
@@ -60,3 +58,18 @@ def add_supported_cxxflags(self, cxxflags):
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
+1 -1
View File
@@ -71,7 +71,7 @@ def checkWebsocket(self, **kw):
Logs.warn(' git submodule init && git submodule update')
Logs.warn('Otherwise, manually download and extract websocketpp library:')
Logs.warn(' mkdir websocketpp')
Logs.warn(' curl -L https://github.com/zaphoyd/websocketpp/tarball/e203dbed45409111c2e95cb3e4a1d178ee57d2bc > websocket.tar.gz')
Logs.warn(' curl -L https://github.com/zaphoyd/websocketpp/tarball/4309749dd98937b8a7be5dc0bfe679ba201c5512 > websocket.tar.gz')
Logs.warn(' tar zxf websocket.tar.gz -C websocketpp/ --strip 1')
Logs.warn('Alternatively, WebSocket support can be disabled with --without-websocket')
self.fatal("The configuration failed")
+15 -11
View File
@@ -65,17 +65,21 @@ using std::size_t;
using boost::noncopyable;
using boost::scoped_ptr;
using ndn::shared_ptr;
using ndn::weak_ptr;
using ndn::enable_shared_from_this;
using ndn::make_shared;
using ndn::static_pointer_cast;
using ndn::dynamic_pointer_cast;
using ndn::const_pointer_cast;
using ndn::function;
using ndn::bind;
using ndn::ref;
using ndn::cref;
using std::shared_ptr;
using std::unique_ptr;
using std::weak_ptr;
using std::bad_weak_ptr;
using std::make_shared;
using std::enable_shared_from_this;
using std::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::const_pointer_cast;
using std::function;
using std::bind;
using std::ref;
using std::cref;
using ndn::Interest;
using ndn::Data;
+4 -4
View File
@@ -36,10 +36,10 @@ Face::Face(const FaceUri& remoteUri, const FaceUri& localUri, bool isLocal)
, m_isOnDemand(false)
, m_isFailed(false)
{
onReceiveInterest += bind(&PacketCounter::operator++, &m_counters.getNInInterests());
onReceiveData += bind(&PacketCounter::operator++, &m_counters.getNInDatas());
onSendInterest += bind(&PacketCounter::operator++, &m_counters.getNOutInterests());
onSendData += bind(&PacketCounter::operator++, &m_counters.getNOutDatas());
onReceiveInterest += [this](const ndn::Interest&) { ++m_counters.getNInInterests(); };
onReceiveData += [this](const ndn::Data&) { ++m_counters.getNInDatas(); };
onSendInterest += [this](const ndn::Interest&) { ++m_counters.getNOutInterests(); };
onSendData += [this](const ndn::Data&) { ++m_counters.getNOutDatas(); };
}
Face::~Face()
+2 -2
View File
@@ -115,8 +115,8 @@ WebSocketChannel::handleOpen(websocketpp::connection_hdl hdl)
websocketpp::lib::error_code ecode;
m_server.close(hdl, websocketpp::close::status::normal, "closed by channel", ecode);
}
shared_ptr<WebSocketFace> face = make_shared<WebSocketFace>(FaceUri(remote), this->getUri(),
hdl, ref(m_server));
shared_ptr<WebSocketFace> face = ndn::make_shared<WebSocketFace>(FaceUri(remote), this->getUri(),
hdl, ref(m_server));
m_onFaceCreatedCallback(face);
m_channelFaces[hdl] = face;
+1 -1
View File
@@ -158,7 +158,7 @@ StrategyChoice::get(const Name& prefix) const
return shared_ptr<const Name>();
}
return make_shared<const Name>(entry->getStrategy().getName());
return make_shared<Name>(entry->getStrategy().getName());
}
static inline bool
+11 -7
View File
@@ -234,6 +234,16 @@ public:
BOOST_CHECK_EQUAL(faces.size(), shouldBe);
}
void
connect(const shared_ptr<TcpChannel>& channel,
const std::string& remoteHost,
const std::string& remotePort)
{
channel->connect(remoteHost, remotePort,
bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
}
public:
LimitedIo limitedIo;
@@ -431,13 +441,7 @@ BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
BOOST_CHECK_NE(channel3, channel4);
scheduler::schedule(time::seconds(1),
bind(&TcpChannel::connect, channel4, "127.0.0.1", "20070",
// does not work without static_cast
static_cast<TcpChannel::FaceCreatedCallback>(
bind(&EndToEndFixture::channel_onFaceCreated, this, _1)),
static_cast<TcpChannel::ConnectFailedCallback>(
bind(&EndToEndFixture::channel_onConnectFailed, this, _1)),
time::seconds(4)));
bind(&EndToEndFixture::connect, this, channel4, "127.0.0.1", "20070"));
scheduler::schedule(time::milliseconds(500),
bind(&EndToEndFixture::checkFaceList, this, 4));
+12 -7
View File
@@ -379,7 +379,7 @@ public:
void
channel_onConnectFailedOk(const std::string& reason)
{
//it's ok, it was supposed to fail
// it's ok, it was supposed to fail
limitedIo.afterOp();
}
@@ -389,6 +389,16 @@ public:
BOOST_CHECK_EQUAL(faces.size(), shouldBe);
}
void
connect(const shared_ptr<UdpChannel>& channel,
const std::string& remoteHost,
const std::string& remotePort)
{
channel->connect(remoteHost, remotePort,
bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
}
public:
LimitedIo limitedIo;
@@ -640,12 +650,7 @@ BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
BOOST_CHECK_NE(channel3, channel4);
scheduler::schedule(time::milliseconds(500),
bind(&UdpChannel::connect, channel4, "127.0.0.1", "20070",
// does not work without static_cast
static_cast<UdpChannel::FaceCreatedCallback>(
bind(&EndToEndFixture::channel_onFaceCreated, this, _1)),
static_cast<UdpChannel::ConnectFailedCallback>(
bind(&EndToEndFixture::channel_onConnectFailed, this, _1))));
bind(&EndToEndFixture::connect, this, channel4, "127.0.0.1", "20070"));
scheduler::schedule(time::milliseconds(400), bind(&EndToEndFixture::checkFaceList, this, 2));
+22 -22
View File
@@ -230,21 +230,21 @@ BOOST_FIXTURE_TEST_CASE(TwoKeys, TwoValidatorFixture)
config.parse(CONFIG, false, CONFIG_PATH.native());
validator.validate(*fibCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester1), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester1), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester1, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester1, _1, _2));
BOOST_REQUIRE(m_tester1.commandValidated());
m_tester1.resetValidation();
validator.validate(*statsCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester1), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester1), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester1, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester1, _1, _2));
BOOST_REQUIRE(m_tester1.commandValidated());
validator.validate(*facesCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester2), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester2), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester2, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester2, _1, _2));
BOOST_REQUIRE(m_tester2.commandValidated());
m_tester2.resetValidation();
@@ -254,8 +254,8 @@ BOOST_FIXTURE_TEST_CASE(TwoKeys, TwoValidatorFixture)
generator.generateWithIdentity(*unauthorizedFibCommand, m_tester2.getIdentityName());
validator.validate(*unauthorizedFibCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester2), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester2), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester2, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester2, _1, _2));
BOOST_REQUIRE(m_tester2.commandValidationFailed());
}
@@ -290,21 +290,21 @@ BOOST_FIXTURE_TEST_CASE(TwoKeysDryRun, TwoValidatorFixture)
config.parse(CONFIG, true, CONFIG_PATH.native());
validator.validate(*fibCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester1), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester1), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester1, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester1, _1, _2));
BOOST_REQUIRE(m_tester1.commandValidationFailed());
m_tester1.resetValidation();
validator.validate(*statsCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester1), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester1), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester1, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester1, _1, _2));
BOOST_REQUIRE(m_tester1.commandValidationFailed());
validator.validate(*facesCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester2), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester2), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester2, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester2, _1, _2));
BOOST_REQUIRE(m_tester2.commandValidationFailed());
m_tester2.resetValidation();
@@ -314,8 +314,8 @@ BOOST_FIXTURE_TEST_CASE(TwoKeysDryRun, TwoValidatorFixture)
generator.generateWithIdentity(*unauthorizedFibCommand, m_tester2.getIdentityName());
validator.validate(*unauthorizedFibCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester2), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester2), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester2, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester2, _1, _2));
BOOST_REQUIRE(m_tester2.commandValidationFailed());
}
@@ -629,22 +629,22 @@ BOOST_FIXTURE_TEST_CASE(Wildcard, TwoValidatorFixture)
config.parse(WILDCARD_CERT_CONFIG, false, CONFIG_PATH.native());
validator.validate(*fibCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester1), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester1), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester1, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester1, _1, _2));
BOOST_REQUIRE(m_tester1.commandValidationFailed());
m_tester1.resetValidation();
validator.validate(*statsCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester1), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester1), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester1, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester1, _1, _2));
BOOST_REQUIRE(m_tester1.commandValidated());
m_tester1.resetValidation();
validator.validate(*facesCommand,
bind(&CommandValidatorTester::onValidated, ref(m_tester1), _1),
bind(&CommandValidatorTester::onValidationFailed, ref(m_tester1), _1, _2));
bind(&CommandValidatorTester::onValidated, &m_tester1, _1),
bind(&CommandValidatorTester::onValidationFailed, &m_tester1, _1, _2));
BOOST_REQUIRE(m_tester1.commandValidated());
m_tester1.resetValidation();
+1 -1
View File
@@ -80,7 +80,7 @@ public:
shared_ptr<InternalFace>
getInternalFace()
{
return ndn::ptr_lib::static_pointer_cast<InternalFace>(m_face);
return static_pointer_cast<InternalFace>(m_face);
}
void
+5 -5
View File
@@ -103,8 +103,8 @@ public:
finalBlockId.toSegment() > currentSegment)
{
m_face.expressInterest(data.getName().getPrefix(-1).appendSegment(currentSegment+1),
bind(&NdnAutoconfig::fetchSegments, this, _2, buffer, onDone),
bind(&NdnAutoconfig::discoverHubStage2, this, "Timeout"));
ndn::bind(&NdnAutoconfig::fetchSegments, this, _2, buffer, onDone),
ndn::bind(&NdnAutoconfig::discoverHubStage2, this, "Timeout"));
}
else
{
@@ -122,9 +122,9 @@ public:
interest.setMustBeFresh(true);
m_face.expressInterest(interest,
bind(&NdnAutoconfig::fetchSegments, this, _2, buffer,
&NdnAutoconfig::discoverHubStage1_registerHubDiscoveryPrefix),
bind(&NdnAutoconfig::discoverHubStage2, this, "Timeout"));
ndn::bind(&NdnAutoconfig::fetchSegments, this, _2, buffer,
&NdnAutoconfig::discoverHubStage1_registerHubDiscoveryPrefix),
ndn::bind(&NdnAutoconfig::discoverHubStage2, this, "Timeout"));
}
void
+8 -6
View File
@@ -27,15 +27,19 @@
#include "version.hpp"
#include <boost/asio.hpp>
#include <boost/noncopyable.hpp>
#include <ndn-cxx/face.hpp>
namespace ndntlvpeek {
class NdnTlvPeek
using ndn::_1;
using ndn::_2;
class NdnTlvPeek : boost::noncopyable
{
public:
explicit
NdnTlvPeek(char* programName)
: m_programName(programName)
, m_mustBeFresh(false)
@@ -180,10 +184,8 @@ public:
try
{
m_face.expressInterest(createInterestPacket(),
ndn::func_lib::bind(&NdnTlvPeek::onData,
this, _1, _2),
ndn::func_lib::bind(&NdnTlvPeek::onTimeout,
this, _1));
bind(&NdnTlvPeek::onData, this, _1, _2),
bind(&NdnTlvPeek::onTimeout, this, _1));
if (m_timeout < ndn::time::milliseconds::zero())
{
if (m_interestLifetime < ndn::time::milliseconds::zero())
+6 -7
View File
@@ -27,18 +27,19 @@
#include "version.hpp"
#include <boost/utility.hpp>
#include <boost/noncopyable.hpp>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/key-chain.hpp>
namespace ndntlvpoke {
using ndn::_1;
using ndn::_2;
class NdnTlvPoke : boost::noncopyable
{
public:
explicit
NdnTlvPoke(char* programName)
: m_programName(programName)
@@ -186,11 +187,9 @@ public:
else
{
m_face.setInterestFilter(m_prefixName,
ndn::bind(&NdnTlvPoke::onInterest,
this, _1, _2, dataPacket),
bind(&NdnTlvPoke::onInterest, this, _1, _2, dataPacket),
ndn::RegisterPrefixSuccessCallback(),
ndn::bind(&NdnTlvPoke::onRegisterFailed,
this, _1, _2));
bind(&NdnTlvPoke::onRegisterFailed, this, _1, _2));
}
if (m_timeout < ndn::time::milliseconds::zero())
m_face.processEvents(getDefaultTimeout());
+14 -4
View File
@@ -70,6 +70,10 @@ usage(const char* programName)
namespace nfdc {
using ndn::bind;
using ndn::_1;
using ndn::_2;
const ndn::time::milliseconds Nfdc::DEFAULT_EXPIRATION_PERIOD = ndn::time::milliseconds::max();
const uint64_t Nfdc::DEFAULT_COST = 0;
@@ -186,9 +190,11 @@ Nfdc::startFibAddNextHop(const ndn::util::FaceUri& canonicalUri)
parameters.setUri(canonicalUri.toString());
m_controller.start<FaceCreateCommand>(parameters,
bind(&Nfdc::fibAddNextHop, this, _1),
[this](const ControlParameters& result) {
fibAddNextHop(result);
},
bind(&Nfdc::onError, this, _1, _2,
"Face creation failed"));
"Face creation failed"));
}
void
@@ -273,7 +279,9 @@ Nfdc::startRibRegisterPrefix(const ndn::util::FaceUri& canonicalUri)
parameters.setUri(canonicalUri.toString());
m_controller.start<FaceCreateCommand>(parameters,
bind(&Nfdc::ribRegisterPrefix, this, _1),
[this](const ControlParameters& result) {
ribRegisterPrefix(result);
},
bind(&Nfdc::onError, this, _1, _2,
"Face creation failed"));
}
@@ -389,7 +397,9 @@ Nfdc::startFaceDestroy(const ndn::util::FaceUri& canonicalUri)
parameters.setUri(canonicalUri.toString());
m_controller.start<FaceCreateCommand>(parameters,
bind(&Nfdc::faceDestroy, this, _1),
[this](const ControlParameters& result) {
faceDestroy(result);
},
bind(&Nfdc::onError, this, _1, _2,
"Face destroy failed"));
}