build: detach the libgpiod API version from the libgpiod package version
Subsystems (2)
cover build: detach the libgpiod API version from the libgpiod package version
The versioning of libgpiod has become quite messy due to the rapid evolution of the project in its initial stages (which forced an ABI version change without bumping the API) and later extension with several bindings and tools kept in the same repository.
Currently the library API version and the package version are the same but we're at a stage where the core C API will most likely remain quite stable but we're still extending other features of the project, like the DBus API, tools and possibly other bindings. Bumping the C API version because we added new features to included programs makes no sense so this series proposes to detach the core C API version from the libgpiod package version (except for the major version updates but I don't expect there to be one anytime soon).
The core C API will also apply to C++ and GLib bindings as they track the C API closely. Rust and Python bindings already have their own API versions.
---
Bartosz Golaszewski (7):
bindings: cxx: move misc.hpp inclusion to the correct place
build: define a separate API version for the core C library
core: change the behavior of gpiod_api_version()
tests: update library API version string tests
tools: display C API *and* libgpiod package version for '-v'
dbus: manager: display C API *and* libgpiod package version for '-v'
dbus: gpiocli: display the libgpiod package version for --version
bindings/cxx/gpiod.hpp | 1 + bindings/cxx/gpiodcxx/line-request.hpp | 2 -- bindings/cxx/tests/tests-misc.cpp | 2 +- bindings/glib/tests/tests-misc.c | 2 +- bindings/python/tests/tests_module.py | 2 +- configure.ac | 4 ++++ dbus/client/gpiocli.c | 2 +- dbus/manager/gpio-manager.c | 5 +++-- lib/misc.c | 2 +- tests/tests-misc.c | 2 +- tools/tools-common.c | 3 ++- 11 files changed, 16 insertions(+), 11 deletions(-)
---
base-commit: d0006cc3d57b0e8fe090a1596934340c34e69ab4
change-id: 20250901-api-version-detach-67d8e984d529
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
PATCH 1/7 bindings: cxx: move misc.hpp inclusion to the correct place
From: Bartosz Golaszewski <[email protected]>
The symbols from gpiodcxx/misc.hpp are correctly exported to users of gpiod.hpp because it's implicitly pulled in by line-request.hpp but that's incorrect: line-request.hpp has no need for any of the symbols from misc.hpp and it should be part of the set of headers included by the top-level gpiod.hpp. Move it to the correct place.
--- bindings/cxx/gpiod.hpp | 1 + bindings/cxx/gpiodcxx/line-request.hpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
bindings/cxx/gpiod.hpp +1 -0
@@ -35,6 +35,7 @@ #include "gpiodcxx/line-info.hpp" #include "gpiodcxx/line-request.hpp" #include "gpiodcxx/line-settings.hpp" +#include "gpiodcxx/misc.hpp" #include "gpiodcxx/request-builder.hpp" #include "gpiodcxx/request-config.hpp" #undef __LIBGPIOD_GPIOD_CXX_INSIDE__
bindings/cxx/gpiodcxx/line-request.hpp +0 -2
@@ -17,8 +17,6 @@ #include <iostream> #include <memory> -#include "misc.hpp" - namespace gpiod { class chip;
Signature · 1 line
2.48.1
PATCH 2/7 build: define a separate API version for the core C library
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
The core C API of libgpiod has become quite stable and unlikely to change soon. We will still be adding some new features to the included programs and some of the bindings (notably: Python and Rust) but it doesn't make sense to bump the C API which hasn't changed, just becuase we're doing a minor release of the larger package.
Define a separate libgpiod C API version in configure.ac. This will affect the C, C++ and GLib APIs as the latter two track the C API closely. Rust and Python bindings already have their own API versions.
Set the API version to v2.2.0 as it hasn't changed in the libgpiod v2.3 release cycle yet.
--- configure.ac | 4 ++++ 1 file changed, 4 insertions(+)
configure.ac +4 -0
@@ -35,6 +35,10 @@ AC_SUBST(ABI_GPIOSIM_VERSION, [1.1.0]) # ... and another one for GLib bindings: AC_SUBST(ABI_GLIB_VERSION, [1.0.0]) +# Core libgpiod API version. +AC_SUBST(API_VERSION, [2.2.0]) +AC_DEFINE_UNQUOTED([GPIOD_API_VERSION_STR], ["$API_VERSION"], [Library API version string.]) + AC_CONFIG_AUX_DIR([autostuff]) AC_CONFIG_MACRO_DIRS([m4]) AM_INIT_AUTOMAKE([foreign subdir-objects])
Signature · 1 line
2.48.1
PATCH 3/7 core: change the behavior of gpiod_api_version()
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Make gpiod_api_version() return the human-readable form of the libgpiod C API instead of the libgpiod package version.
--- lib/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/misc.c +1 -1
@@ -12,5 +12,5 @@ GPIOD_API bool gpiod_is_gpiochip_device(const char *path) GPIOD_API const char *gpiod_api_version(void) { -return GPIOD_VERSION_STR ; +return GPIOD_API_VERSION_STR ; }
Signature · 1 line
2.48.1
PATCH 4/7 tests: update library API version string tests
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
The version string returned by gpiod_api_version() is now stricter and will always be of the form: x.y.z where x, y and z are unsigned integer numbers. We no longer have to parse various suffixes so update the test cases tree-wide.
--- bindings/cxx/tests/tests-misc.cpp | 2 +- bindings/glib/tests/tests-misc.c | 2 +- bindings/python/tests/tests_module.py | 2 +- tests/tests-misc.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
bindings/cxx/tests/tests-misc.cpp +1 -1
@@ -71,7 +71,7 @@ TEST_CASE("api_version() returns a valid API version", "[misc]") SECTION("check api_version() format") { REQUIRE_THAT(::gpiod::api_version(), - regex_matcher("^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)?$")); + regex_matcher("^\\d+\\.\\d+\\.\\d+")); } }
bindings/glib/tests/tests-misc.c +1 -1
@@ -56,7 +56,7 @@ GPIOD_TEST_CASE(is_gpiochip_link_good)GPIOD_TEST_CASE (version_string) { -static const gchar *const pattern ="^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)?$" ; +static const gchar *const pattern ="^\\d+\\.\\d+\\.\\d+" ;g_autoptr (GError) err =NULL ;g_autoptr (GRegex) regex =NULL ;
bindings/python/tests/tests_module.py +1 -1
@@ -50,7 +50,7 @@ class IsGPIOChip(TestCase): class VersionString(TestCase): - VERSION_PATTERN = "^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)?$" + VERSION_PATTERN = "^\\d+\\.\\d+\\.\\d+$" def test_api_version_string(self) -> None: self.assertRegex(gpiod.api_version, VersionString.VERSION_PATTERN)
tests/tests-misc.c +1 -1
@@ -68,7 +68,7 @@ GPIOD_TEST_CASE(is_gpiochip_null_path)GPIOD_TEST_CASE (version_string) { -static const gchar *const pattern ="^\\d+\\.\\d+(\\.\\d+|\\-devel|\\-rc\\d+)?$" ; +static const gchar *const pattern ="^\\d+\\.\\d+\\.\\d+" ;g_autoptr (GError) err =NULL ;g_autoptr (GRegex) regex =NULL ;
Signature · 1 line
2.48.1
PATCH 5/7 tools: display C API *and* libgpiod package version for '-v'
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
With the recent changes to the versioning scheme and the disassociation of the core C API from the libgpiod package version, it now makes sense to display both in the output of '<tool> --version' for all gpio-tools.
--- tools/tools-common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/tools-common.c +2 -1
@@ -93,7 +93,8 @@ void die_perror(const char *fmt, ...)void print_version (void ) { -printf ("%s (libgpiod) v%s\n" ,get_prog_short_name (),gpiod_api_version ()); +printf ("%s v%s (libgpiod v%s)\n" , +get_prog_short_name (),GPIOD_VERSION_STR ,gpiod_api_version ());printf ("Copyright (C) 2017-2023 Bartosz Golaszewski\n" );printf ("License: GPL-2.0-or-later\n" );printf ("This is free software: you are free to change and redistribute it.\n" );
Signature · 1 line
2.48.1
PATCH 6/7 dbus: manager: display C API *and* libgpiod package version for '-v'
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
With the recent changes to the versioning scheme and the disassociation of the core C API from the libgpiod package version, it now makes sense to display both in the output of 'gpio-manager --version'.
--- dbus/manager/gpio-manager.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
dbus/manager/gpio-manager.c +3 -2
@@ -77,8 +77,9 @@ static void on_name_lost(GDBusConnection *con,static void print_version_and_exit (void ) { -g_print ("%s (libgpiod) v%s\nD-Bus API version: %d\n" , -g_get_prgname (),gpiodglib_api_version (),GPIODBUS_API_VERSION ); +g_print ("%s v%s (libgpiod v%s)\nD-Bus API version: %d\n" , +g_get_prgname (),GPIOD_VERSION_STR , +gpiodglib_api_version (),GPIODBUS_API_VERSION );exit (EXIT_SUCCESS ); }
Signature · 1 line
2.48.1
PATCH 7/7 dbus: gpiocli: display the libgpiod package version for --version
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Currently gpiocli does not display the libgpiod API version in the output of gpiocli --version because it's not linked against libgpiod - it's only a consumer of the DBus API.
However, with the recent changes to the versioning scheme and the disassociation of the core C API from the libgpiod package version, it now makes sense to display the latter so add it.
--- dbus/client/gpiocli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
dbus/client/gpiocli.c +1 -1
@@ -116,7 +116,7 @@ static gchar *make_description(void)static void show_version_and_exit (void ) { -g_print ("gpiocli (libgpiod) v%s\nD-Bus API version: %d\n" , +g_print ("gpiocli v%s\nD-Bus API version: %d\n" ,GPIOD_VERSION_STR ,GPIODBUS_API_VERSION );exit (EXIT_SUCCESS );
Signature · 1 line
2.48.1
Quoted 41 lines · Bartosz Golaszewski
The versioning of libgpiod has become quite messy due to the rapid evolution of the project in its initial stages (which forced an ABI version change without bumping the API) and later extension with several bindings and tools kept in the same repository.
Currently the library API version and the package version are the same but we're at a stage where the core C API will most likely remain quite stable but we're still extending other features of the project, like the DBus API, tools and possibly other bindings. Bumping the C API version because we added new features to included programs makes no sense so this series proposes to detach the core C API version from the libgpiod package version (except for the major version updates but I don't expect there to be one anytime soon).
The core C API will also apply to C++ and GLib bindings as they track the C API closely. Rust and Python bindings already have their own API versions.
Signed-off-by Bartosz Golaszewski <[email protected]>---
Bartosz Golaszewski (7):
bindings: cxx: move misc.hpp inclusion to the correct place
build: define a separate API version for the core C library
core: change the behavior ofgpiod_api_version()
tests: update library API version string tests
tools: display C API *and* libgpiod package version for '-v'
dbus: manager: display C API *and* libgpiod package version for '-v'
dbus: gpiocli: display the libgpiod package version for --versionbindings/cxx/gpiod.hpp | 1 + bindings/cxx/gpiodcxx/line-request.hpp | 2 -- bindings/cxx/tests/tests-misc.cpp | 2 +- bindings/glib/tests/tests-misc.c | 2 +- bindings/python/tests/tests_module.py | 2 +- configure.ac | 4 ++++ dbus/client/gpiocli.c | 2 +- dbus/manager/gpio-manager.c | 5 +++-- lib/misc.c | 2 +- tests/tests-misc.c | 2 +- tools/tools-common.c | 3 ++- 11 files changed, 16 insertions(+), 11 deletions(-)
Quoted 7 lines
---
base-commit:d0006cc3d57b0e8fe090a1596934340c34e69ab4
change-id: 20250901-api-version-detach-67d8e984d529Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
Looks reasonable to me!
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 14 lines · Bartosz Golaszewski
The versioning of libgpiod has become quite messy due to the rapid evolution of the project in its initial stages (which forced an ABI version change without bumping the API) and later extension with several bindings and tools kept in the same repository.
Currently the library API version and the package version are the same but we're at a stage where the core C API will most likely remain quite stable but we're still extending other features of the project, like the DBus API, tools and possibly other bindings. Bumping the C API version because we added new features to included programs makes no sense so this series proposes to detach the core C API version from the libgpiod package version (except for the major version updates but I don't expect there to be one anytime soon).
Quoted 1 line
[...]
Applied, thanks!
[1/7] bindings: cxx: move misc.hpp inclusion to the correct place
https://git.kernel.org/brgl/libgpiod/c/aeb74d629b2c060da6e04ba087448bfcb58c791e [2/7] build: define a separate API version for the core C library https://git.kernel.org/brgl/libgpiod/c/cf49a9a57132399fac228285c7fc11d1d1c39bb3 [3/7] core: change the behavior of gpiod_api_version() https://git.kernel.org/brgl/libgpiod/c/a62c7329366d49933f5a69b5aa9f5e79bbec4676 [4/7] tests: update library API version string tests https://git.kernel.org/brgl/libgpiod/c/d30bcd7b2ecaa2da1a299c7f53fbc04325b2c55b [5/7] tools: display C API *and* libgpiod package version for '-v' https://git.kernel.org/brgl/libgpiod/c/8d0cae535df5339fbb0faca9b86452c013869d40 [6/7] dbus: manager: display C API *and* libgpiod package version for '-v' https://git.kernel.org/brgl/libgpiod/c/5204b44f83a110a5404631bea95445e4c50a96df [7/7] dbus: gpiocli: display the libgpiod package version for --version https://git.kernel.org/brgl/libgpiod/c/6c4812be6a822d5c6a09fb0f7d352a91e03cbcdc
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>