From: "Erik Schilling" <erik@riscstar.com>
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>,
"Linus Walleij" <linusw@kernel.org>,
"Vincent Fazio" <vfazio@xes-inc.com>,
"Kent Gibson" <warthog618@gmail.com>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Erik Wierich" <erik@riscstar.com>
Cc: "Bartosz Golaszewski" <brgl@kernel.org>, <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH libgpiod] build: replace autotools with meson & ninja
Date: Thu, 23 Apr 2026 09:25:02 +0200 [thread overview]
Message-ID: <DI0CSOLOJQQ6.2CDH5XKJLN76K@riscstar.com> (raw)
In-Reply-To: <20260422-meson-build-v1-1-a63a7a8b0d2f@oss.qualcomm.com>
On Wed Apr 22, 2026 at 12:27 PM CEST, Bartosz Golaszewski wrote:
> 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.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> I think this is the third or fourth time we try this, maybe this time
> it'll stick. This is a port of the current autotools build system to
> meson & ninja. A PoC yocto recipe update[1] can be used for testing.
>
> [1] https://github.com/brgl/meta-openembedded/tree/topic/libgpiod-meson
> ---
> Makefile.am | 62 ----
> autogen.sh | 17 -
> bindings/Makefile.am | 29 --
> bindings/cxx/Makefile.am | 47 ---
> bindings/cxx/examples/Makefile.am | 47 ---
> bindings/cxx/examples/meson.build | 27 ++
> bindings/cxx/gpiodcxx/Makefile.am | 20 --
> bindings/cxx/meson.build | 73 +++++
> bindings/cxx/tests/Makefile.am | 30 --
> bindings/cxx/tests/meson.build | 29 ++
> bindings/glib/Makefile.am | 133 --------
> bindings/glib/examples/Makefile.am | 22 --
> bindings/glib/examples/meson.build | 25 ++
> bindings/glib/gpiod-glib/meson.build | 18 ++
> bindings/glib/meson.build | 111 +++++++
> bindings/glib/tests/Makefile.am | 29 --
> bindings/glib/tests/meson.build | 27 ++
> bindings/meson.build | 18 ++
> bindings/python/Makefile.am | 58 ----
> bindings/python/examples/Makefile.am | 17 -
> bindings/python/gpiod/Makefile.am | 19 --
> bindings/python/gpiod/ext/Makefile.am | 11 -
> bindings/python/gpiod/meson.build | 41 +++
> bindings/python/meson.build | 10 +
> bindings/python/tests/Makefile.am | 18 --
> bindings/python/tests/gpiosim/Makefile.am | 8 -
> bindings/python/tests/gpiosim/meson.build | 14 +
> bindings/python/tests/meson.build | 34 ++
> bindings/python/tests/system/Makefile.am | 7 -
> bindings/python/tests/system/meson.build | 12 +
> bindings/rust/Makefile.am | 6 -
> bindings/rust/gpiosim-sys/Makefile.am | 6 -
> bindings/rust/gpiosim-sys/src/Makefile.am | 5 -
> bindings/rust/libgpiod-sys/Makefile.am | 6 -
> bindings/rust/libgpiod-sys/src/Makefile.am | 5 -
> bindings/rust/libgpiod/Makefile.am | 28 --
> bindings/rust/libgpiod/examples/Makefile.am | 18 --
> bindings/rust/libgpiod/src/Makefile.am | 15 -
> bindings/rust/libgpiod/tests/Makefile.am | 15 -
> bindings/rust/libgpiod/tests/common/Makefile.am | 5 -
> bindings/rust/meson.build | 40 +++
> configure.ac | 407 ------------------------
> contrib/Makefile.am | 4 -
> dbus/Makefile.am | 10 -
> dbus/client/Makefile.am | 31 --
> dbus/client/gpiocli-test.bash | 2 -
> dbus/client/meson.build | 30 ++
> dbus/data/Makefile.am | 14 -
> dbus/data/meson.build | 24 ++
> dbus/lib/Makefile.am | 29 --
> dbus/lib/meson.build | 35 ++
> dbus/manager/Makefile.am | 21 --
> dbus/manager/meson.build | 26 ++
> dbus/meson.build | 11 +
> dbus/tests/Makefile.am | 25 --
> dbus/tests/meson.build | 25 ++
> docs/Makefile.am | 65 ----
> examples/Makefile.am | 22 --
> examples/meson.build | 25 ++
> include/Makefile.am | 4 -
> include/meson.build | 4 +
> lib/Makefile.am | 28 --
> lib/meson.build | 37 +++
> man/Makefile.am | 70 ----
> man/meson.build | 82 +++++
> meson.build | 155 +++++++++
> meson_options.txt | 38 +++
> tests/Makefile.am | 31 --
> tests/gpiosim-glib/Makefile.am | 13 -
> tests/gpiosim-glib/meson.build | 11 +
> tests/gpiosim/Makefile.am | 15 -
> tests/gpiosim/meson.build | 19 ++
> tests/harness/Makefile.am | 12 -
> tests/harness/meson.build | 9 +
> tests/meson.build | 37 +++
> tests/scripts/Makefile.am | 4 -
> tests/scripts/gpiod-bash-test-helper.inc | 8 +-
> tools/Makefile.am | 25 --
> tools/gpio-tools-test.bash | 3 -
> tools/meson.build | 32 ++
> 80 files changed, 1083 insertions(+), 1522 deletions(-)
docs/building.rst also needs an update with that :).
[...]
> diff --git a/meson.build b/meson.build
> new file mode 100644
> index 0000000000000000000000000000000000000000..10df7969d0f6e8f157e9f1b39bd8cc90b2092d47
> --- /dev/null
> +++ b/meson.build
> @@ -0,0 +1,155 @@
> +# 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.63.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')
> +
> +# 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()
> + cxx = meson.get_compiler('cpp')
> + if cxx.has_header('catch2/catch_all.hpp')
> + catch2_test_dep = declare_dependency()
> + endif
> + endif
> +endif
This effectively leaves catch2 optional even if cxx && tests is mandated
(if catch2-with-main fails to yield a result and catch_all.hpp does
not exist).
I think either this lookup should mandate it to exist if cxx && tests
are chosen OR the executable() in bindings/cxx/tests/meson.build has to
be made conditional on the catch2_test_dep?
As it stands, it does not compile on Fedora (which only ships an old
catch2 version that does not have catch_all.hpp).
> +
> +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()
> + subdir('tests')
> +endif
> +
> +subdir('bindings')
> +
> +if opt_dbus.allowed()
> + subdir('dbus')
> +endif
> +
> +if help2man.found()
> + subdir('man')
> +endif
> diff --git a/meson_options.txt b/meson_options.txt
> new file mode 100644
> index 0000000000000000000000000000000000000000..9b9a5ed6b28347b213cf78df23bbeb2214e8c248
> --- /dev/null
> +++ b/meson_options.txt
> @@ -0,0 +1,38 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# SPDX-FileCopyrightText: 2026 Qualcomm Technologies, Inc. and/or its subsidiaries
> +
> +option('tools', type: 'feature', value: 'disabled',
> + description: 'Build libgpiod command-line tools')
> +
> +option('gpioset-interactive', type: 'feature', value: 'disabled',
> + description: 'Enable gpioset interactive mode (requires libedit >= 3.1)')
> +
> +option('tests', type: 'feature', value: 'disabled',
> + description: 'Build the test suite')
> +
> +option('examples', type: 'feature', value: 'disabled',
> + description: 'Build code examples')
> +
> +option('bindings-cxx', type: 'feature', value: 'disabled',
> + 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', value: 'disabled',
> + description: 'Build GLib 2.0 / GObject bindings')
> +
> +option('dbus', type: 'feature', value: 'disabled',
> + description: 'Build the D-Bus daemon and client (implies bindings-glib)')
> +
> +option('introspection', type: 'feature', value: 'disabled',
> + description: 'Generate GObject introspection data (requires bindings-glib)')
Setting value: 'disabled' on all these options keeps them disabled even
when running with meson setup --auto-features=enabled (which is what
distros like Fedora do to ensure they catch new options).
So I am not sure if all of these should have presets? I think they could
just be left out and be automatically be negotiated by their dependencies
being discovered?
Otherwise people risk bumping libgpiod but forgetting to package up new
tools like the dbus daemon.
> +option('systemd', type: 'feature', value: 'disabled',
> + 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)')
[...]
Tested-by: Erik Wierich <erik@riscstar.com>
prev parent reply other threads:[~2026-04-23 7:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 10:27 [PATCH libgpiod] build: replace autotools with meson & ninja Bartosz Golaszewski
2026-04-22 12:42 ` Vincent Fazio
2026-04-22 14:02 ` Vincent Fazio
2026-04-23 7:25 ` Erik Schilling [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DI0CSOLOJQQ6.2CDH5XKJLN76K@riscstar.com \
--to=erik@riscstar.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=vfazio@xes-inc.com \
--cc=viresh.kumar@linaro.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox