Skip to content

Commit

Permalink
Merge pull request #23 from Pesa/boost-dep
Browse files Browse the repository at this point in the history
Align build requirements with latest ndn-cxx + misc cleanups
  • Loading branch information
pulsejet committed Nov 28, 2023
2 parents 80dd7df + c5d2c10 commit 3e48741
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 51 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ permissions: {}
jobs:
Ubuntu:
uses: named-data/actions/.github/workflows/jenkins-script-ubuntu.yml@v1
PPA:
uses: named-data/actions/.github/workflows/ppa.yml@v1
macOS:
uses: named-data/actions/.github/workflows/jenkins-script-macos.yml@v1
PPA:
uses: named-data/actions/.github/workflows/ppa.yml@v1
with:
extra-deps: libboost-iostreams-dev
6 changes: 5 additions & 1 deletion .waf-tools/default-compiler-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ def getCompilerVersion(self, conf):

def getGeneralFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
return {
'CXXFLAGS': [],
'LINKFLAGS': [],
'DEFINES': ['BOOST_ASIO_NO_DEPRECATED', 'BOOST_FILESYSTEM_NO_DEPRECATED'],
}

def getDebugFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
Expand Down
4 changes: 2 additions & 2 deletions examples/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def build(bld):
# List all .cpp files (whole example in one .cpp)
for ex in bld.path.ant_glob('*.cpp'):
name = ex.change_ext('').path_from(bld.path.get_bld())
bld.program(name='example-%s' % name,
bld.program(name=f'example-{name}',
target=name,
source=[ex],
use='ndn-svs',
Expand All @@ -15,7 +15,7 @@ def build(bld):
# List all directories (example can have multiple .cpp in the directory)
for subdir in bld.path.ant_glob('*', dir=True, src=False):
name = subdir.path_from(bld.path)
bld.program(name='example-%s' % name,
bld.program(name=f'example-{name}',
target=name,
source=subdir.ant_glob('**/*.cpp'),
use='ndn-svs',
Expand Down
4 changes: 2 additions & 2 deletions ndn-svs/core.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2022 University of California, Los Angeles
* Copyright (c) 2012-2023 University of California, Los Angeles
*
* This file is part of ndn-svs, synchronization library for distributed realtime
* applications for NDN.
Expand Down Expand Up @@ -48,7 +48,7 @@ SVSyncCore::SVSyncCore(ndn::Face& face,
, m_retxDist(m_periodicSyncTime.count() * (1.0 - m_periodicSyncJitter), m_periodicSyncTime.count() * (1.0 + m_periodicSyncJitter))
, m_intrReplyDist(0, m_maxSuppressionTime.count())
, m_keyChainMem("pib-memory:", "tpm-memory:")
, m_scheduler(m_face.getIoService())
, m_scheduler(m_face.getIoContext())
{
// Register sync interest filter
m_syncRegisteredPrefix =
Expand Down
10 changes: 4 additions & 6 deletions ndn-svs/fetcher.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2022 University of California, Los Angeles
* Copyright (c) 2012-2023 University of California, Los Angeles
*
* This file is part of ndn-svs, synchronization library for distributed realtime
* applications for NDN.
Expand All @@ -22,7 +22,7 @@ namespace ndn::svs {
Fetcher::Fetcher(Face& face,
const SecurityOptions& securityOptions)
: m_face(face)
, m_scheduler(face.getIoService())
, m_scheduler(face.getIoContext())
, m_securityOptions(securityOptions)
{}

Expand Down Expand Up @@ -87,13 +87,11 @@ Fetcher::onData(const Interest& interest, const Data& data,
}
else
{
auto onDataValidated = [qi] (const Data& data)
{
auto onDataValidated = [qi] (const Data& data) {
qi.afterSatisfied(qi.interest, data);
};

auto onValidationFailed = [this, qi] (const Data& data, const ValidationError& error)
{
auto onValidationFailed = [this, qi] (const Data& data, const ValidationError& error) {
if (qi.nRetriesOnValidationFail > 0) {
this->m_scheduler.schedule(ndn::time::milliseconds(this->m_securityOptions.millisBeforeRetryOnValidationFail),
[this, qi] {
Expand Down
6 changes: 3 additions & 3 deletions ndn-svs/svspubsub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ SVSPubSub::onSyncData(const Data& firstData, const std::pair<Name, SeqNo>& publi
// Return data to packet subscriptions
SubscriptionData subData = {
innerData.getName(),
ndn::make_span(innerContent.value(), innerContent.value_size()),
innerContent.value_bytes(),
publication.first,
publication.second,
innerData,
Expand All @@ -342,8 +342,8 @@ SVSPubSub::onSyncData(const Data& firstData, const std::pair<Name, SeqNo>& publi
// Fetch remaining segments
auto pubName = firstData.getName().getPrefix(-2);
Interest interest(pubName); // strip off version and segment number
ndn::util::SegmentFetcher::Options opts;
auto fetcher = ndn::util::SegmentFetcher::start(m_face, interest, m_nullValidator, opts);
ndn::SegmentFetcher::Options opts;
auto fetcher = ndn::SegmentFetcher::start(m_face, interest, m_nullValidator, opts);

fetcher->onComplete.connectSingleShot([this, publication] (const ndn::ConstBufferPtr& data) {
try {
Expand Down
10 changes: 6 additions & 4 deletions tests/unit-tests/version-vector.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012-2021 University of California, Los Angeles
* Copyright (c) 2012-2023 University of California, Los Angeles
*
* This file is part of ndn-svs, synchronization library for distributed realtime
* applications for NDN.
Expand All @@ -23,8 +23,9 @@ namespace ndn {
namespace svs {
namespace test {

struct TestVersionVectorFixture
class TestVersionVectorFixture
{
protected:
TestVersionVectorFixture()
{
v.set("one", 1);
Expand Down Expand Up @@ -75,8 +76,9 @@ BOOST_AUTO_TEST_CASE(EncodeDecode)
BOOST_AUTO_TEST_CASE(DecodeStatic)
{
// Hex: CA0A070508036F6E65CC0101CA0A0705080374776FCC0102
const char* encoded = "\xCA\x0A\x07\x05\x08\x03\x6F\x6E\x65\xCC\x01\x01\xCA\x0A\x07\x05\x08\x03\x74\x77\x6F\xCC\x01\x02";
VersionVector dv(ndn::encoding::makeBinaryBlock(tlv::StateVector, encoded, 24));
constexpr std::string_view encoded{"\xCA\x0A\x07\x05\x08\x03\x6F\x6E\x65\xCC\x01\x01"
"\xCA\x0A\x07\x05\x08\x03\x74\x77\x6F\xCC\x01\x02"};
VersionVector dv(ndn::encoding::makeStringBlock(tlv::StateVector, encoded));
BOOST_CHECK_EQUAL(dv.get("one"), 1);
BOOST_CHECK_EQUAL(dv.get("two"), 2);
}
Expand Down
11 changes: 6 additions & 5 deletions tests/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
top = '..'

def build(bld):
bld.program(target='../unit-tests',
name='unit-tests',
source=bld.path.ant_glob('**/*.cpp'),
use='ndn-svs',
install_path=None)
bld.program(
target=f'{top}/unit-tests',
name='unit-tests',
source=bld.path.ant_glob('**/*.cpp'),
use='BOOST_TESTS ndn-svs',
install_path=None)
58 changes: 32 additions & 26 deletions wscript
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-

from waflib import Context, Logs, Utils
import os, subprocess
import os
import subprocess
from waflib import Context, Logs

VERSION = '0.1.0'
APPNAME = 'ndn-svs'
GIT_TAG_PREFIX = 'ndn-svs-'
GIT_TAG_PREFIX = ''

def options(opt):
opt.load(['compiler_cxx', 'gnu_dirs'])
Expand All @@ -32,7 +33,7 @@ def options(opt):
help='Build unit tests')

optgrp.add_option('--with-compression', action='store_true', default=False,
dest='with_compression', help='Build with state vector compression extension')
help='Build with state vector compression extension')

def configure(conf):
conf.start_msg('Building static library')
Expand Down Expand Up @@ -67,18 +68,21 @@ def configure(conf):
conf.find_program(['pkgconf', 'pkg-config'], var='PKGCONFIG')

pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'],
conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.1', '--cflags', '--libs'],
uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)

boost_libs = ['system']
if conf.env.WITH_TESTS:
boost_libs.append('unit_test_framework')

boost_libs = []
if conf.options.with_compression:
boost_libs.append('iostreams')
conf.define('COMPRESSION', 1)

conf.check_boost(lib=boost_libs, mt=True)
if conf.env.BOOST_VERSION_NUMBER < 107100:
conf.fatal('The minimum supported version of Boost is 1.71.0.\n'
'Please upgrade your distribution or manually install a newer version of Boost.\n'
'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')

if conf.env.WITH_TESTS:
conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')

conf.check_compiler_flags()

Expand All @@ -91,6 +95,7 @@ def configure(conf):
# system has a different version of the ndn-svs library installed.
conf.env.prepend_value('STLIBPATH', ['.'])

conf.define_cond('COMPRESSION', conf.options.with_compression)
conf.define_cond('HAVE_TESTS', conf.env.WITH_TESTS)
# The config header will contain all defines that were added using conf.define()
# or conf.define_cond(). Everything that was added directly to conf.env.DEFINES
Expand All @@ -101,33 +106,34 @@ def configure(conf):
def build(bld):
libndn_svs = dict(
target='ndn-svs',
vnum=VERSION,
cnum=VERSION,
source=bld.path.ant_glob('ndn-svs/**/*.cpp'),
use='NDN_CXX BOOST',
use='BOOST NDN_CXX',
includes='ndn-svs .',
export_includes='ndn-svs .',
install_path='${LIBDIR}')

if bld.env.enable_shared:
bld.shlib(name='ndn-svs',
**libndn_svs)
bld.shlib(
name='ndn-svs',
vnum=VERSION,
cnum=VERSION,
**libndn_svs)

if bld.env.enable_static:
bld.stlib(name='ndn-svs-static' if bld.env.enable_shared else 'ndn-svs',
**libndn_svs)
bld.stlib(
name='ndn-svs-static' if bld.env.enable_shared else 'ndn-svs',
**libndn_svs)

if bld.env.WITH_TESTS:
bld.recurse('tests')

if bld.env.WITH_EXAMPLES:
bld.recurse('examples')

# Install header files
headers = bld.path.ant_glob('ndn-svs/**/*.hpp')
bld.install_files('${INCLUDEDIR}', headers, relative_trick=True)

bld.install_files('${INCLUDEDIR}/ndn-svs',
bld.path.find_resource('config.hpp'))
bld.install_files('${INCLUDEDIR}/ndn-svs', 'config.hpp')

bld(features='subst',
source='libndn-svs.pc.in',
Expand Down Expand Up @@ -169,16 +175,16 @@ def version(ctx):
# first, try to get a version string from git
gotVersionFromGit = False
try:
cmd = ['git', 'describe', '--always', '--match', '%s*' % GIT_TAG_PREFIX]
out = subprocess.check_output(cmd, universal_newlines=True).strip()
cmd = ['git', 'describe', '--always', '--match', f'{GIT_TAG_PREFIX}*']
out = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
if out:
gotVersionFromGit = True
if out.startswith(GIT_TAG_PREFIX):
Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX)
else:
# no tags matched
Context.g_module.VERSION = '%s-commit-%s' % (VERSION_BASE, out)
except (OSError, subprocess.CalledProcessError):
Context.g_module.VERSION = f'{VERSION_BASE}-commit-{out}'
except (OSError, subprocess.SubprocessError):
pass

versionFile = ctx.path.find_node('VERSION.info')
Expand All @@ -196,14 +202,14 @@ def version(ctx):
# already up-to-date
return
except EnvironmentError as e:
Logs.warn('%s exists but is not readable (%s)' % (versionFile, e.strerror))
Logs.warn(f'{versionFile} exists but is not readable ({e.strerror})')
else:
versionFile = ctx.path.make_node('VERSION.info')

try:
versionFile.write(Context.g_module.VERSION)
except EnvironmentError as e:
Logs.warn('%s is not writable (%s)' % (versionFile, e.strerror))
Logs.warn(f'{versionFile} is not writable ({e.strerror})')

def dist(ctx):
ctx.algo = 'tar.xz'
Expand Down

0 comments on commit 3e48741

Please sign in to comment.