diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc9b3bf..55239f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py index 4aa9e9b..bee5072 100644 --- a/.waf-tools/default-compiler-flags.py +++ b/.waf-tools/default-compiler-flags.py @@ -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""" diff --git a/examples/wscript b/examples/wscript index 342f8f4..3d1be68 100644 --- a/examples/wscript +++ b/examples/wscript @@ -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', @@ -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', diff --git a/ndn-svs/core.cpp b/ndn-svs/core.cpp index 23c8d60..4b65543 100644 --- a/ndn-svs/core.cpp +++ b/ndn-svs/core.cpp @@ -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. @@ -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 = diff --git a/ndn-svs/fetcher.cpp b/ndn-svs/fetcher.cpp index 9710bac..19e37eb 100644 --- a/ndn-svs/fetcher.cpp +++ b/ndn-svs/fetcher.cpp @@ -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. @@ -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) {} @@ -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] { diff --git a/ndn-svs/svspubsub.cpp b/ndn-svs/svspubsub.cpp index d78cf70..2fcb8ca 100644 --- a/ndn-svs/svspubsub.cpp +++ b/ndn-svs/svspubsub.cpp @@ -316,7 +316,7 @@ SVSPubSub::onSyncData(const Data& firstData, const std::pair& 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, @@ -342,8 +342,8 @@ SVSPubSub::onSyncData(const Data& firstData, const std::pair& 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 { diff --git a/tests/unit-tests/version-vector.t.cpp b/tests/unit-tests/version-vector.t.cpp index 2aa9473..326a525 100644 --- a/tests/unit-tests/version-vector.t.cpp +++ b/tests/unit-tests/version-vector.t.cpp @@ -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. @@ -23,8 +23,9 @@ namespace ndn { namespace svs { namespace test { -struct TestVersionVectorFixture +class TestVersionVectorFixture { +protected: TestVersionVectorFixture() { v.set("one", 1); @@ -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); } diff --git a/tests/wscript b/tests/wscript index 5e21726..8944e81 100644 --- a/tests/wscript +++ b/tests/wscript @@ -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) diff --git a/wscript b/wscript index 5c784f6..2f8ab1c 100644 --- a/wscript +++ b/wscript @@ -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']) @@ -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') @@ -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() @@ -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 @@ -101,21 +106,23 @@ 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') @@ -123,11 +130,10 @@ def build(bld): 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', @@ -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') @@ -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'