Skip to content

Commit 679c42a

Browse files
committed
build+ci: sync with ndn-cxx
Change-Id: Iff3ad63469eccb47571ba4abd3d42936f0cd8650
1 parent 5ca40bb commit 679c42a

File tree

14 files changed

+225
-234
lines changed

14 files changed

+225
-234
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: CI
22
on:
33
push:
4+
branches:
5+
- '**'
46
paths-ignore:
5-
- 'docs/**'
67
- '*.conf.sample*'
7-
- '*.md'
8+
- 'docs/**'
9+
- '.editorconfig'
10+
- '.gitignore'
811
- '.mailmap'
12+
- '*.md'
913
workflow_dispatch:
1014

1115
permissions: {}

.jenkins

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ case $(uname) in
1010
fi
1111
export ID VERSION_ID
1212
export ID_LIKE="${ID} ${ID_LIKE} linux"
13-
export PATH="${HOME}/.local/bin${PATH:+:}${PATH}"
13+
if [[ -z $GITHUB_ACTIONS ]]; then
14+
export PATH="${HOME}/.local/bin${PATH:+:}${PATH}"
15+
fi
1416
;;
1517
Darwin)
1618
# Emulate a subset of os-release(5)
1719
export ID=macos
1820
export VERSION_ID=$(sw_vers -productVersion)
19-
export PATH="/usr/local/bin${PATH:+:}${PATH}"
21+
if [[ -z $GITHUB_ACTIONS ]]; then
22+
export PATH="/usr/local/bin${PATH:+:}${PATH}"
23+
fi
2024
if [[ -x /opt/homebrew/bin/brew ]]; then
2125
eval "$(/opt/homebrew/bin/brew shellenv)"
2226
elif [[ -x /usr/local/bin/brew ]]; then
@@ -27,9 +31,9 @@ esac
2731

2832
export CACHE_DIR=${CACHE_DIR:-/tmp}
2933

30-
if [[ $JOB_NAME == *"code-coverage" ]]; then
31-
export DISABLE_ASAN=yes
32-
export DISABLE_HEADERS_CHECK=yes
34+
if [[ $JOB_NAME == *code-coverage ]]; then
35+
export DISABLE_ASAN=1
36+
export DISABLE_HEADERS_CHECK=1
3337
fi
3438

3539
# https://reproducible-builds.org/docs/source-date-epoch/

.jenkins.d/00-deps.sh

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
set -eo pipefail
33

44
APT_PKGS=(
5-
build-essential
5+
dpkg-dev
6+
g++
67
libboost-chrono-dev
78
libboost-date-time-dev
89
libboost-dev
@@ -14,26 +15,42 @@ APT_PKGS=(
1415
libboost-thread-dev
1516
libsqlite3-dev
1617
libssl-dev
17-
pkg-config
18-
python3-minimal
18+
pkgconf
19+
python3
1920
)
20-
FORMULAE=(boost openssl pkg-config)
21-
PIP_PKGS=()
21+
DNF_PKGS=(
22+
boost-devel
23+
gcc-c++
24+
libasan
25+
lld
26+
openssl-devel
27+
pkgconf
28+
python3
29+
sqlite-devel
30+
)
31+
FORMULAE=(boost openssl pkgconf)
2232
case $JOB_NAME in
2333
*code-coverage)
24-
APT_PKGS+=(lcov python3-pip)
25-
PIP_PKGS+=('gcovr~=5.2')
34+
APT_PKGS+=(lcov)
2635
;;
2736
*Docs)
28-
APT_PKGS+=(doxygen graphviz python3-pip)
37+
APT_PKGS+=(doxygen graphviz)
2938
FORMULAE+=(doxygen graphviz)
30-
PIP_PKGS+=(sphinx sphinxcontrib-doxylink)
3139
;;
3240
esac
3341

42+
install_uv() {
43+
if [[ -z $GITHUB_ACTIONS && $ID_LIKE == *debian* ]]; then
44+
sudo apt-get install -qy --no-install-recommends pipx
45+
pipx upgrade uv || pipx install uv
46+
fi
47+
}
48+
3449
set -x
3550

3651
if [[ $ID == macos ]]; then
52+
export HOMEBREW_COLOR=1
53+
export HOMEBREW_NO_ENV_HINTS=1
3754
if [[ -n $GITHUB_ACTIONS ]]; then
3855
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
3956
fi
@@ -43,10 +60,17 @@ elif [[ $ID_LIKE == *debian* ]]; then
4360
sudo apt-get update -qq
4461
sudo apt-get install -qy --no-install-recommends "${APT_PKGS[@]}"
4562
elif [[ $ID_LIKE == *fedora* ]]; then
46-
sudo dnf install -y gcc-c++ libasan lld pkgconf-pkg-config python3 \
47-
boost-devel openssl-devel sqlite-devel
63+
sudo dnf install -y "${DNF_PKGS[@]}"
4864
fi
4965

50-
if (( ${#PIP_PKGS[@]} )); then
51-
pip3 install --user --upgrade --upgrade-strategy=eager "${PIP_PKGS[@]}"
52-
fi
66+
case $JOB_NAME in
67+
*code-coverage)
68+
install_uv
69+
;;
70+
*Docs)
71+
install_uv
72+
export FORCE_COLOR=1
73+
export UV_NO_MANAGED_PYTHON=1
74+
uv tool install sphinx --upgrade --with-requirements docs/requirements.txt
75+
;;
76+
esac

.jenkins.d/10-build.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ set -eo pipefail
44
if [[ -z $DISABLE_ASAN ]]; then
55
ASAN="--with-sanitizer=address"
66
fi
7-
if [[ $JOB_NAME == *"code-coverage" ]]; then
7+
if [[ $JOB_NAME == *code-coverage ]]; then
88
COVERAGE="--with-coverage"
99
fi
1010

1111
set -x
1212

13-
if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
13+
if [[ $JOB_NAME != *code-coverage && $JOB_NAME != *limited-build ]]; then
1414
# Build in release mode with tests
1515
./waf --color=yes configure --with-tests
1616
./waf --color=yes build
@@ -30,7 +30,5 @@ fi
3030
./waf --color=yes configure --debug --with-tests $ASAN $COVERAGE
3131
./waf --color=yes build
3232

33-
# (tests will be run against the debug version)
34-
3533
# Install
3634
sudo ./waf --color=yes install

.jenkins.d/30-coverage.sh

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
#!/usr/bin/env bash
2-
set -exo pipefail
2+
set -eo pipefail
33

4-
if [[ $JOB_NAME == *"code-coverage" ]]; then
5-
# Generate an XML report (Cobertura format) and a detailed HTML report using gcovr
6-
# Note: trailing slashes are important in the paths below. Do not remove them!
7-
gcovr --object-directory build \
8-
--filter src/ \
9-
--exclude-throw-branches \
10-
--exclude-unreachable-branches \
11-
--cobertura build/coverage.xml \
12-
--html-details build/gcovr/ \
13-
--print-summary
4+
[[ $JOB_NAME == *code-coverage ]] || exit 0
145

15-
# Generate a detailed HTML report using lcov
16-
lcov --quiet \
17-
--capture \
18-
--directory . \
19-
--exclude "$PWD/tests/*" \
20-
--no-external \
21-
--rc lcov_branch_coverage=1 \
22-
--output-file build/coverage.info
6+
export FORCE_COLOR=1
7+
export UV_NO_MANAGED_PYTHON=1
238

24-
genhtml --branch-coverage \
25-
--demangle-cpp \
26-
--legend \
27-
--output-directory build/lcov \
28-
--title "NDNS unit tests" \
29-
build/coverage.info
30-
fi
9+
set -x
10+
11+
# Generate an XML report (Cobertura format) and a detailed HTML report using gcovr
12+
# Note: trailing slashes are important in the paths below. Do not remove them!
13+
14+
--object-directory build \
15+
--filter src/ \
16+
--exclude-throw-branches \
17+
--exclude-unreachable-branches \
18+
--cobertura build/coverage.xml \
19+
--html-details build/gcovr/ \
20+
--print-summary
21+
22+
# Generate a detailed HTML report using lcov
23+
lcov --quiet \
24+
--capture \
25+
--directory . \
26+
--exclude "$PWD/tests/*" \
27+
--no-external \
28+
--rc lcov_branch_coverage=1 \
29+
--output-file build/coverage.info
30+
31+
genhtml --branch-coverage \
32+
--demangle-cpp \
33+
--legend \
34+
--output-directory build/lcov \
35+
--title "NDNS unit tests" \
36+
build/coverage.info

.waf-tools/default-compiler-flags.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,32 @@ def configure(conf):
1111
conf.start_msg('Checking C++ compiler version')
1212

1313
cxx = conf.env.CXX_NAME # generic name of the compiler
14-
ccver = tuple(int(i) for i in conf.env.CC_VERSION)
14+
ccver = get_compiler_ver(conf)
1515
ccverstr = '.'.join(conf.env.CC_VERSION)
1616
errmsg = ''
1717
warnmsg = ''
1818
if cxx == 'gcc':
19-
if ccver < (7, 4, 0):
19+
if ccver < (9, 1, 0):
2020
errmsg = ('The version of gcc you are using is too old.\n'
21-
'The minimum supported gcc version is 9.3.')
22-
elif ccver < (9, 3, 0):
23-
warnmsg = ('Using a version of gcc older than 9.3 is not '
21+
'The minimum supported gcc version is 10.2.')
22+
elif ccver < (10, 2, 0):
23+
warnmsg = ('Using a version of gcc older than 10.2 is not '
2424
'officially supported and may result in build failures.')
2525
conf.flags = GccFlags()
2626
elif cxx == 'clang':
2727
if Utils.unversioned_sys_platform() == 'darwin':
28-
if ccver < (10, 0, 0):
28+
if ccver < (11, 0, 0):
2929
errmsg = ('The version of Xcode you are using is too old.\n'
30-
'The minimum supported Xcode version is 12.4.')
31-
elif ccver < (12, 0, 0):
32-
warnmsg = ('Using a version of Xcode older than 12.4 is not '
30+
'The minimum supported Xcode version is 13.0.')
31+
elif ccver < (13, 0, 0):
32+
warnmsg = ('Using a version of Xcode older than 13.0 is not '
3333
'officially supported and may result in build failures.')
3434
elif ccver < (7, 0, 0):
3535
errmsg = ('The version of clang you are using is too old.\n'
36-
'The minimum supported clang version is 7.0.')
36+
'The minimum supported clang version is 10.0.')
37+
elif ccver < (10, 0, 0):
38+
warnmsg = ('Using a version of clang older than 10.0 is not '
39+
'officially supported and may result in build failures.')
3740
conf.flags = ClangFlags()
3841
else:
3942
warnmsg = f'{cxx} compiler is unsupported'
@@ -57,6 +60,10 @@ def configure(conf):
5760
conf.env.DEFINES += generalFlags['DEFINES']
5861

5962

63+
def get_compiler_ver(conf):
64+
return tuple(int(i) for i in conf.env.CC_VERSION)
65+
66+
6067
@Configure.conf
6168
def check_compiler_flags(conf):
6269
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
@@ -121,9 +128,6 @@ def add_supported_linkflags(self, linkflags):
121128

122129

123130
class CompilerFlags:
124-
def getCompilerVersion(self, conf):
125-
return tuple(int(i) for i in conf.env.CC_VERSION)
126-
127131
def getGeneralFlags(self, conf):
128132
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
129133
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
@@ -223,7 +227,7 @@ def getGeneralFlags(self, conf):
223227
elif Utils.unversioned_sys_platform() == 'freebsd':
224228
# Bug #4790
225229
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
226-
if self.getCompilerVersion(conf) >= (18, 0, 0):
230+
if get_compiler_ver(conf) >= (18, 0, 0) and get_compiler_ver(conf) < (20, 1, 0):
227231
# Bug #5300
228232
flags['CXXFLAGS'] += ['-Wno-enum-constexpr-conversion']
229233
return flags
@@ -237,10 +241,10 @@ def getDebugFlags(self, conf):
237241
flags = super().getDebugFlags(conf)
238242
flags['CXXFLAGS'] += self.__cxxFlags
239243
# Enable assertions in libc++
240-
if self.getCompilerVersion(conf) >= (18, 0, 0):
244+
if get_compiler_ver(conf) >= (18, 0, 0):
241245
# https://libcxx.llvm.org/Hardening.html
242246
flags['DEFINES'] += ['_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE']
243-
elif self.getCompilerVersion(conf) >= (15, 0, 0):
247+
elif get_compiler_ver(conf) >= (15, 0, 0):
244248
# https://releases.llvm.org/15.0.0/projects/libcxx/docs/UsingLibcxx.html#enabling-the-safe-libc-mode
245249
flags['DEFINES'] += ['_LIBCPP_ENABLE_ASSERTIONS=1']
246250
# Tell libc++ to avoid including transitive headers

.waf-tools/sphinx.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# inspired by code by Hans-Martin von Gaudecker, 2012
2+
3+
"""Support for Sphinx documentation"""
4+
5+
import os
6+
from waflib import Task, TaskGen
7+
8+
9+
class sphinx_build(Task.Task):
10+
color = 'BLUE'
11+
run_str = '${SPHINX_BUILD} -q -b ${BUILDERNAME} -D ${VERSION} -D ${RELEASE} -d ${DOCTREEDIR} ${SRCDIR} ${OUTDIR}'
12+
13+
def keyword(self):
14+
return f'Processing ({self.env.BUILDERNAME})'
15+
16+
17+
# from https://docs.python.org/3.12/whatsnew/3.12.html#imp
18+
def load_source(modname, filename):
19+
import importlib.util
20+
from importlib.machinery import SourceFileLoader
21+
loader = SourceFileLoader(modname, filename)
22+
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
23+
module = importlib.util.module_from_spec(spec)
24+
loader.exec_module(module)
25+
return module
26+
27+
28+
@TaskGen.feature('sphinx')
29+
@TaskGen.before_method('process_source')
30+
def process_sphinx(self):
31+
"""Set up the task generator with a Sphinx instance and create a task."""
32+
33+
conf = self.path.find_node(self.config)
34+
if not conf:
35+
self.bld.fatal(f'Sphinx configuration file {repr(self.config)} not found')
36+
37+
inputs = [conf] + self.to_nodes(self.source)
38+
task = self.create_task('sphinx_build', inputs, always_run=getattr(self, 'always', False))
39+
40+
confdir = conf.parent.abspath()
41+
buildername = getattr(self, 'builder', 'html')
42+
srcdir = getattr(self, 'srcdir', confdir)
43+
outdir = self.path.find_or_declare(getattr(self, 'outdir', buildername)).get_bld()
44+
doctreedir = getattr(self, 'doctreedir', os.path.join(outdir.abspath(), '.doctrees'))
45+
release = getattr(self, 'release', self.version)
46+
47+
task.env['BUILDERNAME'] = buildername
48+
task.env['SRCDIR'] = srcdir
49+
task.env['OUTDIR'] = outdir.abspath()
50+
task.env['DOCTREEDIR'] = doctreedir
51+
task.env['VERSION'] = f'version={self.version}'
52+
task.env['RELEASE'] = f'release={release}'
53+
54+
if buildername == 'man':
55+
confdata = load_source('sphinx_conf', conf.abspath())
56+
for i in confdata.man_pages:
57+
target = outdir.find_or_declare(f'{i[1]}.{i[4]}')
58+
task.outputs.append(target)
59+
if self.install_path:
60+
self.bld.install_files(f'{self.install_path}/man{i[4]}/', target)
61+
else:
62+
task.outputs.append(outdir)
63+
64+
# prevent process_source from complaining that there is no extension mapping for .rst files
65+
self.source = []
66+
67+
68+
def configure(conf):
69+
"""Check if sphinx-build program is available."""
70+
conf.find_program('sphinx-build', var='SPHINX_BUILD', mandatory=False)
71+
72+
73+
# sphinx command
74+
from waflib.Build import BuildContext
75+
class sphinx(BuildContext):
76+
cmd = 'sphinx'
77+
fun = 'sphinx'

0 commit comments

Comments
 (0)