Skip to content

Commit

Permalink
Restructure version handling
Browse files Browse the repository at this point in the history
Implementation and API version information is added to the API
documentation. The README now contains an API version-specific link.

A script is added to the test suite, verifying the documentation and
shared library version information to be correct.

The library implementation now identifies itself as 1.0.0. The ABI is
version 0.0.

Signed-off-by: Mattias Rönnblom <[email protected]>
  • Loading branch information
m-ronnblom committed Nov 4, 2020
1 parent ec5614a commit 674c977
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 6 deletions.
13 changes: 10 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ bin_SCRIPTS = app/pafappc

# For information on how to update these numbers, see:
# https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html#Libtool-versioning
PAF_VERSION_CURRENT=0
PAF_VERSION_REVISION=0
PAF_VERSION_CURRENT=@PAF_ABI_MINOR_VERSION@
PAF_VERSION_REVISION=@PAF_PATCH_VERSION@
PAF_VERSION_AGE=$(PAF_VERSION_CURRENT)

libpaf_la_SOURCES = src/util.c src/epoll_reg.c src/ptimer.c src/log.c \
Expand Down Expand Up @@ -90,6 +90,13 @@ distclean-local:
common/config.h.in
find . -name \*~ -print0 | xargs -0 rm -f

verify-versions: all
./test/verify_versions.py $(srcdir)/include/paf.h \
$(srcdir)/README.md $(builddir) \
@PAF_ABI_MAJOR_VERSION@ @PAF_ABI_MINOR_VERSION@ \
@PAF_MAJOR_VERSION@ @PAF_MINOR_VERSION@ \
@PAF_PATCH_VERSION@

paftest-run: paftest
./paftest -c $(TESTS)

Expand All @@ -105,7 +112,7 @@ paftest-run-valgrind: paftest
--suppressions=test/lttng.supp \
--num-callers=20 ./paftest -v -c $(TESTS)

BASIC_TEST_TARGETS=paftest-run
BASIC_TEST_TARGETS=verify-versions paftest-run

if VALGRIND
TEST_TARGETS=paftest-run-valgrind $(BASIC_TEST_TARGETS)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ API documentation in Doxygen format is available in paf.h. `make
doxygen` will create HTML version. If the `pdflatex` tool is
installed, a PDF version will also be produced.

An online copy of the latest documentation can be found at:
https://ericsson.github.io/libpaf/api/latest/
An online copy of this API version's documentation can be found here:
https://ericsson.github.io/libpaf/api/0.0/
16 changes: 15 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
-*- Autoconf -*-

AC_INIT(libpaf, 0.1, [[email protected]])
m4_define([paf_major_version], [1])
m4_define([paf_minor_version], [0])
m4_define([paf_patch_version], [0])
m4_define([paf_version],[paf_major_version.paf_minor_version.paf_patch_version])

m4_define([paf_abi_major_version], [m4_eval(paf_major_version - 1)])
m4_define([paf_abi_minor_version], [paf_minor_version])

AC_INIT(libpaf, [paf_version], [[email protected]])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_MACRO_DIR([m4])
AC_PREREQ([2.63])
AC_PROG_CC

AC_SUBST([PAF_ABI_MAJOR_VERSION], [paf_abi_major_version])
AC_SUBST([PAF_ABI_MINOR_VERSION], [paf_abi_minor_version])
AC_SUBST([PAF_MAJOR_VERSION], [paf_major_version])
AC_SUBST([PAF_MINOR_VERSION], [paf_minor_version])
AC_SUBST([PAF_PATCH_VERSION], [paf_patch_version])

AC_USE_SYSTEM_EXTENSIONS

LT_INIT
Expand Down
5 changes: 5 additions & 0 deletions include/paf.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ extern "C" {
* - paf_value.h Property value.
* - paf_err.h Error handling.
* - paf_match.h Subscription matching.
*
* @author Mattias Rönnblom
* @version 0.0 [API]
* @version 1.0.0 [Implementation]
*
*/

/*!
Expand Down
123 changes: 123 additions & 0 deletions test/verify_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/python3

import sys
import re
import os
import stat

if len(sys.argv) != 9:
print("Usage: %s <paf-hdr-file> <readme> <builddir> <expected-abi-major> "
"<expected-abi-minor> <expected-impl-major>"
"<exepected-impl-minor> <expected-impl-patch>" % sys.argv[0])
sys.exit(1)

hdr_abi_version_re = \
re.compile(r'@version\s+([0-9]+)\.([0-9]+).*API.*')
hdr_impl_version_re = \
re.compile(r'@version\s+([0-9]+)\.([0-9]+)\.([0-9]+).*Implementation.*')

readme_link_re = re.compile(r'paf/api/([0-9]+)\.([0-9]+)/')

def check_hdr(hdr_file, abi_major, abi_minor, impl_major, impl_minor,
impl_patch):
hdr = open(hdr_file).read()

print("ABI version: %d.%d." % (abi_major, abi_minor))
print("Implementation version: %d.%d.%d" %
(impl_major, impl_minor, impl_patch))
print("Header file: %s" % hdr_file)

hdr_abi_m = hdr_abi_version_re.search(hdr)
if not hdr_abi_m:
print("Can't find ABI version info in %s." % hdr_file)
sys.exit(1)
hdr_abi_major, hdr_abi_minor = [int(ver) for ver in hdr_abi_m.groups()]

print("Pathfinder ABI documented to be version %d.%d." %
(hdr_abi_major, hdr_abi_minor))

if abi_major != hdr_abi_major:
print("Incorrect ABI major version in header file.")
sys.exit(1)

if abi_minor != hdr_abi_minor:
print("Incorrect ABI minor version in header file.")
sys.exit(1)

hdr_impl_m = hdr_impl_version_re.search(hdr)
if not hdr_impl_m:
print("Can't find Implementation version info in %s." % hdr_file)
sys.exit(1)
hdr_impl_major, hdr_impl_minor, hdr_impl_patch = \
[int(ver) for ver in hdr_impl_m.groups()]

print("Pathfinder library implementation documented to be "
"version %d.%d.%d." % (hdr_impl_major, hdr_impl_minor,
hdr_impl_patch))

if impl_major != hdr_impl_major:
print("Incorrect implementation major version in header file.")
sys.exit(1)

if impl_minor != hdr_impl_minor:
print("Incorrect implementation minor version in header file.")
sys.exit(1)

if impl_patch != hdr_impl_patch:
print("Incorrect implementation patch version in header file.")
sys.exit(1)

def check_readme(readme_file, abi_major, abi_minor):
readme = open(readme_file).read()

readme_m = readme_link_re.search(readme)

if not readme_m:
print("Can't find API documentation link in %s." % readme_file)
sys.exit(1)

readme_abi_major, readme_abi_minor = [int(ver) for ver in readme_m.groups()]

print("README documentation link points towards version %d.%d." %
(readme_abi_major, readme_abi_minor))

if abi_major != readme_abi_major:
print("Incorrect ABI major version in link.")
sys.exit(1)

if abi_minor != readme_abi_minor:
print("Incorrect ABI minor version in link.")
sys.exit(1)

def check_so(builddir, abi_major, abi_minor, patch):
so_file = "%s/.libs/libpaf.so.%d.%d.%d" % \
(builddir, abi_major, abi_minor, patch)
try:
st = os.stat(so_file)
if stat.S_ISREG(st.st_mode):
print("Shared library file is at \"%s\", as expected." % so_file)
else:
print("\"%s\" is not a regular file." % so_file)
sys.exit(1)
except FileNotFoundError:
print("Shared library file \"%s\" not found." % so_file)
sys.exit(1)

paf_hdr_file = sys.argv[1]
readme = sys.argv[2]
builddir = sys.argv[3]
abi_major = int(sys.argv[4])
abi_minor = int(sys.argv[5])
impl_major = int(sys.argv[6])
impl_minor = int(sys.argv[7])
impl_patch = int(sys.argv[8])

check_hdr(paf_hdr_file, abi_major, abi_minor, impl_major, impl_minor,
impl_patch)

check_readme(readme, abi_major, abi_minor)

check_so(builddir, abi_major, abi_minor, impl_patch)

print("All good.")
sys.exit(0)

0 comments on commit 674c977

Please sign in to comment.