Skip to content

Commit 34a0b3f

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: I438afdd31870b92c54dce30254a485ebb4667b56
1 parent 1fa0861 commit 34a0b3f

File tree

6 files changed

+49
-44
lines changed

6 files changed

+49
-44
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
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

Lines changed: 16 additions & 11 deletions
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

Lines changed: 3 additions & 2 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
@@ -16,7 +17,7 @@ APT_PKGS=(
1617
libsqlite3-dev
1718
libssl-dev
1819
pkg-config
19-
python3-minimal
20+
python3
2021
)
2122
FORMULAE=(boost openssl pkg-config)
2223
PIP_PKGS=()

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ChronoSync: synchronization library for distributed realtime applications for NDN
22

3+
![Latest version](https://img.shields.io/github/v/tag/named-data/ChronoSync?label=Latest%20version)
4+
![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
35
[![CI](https://github.com/named-data/ChronoSync/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/ChronoSync/actions/workflows/ci.yml)
46
[![Docs](https://github.com/named-data/ChronoSync/actions/workflows/docs.yml/badge.svg)](https://github.com/named-data/ChronoSync/actions/workflows/docs.yml)
5-
![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
6-
![Latest version](https://img.shields.io/github/v/tag/named-data/ChronoSync?label=Latest%20version)
77

88
> [!NOTE]
99
> DEPRECATION NOTICE: ChronoSync's design is outdated. We recommend using more recent

docs/conf.py

Lines changed: 1 addition & 1 deletion
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 = 'ChronoSync: A Synchronization Protocol for NDN'
13-
copyright = 'Copyright © 2012-2023 Regents of the University of California.'
13+
copyright = 'Copyright © 2012-2024 Regents of the University of California.'
1414
author = 'Named Data Networking Project'
1515

1616
# The short X.Y version.

wscript

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -140,43 +140,41 @@ def version(ctx):
140140
Context.g_module.VERSION_SPLIT = VERSION_BASE.split('.')
141141

142142
# first, try to get a version string from git
143-
gotVersionFromGit = False
143+
version_from_git = ''
144144
try:
145-
cmd = ['git', 'describe', '--always', '--match', f'{GIT_TAG_PREFIX}*']
146-
out = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
147-
if out:
148-
gotVersionFromGit = True
149-
if out.startswith(GIT_TAG_PREFIX):
150-
Context.g_module.VERSION = out.lstrip(GIT_TAG_PREFIX)
145+
cmd = ['git', 'describe', '--abbrev=8', '--always', '--match', f'{GIT_TAG_PREFIX}*']
146+
version_from_git = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
147+
if version_from_git:
148+
if version_from_git.startswith(GIT_TAG_PREFIX):
149+
Context.g_module.VERSION = version_from_git.lstrip(GIT_TAG_PREFIX)
151150
else:
152151
# no tags matched
153-
Context.g_module.VERSION = f'{VERSION_BASE}-commit-{out}'
152+
Context.g_module.VERSION = f'{VERSION_BASE}+git.{version_from_git}'
154153
except (OSError, subprocess.SubprocessError):
155154
pass
156155

157-
versionFile = ctx.path.find_node('VERSION.info')
158-
if not gotVersionFromGit and versionFile is not None:
156+
# fallback to the VERSION.info file, if it exists and is not empty
157+
version_from_file = ''
158+
version_file = ctx.path.find_node('VERSION.info')
159+
if version_file is not None:
159160
try:
160-
Context.g_module.VERSION = versionFile.read()
161-
return
162-
except EnvironmentError:
163-
pass
164-
165-
# version was obtained from git, update VERSION file if necessary
166-
if versionFile is not None:
167-
try:
168-
if versionFile.read() == Context.g_module.VERSION:
169-
# already up-to-date
170-
return
171-
except EnvironmentError as e:
172-
Logs.warn(f'{versionFile} exists but is not readable ({e.strerror})')
173-
else:
174-
versionFile = ctx.path.make_node('VERSION.info')
161+
version_from_file = version_file.read().strip()
162+
except OSError as e:
163+
Logs.warn(f'{e.filename} exists but is not readable ({e.strerror})')
164+
if version_from_file and not version_from_git:
165+
Context.g_module.VERSION = version_from_file
166+
return
175167

168+
# update VERSION.info if necessary
169+
if version_from_file == Context.g_module.VERSION:
170+
# already up-to-date
171+
return
172+
if version_file is None:
173+
version_file = ctx.path.make_node('VERSION.info')
176174
try:
177-
versionFile.write(Context.g_module.VERSION)
178-
except EnvironmentError as e:
179-
Logs.warn(f'{versionFile} is not writable ({e.strerror})')
175+
version_file.write(Context.g_module.VERSION)
176+
except OSError as e:
177+
Logs.warn(f'{e.filename} is not writable ({e.strerror})')
180178

181179
def dist(ctx):
182180
ctx.algo = 'tar.xz'

0 commit comments

Comments
 (0)