Skip to contentSkip to conversation

libgpiod: add support for libgpiod v2

PATCH New Bartosz Golaszewski 1 participant 3 messages Feb 16, 2023

lore
Share & tools
lore
#0 lore raw

v2 cover libgpiod: add support for libgpiod v2

From: Bartosz Golaszewski <[email protected]>

We've just tagged the release candidate for libgpiod v2. This is a major release entirely overhauling the API in a backward incompatible way.

While this is not the final release yet, it's not likely to change much so I'd like to make it available in meta-openembedded to give it exposure to some testing. When we do release v2.0, it'll be just a matter of bumping the version.

Currently no other package depends on libgpiod in meta-openembedded, so I'd like to avoid having two packages (libgpiod and libgpiod2). Instead let's provide recipes for both versions but keep them under the common libgpiod name as it's unlikely anyone would need both versions in a single system. This is after all a medium-sized project that shouldn't require too much work in order to port a user to the new major release.

The first patch contains an update of libgpiod v1.6.x to the most recent bug-fix release.

The second contains the recipe for libgpiod v2.0-rc1 while also moving the bitbake code around in order to factor out common elements.

The third contains a recipe for the python bindings that are now in their own project in meta-python.

The new recipes provide the same functionality - including ptest for the C library, tools and language bindings.

v1 -> v2:
- Several bugs detected in master-next were fixed and this recipe adds support for libgpiod v2.0-c2. The package now builds with clang, musl as well as clang & musl.

Bartosz Golaszewski (2):
libgpiod: add a recipe for libgpiod v2.0-rc2
python3-gpiod: new package

 .../{files => libgpiod-1.6.4}/run-ptest       |  0
 .../libgpiod/libgpiod-2.0-rc2/run-ptest       | 24 ++++++++
 .../recipes-support/libgpiod/libgpiod-src.inc |  1 +
 meta-oe/recipes-support/libgpiod/libgpiod.inc | 61 +++++++++++++++++++
 .../libgpiod/libgpiod_1.6.4.bb                | 56 ++---------------
 .../libgpiod/libgpiod_2.0-rc2.bb              | 21 +++++++
 .../packagegroups/packagegroup-meta-python.bb |  1 +
 .../python/python3-gpiod/run-ptest            | 15 +++++
 .../python/python3-gpiod_2.0-rc2.bb           | 45 ++++++++++++++
 9 files changed, 174 insertions(+), 50 deletions(-)
 rename meta-oe/recipes-support/libgpiod/{files => libgpiod-1.6.4}/run-ptest (100%)
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.0-rc2/run-ptest
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-src.inc
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod.inc
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod_2.0-rc2.bb
 create mode 100644 meta-python/recipes-devtools/python/python3-gpiod/run-ptest
 create mode 100644 meta-python/recipes-devtools/python/python3-gpiod_2.0-rc2.bb
Signature · 1 line
2.37.2
#1 lore raw

PATCH v2 1/2 libgpiod: add a recipe for libgpiod v2.0-rc2

From: Bartosz Golaszewski <[email protected]>

This is a recipe for libgpiod v2 release candidate. Let's put common bits and pieces into an .inc file and the source fetching into a separate include that will be later reused by the python bindings that for v2 will be moved into a separate recipe in meta-python.

---
 .../{files => libgpiod-1.6.4}/run-ptest       |  0
 .../libgpiod/libgpiod-2.0-rc2/run-ptest       | 24 ++++++++
 .../recipes-support/libgpiod/libgpiod-src.inc |  1 +
 meta-oe/recipes-support/libgpiod/libgpiod.inc | 61 +++++++++++++++++++
 .../libgpiod/libgpiod_1.6.4.bb                | 56 ++---------------
 .../libgpiod/libgpiod_2.0-rc2.bb              | 21 +++++++
 6 files changed, 113 insertions(+), 50 deletions(-)
 rename meta-oe/recipes-support/libgpiod/{files => libgpiod-1.6.4}/run-ptest (100%)
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-2.0-rc2/run-ptest
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod-src.inc
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod.inc
 create mode 100644 meta-oe/recipes-support/libgpiod/libgpiod_2.0-rc2.bb
meta-oe/recipes-support/libgpiod/libgpiod-1.6.4/run-ptest renamed from meta-oe/recipes-support/libgpiod/files/run-ptest +0 -0
similarity index 100%
rename from meta-oe/recipes-support/libgpiod/files/run-ptest
rename to meta-oe/recipes-support/libgpiod/libgpiod-1.6.4/run-ptest
meta-oe/recipes-support/libgpiod/libgpiod-2.0-rc2/run-ptest new file +24 -0
new file mode 100644
index 000000000..9475f0253
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+testbins="gpiod-test gpio-tools-test gpiod-cxx-test"
+
+ptestdir=$(dirname "$(readlink -f "$0")")
+cd $ptestdir/tests
+
+# libgpiod v2 uses gpio-sim - a configfs-based testing module. We need to
+# make sure configfs is mounted before running any tests.
+modprobe configfs
+mountpoint /sys/kernel/config > /dev/null || mount -t configfs configfs /sys/kernel/config
+
+for testbin in $testbins; do
+	if test -e ./$testbin; then
+		./$testbin > ./$testbin.out 2>&1
+		if [ $? -ne 0 ]; then
+			echo "FAIL: $testbin"
+		else
+			echo "PASS: $testbin"
+		fi
+	else
+		echo "SKIP: $testbin"
+	fi
+done
meta-oe/recipes-support/libgpiod/libgpiod-src.inc new file +1 -0
new file mode 100644
index 000000000..6bab4c1f4
@@ -0,0 +1 @@
+SRC_URI += "https://www.kernel.org/pub/software/libs/libgpiod/libgpiod-${PV}.tar.xz"
meta-oe/recipes-support/libgpiod/libgpiod.inc new file +61 -0

61 lines not on this page · raw message

meta-oe/recipes-support/libgpiod/libgpiod_1.6.4.bb +6 -50

86 lines not on this page · raw message

meta-oe/recipes-support/libgpiod/libgpiod_2.0-rc2.bb new file +21 -0
new file mode 100644
index 000000000..158175cdb
@@ -0,0 +1,21 @@
+require libgpiod.inc
+
+LICENSE = "GPL-2.0-or-later & LGPL-2.1-or-later & CC-BY-SA-4.0"
+LIC_FILES_CHKSUM = " \
+    file://LICENSES/GPL-2.0-or-later.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
+    file://LICENSES/LGPL-2.1-or-later.txt;md5=4b54a1fd55a448865a0b32d41598759d \
+    file://LICENSES/CC-BY-SA-4.0.txt;md5=fba3b94d88bfb9b81369b869a1e9a20f \
+"
+
+SRC_URI[sha256sum] = "1b931bfabef897911e59d45c80b8930c43fa72f08aab9c03e8dfd4005881c09e"
+
+S = "${WORKDIR}/libgpiod-2.0"
+
+# We must enable gpioset-interactive for all gpio-tools tests to pass
+PACKAGECONFIG[tests] = "--enable-tests --enable-gpioset-interactive,--disable-tests,kmod util-linux glib-2.0 catch2 libedit"
+PACKAGECONFIG[gpioset-interactive] = "--enable-gpioset-interactive,--disable-gpioset-interactive,libedit"
+
+FILES:${PN}-tools += "${bindir}/gpionotify"
+FILES:${PN}-ptest += "${libdir}/libgpiosim.so.*"
+
+RRECOMMENDS:${PN}-ptest += "kernel-module-gpio-sim"
Signature · 1 line
2.37.2
#2 lore raw

PATCH v2 2/2 python3-gpiod: new package

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Add a recipe for libgpiod v2 python bindings. This is a release candidate but once the proper v2.0 is released, it will be made public on pypi and the recipe modified accordingly.

As libgpiod python bindings now use setuptools and not make, we can separate the recipe from the rest of the library.

---
 .../packagegroups/packagegroup-meta-python.bb |  1 +
 .../python/python3-gpiod/run-ptest            | 15 +++++++
 .../python/python3-gpiod_2.0-rc2.bb           | 45 +++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-gpiod/run-ptest
 create mode 100644 meta-python/recipes-devtools/python/python3-gpiod_2.0-rc2.bb
meta-python/recipes-core/packagegroups/packagegroup-meta-python.bb +1 -0
index 2275ccd6c..2428674c4 100644
@@ -157,6 +157,7 @@ RDEPENDS:packagegroup-meta-python3 = "\
     python3-gmqtt \
     python3-gnupg \
     python3-google-api-python-client \
+    python3-gpiod \
     python3-gpsd-py3 \
     python3-graphviz \
     python3-greenlet \
meta-python/recipes-devtools/python/python3-gpiod/run-ptest new file +15 -0
new file mode 100644
index 000000000..bf1244b07
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+cd $(dirname "$(readlink -f "$0")")
+
+# python3-gpiod uses gpio-sim - a configfs-based testing module. We need to
+# make sure configfs is mounted before running any tests.
+modprobe configfs
+mountpoint /sys/kernel/config > /dev/null || mount -t configfs configfs /sys/kernel/config
+
+python3 -m gpiod-test -v > ./python3-gpiod.out 2>&1
+if [ $? -ne 0 ]; then
+	echo "FAIL: python3-gpiod"
+else
+	echo "PASS: python3-gpiod"
+fi
meta-python/recipes-devtools/python/python3-gpiod_2.0-rc2.bb new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.37.2