Skip to contentSkip to conversation

build: detach the libgpiod API version from the libgpiod package version

PATCH Applied Bartosz Golaszewski 2 participants 10 messages Sep 3, 2025 – Sep 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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]>
#1 lore raw

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
index 606994dd606a19d63bfcccff90fdce972148397f..c5fda421ffadad83f5f7dd1e60eed1de55354095 100644
@@ -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
index 96050191317f1790c6322d93439af6f93bcbd960..e41f31a115ce86d469236f33730112333a495519 100644
@@ -17,8 +17,6 @@
 #include <iostream>
 #include <memory>
 
-#include "misc.hpp"
-
 namespace gpiod {
 
 class chip;
Signature · 1 line
2.48.1
#2 lore raw

PATCH 2/7 build: define a separate API version for the core C library

In reply to Bartosz Golaszewski

From: 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
index fe9673904c5ffcda2c7aa6783b28a93793a01c0c..4d4996053dafcbf95c60ba1396910fec4826ad7e 100644
@@ -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
#3 lore raw

PATCH 3/7 core: change the behavior of gpiod_api_version()

In reply to Bartosz Golaszewski

From: 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
index e109f8086b4c22edccfb5e88b89e4bf2fac4feee..33d68379032f6dfdc17d40c13ac08a5d911dc93f 100644
@@ -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
#4 lore raw

PATCH 4/7 tests: update library API version string tests

In reply to Bartosz Golaszewski

From: 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
index 33fc3faf029d7969f547f5c528abee6bd9f02020..8fef2e18f9dd494cdd0818bd3d2225111a869871 100644
@@ -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
index 356e408ec4c2240bb2211d2a064f85794da625fa..37f9d6849f9f8dc7155cc22d51dd5bda8bc5e4c2 100644
@@ -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
index 7120c6346ba4666adb250d0880d5777dbb7666ea..406bfe7c4c486bce34848246e2e58ce028cfde4a 100644
@@ -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
index 9d4f3dedbae6f0e415d85be52d7b47dad01cce43..00f3272d2ebc199801792209b428503912b97309 100644
@@ -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
#5 lore raw

PATCH 5/7 tools: display C API *and* libgpiod package version for '-v'

In reply to Bartosz Golaszewski

From: 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
index a684fcbd22eb32ccc822b83d5bf96fa9b976a9e9..8c2d5bc055ce48982d45d667aa975ec14cffc925 100644
@@ -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
#6 lore raw

PATCH 6/7 dbus: manager: display C API *and* libgpiod package version for '-v'

In reply to Bartosz Golaszewski

From: 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
index 03ca7ab828e4f7ca57ca992f244a0c0afeb5b6a9..3aaf1c9f5480645382d35a11e790faa806de66b5 100644
@@ -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
#7 lore raw

PATCH 7/7 dbus: gpiocli: display the libgpiod package version for --version

In reply to Bartosz Golaszewski

From: 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
index 26d641be570b0508d87dee1c17e197b2ccff2d7d..4ab5d3f9bb24f0d1cdef20e369ab00de097a4674 100644
@@ -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
Acked-by on the v1 series
#8 lore raw
In reply to Bartosz Golaszewski
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.

---
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(-)
Quoted 7 lines

---
base-commit: d0006cc3d57b0e8fe090a1596934340c34e69ab4
change-id: 20250901-api-version-detach-67d8e984d529

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>

Looks reasonable to me!

author Applied
#9 lore raw
In reply to Bartosz Golaszewski

From: 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]>