1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00

build: replace autotools with meson & ninja

Port the project from autotools to meson. All build options are
preserved with the same semantics.

The goal of this change is to produce the same set of files as the
current autotools approach: libraries with correct SONAME/version,
headers, pkg-config files, GObject introspection data, Python extension
modules, D-Bus interface and configuration files. This is done to enable
a one-liner test command running all available test suites.

The only thing we drop is the `make docs` target as it's rarely used and
docs can be generated easily with sphinx directly. They are also not
required for testing.

The Rust workspace is built via a custom target that invokes cargo and
uses SYSTEM_DEPS_* environment variables to point the libgpiod-sys and
gpiosim-sys crates at the locally built C libraries.

In addition to porting the build files to meson, update the docs, remove
unneded items from .gitignore files (or remove them entirely if they're
no longer needed) and update the shunit2 test scripts to no longer care
about source directories.

Tested-by: Erik Wierich <erik@riscstar.com>
Tested-by: Vincent Fazio <vfazio@xes-inc.com>
Link: https://patch.msgid.link/20260428-meson-build-v3-1-8da6976fb0a2@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
Bartosz Golaszewski
2026-04-28 11:08:34 +02:00
parent 7acbbcf778
commit 97bab4cc87
98 changed files with 1129 additions and 1684 deletions

27
.gitignore vendored
View File

@@ -1,37 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
*.o
*.lo
*.la
generated-*.c
generated-*.h
*.pc
*.tar.gz
*.patch
*.swp
tags
# autotools stuff
.deps/
.libs/
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
autostuff/
config.h
config.h.in
config.h.in~
config.log
config.status
configure
configure~
libtool
*-libtool
m4/
stamp-h1
# profiling
*.gcda
*.gcno

View File

@@ -1,62 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = foreign
SUBDIRS = include lib contrib
EXTRA_DIST = \
LICENSES/GPL-2.0-or-later.txt \
LICENSES/Apache-2.0.txt \
LICENSES/LGPL-2.1-or-later.txt \
LICENSES/CC-BY-SA-4.0.txt \
LICENSES/CC0-1.0.txt \
LICENSES/GPL-2.0-only.txt \
LICENSES/Linux-syscall-note.txt \
LICENSES/BSD-3-Clause.txt
if WITH_EXAMPLES
SUBDIRS += examples
endif
if WITH_TOOLS
SUBDIRS += tools
endif
if WITH_TESTS
SUBDIRS += tests
endif
# Build bindings after core tests. When building tests for bindings, we need
# libgpiosim to be already present.
SUBDIRS += bindings
if WITH_DBUS
SUBDIRS += dbus
endif
if WITH_MANPAGES
SUBDIRS += man
endif
if WITH_DOCS
SUBDIRS += docs
docs:
$(MAKE) -C docs docs
.PHONY: docs
endif

View File

@@ -1,17 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
# SPDX-FileCopyrightText: 2017 Thierry Reding <treding@nvidia.com>
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd "$srcdir"
autoreconf --force --install --verbose || exit 1
cd $ORIGDIR || exit $?
if test -z "$NOCONFIGURE"; then
exec "$srcdir"/configure "$@"
fi

View File

@@ -1,29 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
SUBDIRS = .
if WITH_BINDINGS_CXX
SUBDIRS += cxx
endif
if WITH_BINDINGS_PYTHON
SUBDIRS += python
endif
if WITH_BINDINGS_RUST
SUBDIRS += rust
endif
if WITH_BINDINGS_GLIB
SUBDIRS += glib
endif

View File

@@ -1,47 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
lib_LTLIBRARIES = libgpiodcxx.la
libgpiodcxx_la_SOURCES = \
chip.cpp \
chip-info.cpp \
edge-event-buffer.cpp \
edge-event.cpp \
exception.cpp \
info-event.cpp \
internal.cpp \
internal.hpp \
line.cpp \
line-config.cpp \
line-info.cpp \
line-request.cpp \
line-settings.cpp \
misc.cpp \
request-builder.cpp \
request-config.cpp
libgpiodcxx_la_CXXFLAGS = -Wall -Wextra -g -std=gnu++17
libgpiodcxx_la_CXXFLAGS += -fvisibility=hidden -I$(top_srcdir)/include/
libgpiodcxx_la_CXXFLAGS += $(PROFILING_CFLAGS)
libgpiodcxx_la_LDFLAGS = -version-info $(subst .,:,$(ABI_CXX_VERSION))
libgpiodcxx_la_LDFLAGS += $(PROFILING_LDFLAGS)
libgpiodcxx_la_LIBADD = $(top_builddir)/lib/libgpiod.la
include_HEADERS = gpiod.hpp
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgpiodcxx.pc
SUBDIRS = gpiodcxx .
if WITH_TESTS
SUBDIRS += tests
endif
if WITH_EXAMPLES
SUBDIRS += examples
endif

View File

@@ -1,16 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
async_watch_line_value
find_line_by_name
get_chip_info
get_line_info
get_line_value
get_multiple_line_values
reconfigure_input_to_output
toggle_line_value
toggle_multiple_line_values
watch_line_info
watch_line_rising
watch_line_value
watch_multiple_line_values

View File

@@ -1,47 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17
LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
noinst_PROGRAMS = \
async_watch_line_value \
find_line_by_name \
get_chip_info \
get_line_info \
get_line_value \
get_multiple_line_values \
reconfigure_input_to_output \
toggle_line_value \
toggle_multiple_line_values \
watch_line_info \
watch_line_rising \
watch_line_value \
watch_multiple_line_values
async_watch_line_value_SOURCES = async_watch_line_value.cpp
find_line_by_name_SOURCES = find_line_by_name.cpp
get_chip_info_SOURCES = get_chip_info.cpp
get_line_info_SOURCES = get_line_info.cpp
get_line_value_SOURCES = get_line_value.cpp
get_multiple_line_values_SOURCES = get_multiple_line_values.cpp
reconfigure_input_to_output_SOURCES = reconfigure_input_to_output.cpp
toggle_line_value_SOURCES = toggle_line_value.cpp
toggle_multiple_line_values_SOURCES = toggle_multiple_line_values.cpp
watch_line_info_SOURCES = watch_line_info.cpp
watch_line_value_SOURCES = watch_line_value.cpp
watch_line_rising_SOURCES = watch_line_rising.cpp
watch_multiple_line_values_SOURCES = watch_multiple_line_values.cpp

View File

@@ -0,0 +1,26 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
cxx_examples = [
'async_watch_line_value',
'find_line_by_name',
'get_chip_info',
'get_line_info',
'get_line_value',
'get_multiple_line_values',
'reconfigure_input_to_output',
'toggle_line_value',
'toggle_multiple_line_values',
'watch_line_info',
'watch_line_rising',
'watch_line_value',
'watch_multiple_line_values',
]
foreach ex : cxx_examples
executable(ex,
sources: [ex + '.cpp'],
include_directories: cxx_inc,
dependencies: [libgpiodcxx_dep],
)
endforeach

View File

@@ -1,20 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2021 Bartosz Golaszewski <brgl@bgdev.pl>
otherincludedir = $(includedir)/gpiodcxx
otherinclude_HEADERS = \
chip.hpp \
chip-info.hpp \
edge-event-buffer.hpp \
edge-event.hpp \
exception.hpp \
info-event.hpp \
line.hpp \
line-config.hpp \
line-info.hpp \
line-request.hpp \
line-settings.hpp \
misc.hpp \
request-builder.hpp \
request-config.hpp \
timestamp.hpp

74
bindings/cxx/meson.build Normal file
View File

@@ -0,0 +1,74 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
cxx_inc = include_directories('.', '../../include')
libgpiodcxx_both = both_libraries('gpiodcxx',
sources: [
'chip.cpp',
'chip-info.cpp',
'edge-event-buffer.cpp',
'edge-event.cpp',
'exception.cpp',
'info-event.cpp',
'internal.cpp',
'line.cpp',
'line-config.cpp',
'line-info.cpp',
'line-request.cpp',
'line-settings.cpp',
'misc.cpp',
'request-builder.cpp',
'request-config.cpp',
],
include_directories: cxx_inc,
cpp_args: ['-fvisibility=hidden'] + profiling_c_args,
link_args: profiling_link_args,
dependencies: [libgpiod_dep],
version: libgpiodcxx_version,
soversion: libgpiodcxx_soversion,
install: true,
)
libgpiodcxx_lib = libgpiodcxx_both.get_shared_lib()
install_headers('gpiod.hpp')
install_headers(
'gpiodcxx/chip.hpp',
'gpiodcxx/chip-info.hpp',
'gpiodcxx/edge-event-buffer.hpp',
'gpiodcxx/edge-event.hpp',
'gpiodcxx/exception.hpp',
'gpiodcxx/info-event.hpp',
'gpiodcxx/line.hpp',
'gpiodcxx/line-config.hpp',
'gpiodcxx/line-info.hpp',
'gpiodcxx/line-request.hpp',
'gpiodcxx/line-settings.hpp',
'gpiodcxx/misc.hpp',
'gpiodcxx/request-builder.hpp',
'gpiodcxx/request-config.hpp',
'gpiodcxx/timestamp.hpp',
subdir: 'gpiodcxx',
)
pkgconfig.generate(libgpiodcxx_lib,
name: 'libgpiodcxx',
description: 'C++ bindings for libgpiod',
url: 'https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/',
version: meson.project_version(),
requires: ['libgpiod'],
)
libgpiodcxx_dep = declare_dependency(
link_with: libgpiodcxx_lib,
include_directories: cxx_inc,
)
if opt_examples.allowed()
subdir('examples')
endif
if opt_tests.allowed()
subdir('tests')
endif

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
gpiod-cxx-test

View File

@@ -1,30 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
AM_CXXFLAGS = -I$(top_srcdir)/bindings/cxx/ -I$(top_srcdir)/include
AM_CXXFLAGS += -I$(top_srcdir)/tests/gpiosim/
AM_CXXFLAGS += -Wall -Wextra -g -std=gnu++17 $(CATCH2_CFLAGS)
AM_LDFLAGS = -pthread $(CATCH2_LIBS)
LDADD = $(top_builddir)/bindings/cxx/libgpiodcxx.la
LDADD += $(top_builddir)/tests/gpiosim/libgpiosim.la
noinst_PROGRAMS = gpiod-cxx-test
gpiod_cxx_test_SOURCES = \
check-kernel.cpp \
gpiod-cxx-test-main.cpp \
gpiosim.cpp \
gpiosim.hpp \
helpers.cpp \
helpers.hpp \
tests-chip.cpp \
tests-chip-info.cpp \
tests-edge-event.cpp \
tests-info-event.cpp \
tests-line.cpp \
tests-line-config.cpp \
tests-line-info.cpp \
tests-line-request.cpp \
tests-line-settings.cpp \
tests-misc.cpp \
tests-request-config.cpp

View File

@@ -0,0 +1,29 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
executable('gpiod-cxx-test',
sources: [
'check-kernel.cpp',
'gpiod-cxx-test-main.cpp',
'gpiosim.cpp',
'helpers.cpp',
'tests-chip.cpp',
'tests-chip-info.cpp',
'tests-edge-event.cpp',
'tests-info-event.cpp',
'tests-line.cpp',
'tests-line-config.cpp',
'tests-line-info.cpp',
'tests-line-request.cpp',
'tests-line-settings.cpp',
'tests-misc.cpp',
'tests-request-config.cpp',
],
include_directories: [
cxx_inc,
include_directories('../../..'),
include_directories('../../../tests/gpiosim'),
],
dependencies: [libgpiodcxx_dep, catch2_test_dep, threads_dep],
link_with: [libgpiosim_lib],
)

View File

@@ -1,7 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
*.gir
*.typelib
Gpiodglib-1.0
gi-docgen.toml

View File

@@ -1,133 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
SUBDIRS = .
if WITH_TESTS
SUBDIRS += tests
endif
if WITH_EXAMPLES
SUBDIRS += examples
endif
lib_LTLIBRARIES = libgpiod-glib.la
libgpiod_glib_la_SOURCES = \
chip.c \
chip-info.c \
edge-event.c \
error.c \
info-event.c \
internal.c \
internal.h \
line-config.c \
line-info.c \
line-request.c \
line-settings.c \
misc.c \
request-config.c
otherincludedir = $(includedir)/gpiod-glib
otherinclude_HEADERS = \
gpiod-glib/chip.h \
gpiod-glib/chip-info.h \
gpiod-glib/edge-event.h \
gpiod-glib/error.h \
gpiod-glib/generated-enums.h \
gpiod-glib/info-event.h \
gpiod-glib/line.h \
gpiod-glib/line-config.h \
gpiod-glib/line-info.h \
gpiod-glib/line-request.h \
gpiod-glib/line-settings.h \
gpiod-glib/misc.h \
gpiod-glib/request-config.h
EXTRA_DIST = \
generated-enums.c.template \
generated-enums.h.template
project_headers = \
$(srcdir)/gpiod-glib/line.h \
$(srcdir)/gpiod-glib/edge-event.h \
$(srcdir)/gpiod-glib/info-event.h
generated-enums.c: $(project_headers) generated-enums.c.template
$(AM_V_GEN)$(GLIB_MKENUMS) \
--template=$(srcdir)/generated-enums.c.template \
--output=$(builddir)/$@ \
$(project_headers)
gpiod-glib/generated-enums.h: $(project_headers) generated-enums.h.template
$(AM_V_GEN)$(GLIB_MKENUMS) \
--template=$(srcdir)/generated-enums.h.template \
--output=$(srcdir)/$@ \
$(project_headers)
nodist_libgpiod_glib_la_SOURCES = \
generated-enums.c \
gpiod-glib/generated-enums.h
BUILT_SOURCES = $(nodist_libgpiod_glib_la_SOURCES)
CLEANFILES = $(nodist_libgpiod_glib_la_SOURCES)
libgpiod_glib_la_CFLAGS = -Wall -Wextra -g
libgpiod_glib_la_CFLAGS += -I$(top_srcdir)/include/ -include $(top_builddir)/config.h
libgpiod_glib_la_CFLAGS += $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GIO_UNIX_CFLAGS)
libgpiod_glib_la_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-glib\"
libgpiod_glib_la_CFLAGS += $(PROFILING_CFLAGS)
libgpiod_glib_la_LDFLAGS = -version-info $(subst .,:,$(ABI_GLIB_VERSION))
libgpiod_glib_la_LDFLAGS += -lgpiod -L$(top_builddir)/lib
libgpiod_glib_la_LDFLAGS += $(GLIB_LIBS) $(GIO_LIBS) $(GIO_UNIX_LIBS)
libgpiod_glib_la_LDFLAGS += $(PROFILING_LDFLAGS)
include_HEADERS = gpiod-glib.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gpiod-glib.pc
if HAVE_INTROSPECTION
INTROSPECTION_GIRS = Gpiodglib-1.0.gir
girdir = $(INTROSPECTION_GIRDIR)
gir_DATA = Gpiodglib-1.0.gir
typelibsdir = $(INTROSPECTION_TYPELIBDIR)
typelibs_DATA = Gpiodglib-1.0.typelib
Gpiodglib_1_0_gir_SCANNERFLAGS = \
--c-include="gpiod-glib.h" \
--warn-all \
--namespace Gpiodglib \
--identifier-prefix Gpiodglib \
--symbol-prefix gpiodglib
Gpiodglib_1_0_gir_CFLAGS = \
$(libgpiod_glib_la_CFLAGS) \
-DGPIODGLIB_COMPILATION
Gpiodglib-1.0.gir: libgpiod-glib.la
Gpiodglib_1_0_gir_INCLUDES = Gio-2.0
Gpiodglib_1_0_gir_LIBS = libgpiod-glib.la
Gpiodglib_1_0_gir_FILES = $(otherinclude_HEADERS) $(libgpiod_glib_la_SOURCES)
Gpiodglib_1_0_gir_EXPORT_PACKAGES = gpiod-glib
include $(INTROSPECTION_MAKEFILE)
endif
if HAS_GI_DOCGEN
doc: Gpiodglib-1.0.gir gi-docgen.toml
$(AM_V_GEN)gi-docgen generate --config gi-docgen.toml Gpiodglib-1.0.gir
.PHONY: doc
EXTRA_DIST += gi-docgen.toml
endif

View File

@@ -1,14 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
find_line_by_name_glib
get_chip_info_glib
get_line_info_glib
get_line_value_glib
get_multiple_line_values_glib
reconfigure_input_to_output_glib
toggle_line_value_glib
toggle_multiple_line_values_glib
watch_line_info_glib
watch_line_value_glib
watch_multiple_edge_rising_glib

View File

@@ -1,22 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
noinst_PROGRAMS = \
find_line_by_name_glib \
get_chip_info_glib \
get_line_info_glib \
get_line_value_glib \
get_multiple_line_values_glib \
reconfigure_input_to_output_glib \
toggle_line_value_glib \
toggle_multiple_line_values_glib \
watch_line_info_glib \
watch_line_value_glib \
watch_multiple_edge_rising_glib
AM_CFLAGS = -I$(top_srcdir)/bindings/glib/
AM_CFLAGS += -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiotools-glib\"
LDADD = $(top_builddir)/bindings/glib/libgpiod-glib.la
LDADD += $(GLIB_LIBS) $(GOBJECT_LIBS)

View File

@@ -0,0 +1,25 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
glib_examples = [
'find_line_by_name_glib',
'get_chip_info_glib',
'get_line_info_glib',
'get_line_value_glib',
'get_multiple_line_values_glib',
'reconfigure_input_to_output_glib',
'toggle_line_value_glib',
'toggle_multiple_line_values_glib',
'watch_line_info_glib',
'watch_line_value_glib',
'watch_multiple_edge_rising_glib',
]
foreach ex : glib_examples
executable(ex,
sources: [ex + '.c'],
include_directories: glib_inc,
c_args: ['-DG_LOG_DOMAIN="gpiotools-glib"'],
dependencies: [libgpiod_glib_dep, glib_dep, gobject_dep],
)
endforeach

View File

@@ -0,0 +1,18 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
gen_enum_h = custom_target('generated-enums-h',
input: [
files('line.h', 'edge-event.h', 'info-event.h'),
files('../generated-enums.h.template'),
],
output: 'generated-enums.h',
command: [
glib_mkenums,
'--template', '@INPUT3@',
'--output', '@OUTPUT@',
'@INPUT0@', '@INPUT1@', '@INPUT2@',
],
install: true,
install_dir: get_option('includedir') / 'gpiod-glib',
)

112
bindings/glib/meson.build Normal file
View File

@@ -0,0 +1,112 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
subdir('gpiod-glib')
project_headers = files(
'gpiod-glib/line.h',
'gpiod-glib/edge-event.h',
'gpiod-glib/info-event.h',
)
gen_enum_c = custom_target('generated-enums-c',
input: project_headers + [files('generated-enums.c.template')],
output: 'generated-enums.c',
command: [
glib_mkenums,
'--template', '@INPUT3@',
'--output', '@OUTPUT@',
'@INPUT0@', '@INPUT1@', '@INPUT2@',
],
)
glib_sources = [
'chip.c',
'chip-info.c',
'edge-event.c',
'error.c',
'info-event.c',
'internal.c',
'line-config.c',
'line-info.c',
'line-request.c',
'line-settings.c',
'misc.c',
'request-config.c',
]
glib_public_headers = files(
'gpiod-glib/chip.h',
'gpiod-glib/chip-info.h',
'gpiod-glib/edge-event.h',
'gpiod-glib/error.h',
'gpiod-glib/info-event.h',
'gpiod-glib/line.h',
'gpiod-glib/line-config.h',
'gpiod-glib/line-info.h',
'gpiod-glib/line-request.h',
'gpiod-glib/line-settings.h',
'gpiod-glib/misc.h',
'gpiod-glib/request-config.h',
)
glib_inc = include_directories('.', '../../include')
libgpiod_glib_both = both_libraries('gpiod-glib',
sources: glib_sources + [gen_enum_c, gen_enum_h],
include_directories: glib_inc,
c_args: ['-DG_LOG_DOMAIN="gpiod-glib"', '-DGPIODGLIB_COMPILATION'] + profiling_c_args,
link_args: profiling_link_args,
dependencies: [libgpiod_dep, glib_dep, gobject_dep, gio_dep, gio_unix_dep],
version: libgpiod_glib_version,
soversion: libgpiod_glib_soversion,
install: true,
)
libgpiod_glib_lib = libgpiod_glib_both.get_shared_lib()
install_headers('gpiod-glib.h')
install_headers(glib_public_headers, subdir: 'gpiod-glib')
pkgconfig.generate(libgpiod_glib_lib,
name: 'gpiod-glib',
description: 'GObject bindings for libgpiod',
url: 'https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/',
version: meson.project_version(),
requires_private: ['libgpiod >= 2.1'],
)
libgpiod_glib_dep = declare_dependency(
link_with: libgpiod_glib_lib,
include_directories: glib_inc,
)
if opt_introspection.allowed() and gir_dep.found()
gnome = import('gnome')
glib_gir = gnome.generate_gir(libgpiod_glib_lib,
sources: glib_sources + glib_public_headers + [gen_enum_c, gen_enum_h],
namespace: 'Gpiodglib',
nsversion: '1.0',
identifier_prefix: 'Gpiodglib',
symbol_prefix: 'gpiodglib',
includes: ['Gio-2.0'],
header: 'gpiod-glib.h',
export_packages: 'gpiod-glib',
extra_args: [
'--c-include=gpiod-glib.h',
'--warn-all',
'-DGPIODGLIB_COMPILATION',
],
include_directories: glib_inc,
install: true,
)
endif
if opt_examples.allowed()
subdir('examples')
endif
if opt_tests.allowed()
subdir('tests')
endif

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
gpiod-glib-test

View File

@@ -1,29 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
noinst_PROGRAMS = gpiod-glib-test
gpiod_glib_test_SOURCES = \
helpers.c \
helpers.h \
tests-chip.c \
tests-chip-info.c \
tests-edge-event.c \
tests-info-event.c \
tests-line-config.c \
tests-line-info.c \
tests-line-request.c \
tests-line-settings.c \
tests-misc.c \
tests-request-config.c
AM_CFLAGS = -I$(top_srcdir)/bindings/glib/
AM_CFLAGS += -I$(top_srcdir)/tests/gpiosim-glib/
AM_CFLAGS += -I$(top_srcdir)/tests/harness/
AM_CFLAGS += -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) $(GIO_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-glib-test\"
LDADD = $(top_builddir)/bindings/glib/libgpiod-glib.la
LDADD += $(top_builddir)/tests/gpiosim/libgpiosim.la
LDADD += $(top_builddir)/tests/gpiosim-glib/libgpiosim-glib.la
LDADD += $(top_builddir)/tests/harness/libgpiod-test-harness.la
LDADD += $(GLIB_LIBS) $(GIO_LIBS)

View File

@@ -0,0 +1,27 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
executable('gpiod-glib-test',
sources: [
'helpers.c',
'tests-chip.c',
'tests-chip-info.c',
'tests-edge-event.c',
'tests-info-event.c',
'tests-line-config.c',
'tests-line-info.c',
'tests-line-request.c',
'tests-line-settings.c',
'tests-misc.c',
'tests-request-config.c',
],
include_directories: [
glib_inc,
include_directories('../../..'),
include_directories('../../../tests/gpiosim-glib'),
include_directories('../../../tests/harness'),
],
c_args: ['-DG_LOG_DOMAIN="gpiod-glib-test"'],
dependencies: [libgpiod_glib_dep, glib_test_dep, gio_test_dep],
link_with: [libgpiosim_lib, libgpiosim_glib_lib, libgpiod_test_harness_lib],
)

18
bindings/meson.build Normal file
View File

@@ -0,0 +1,18 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
if opt_bindings_cxx.allowed()
subdir('cxx')
endif
if opt_bindings_glib.allowed() and glib_dep.found() and glib_mkenums.found()
subdir('glib')
endif
if opt_bindings_python.allowed()
subdir('python')
endif
if opt_bindings_rust.allowed()
subdir('rust')
endif

View File

@@ -1,58 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
EXTRA_DIST = \
MANIFEST.in \
README.md \
build_tests.py \
generate_pypi_artifacts.sh \
pyproject.toml \
setup.py
if WITH_TESTS
python-tests:
TOP_SRCDIR=$(abs_top_builddir) \
TOP_BUILDDIR=$(abs_top_builddir) \
$(PYTHON) build_tests.py
python-tests-run:
PYTHONPATH=$(abs_top_srcdir)/bindings/python \
LD_LIBRARY_PATH=$(abs_top_builddir)/lib/.libs/:\
$(abs_top_builddir)/tests/gpiosim/.libs/ \
$(PYTHON) -B -m tests
else
python-tests:
endif
clean-local:
rm -rf dist
rm -rf gpiod.egg-info
rm -f gpiod/_ext.*.so
rm -f tests/*/_ext.*.so
all-local: python-tests
CFLAGS="-I$(abs_top_srcdir)/include/ -I$(abs_top_srcdir)/tests/gpiosim \
-L$(abs_top_builddir)/lib/.libs/ -L$(abs_top_builddir)/tests/gpiosim/.libs/" \
$(PYTHON) -m build
install-exec-local:
$(PYTHON) -m pip install dist/*.whl \
--ignore-installed --prefix=$(prefix) --root=$(if $(DESTDIR),$(DESTDIR),/)
SUBDIRS = gpiod
if WITH_TESTS
SUBDIRS += tests
endif
if WITH_EXAMPLES
SUBDIRS += examples
endif

View File

@@ -107,7 +107,7 @@ with gpiod.request_lines(
The test suite for the python bindings can be run by calling:
```
make python-tests-run
python -B -m tests
```
from the `libgpiod/bindings/python` directory as root (necessary to be able
@@ -130,4 +130,4 @@ Ideally the gpiod library will continue to pass strict checks:
```
mypy --strict
```
```

View File

@@ -1,17 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
EXTRA_DIST = \
async_watch_line_value.py \
find_line_by_name.py \
get_chip_info.py \
get_line_info.py \
get_line_value.py \
get_multiple_line_values.py \
reconfigure_input_to_output.py \
toggle_line_value.py \
toggle_multiple_line_values.py \
watch_line_info.py \
watch_line_value.py \
watch_line_rising.py \
watch_multiple_line_values.py

View File

@@ -1,19 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
SUBDIRS = ext
EXTRA_DIST = \
chip_info.py \
chip.py \
_ext.pyi \
edge_event.py \
exception.py \
info_event.py \
__init__.py \
_internal.py \
line_info.py \
line.py \
line_request.py \
line_settings.py \
version.py

View File

@@ -1,11 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
EXTRA_DIST = \
chip.c \
common.c \
internal.h \
line-config.c \
line-settings.c \
module.c \
request.c

View File

@@ -0,0 +1,43 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
py.extension_module('_ext',
sources: [
'ext/chip.c',
'ext/common.c',
'ext/line-config.c',
'ext/line-settings.c',
'ext/module.c',
'ext/request.c',
],
include_directories: [libgpiod_inc],
dependencies: [libgpiod_dep],
c_args: ['-D_GNU_SOURCE=1', '-Wall', '-Wextra'],
subdir: 'gpiod',
install: true,
)
py_sources = [
'__init__.py',
'chip.py',
'chip_info.py',
'edge_event.py',
'exception.py',
'info_event.py',
'_internal.py',
'line_info.py',
'line.py',
'line_request.py',
'line_settings.py',
'version.py',
'_ext.pyi',
'py.typed',
]
py.install_sources(files(py_sources), subdir: 'gpiod')
fs = import('fs')
foreach f : py_sources
fs.copyfile(f)
endforeach

View File

@@ -0,0 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
py = import('python').find_installation('python3', required: true)
subdir('gpiod')
if opt_tests.allowed()
subdir('tests')
endif

View File

@@ -1,18 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
SUBDIRS = gpiosim system
EXTRA_DIST = \
helpers.py \
__init__.py \
__main__.py \
tests_chip_info.py \
tests_chip.py \
tests_edge_event.py \
tests_info_event.py \
tests_line.py \
tests_line_info.py \
tests_line_request.py \
tests_line_settings.py \
tests_module.py

View File

@@ -1,8 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
EXTRA_DIST = \
chip.py \
_ext.pyi \
ext.c \
__init__.py

View File

@@ -0,0 +1,16 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
py.extension_module('_ext',
sources: ['ext.c'],
include_directories: [libgpiosim_inc],
link_with: [libgpiosim_lib],
c_args: ['-D_GNU_SOURCE=1', '-Wall', '-Wextra'],
install: false,
)
fs = import('fs')
foreach f : ['__init__.py', 'chip.py', '_ext.pyi']
fs.copyfile(f)
endforeach

View File

@@ -0,0 +1,36 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
subdir('gpiosim')
subdir('system')
fs = import('fs')
foreach f : [
'__init__.py',
'__main__.py',
'helpers.py',
'tests_chip.py',
'tests_chip_info.py',
'tests_edge_event.py',
'tests_info_event.py',
'tests_line.py',
'tests_line_info.py',
'tests_line_request.py',
'tests_line_settings.py',
'tests_module.py',
]
fs.copyfile(f)
endforeach
test_env = environment()
test_env.set('PYTHONPATH', meson.global_build_root() / 'bindings' / 'python')
test_env.append('LD_LIBRARY_PATH', meson.global_build_root() / 'lib')
test_env.append('LD_LIBRARY_PATH', meson.global_build_root() / 'tests' / 'gpiosim')
test('python-tests',
py,
args: ['-B', '-m', 'tests'],
env: test_env,
is_parallel: false,
)

View File

@@ -1,7 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
EXTRA_DIST = \
_ext.pyi \
ext.c \
__init__.py

View File

@@ -0,0 +1,14 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
py.extension_module('_ext',
sources: ['ext.c'],
c_args: ['-D_GNU_SOURCE=1', '-Wall', '-Wextra'],
install: false,
)
fs = import('fs')
foreach f : ['__init__.py', '_ext.pyi']
fs.copyfile(f)
endforeach

View File

@@ -2,5 +2,4 @@
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Viresh Kumar <viresh.kumar@linaro.org>
target
Cargo.lock

View File

@@ -1,6 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Viresh Kumar <viresh.kumar@linaro.org>
EXTRA_DIST = Cargo.toml
SUBDIRS = gpiosim-sys libgpiod libgpiod-sys

View File

@@ -1,6 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = build.rs Cargo.toml README.md
SUBDIRS = src

View File

@@ -1,5 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = lib.rs sim.rs

View File

@@ -1,6 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = build.rs Cargo.toml README.md wrapper.h
SUBDIRS = src

View File

@@ -1,5 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = lib.rs

View File

@@ -1,28 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
# We do not want to build against the system libs when building with make. So we
# specify the paths to the build directory of the C lib.
command = SYSTEM_DEPS_LIBGPIOD_NO_PKG_CONFIG=1 \
SYSTEM_DEPS_LIBGPIOD_SEARCH_NATIVE="${PWD}/../../../lib/.libs/" \
SYSTEM_DEPS_LIBGPIOD_LIB=gpiod \
SYSTEM_DEPS_LIBGPIOD_INCLUDE="${PWD}/../../../include/" \
cargo build --features=vnext --release --lib
if WITH_TESTS
command += --tests
endif
if WITH_EXAMPLES
command += --examples
endif
all:
$(command)
clean:
cargo clean
EXTRA_DIST = Cargo.toml
SUBDIRS = examples src tests

View File

@@ -1,18 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = \
buffered_event_lifetimes.rs \
find_line_by_name.rs \
get_chip_info.rs \
get_line_info.rs \
get_line_value.rs \
get_multiple_line_values.rs \
reconfigure_input_to_output.rs \
toggle_line_value.rs \
toggle_multiple_line_values.rs \
watch_line_info.rs \
watch_line_rising.rs \
watch_line_value.rs \
watch_multiple_line_values.rs

View File

@@ -1,15 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = \
chip.rs \
edge_event.rs \
event_buffer.rs \
info_event.rs \
lib.rs \
line_config.rs \
line_info.rs \
line_request.rs \
line_settings.rs \
request_config.rs

View File

@@ -1,15 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = \
chip.rs \
edge_event.rs \
info_event.rs \
line_config.rs \
line_info.rs \
line_request.rs \
line_settings.rs \
request_config.rs
SUBDIRS = common

View File

@@ -1,5 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Linaro Ltd.
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = config.rs mod.rs

40
bindings/rust/meson.build Normal file
View File

@@ -0,0 +1,40 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
fs = import('fs')
libgpiod_so_dir = fs.parent(libgpiod_lib.full_path())
libgpiosim_a_dir = fs.parent(libgpiosim_static.full_path())
libgpiod_src_inc = meson.project_source_root() / 'include'
rust_src_dir = meson.current_source_dir()
rust_build_dir = meson.current_build_dir()
# We do not want to build against the system libs when building with meson. So
# we specify the paths to the build directory of the C lib.
cargo_env = environment()
cargo_env.set('SYSTEM_DEPS_LIBGPIOD_NO_PKG_CONFIG', '1')
cargo_env.set('SYSTEM_DEPS_LIBGPIOD_SEARCH_NATIVE', libgpiod_so_dir)
cargo_env.set('SYSTEM_DEPS_LIBGPIOD_LIB', 'gpiod')
cargo_env.set('SYSTEM_DEPS_LIBGPIOD_INCLUDE', libgpiod_src_inc)
# gpiosim-sys links against the static gpiosim archive via a hardcoded
# relative path in its build.rs, override that with RUSTFLAGS so the
# build succeeds with an out-of-tree meson build.
cargo_env.set('RUSTFLAGS', '-L ' + libgpiosim_a_dir)
# We use a stamp file as the custom_target output because cargo manages its
# own build artifacts inside the target directory.
rust_stamp = custom_target('rust-bindings',
output: 'rust-bindings.stamp',
command: [
cargo,
'build',
'--features=vnext',
'--release',
'--lib',
'--manifest-path', rust_src_dir / 'Cargo.toml',
'--target-dir', rust_build_dir / 'target',
'&&', 'touch', '@OUTPUT@',
],
env: cargo_env,
depends: [libgpiod_lib, libgpiosim_static],
build_by_default: true,
)

View File

@@ -1,407 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <brgl@bgdev.pl>
AC_PREREQ([2.71])
AC_INIT([libgpiod], [2.3], [], [],
[https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/])
AC_SUBST(EXTRA_VERSION, [-devel])
AC_DEFINE_UNQUOTED([GPIOD_VERSION_STR],
["$PACKAGE_VERSION$EXTRA_VERSION"],
[Full library version string.])
AC_SUBST(VERSION_STR, [$PACKAGE_VERSION$EXTRA_VERSION])
# From the libtool manual:
#
# (...)
# 3. If the library source code has changed at all since the last update, then
# increment revision ('c:r:a' becomes 'c:r+1:a').
# 4. If any interfaces have been added, removed, or changed since the last
# update, increment current, and set revision to 0.
# 5. If any interfaces have been added since the last public release, then
# increment age.
# 6. If any interfaces have been removed or changed since the last public
# release, then set age to 0.
#
# Define the libtool version as (C.R.A):
# NOTE: this version only applies to the core C library.
AC_SUBST(ABI_VERSION, [4.1.1])
# Have a separate ABI version for C++ bindings:
AC_SUBST(ABI_CXX_VERSION, [3.0.1])
# ABI version for libgpiosim (we need this since it can be installed if we
# enable tests).
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])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
m4_pattern_forbid([^AX_],
[Unexpanded AX_ macro found. Please install GNU autoconf-archive.])
AC_CONFIG_SRCDIR([lib])
AC_CONFIG_HEADERS([config.h])
AC_DEFINE([_GNU_SOURCE], [], [We want GNU extensions])
# Silence warning: ar: 'u' modifier ignored since 'D' is the default
AC_SUBST(AR_FLAGS, [cr])
AM_PROG_AR
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_EGREP
LT_INIT
PKG_PROG_PKG_CONFIG([0.28])
AC_DEFUN([ERR_NOT_FOUND],
[AC_MSG_ERROR([$1 not found (needed to build $2)], [1])])
AC_DEFUN([FUNC_NOT_FOUND_LIB],
[ERR_NOT_FOUND([$1()], [the library])])
AC_DEFUN([HEADER_NOT_FOUND_LIB],
[ERR_NOT_FOUND([$1 header], [the library])])
# This is always checked (library needs this)
AC_CHECK_INCLUDES_DEFAULT
AC_FUNC_MALLOC
AC_HEADER_STDBOOL
AC_CHECK_FUNC([ioctl], [], [FUNC_NOT_FOUND_LIB([ioctl])])
AC_CHECK_FUNC([open], [], [FUNC_NOT_FOUND_LIB([open])])
AC_CHECK_FUNC([close], [], [FUNC_NOT_FOUND_LIB([close])])
AC_CHECK_FUNC([read], [], [FUNC_NOT_FOUND_LIB([read])])
AC_CHECK_FUNC([ppoll], [], [FUNC_NOT_FOUND_LIB([ppoll])])
AC_CHECK_FUNC([realpath], [], [FUNC_NOT_FOUND_LIB([realpath])])
AC_CHECK_FUNC([readlink], [], [FUNC_NOT_FOUND_LIB([readlink])])
AC_CHECK_HEADERS([fcntl.h], [], [HEADER_NOT_FOUND_LIB([fcntl.h])])
AC_CHECK_HEADERS([getopt.h], [], [HEADER_NOT_FOUND_LIB([getopt.h])])
AC_CHECK_HEADERS([dirent.h], [], [HEADER_NOT_FOUND_LIB([dirent.h])])
AC_CHECK_HEADERS([poll.h], [], [HEADER_NOT_FOUND_LIB([poll.h])])
AC_CHECK_HEADERS([sys/sysmacros.h], [], [HEADER_NOT_FOUND_LIB([sys/sysmacros.h])])
AC_CHECK_HEADERS([sys/ioctl.h], [], [HEADER_NOT_FOUND_LIB([sys/ioctl.h])])
AC_CHECK_HEADERS([sys/param.h], [], [HEADER_NOT_FOUND_LIB([sys/param.h])])
AC_CHECK_HEADERS([sys/stat.h], [], [HEADER_NOT_FOUND_LIB([sys/stat.h])])
AC_CHECK_HEADERS([sys/types.h], [], [HEADER_NOT_FOUND_LIB([sys/types.h])])
AC_CHECK_HEADERS([linux/const.h], [], [HEADER_NOT_FOUND_LIB([linux/const.h])])
AC_CHECK_HEADERS([linux/ioctl.h], [], [HEADER_NOT_FOUND_LIB([linux/ioctl.h])])
AC_CHECK_HEADERS([linux/types.h], [], [HEADER_NOT_FOUND_LIB([linux/types.h])])
AC_ARG_ENABLE([tools],
[AS_HELP_STRING([--enable-tools],[enable libgpiod command-line tools [default=no]])],
[if test "x$enableval" = xyes; then with_tools=true; fi],
[with_tools=false])
AM_CONDITIONAL([WITH_TOOLS], [test "x$with_tools" = xtrue])
AC_DEFUN([FUNC_NOT_FOUND_TOOLS],
[ERR_NOT_FOUND([$1()], [tools])])
AC_ARG_ENABLE([gpioset-interactive],
[AS_HELP_STRING([--enable-gpioset-interactive],
[enable gpioset interactive mode [default=no]])],
[if test "x$enableval" = xyes; then with_gpioset_interactive=true; fi],
[with_gpioset_interactive=false])
AM_CONDITIONAL([WITH_GPIOSET_INTERACTIVE],
[test "x$with_gpioset_interactive" = xtrue])
if test "x$with_tools" = xtrue
then
# These are only needed to build tools
AC_CHECK_FUNC([daemon], [], [FUNC_NOT_FOUND_TOOLS([daemon])])
AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_TOOLS([asprintf])])
AC_CHECK_FUNC([scandir], [], [FUNC_NOT_FOUND_TOOLS([scandir])])
AC_CHECK_FUNC([versionsort], [], [FUNC_NOT_FOUND_TOOLS([versionsort])])
AC_CHECK_FUNC([strtoull], [], [FUNC_NOT_FOUND_TOOLS([strtoull])])
AC_CHECK_FUNC([nanosleep], [], [FUNC_NOT_FOUND_TOOLS([nanosleep])])
if test "x$with_gpioset_interactive" = xtrue
then
PKG_CHECK_MODULES([LIBEDIT], [libedit >= 3.1])
fi
fi
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--enable-tests],[enable libgpiod tests [default=no]])],
[if test "x$enableval" = xyes; then with_tests=true; fi],
[with_tests=false])
AM_CONDITIONAL([WITH_TESTS], [test "x$with_tests" = xtrue])
AC_ARG_ENABLE([profiling],
[AS_HELP_STRING([--enable-profiling],
[enable gcov profiling on the core library and tests [default=no]])],
[if test "x$enableval" = xyes; then with_profiling=true; fi],
[with_profiling=false])
if test "x$with_profiling" = xtrue
then
AC_SUBST(PROFILING_CFLAGS, ["-fprofile-arcs -ftest-coverage"])
AC_SUBST(PROFILING_LDFLAGS, ["-lgcov"])
fi
AC_DEFUN([FUNC_NOT_FOUND_TESTS],
[ERR_NOT_FOUND([$1()], [tests])])
AC_DEFUN([HEADER_NOT_FOUND_TESTS],
[ERR_NOT_FOUND([$1 header], [the test suite])])
if test "x$with_tests" = xtrue
then
# For libgpiosim
PKG_CHECK_MODULES([KMOD], [libkmod >= 18])
PKG_CHECK_MODULES([MOUNT], [mount >= 2.33.1])
# For core library tests
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.74])
PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.74])
AC_CHECK_FUNC([atexit], [], [FUNC_NOT_FOUND_TESTS([atexit])])
AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_TESTS([asprintf])])
AC_CHECK_FUNC([prctl], [], [FUNC_NOT_FOUND_TESTS([prctl])])
AC_CHECK_FUNC([unlink], [], [FUNC_NOT_FOUND_TESTS([unlink])])
AC_CHECK_FUNC([unlinkat], [], [FUNC_NOT_FOUND_TESTS([unlinkat])])
AC_CHECK_FUNC([openat], [], [FUNC_NOT_FOUND_TESTS([openat])])
AC_CHECK_FUNC([mkdirat], [], [FUNC_NOT_FOUND_TESTS([mkdirat])])
AC_CHECK_FUNC([write], [], [FUNC_NOT_FOUND_TESTS([write])])
AC_CHECK_FUNC([twalk], [], [FUNC_NOT_FOUND_TESTS([twalk])])
AC_CHECK_FUNC([tsearch], [], [FUNC_NOT_FOUND_TESTS([tsearch])])
AC_CHECK_FUNC([tdestroy], [], [FUNC_NOT_FOUND_TESTS([tdestroy])])
AC_CHECK_FUNC([tdelete], [], [FUNC_NOT_FOUND_TESTS([tdelete])])
AC_CHECK_FUNC([setrlimit], [], [FUNC_NOT_FOUND_TESTS([setrlimit])])
AC_CHECK_HEADERS([sys/utsname.h], [], [FUNC_NOT_FOUND_TESTS([sys/utsname.h])])
AC_CHECK_HEADERS([sys/mount.h], [], [FUNC_NOT_FOUND_TESTS([sys/mount.h])])
AC_CHECK_HEADERS([sys/prctl.h], [], [FUNC_NOT_FOUND_TESTS([sys/prctl.h])])
AC_CHECK_HEADERS([sys/random.h], [], [FUNC_NOT_FOUND_TESTS([sys/random.h])])
AC_CHECK_HEADERS([linux/version.h], [], [FUNC_NOT_FOUND_TESTS([linux/version.h])])
AC_CHECK_HEADERS([pthread.h], [], [FUNC_NOT_FOUND_TESTS([pthread.h])])
AC_CHECK_LIB(pthread, pthread_mutex_lock, [], ERR_NOT_FOUND([pthread library], [tests]))
if test "x$with_tools" = xtrue
then
AC_CHECK_PROG([has_shunit2], [shunit2], [true], [false])
if test "x$has_shunit2" = "xfalse"
then
AC_MSG_NOTICE([shunit2 not found - gpio-tools tests cannot be run])
fi
fi
fi
AC_ARG_ENABLE([examples],
[AS_HELP_STRING([--enable-examples], [enable building code examples[default=no]])],
[if test "x$enableval" = xyes; then with_examples=true; fi],
[with_examples=false])
AM_CONDITIONAL([WITH_EXAMPLES], [test "x$with_examples" = xtrue])
AC_ARG_ENABLE([bindings-cxx],
[AS_HELP_STRING([--enable-bindings-cxx],[enable C++ bindings [default=no]])],
[if test "x$enableval" = xyes; then with_bindings_cxx=true; fi],
[with_bindings_cxx=false])
AM_CONDITIONAL([WITH_BINDINGS_CXX], [test "x$with_bindings_cxx" = xtrue])
AC_DEFUN([HEADER_NOT_FOUND_CXX],
[ERR_NOT_FOUND([$1 header], [C++ bindings])])
if test "x$with_bindings_cxx" = xtrue
then
LT_LANG([C++])
# This needs autoconf-archive
AX_CXX_COMPILE_STDCXX_17([ext], [mandatory])
if test "x$with_tests" = xtrue
then
PKG_CHECK_MODULES([CATCH2], [catch2-with-main >= 3.0],, [
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([catch2/catch_all.hpp], [],
[HEADER_NOT_FOUND_CXX([catch2/catch_all.hpp])])
AC_LANG_POP([C++])
])
fi
fi
AC_ARG_ENABLE([bindings-python],
[AS_HELP_STRING([--enable-bindings-python],[enable python3 bindings [default=no]])],
[if test "x$enableval" = xyes; then with_bindings_python=true; fi],
[with_bindings_python=false])
AM_CONDITIONAL([WITH_BINDINGS_PYTHON], [test "x$with_bindings_python" = xtrue])
if test "x$with_bindings_python" = xtrue
then
AM_PATH_PYTHON([3.10], [],
[AC_MSG_ERROR([python3 not found - needed for python bindings])])
fi
AC_ARG_ENABLE([bindings-rust],
[AS_HELP_STRING([--enable-bindings-rust],[enable rust bindings [default=no]])],
[if test "x$enableval" = xyes; then with_bindings_rust=true; fi],
[with_bindings_rust=false])
AM_CONDITIONAL([WITH_BINDINGS_RUST], [test "x$with_bindings_rust" = xtrue])
if test "x$with_bindings_rust" = xtrue
then
AC_CHECK_PROG([has_cargo], [cargo], [true], [false])
if test "x$has_cargo" = xfalse
then
AC_MSG_ERROR([cargo not found - needed for rust bindings])
fi
fi
AC_ARG_ENABLE([dbus],
[AS_HELP_STRING([--enable-dbus], [build dbus daemon [default=no]])],
[if test "x$enableval" == xyes; then with_dbus=true; fi],
[with_dbus=false])
AM_CONDITIONAL([WITH_DBUS], [test "x$with_dbus" = xtrue])
AC_ARG_ENABLE([bindings-glib],
[AS_HELP_STRING([--enable-bindings-glib],[enable GLib 2.0 bindings [default=no]])],
[if test "x$enableval" = xyes; then with_bindings_glib=true; fi],
[with_bindings_glib=false])
AC_DEFUN([FUNC_NOT_FOUND_DBUS],
[ERR_NOT_FOUND([$1()], [dbus daemon])])
if test "x$with_dbus" = xtrue
then
AC_CHECK_FUNC([daemon], [], [FUNC_NOT_FOUND_DBUS([daemon])])
AC_CHECK_FUNC([strverscmp], [], [FUNC_NOT_FOUND_DBUS([strverscmp])])
PKG_CHECK_MODULES([GUDEV], [gudev-1.0 >= 230])
AC_CHECK_PROG([has_gdbus_codegen], [gdbus-codegen], [true], [false])
if test "x$has_gdbus_codegen" = xfalse
then
AC_MSG_ERROR([gdbus-codegen not found - needed to build dbus daemon])
fi
# Imply GLib bindings for D-Bus
with_bindings_glib=true
fi
AM_CONDITIONAL([WITH_BINDINGS_GLIB], [test "x$with_bindings_glib" = xtrue])
AC_DEFUN([GLIB_MKENUMS_NOT_FOUND],
[AC_MSG_ERROR([glib-mkenums not found - needed to build GLib bindings])])
if test "x$with_bindings_glib" = xtrue
then
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.80])
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.80])
PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.80])
PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.80])
PKG_CHECK_VAR([GLIB_MKENUMS], [glib-2.0], [glib_mkenums], [], GLIB_MKENUMS_NOT_FOUND)
AC_CHECK_PROG([has_glib_mkenums], [glib-mkenums], [true], [false])
if test "x$has_glib_mkenums" == xfalse
then
GLIB_MKENUMS_NOT_FOUND
fi
AC_CHECK_PROG([has_gi_docgen], [gi-docgen], [true], [false])
if test "x$has_gi_docgen" = xfalse
then
AC_MSG_NOTICE([gi-docgen not found - GLib documentation cannot be generated])
fi
fi
AM_CONDITIONAL([HAS_GI_DOCGEN], [test "x$has_gi_docgen" = xtrue])
AM_COND_IF([HAS_GI_DOCGEN], [AC_CONFIG_FILES([bindings/glib/gi-docgen.toml])])
# GObject-introspection
found_introspection=no
m4_ifdef([GOBJECT_INTROSPECTION_CHECK],
[GOBJECT_INTROSPECTION_CHECK([0.6.2])],
[AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")])
AC_ARG_ENABLE([systemd],
[AS_HELP_STRING([--enable-systemd], [enable systemd support [default=no]])],
[if test "x$enableval" == xyes; then with_systemd=true; fi],
[with_systemd=false])
AM_CONDITIONAL([WITH_SYSTEMD], [test "x$with_systemd" = xtrue])
if test "x$with_systemd" = xtrue
then
PKG_CHECK_VAR([systemdsystemunitdir], [systemd], [systemdsystemunitdir], [],
AC_MSG_ERROR([systemdsystemunitdir not found - needed to enable systemd support]))
AC_CONFIG_FILES([dbus/data/gpio-manager.service])
fi
if test "x$cross_compiling" = xno
then
AC_CHECK_PROG([has_help2man], [help2man], [true], [false])
fi
AM_CONDITIONAL([WITH_MANPAGES], [test "x$has_help2man" = xtrue])
if test "x$has_help2man" = xfalse
then
AC_MSG_NOTICE([help2man not found - man pages and documentation cannot be generated])
fi
AC_DEFUN([DOC_PROG_NOT_FOUND], [AC_MSG_NOTICE([$1 not found - documentation cannot be generated])])
AC_CHECK_PROG([has_doxygen], [doxygen], [true], [false])
AC_CHECK_PROG([has_sphinx], [sphinx-build], [true], [false])
AC_CHECK_PROG([has_pandoc], [pandoc], [true], [false])
AM_CONDITIONAL([WITH_DOCS], [test "x$has_doxygen" = xtrue && test "x$has_sphinx" = xtrue && test "x$has_pandoc" = xtrue && test "x$has_help2man" = xtrue])
if test "x$has_doxygen" = xfalse
then
DOC_PROG_NOT_FOUND(["doxygen"])
fi
if test "x$has_sphinx" = xfalse
then
DOC_PROG_NOT_FOUND(["sphinx-build"])
fi
if test "x$has_pandoc" = xfalse
then
DOC_PROG_NOT_FOUND(["pandoc"])
fi
AC_CONFIG_FILES([Makefile
include/Makefile
lib/Makefile
lib/libgpiod.pc
contrib/Makefile
docs/Makefile
examples/Makefile
tools/Makefile
tests/Makefile
tests/gpiosim/Makefile
tests/gpiosim-glib/Makefile
tests/harness/Makefile
tests/scripts/Makefile
bindings/cxx/libgpiodcxx.pc
bindings/Makefile
bindings/cxx/Makefile
bindings/cxx/gpiodcxx/Makefile
bindings/cxx/examples/Makefile
bindings/cxx/tests/Makefile
bindings/glib/gpiod-glib.pc
bindings/glib/Makefile
bindings/glib/examples/Makefile
bindings/glib/tests/Makefile
bindings/python/Makefile
bindings/python/gpiod/Makefile
bindings/python/gpiod/ext/Makefile
bindings/python/examples/Makefile
bindings/python/tests/Makefile
bindings/python/tests/gpiosim/Makefile
bindings/python/tests/system/Makefile
bindings/rust/libgpiod-sys/src/Makefile
bindings/rust/libgpiod-sys/Makefile
bindings/rust/libgpiod/src/Makefile
bindings/rust/libgpiod/tests/common/Makefile
bindings/rust/libgpiod/tests/Makefile
bindings/rust/libgpiod/Makefile
bindings/rust/libgpiod/examples/Makefile
bindings/rust/Makefile
bindings/rust/gpiosim-sys/src/Makefile
bindings/rust/gpiosim-sys/Makefile
dbus/Makefile
dbus/client/Makefile
dbus/data/Makefile
dbus/lib/Makefile
dbus/manager/Makefile
dbus/tests/Makefile
man/Makefile])
AC_OUTPUT

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = Android.bp

View File

@@ -1,10 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
SUBDIRS = data lib manager client
if WITH_TESTS
SUBDIRS += tests
endif

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
gpiocli

View File

@@ -1,31 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
AM_CFLAGS = -include $(top_builddir)/config.h
AM_CFLAGS += -I$(top_builddir)/dbus/lib/ -I$(top_srcdir)/dbus/lib/
AM_CFLAGS += -Wall -Wextra -g
AM_CFLAGS += $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GIO_UNIX_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiocli\"
AM_LDFLAGS = $(GLIB_LIBS) $(GIO_LIBS) $(GIO_UNIX_LIBS)
LDADD = $(top_builddir)/dbus/lib/libgpiodbus.la
bin_PROGRAMS = gpiocli
gpiocli_SOURCES = \
common.c \
common.h \
detect.c \
find.c \
get.c \
gpiocli.c \
info.c \
monitor.c \
notify.c \
reconfigure.c \
release.c \
request.c \
requests.c \
set.c \
wait.c
dist_noinst_SCRIPTS = gpiocli-test.bash

View File

@@ -7,8 +7,6 @@
# is already running.
#
SOURCE_DIR="$(dirname "${BASH_SOURCE[0]}")"
wait_for_sim() {
COUNTER=100

30
dbus/client/meson.build Normal file
View File

@@ -0,0 +1,30 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
gpiocli_exe = executable('gpiocli',
sources: [
'common.c',
'common.h',
'detect.c',
'find.c',
'get.c',
'gpiocli.c',
'info.c',
'monitor.c',
'notify.c',
'reconfigure.c',
'release.c',
'request.c',
'requests.c',
'set.c',
'wait.c',
],
c_args: ['-DG_LOG_DOMAIN="gpiocli"'],
dependencies: [
libgpiodbus_dep,
glib_dep,
gio_dep,
gio_unix_dep,
],
install: true,
)

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2026 David Lechner <dlechner@baylibre.com>
gpio-manager.service

View File

@@ -1,14 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
dbusdir = $(sysconfdir)/dbus-1/system.d/
dist_dbus_DATA = io.gpiod1.conf
if WITH_SYSTEMD
dist_systemdsystemunit_DATA = gpio-manager.service
udevdir = $(libdir)/udev/rules.d/
dist_udev_DATA = 90-gpio.rules
endif

24
dbus/data/meson.build Normal file
View File

@@ -0,0 +1,24 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
install_data('io.gpiod1.conf',
install_dir: get_option('sysconfdir') / 'dbus-1' / 'system.d',
)
if opt_systemd.allowed() and systemd_dep.found()
service_conf = configuration_data()
service_conf.set('prefix', get_option('prefix'))
gpio_manager_service = configure_file(
input: 'gpio-manager.service.in',
output: 'gpio-manager.service',
configuration: service_conf,
)
install_data(gpio_manager_service,
install_dir: systemd_unit_dir,
)
install_data('90-gpio.rules',
install_dir: get_option('libdir') / 'udev' / 'rules.d',
)
endif

View File

@@ -1,29 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
libgpiodbus_la_CFLAGS = -include $(top_builddir)/config.h -Wall -Wextra -g
libgpiodbus_la_CFLAGS += $(GLIB_CFLAGS) $(GIO_CFLAGS)
libgpiodbus_la_CFLAGS += -DG_LOG_DOMAIN=\"gpiodbus\"
libgpiodbus_la_LDFLAGS = -version-info 1
generated-gpiodbus.h generated-gpiodbus.c: io.gpiod1.xml
$(AM_V_GEN)gdbus-codegen \
--interface-prefix io.gpiod1 \
--c-namespace Gpiodbus \
--generate-c-code generated-gpiodbus \
--c-generate-object-manager \
--c-generate-autocleanup=all \
--glib-min-required 2.74.0 \
$(srcdir)/io.gpiod1.xml
lib_LTLIBRARIES = libgpiodbus.la
libgpiodbus_la_SOURCES = \
generated-gpiodbus.c \
generated-gpiodbus.h \
gpiodbus.h
BUILT_SOURCES = generated-gpiodbus.c generated-gpiodbus.h
CLEANFILES = $(BUILT_SOURCES)
dbusdir = $(datadir)/dbus-1/interfaces
dist_dbus_DATA = io.gpiod1.xml

35
dbus/lib/meson.build Normal file
View File

@@ -0,0 +1,35 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
gnome = import('gnome')
generated_dbus = gnome.gdbus_codegen('generated-gpiodbus',
sources: 'io.gpiod1.xml',
interface_prefix: 'io.gpiod1',
namespace: 'Gpiodbus',
object_manager: true,
autocleanup: 'all',
extra_args: ['--glib-min-required', '2.74.0'],
)
dbus_lib_inc = include_directories('.', '../../include')
libgpiodbus_both = both_libraries('gpiodbus',
sources: ['gpiodbus.h', generated_dbus],
include_directories: dbus_lib_inc,
c_args: ['-DG_LOG_DOMAIN="gpiodbus"'],
dependencies: [glib_dep, gio_dep],
soversion: 1,
install: true,
)
libgpiodbus_lib = libgpiodbus_both.get_shared_lib()
install_data('io.gpiod1.xml',
install_dir: get_option('datadir') / 'dbus-1' / 'interfaces',
)
libgpiodbus_dep = declare_dependency(
link_with: libgpiodbus_lib,
include_directories: dbus_lib_inc,
sources: generated_dbus,
)

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
gpio-manager

View File

@@ -1,21 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
AM_CFLAGS = -I$(top_srcdir)/bindings/glib/ -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g
AM_CFLAGS += -I$(top_builddir)/dbus/lib/ -I$(top_srcdir)/dbus/lib/
AM_CFLAGS += $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GIO_UNIX_CFLAGS) $(GUDEV_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpio-manager\"
AM_CFLAGS += $(PROFILING_CFLAGS)
AM_LDFLAGS = $(GLIB_LIBS) $(GIO_LIBS) $(GIO_UNIX_LIBS) $(GUDEV_LIBS)
AM_LDFLAGS += $(PROFILING_LDFLAGS)
LDADD = $(top_builddir)/bindings/glib/libgpiod-glib.la
LDADD += $(top_builddir)/dbus/lib/libgpiodbus.la
bin_PROGRAMS = gpio-manager
gpio_manager_SOURCES = \
daemon.c \
daemon.h \
helpers.c \
helpers.h \
gpio-manager.c

26
dbus/manager/meson.build Normal file
View File

@@ -0,0 +1,26 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
gpio_manager_exe = executable('gpio-manager',
sources: [
'daemon.c',
'daemon.h',
'helpers.c',
'helpers.h',
'gpio-manager.c',
],
include_directories: [
libgpiod_inc,
include_directories('../../bindings/glib'),
],
c_args: ['-DG_LOG_DOMAIN="gpio-manager"'],
dependencies: [
libgpiod_glib_dep,
libgpiodbus_dep,
glib_dep,
gio_dep,
gio_unix_dep,
gudev_dep,
],
install: true,
)

11
dbus/meson.build Normal file
View File

@@ -0,0 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
subdir('data')
subdir('lib')
subdir('manager')
subdir('client')
if opt_tests.allowed()
subdir('tests')
endif

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
gpiodbus-test

View File

@@ -1,25 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
noinst_PROGRAMS = gpiodbus-test
gpiodbus_test_SOURCES = \
daemon-process.c \
daemon-process.h \
helpers.c \
helpers.h \
tests-chip.c \
tests-line.c \
tests-request.c
AM_CFLAGS = -I$(top_srcdir)/tests/gpiosim-glib/
AM_CFLAGS += -I$(top_builddir)/dbus/lib/ -I$(top_srcdir)/dbus/lib/
AM_CFLAGS += -I$(top_srcdir)/tests/harness/
AM_CFLAGS += -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89
AM_CFLAGS += $(GLIB_CFLAGS) $(GIO_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiodbus-test\"
LDADD = $(top_builddir)/tests/gpiosim/libgpiosim.la
LDADD += $(top_builddir)/tests/gpiosim-glib/libgpiosim-glib.la
LDADD += $(top_builddir)/tests/harness/libgpiod-test-harness.la
LDADD += $(top_builddir)/dbus/lib/libgpiodbus.la
LDADD += $(GLIB_LIBS) $(GIO_LIBS)

25
dbus/tests/meson.build Normal file
View File

@@ -0,0 +1,25 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
executable('gpiodbus-test',
sources: [
'daemon-process.c',
'daemon-process.h',
'helpers.c',
'helpers.h',
'tests-chip.c',
'tests-line.c',
'tests-request.c',
],
include_directories: [
include_directories('../../tests/gpiosim-glib'),
include_directories('../../tests/harness'),
],
c_args: ['-DG_LOG_DOMAIN="gpiodbus-test"'],
dependencies: [
libgpiodbus_dep,
glib_test_dep,
gio_test_dep,
],
link_with: [libgpiosim_lib, libgpiosim_glib_lib, libgpiod_test_harness_lib],
)

View File

@@ -1,65 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2024-2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
DOCS_DEPS = \
bindings.rst \
building.rst \
conf.py \
contributing.rst \
core_api.rst \
core_chip_info.rst \
core_chips.rst \
core_edge_event.rst \
core_line_config.rst \
core_line_defs.rst \
core_line_info.rst \
core_line_request.rst \
core_line_settings.rst \
core_line_watch.rst \
core_misc.rst \
core_request_config.rst \
cpp_api.rst \
cpp_chip_info.rst \
cpp_chip.rst \
cpp_edge_event_buffer.rst \
cpp_edge_event.rst \
cpp_exceptions.rst \
cpp_info_event.rst \
cpp_line_config.rst \
cpp_line_info.rst \
cpp_line_request.rst \
cpp_line.rst \
cpp_line_settings.rst \
cpp_misc.rst \
cpp_request_config.rst \
dbus.rst \
dbus_api.rst \
Doxyfile \
index.rst \
glib_api.rst \
gpio_tools.rst \
gpiocli_top.rst \
python_api.rst \
python_chip_info.rst \
python_chip.rst \
python_edge_event.rst \
python_exceptions.rst \
python_info_event.rst \
python_line_info.rst \
python_line_request.rst \
python_line.rst \
python_line_settings.rst \
python_misc.rst \
rust_api.rst \
testing.rst
docs: $(DOCS_DEPS)
pushd ..; sphinx-build ./docs/ ./docs/sphinx-output; popd
.PHONY: docs
clean-local:
rm -rf sphinx-output
rm -rf doxygen-output
EXTRA_DIST = $(DOCS_DEPS) requirements.txt

View File

@@ -24,58 +24,43 @@ Building
The core C library does not have any external dependencies other than the
standard C library with GNU extensions.
The project is built using GNU autotools. In the general case, the steps needed
to download a source tarball, unpack it, build the library together with the
command-line tools and install the resulting binaries are as follows:
The project is built using the meson build system. In the general case, the
steps needed to download a source tarball, unpack it, build the library
together with the command-line tools and install the resulting binaries are
as follows:
.. code-block:: none
wget https://mirrors.edge.kernel.org/pub/software/libs/libgpiod/libgpiod-x.y.z.tar.xz
tar -xvf ./libgpiod-x.y.z.tar.xz
cd ./libgpiod-x.y.z/
./configure --enable-tools
make
sudo make install
mkdir build
cd build
meson setup .. -Dtools=enabled
ninja
sudo ninja install
The build system requires the following packages to be installed on the host
system for the basic build:
* ``autotools``
* ``autoconf-archive``
* ``libtool``
* ``meson``
* ``ninja-build``
* ``pkg-config``
.. note::
Development files for additional libraries may be required depending on
selected options. The configure script will report any missing additional
required dependencies.
selected options. Meson will report any missing additional required
dependencies at configuration stage.
.. note::
The command-line tools optionally depend on libedit for the interactive
feature.
The project can also be built directly from the git repository. However in this
case the configure script does not exist and must be created first - either by
calling ``autoreconf``:
The project can also be built directly from the git repository.
.. code-block:: none
autoreconf -ifv
./configure --enable-tools
make
Or by executing the provided ``autogen.sh`` script directly from the git tree:
.. code-block:: none
./autogen.sh --enable-tools
make
.. note::
The autogen script will execute ``./configure`` and pass all the
command-line arguments to it.
For all configure features, see: ``./configure --help``.
For all configure features, use: ``meson introspect --buildoptions`` or see
the contents of the ``meson_options.txt`` file in the top-level directory of
the repository.
Installing
----------
@@ -84,11 +69,11 @@ To install the project run:
.. code-block:: none
make install
ninja install
.. note::
The above may require superuser privileges.
This will install libgpiod under the default system paths. If you want to
install it under non-standard path, pass the ``--prefix=<install path>``
option to ``configure``.
option to ``meson setup``.

16
examples/.gitignore vendored
View File

@@ -1,16 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2023 Kent Gibson <warthog618@gmail.com>
async_watch_line_value
find_line_by_name
get_chip_info
get_line_info
get_line_value
get_multiple_line_values
reconfigure_input_to_output
toggle_line_value
toggle_multiple_line_values
watch_line_info
watch_line_rising
watch_line_value
watch_multiple_line_values

View File

@@ -1,22 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2023 Kent Gibson <warthog618@gmail.com>
AM_CFLAGS = -I$(top_srcdir)/include/ -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89
LDADD = $(top_builddir)/lib/libgpiod.la
noinst_PROGRAMS = \
async_watch_line_value \
find_line_by_name \
get_chip_info \
get_line_info \
get_line_value \
get_multiple_line_values \
reconfigure_input_to_output \
toggle_line_value \
toggle_multiple_line_values \
watch_line_info \
watch_line_rising \
watch_line_value \
watch_multiple_line_values

25
examples/meson.build Normal file
View File

@@ -0,0 +1,25 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
c_examples = [
'async_watch_line_value',
'find_line_by_name',
'get_chip_info',
'get_line_info',
'get_line_value',
'get_multiple_line_values',
'reconfigure_input_to_output',
'toggle_line_value',
'toggle_multiple_line_values',
'watch_line_info',
'watch_line_rising',
'watch_line_value',
'watch_multiple_line_values',
]
foreach ex : c_examples
executable(ex,
sources: [ex + '.c'],
dependencies: [libgpiod_dep],
)
endforeach

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
include_HEADERS = gpiod.h

4
include/meson.build Normal file
View File

@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
install_headers('gpiod.h')

View File

@@ -1,28 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
lib_LTLIBRARIES = libgpiod.la
libgpiod_la_SOURCES = \
chip.c \
chip-info.c \
edge-event.c \
info-event.c \
internal.h \
internal.c \
line-config.c \
line-info.c \
line-request.c \
line-settings.c \
misc.c \
request-config.c \
uapi/gpio.h
libgpiod_la_CFLAGS = -Wall -Wextra -g -std=gnu89
libgpiod_la_CFLAGS += -fvisibility=hidden -I$(top_srcdir)/include/
libgpiod_la_CFLAGS += -include $(top_builddir)/config.h
libgpiod_la_CFLAGS += $(PROFILING_CFLAGS)
libgpiod_la_LDFLAGS = -version-info $(subst .,:,$(ABI_VERSION))
libgpiod_la_LDFLAGS += $(PROFILING_LDFLAGS)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgpiod.pc

38
lib/meson.build Normal file
View File

@@ -0,0 +1,38 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
libgpiod_both = both_libraries('gpiod',
sources: [
'chip.c',
'chip-info.c',
'edge-event.c',
'info-event.c',
'internal.c',
'line-config.c',
'line-info.c',
'line-request.c',
'line-settings.c',
'misc.c',
'request-config.c',
],
include_directories: [libgpiod_inc, include_directories('.')],
c_args: ['-fvisibility=hidden'] + profiling_c_args,
link_args: profiling_link_args,
version: libgpiod_version,
soversion: libgpiod_soversion,
install: true,
)
libgpiod_lib = libgpiod_both.get_shared_lib()
pkgconfig = import('pkgconfig')
pkgconfig.generate(libgpiod_lib,
name: 'libgpiod',
description: 'Library and tools for the Linux GPIO chardev',
url: 'https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/',
version: meson.project_version(),
)
libgpiod_dep = declare_dependency(
link_with: libgpiod_lib,
include_directories: libgpiod_inc,
)

4
man/.gitignore vendored
View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
*.man

View File

@@ -1,70 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
# SPDX-FileCopyrightText: 2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
MAN_ENTRIES =
MAN_DEPS =
if WITH_TOOLS
TOOLS = \
gpiodetect \
gpioinfo \
gpioget \
gpioset \
gpiomon \
gpionotify
MAN_ENTRIES += $(TOOLS)
MAN_DEPS += $(foreach dep,$(TOOLS),$(top_builddir)/tools/$(dep))
endif
if WITH_DBUS
GPIOCLI_CMDS = \
detect \
find \
info \
get \
monitor \
notify \
reconfigure \
release \
request \
requests \
set \
wait
MAN_ENTRIES += \
gpio-manager \
gpiocli \
$(foreach cmd,$(GPIOCLI_CMDS),gpiocli-$(cmd))
MAN_DEPS += \
$(top_builddir)/dbus/manager/gpio-manager
$(top_builddir)/dbus/client/gpiocli
endif
dist_man1_MANS := $(foreach entry,$(MAN_ENTRIES),$(entry).man)
%.man: $(MAN_DEPS)
$(AM_V_GEN)export PATH=$(top_builddir)/dbus/manager/:$(top_builddir)/dbus/client/:$(top_builddir)/tools/:$$PATH; \
if [ "$(*F)" = "gpio-manager" ]; then \
EXEC=$(*F); \
NAME="libgpiod D-Bus daemon"; \
HELP=--help-option=--help; \
else \
EXEC=$(if $(findstring -,$(*F)),$(word 1,$(subst -, ,$(*F))),$(*F)); \
NAME=$(if $(findstring -,$(*F)),$(word 2,$(subst -, ,$(*F))),"libgpiod command-line utility"); \
HELP=$(if $(findstring -,$(*F)),--help-option="$(word 2,$(subst -, ,$(*F))) --help",--help-option=--help); \
fi; \
help2man $$EXEC \
--include=$(srcdir)/template --output=$(builddir)/$@ --no-info \
--name="$$NAME" "$$HELP" --manual=$(*F)
clean-local:
rm -f $(dist_man1_MANS)
EXTRA_DIST = template

82
man/meson.build Normal file
View File

@@ -0,0 +1,82 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
man_template = files('template')
man1_dir = get_option('mandir') / 'man1'
if opt_tools.allowed()
foreach tool : ['gpiodetect', 'gpioinfo', 'gpioget', 'gpioset', 'gpiomon', 'gpionotify']
custom_target(tool + '.1',
output: tool + '.1',
command: [
help2man,
tools_exes[tool],
'--include', man_template,
'--no-info',
'--name=libgpiod command-line utility',
'--help-option=--help',
'--manual=' + tool,
'--output=@OUTPUT@',
],
install: true,
install_dir: man1_dir,
)
endforeach
endif
if opt_dbus.allowed()
gpiocli_cmds = [
'detect', 'find', 'info', 'get', 'monitor', 'notify',
'reconfigure', 'release', 'request', 'requests', 'set', 'wait',
]
custom_target('gpio-manager.1',
output: 'gpio-manager.1',
command: [
help2man,
gpio_manager_exe,
'--include', man_template,
'--no-info',
'--name=libgpiod D-Bus daemon',
'--help-option=--help',
'--manual=gpio-manager',
'--output=@OUTPUT@',
],
install: true,
install_dir: man1_dir,
)
custom_target('gpiocli.1',
output: 'gpiocli.1',
command: [
help2man,
gpiocli_exe,
'--include', man_template,
'--no-info',
'--name=libgpiod command-line utility',
'--help-option=--help',
'--manual=gpiocli',
'--output=@OUTPUT@',
],
install: true,
install_dir: man1_dir,
)
foreach cmd : gpiocli_cmds
custom_target('gpiocli-' + cmd + '.1',
output: 'gpiocli-' + cmd + '.1',
command: [
help2man,
gpiocli_exe,
'--include', man_template,
'--no-info',
'--name=' + cmd,
'--help-option=' + cmd + ' --help',
'--manual=gpiocli-' + cmd,
'--output=@OUTPUT@',
],
install: true,
install_dir: man1_dir,
)
endforeach
endif

167
meson.build Normal file
View File

@@ -0,0 +1,167 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
project('libgpiod', ['c', 'cpp'],
version: '2.3',
license: 'LGPL-2.1-or-later',
default_options: [
'c_std=gnu89',
'cpp_std=gnu++17',
'warning_level=2',
],
meson_version: '>= 0.64.0',
)
extra_version = '-devel'
version_str = meson.project_version() + extra_version
# Core libgpiod API version.
api_version = '2.2.0'
# Core C library ABI version.
libgpiod_soversion = '3'
libgpiod_version = '3.1.1'
# Have a separate ABI version for C++ bindings:
libgpiodcxx_soversion = '2'
libgpiodcxx_version = '2.1.0'
# ABI version for libgpiosim (we need this since it can be installed if we
# enable tests).
libgpiosim_soversion = '1'
libgpiosim_version = '1.0.1'
# ... and another one for GLib bindings:
libgpiod_glib_soversion = '1'
libgpiod_glib_version = '1.0.0'
add_project_arguments(
'-D_GNU_SOURCE',
'-DGPIOD_VERSION_STR="@0@"'.format(version_str),
'-DGPIOD_API_VERSION_STR="@0@"'.format(api_version),
language: ['c', 'cpp'],
)
opt_tools = get_option('tools')
opt_gpioset_interactive = get_option('gpioset-interactive')
opt_tests = get_option('tests')
opt_examples = get_option('examples')
opt_bindings_cxx = get_option('bindings-cxx')
opt_bindings_python = get_option('bindings-python')
opt_bindings_rust = get_option('bindings-rust')
opt_bindings_glib = get_option('bindings-glib')
opt_dbus = get_option('dbus')
opt_introspection = get_option('introspection')
opt_systemd = get_option('systemd')
if get_option('profiling')
profiling_c_args = ['-fprofile-arcs', '-ftest-coverage']
profiling_link_args = ['-lgcov']
else
profiling_c_args = []
profiling_link_args = []
endif
# D-Bus implies glib bindings.
if opt_dbus.enabled() and not opt_bindings_glib.enabled()
opt_bindings_glib = opt_dbus
endif
# Introspection requires glib bindings.
if opt_introspection.enabled()
assert(opt_bindings_glib.allowed(),
'introspection requires -Dbindings-glib=enabled')
endif
# systemd requires D-Bus.
if opt_systemd.enabled()
assert(opt_dbus.allowed(),
'systemd support requires -Ddbus=enabled')
endif
libgpiod_inc = include_directories('include')
libedit_dep = dependency('libedit', version: '>= 3.1', required: opt_gpioset_interactive)
if opt_tests.allowed()
libkmod_dep = dependency('libkmod', version: '>= 18', required: opt_tests)
mount_dep = dependency('mount', version: '>= 2.33.1', required: opt_tests)
threads_dep = dependency('threads', required: opt_tests)
# glib/gio are also used by tests (different min-version from bindings).
glib_test_dep = dependency('glib-2.0', version: '>= 2.74', required: opt_tests)
gio_test_dep = dependency('gio-2.0', version: '>= 2.74', required: opt_tests)
endif
if opt_bindings_cxx.allowed() and opt_tests.allowed()
catch2_test_dep = dependency('catch2-with-main', version: '>= 3.0', required: false)
if not catch2_test_dep.found()
# Some distros don't ship pkgconfig or cmake info for catch2 but they do
# package it so check the header.
cxx = meson.get_compiler('cpp')
if cxx.has_header('catch2/catch_all.hpp')
catch2_test_dep = declare_dependency()
else
error('catch2 not found, unable to build tests')
endif
endif
endif
if opt_bindings_glib.allowed()
glib_dep = dependency('glib-2.0', version: '>= 2.80', required: opt_bindings_glib)
gobject_dep = dependency('gobject-2.0', version: '>= 2.80', required: opt_bindings_glib)
gio_dep = dependency('gio-2.0', version: '>= 2.80', required: opt_bindings_glib)
gio_unix_dep = dependency('gio-unix-2.0', version: '>= 2.80', required: opt_bindings_glib)
glib_mkenums = find_program('glib-mkenums', required: opt_bindings_glib)
endif
if opt_dbus.allowed()
gudev_dep = dependency('gudev-1.0', version: '>= 230', required: opt_dbus)
gdbus_codegen = find_program('gdbus-codegen', required: opt_dbus)
endif
if opt_introspection.allowed()
gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.2',
required: opt_introspection)
g_ir_scanner = find_program('g-ir-scanner', required: opt_introspection)
g_ir_compiler = find_program('g-ir-compiler', required: opt_introspection)
endif
if opt_systemd.allowed()
systemd_dep = dependency('systemd', required: opt_systemd)
if systemd_dep.found()
opt_systemd_unit_dir = get_option('systemd-unit-dir')
if opt_systemd_unit_dir != ''
systemd_unit_dir = opt_systemd_unit_dir
else
systemd_unit_dir = systemd_dep.get_variable('systemdsystemunitdir')
endif
endif
endif
if opt_bindings_rust.allowed()
cargo = find_program('cargo', required: opt_bindings_rust)
endif
help2man = find_program('help2man', required: false)
subdir('include')
subdir('lib')
if opt_tools.allowed()
subdir('tools')
endif
if opt_examples.allowed()
subdir('examples')
endif
if opt_tests.allowed() and libkmod_dep.found() and mount_dep.found()
subdir('tests')
endif
subdir('bindings')
if opt_dbus.allowed() and gudev_dep.found() and gdbus_codegen.found()
subdir('dbus')
endif
if help2man.found()
subdir('man')
endif

41
meson_options.txt Normal file
View File

@@ -0,0 +1,41 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
option('tools', type: 'feature',
description: 'Build libgpiod command-line tools')
option('gpioset-interactive', type: 'feature',
description: 'Enable gpioset interactive mode (requires libedit >= 3.1)')
option('tests', type: 'feature',
description: 'Build the test suite')
option('examples', type: 'feature', value: 'disabled',
description: 'Build code examples')
option('bindings-cxx', type: 'feature',
description: 'Build C++ bindings')
option('bindings-python', type: 'feature', value: 'disabled',
description: 'Build Python 3 bindings (requires Python >= 3.10)')
option('bindings-rust', type: 'feature', value: 'disabled',
description: 'Build Rust bindings (requires cargo)')
option('bindings-glib', type: 'feature',
description: 'Build GLib 2.0 / GObject bindings')
option('dbus', type: 'feature',
description: 'Build the D-Bus daemon and client (implies bindings-glib)')
option('introspection', type: 'feature',
description: 'Generate GObject introspection data (requires bindings-glib)')
option('systemd', type: 'feature',
description: 'Install systemd unit and udev rules (requires dbus)')
option('systemd-unit-dir', type: 'string', value: '',
description: 'Directory for systemd system unit files (default: from pkg-config)')
option('profiling', type: 'boolean', value: false,
description: 'Enable gcov profiling on the core library and tests')

4
tests/.gitignore vendored
View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
gpiod-test

View File

@@ -1,31 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <brgl@bgdev.pl>
SUBDIRS = gpiosim gpiosim-glib harness scripts
AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/tests/gpiosim-glib/
AM_CFLAGS += -I$(top_srcdir)/tests/harness/
AM_CFLAGS += -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) $(GIO_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-test\"
LDADD = $(top_builddir)/lib/libgpiod.la
LDADD += $(top_builddir)/tests/gpiosim/libgpiosim.la
LDADD += $(top_builddir)/tests/gpiosim-glib/libgpiosim-glib.la
LDADD += $(top_builddir)/tests/harness/libgpiod-test-harness.la
LDADD += $(GLIB_LIBS) $(GIO_LIBS)
noinst_PROGRAMS = gpiod-test
gpiod_test_SOURCES = \
helpers.h \
tests-chip.c \
tests-chip-info.c \
tests-edge-event.c \
tests-info-event.c \
tests-kernel-uapi.c \
tests-line-config.c \
tests-line-info.c \
tests-line-request.c \
tests-line-settings.c \
tests-misc.c \
tests-request-config.c

View File

@@ -1,13 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
noinst_LTLIBRARIES = libgpiosim-glib.la
libgpiosim_glib_la_SOURCES = \
gpiosim-glib.c \
gpiosim-glib.h
AM_CFLAGS = -I$(top_srcdir)/tests/gpiosim/
AM_CFLAGS += -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) $(GIO_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiosim-glib\"
libgpiosim_glib_la_LDFLAGS = -lgpiosim

View File

@@ -0,0 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
libgpiosim_glib_lib = static_library('gpiosim-glib',
sources: ['gpiosim-glib.c'],
include_directories: [include_directories('../gpiosim')],
c_args: ['-DG_LOG_DOMAIN="gpiosim-glib"'],
dependencies: [glib_test_dep, gio_test_dep],
link_with: [libgpiosim_lib],
pic: true,
)

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <brgl@bgdev.pl>
gpiosim-selftest

View File

@@ -1,15 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <brgl@bgdev.pl>
lib_LTLIBRARIES = libgpiosim.la
noinst_PROGRAMS = gpiosim-selftest
AM_CFLAGS = -Wall -Wextra -g -fvisibility=hidden -std=gnu89
AM_CFLAGS += -include $(top_builddir)/config.h
libgpiosim_la_SOURCES = gpiosim.c gpiosim.h
libgpiosim_la_CFLAGS = $(AM_CFLAGS) $(KMOD_CFLAGS) $(MOUNT_CFLAGS)
libgpiosim_la_LDFLAGS = -version-info $(subst .,:,$(ABI_GPIOSIM_VERSION))
libgpiosim_la_LDFLAGS += $(KMOD_LIBS) $(MOUNT_LIBS) -pthread
gpiosim_selftest_LDADD = libgpiosim.la

19
tests/gpiosim/meson.build Normal file
View File

@@ -0,0 +1,19 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
libgpiosim_both = both_libraries('gpiosim',
sources: ['gpiosim.c'],
c_args: ['-fvisibility=hidden'],
dependencies: [libkmod_dep, mount_dep, threads_dep],
version: libgpiosim_version,
soversion: libgpiosim_soversion,
install: true,
)
libgpiosim_lib = libgpiosim_both.get_shared_lib()
libgpiosim_static = libgpiosim_both.get_static_lib()
libgpiosim_inc = include_directories('.')
executable('gpiosim-selftest',
sources: ['gpiosim-selftest.c'],
link_with: [libgpiosim_lib],
)

View File

@@ -1,12 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
noinst_LTLIBRARIES = libgpiod-test-harness.la
libgpiod_test_harness_la_SOURCES = \
gpiod-test.c \
gpiod-test.h \
gpiod-test-common.h
AM_CFLAGS = -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS)
AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-test\"

View File

@@ -0,0 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
libgpiod_test_harness_lib = static_library('gpiod-test-harness',
sources: ['gpiod-test.c'],
c_args: ['-DG_LOG_DOMAIN="gpiod-test"'],
dependencies: [glib_test_dep],
pic: true,
)

37
tests/meson.build Normal file
View File

@@ -0,0 +1,37 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
subdir('gpiosim')
subdir('gpiosim-glib')
subdir('harness')
executable('gpiod-test',
sources: [
'helpers.h',
'tests-chip.c',
'tests-chip-info.c',
'tests-edge-event.c',
'tests-info-event.c',
'tests-kernel-uapi.c',
'tests-line-config.c',
'tests-line-info.c',
'tests-line-request.c',
'tests-line-settings.c',
'tests-misc.c',
'tests-request-config.c',
],
include_directories: [
libgpiod_inc,
include_directories('gpiosim'),
include_directories('gpiosim-glib'),
include_directories('harness'),
],
c_args: ['-DG_LOG_DOMAIN="gpiod-test"'],
dependencies: [
libgpiod_dep,
glib_test_dep,
gio_test_dep,
threads_dep,
],
link_with: [libgpiosim_lib, libgpiosim_glib_lib, libgpiod_test_harness_lib],
)

View File

@@ -1,4 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
EXTRA_DIST = gpiod-bash-test-helper.inc

View File

@@ -176,14 +176,14 @@ run_prog() {
# testing script.
cmd=$1
shift
output=$(timeout 10s "$SOURCE_DIR/$cmd" "$@" 2>&1)
output=$(timeout 10s "$cmd" "$@" 2>&1)
status=$?
}
dut_run() {
cmd=$1
shift
coproc timeout 10s "$SOURCE_DIR/$cmd" "$@" 2>&1
coproc timeout 10s "$cmd" "$@" 2>&1
DUT_PID=$COPROC_PID
read -r -t1 -n1 -u "${COPROC[0]}" DUT_FIRST_CHAR
}
@@ -191,7 +191,7 @@ dut_run() {
dut_run_redirect() {
cmd=$1
shift
coproc timeout 10s "$SOURCE_DIR/$cmd" "$@" > "$SHUNIT_TMPDIR/$DUT_OUTPUT" 2>&1
coproc timeout 10s "$cmd" "$@" > "$SHUNIT_TMPDIR/$DUT_OUTPUT" 2>&1
DUT_PID=$COPROC_PID
# give the process time to spin up
# FIXME - find a better solution
@@ -278,7 +278,7 @@ tearDown() {
}
request_release_line() {
"$SOURCE_DIR/gpioget" -c "$@" >/dev/null
"gpioget" -c "$@" >/dev/null
}
die() {

9
tools/.gitignore vendored
View File

@@ -1,9 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
gpiodetect
gpioinfo
gpioget
gpioset
gpiomon
gpionotify

View File

@@ -1,25 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
AM_CFLAGS = -I$(top_srcdir)/include/ -include $(top_builddir)/config.h
AM_CFLAGS += -Wall -Wextra -g -std=gnu89
noinst_LTLIBRARIES = libtools-common.la
libtools_common_la_SOURCES = tools-common.c tools-common.h
LDADD = libtools-common.la $(top_builddir)/lib/libgpiod.la
if WITH_GPIOSET_INTERACTIVE
AM_CFLAGS += -DGPIOSET_INTERACTIVE $(LIBEDIT_CFLAGS)
LDADD += $(LIBEDIT_LIBS)
endif
bin_PROGRAMS = gpiodetect gpioinfo gpioget gpioset gpiomon gpionotify
if WITH_TESTS
dist_noinst_SCRIPTS = gpio-tools-test.bash
endif

View File

@@ -4,9 +4,6 @@
# SPDX-FileCopyrightText: 2022 Kent Gibson <warthog618@gmail.com>
# SPDX-FileCopyrightText: 2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
export SOURCE_DIR
SOURCE_DIR="$(dirname "${BASH_SOURCE[0]}")"
#
# gpiodetect test cases
#

32
tools/meson.build Normal file
View File

@@ -0,0 +1,32 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
tools_common_lib = static_library('tools-common',
sources: ['tools-common.c'],
include_directories: libgpiod_inc,
pic: true,
)
tools_common_dep = declare_dependency(
link_with: tools_common_lib,
include_directories: include_directories('.'),
)
tools_c_args = []
tools_deps = [libgpiod_dep, tools_common_dep]
if opt_gpioset_interactive.allowed() and libedit_dep.found()
tools_c_args += ['-DGPIOSET_INTERACTIVE']
tools_deps += [libedit_dep]
endif
tools_exes = {}
foreach tool : ['gpiodetect', 'gpioinfo', 'gpioget', 'gpioset', 'gpiomon', 'gpionotify']
tools_exes += {tool: executable(tool,
sources: [tool + '.c'],
include_directories: libgpiod_inc,
dependencies: tools_deps,
c_args: tools_c_args,
install: true,
)}
endforeach