Skip to content

Commit 44b0f8c

Browse files
committed
build: change the fallback version suffix to +git.{sha}
Seems to be more commonly used than the current `-commit-{sha}`. Also cleanup/simplify the version handling code and fix the list of dependencies in the CI scripts. Change-Id: I75d9e492523c296ad69c5b94be071836308f4ad8
1 parent ecb2db1 commit 44b0f8c

File tree

6 files changed

+52
-45
lines changed

6 files changed

+52
-45
lines changed

.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ trim_trailing_whitespace = true
2626
[*.{yaml,yml}]
2727
indent_style = space
2828
indent_size = 2
29+
trim_trailing_whitespace = true

.gitignore

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1-
# Emacs
1+
# Backup files
22
*~
3+
*.bak
4+
*.orig
5+
*.rej
6+
7+
# Waf build system
8+
/build/
9+
.waf-*-*/
10+
.waf3-*-*/
11+
.lock-waf*
12+
13+
# Compiled python code
14+
__pycache__/
15+
*.py[cod]
16+
17+
# Emacs
318
\#*\#
419
/.emacs.desktop
520
/.emacs.desktop.lock
@@ -15,15 +30,5 @@
1530
.LSOverride
1631
._*
1732

18-
# Waf build system
19-
/build/
20-
.waf-*-*/
21-
.waf3-*-*/
22-
.lock-waf*
23-
24-
# Compiled python code
25-
__pycache__/
26-
*.py[cod]
27-
2833
# Other
2934
/VERSION.info

.jenkins.d/00-deps.sh

+3-2
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
@@ -15,7 +16,7 @@ APT_PKGS=(
1516
libsqlite3-dev
1617
libssl-dev
1718
pkg-config
18-
python3-minimal
19+
python3
1920
)
2021
FORMULAE=(boost openssl pkg-config)
2122
PIP_PKGS=()

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# NAC: Name-Based Access Control Library for NDN
22

3+
![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
34
[![CI](https://github.com/named-data/name-based-access-control/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/name-based-access-control/actions/workflows/ci.yml)
45
[![Docs](https://github.com/named-data/name-based-access-control/actions/workflows/docs.yml/badge.svg)](https://github.com/named-data/name-based-access-control/actions/workflows/docs.yml)
5-
![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
66

77
## Reporting bugs
88

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1111

1212
project = 'NAC: Name-based Access Control library'
13-
copyright = 'Copyright © 2014-2023 Regents of the University of California.'
13+
copyright = 'Copyright © 2014-2024 Regents of the University of California.'
1414
author = 'Named Data Networking Project'
1515

1616
# The short X.Y version.

wscript

+30-30
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from waflib import Context, Logs
66

77
VERSION = '0.1.0'
88
APPNAME = 'ndn-nac'
9-
GIT_TAG_PREFIX = 'nac-'
9+
GIT_TAG_PREFIX = 'ndn-nac-'
1010

1111
def options(opt):
1212
opt.load(['compiler_cxx', 'gnu_dirs'])
@@ -168,43 +168,43 @@ def version(ctx):
168168
Context.g_module.VERSION_SPLIT = VERSION_BASE.split('.')
169169

170170
# first, try to get a version string from git
171-
gotVersionFromGit = False
171+
version_from_git = ''
172172
try:
173-
cmd = ['git', 'describe', '--always', '--match', f'{GIT_TAG_PREFIX}*']
174-
out = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
175-
if out:
176-
gotVersionFromGit = True
177-
if out.startswith(GIT_TAG_PREFIX):
178-
Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX)
173+
cmd = ['git', 'describe', '--abbrev=8', '--always', '--match', f'{GIT_TAG_PREFIX}*']
174+
version_from_git = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
175+
if version_from_git:
176+
if GIT_TAG_PREFIX and version_from_git.startswith(GIT_TAG_PREFIX):
177+
Context.g_module.VERSION = version_from_git[len(GIT_TAG_PREFIX):]
178+
elif not GIT_TAG_PREFIX and ('.' in version_from_git or '-' in version_from_git):
179+
Context.g_module.VERSION = version_from_git
179180
else:
180-
# no tags matched
181-
Context.g_module.VERSION = f'{VERSION_BASE}-commit-{out}'
181+
# no tags matched (or we are in a shallow clone)
182+
Context.g_module.VERSION = f'{VERSION_BASE}+git.{version_from_git}'
182183
except (OSError, subprocess.SubprocessError):
183184
pass
184185

185-
versionFile = ctx.path.find_node('VERSION.info')
186-
if not gotVersionFromGit and versionFile is not None:
186+
# fallback to the VERSION.info file, if it exists and is not empty
187+
version_from_file = ''
188+
version_file = ctx.path.find_node('VERSION.info')
189+
if version_file is not None:
187190
try:
188-
Context.g_module.VERSION = versionFile.read()
189-
return
190-
except EnvironmentError:
191-
pass
192-
193-
# version was obtained from git, update VERSION file if necessary
194-
if versionFile is not None:
195-
try:
196-
if versionFile.read() == Context.g_module.VERSION:
197-
# already up-to-date
198-
return
199-
except EnvironmentError as e:
200-
Logs.warn(f'{versionFile} exists but is not readable ({e.strerror})')
201-
else:
202-
versionFile = ctx.path.make_node('VERSION.info')
191+
version_from_file = version_file.read().strip()
192+
except OSError as e:
193+
Logs.warn(f'{e.filename} exists but is not readable ({e.strerror})')
194+
if version_from_file and not version_from_git:
195+
Context.g_module.VERSION = version_from_file
196+
return
203197

198+
# update VERSION.info if necessary
199+
if version_from_file == Context.g_module.VERSION:
200+
# already up-to-date
201+
return
202+
if version_file is None:
203+
version_file = ctx.path.make_node('VERSION.info')
204204
try:
205-
versionFile.write(Context.g_module.VERSION)
206-
except EnvironmentError as e:
207-
Logs.warn(f'{versionFile} is not writable ({e.strerror})')
205+
version_file.write(Context.g_module.VERSION)
206+
except OSError as e:
207+
Logs.warn(f'{e.filename} is not writable ({e.strerror})')
208208

209209
def dist(ctx):
210210
ctx.algo = 'tar.xz'

0 commit comments

Comments
 (0)