All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
@ 2022-12-05 13:22 Andrew Jeffery
  2022-12-05 13:22 ` [libgpiod][WIP PATCH 1/2] Introduce meson as a build system Andrew Jeffery
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-05 13:22 UTC (permalink / raw)
  To: linux-gpio

Hello,

Based on a recent poke [1] and in-between meetings I've put together a
WIP series that converts libgpiod's build from autotools to meson. As
far as I'm aware the meson build supports all the significant options to
enable or disable features exposed by the autotools build:

* Tests
* Tools
  * Interactive gpioset
* Bindings
  * C++
  * Python
  * Rust
* Documentation
  * Manpages
  * Doxygen

[1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/

Meson has pretty good support for handling python and so the patch does
away with setup.py entirely. However, the rust case isn't quite so
simple. In order to handle the dependencies of the rust bindings I've
called out to cargo through a custom target. It's not great, but from
what I could see it seems to be the path of least resistance given
meson's support for rust.

There's no support for installing the rust bindings through meson, but
this is not worse than the support we appeared to have under autotools.

It's worth noting that you'll probably want to disable the rust bindings
if you need to run the install phase for libgpiod under e.g. sudo but
have used rustup to install cargo for your unpriviledged user.

Also, if you've used rustup to install the rust toolchain you may also
need to install clang in order to pick up C toolchain headers for
consumption by bindgen.

Anyway, feedback on the rust part is definitely appreciated. Maybe
there's a better approach?

Moving along, the following tests pass in their entirety in my test VM:

* gpiod-test
* gpiod-cxx-test
* python -m gpiod.test

I've also briefly compared the install trees for the autotools and meson
builds under some configurations. The differences are accounted for by
meson defaulting to multi-arch installation paths for shared objects and
picking the generic rather than interpreter-version-specific python3
dist-packages directory under $PREFIX. Let me know if those seem
problematic.

A complete meson setup invocation looks as follows:

```
$ meson setup -Dbindings=cxx,python,rust -Ddocumentation=man,inline -Dexamples=true -Dtests=true -Dtools=true build
```

Subsequently the build can be performed with:

```
$ meson compile -C build
```

Meson defaults to using ninja as its backend, and automatically exploits
ccache[2] when available to keep repeated builds speedy.

[2] https://ccache.dev/

We end up with a net reduction of 254 LOC for the build system, and,
IMO, a single and fairly readable language to express it. Along with
that comes easy integration as a dependency in other (meson) projects
and a straight-forward path for their cross-compilation.

Let me know what you think.

Andrew

Andrew Jeffery (2):
  Introduce meson as a build system
  Remove autotools in favour of meson

 Doxyfile.in                               |   2 +-
 Makefile.am                               |  43 ----
 autogen.sh                                |  17 --
 bindings/Makefile.am                      |  22 --
 bindings/cxx/Makefile.am                  |  48 ----
 bindings/cxx/examples/Makefile.am         |  26 ---
 bindings/cxx/examples/meson.build         |   9 +
 bindings/cxx/gpiodcxx/Makefile.am         |  20 --
 bindings/cxx/gpiodcxx/meson.build         |  19 ++
 bindings/cxx/meson.build                  |  49 ++++
 bindings/cxx/tests/Makefile.am            |  32 ---
 bindings/cxx/tests/meson.build            |  26 +++
 bindings/meson.build                      |  14 ++
 bindings/python/Makefile.am               |  35 ---
 bindings/python/examples/Makefile.am      |  10 -
 bindings/python/examples/meson.build      |  12 +
 bindings/python/gpiod/Makefile.am         |  17 --
 bindings/python/gpiod/ext/Makefile.am     |  11 -
 bindings/python/gpiod/ext/meson.build     |  14 ++
 bindings/python/gpiod/meson.build         |  17 ++
 bindings/python/meson.build               |  16 ++
 bindings/python/setup.py                  |  47 ----
 bindings/python/tests/Makefile.am         |  17 --
 bindings/python/tests/gpiosim/Makefile.am |   7 -
 bindings/python/tests/gpiosim/meson.build |  12 +
 bindings/python/tests/meson.build         |  17 ++
 bindings/rust/Makefile.am                 |  19 --
 bindings/rust/gpiosim-sys/build.rs        |   9 +-
 bindings/rust/libgpiod-sys/build.rs       |   9 +-
 bindings/rust/meson.build                 |  33 +++
 configure.ac                              | 272 ----------------------
 include/Makefile.am                       |   4 -
 include/meson.build                       |   7 +
 lib/Makefile.am                           |  27 ---
 lib/meson.build                           |  30 +++
 man/Makefile.am                           |  16 --
 man/meson.build                           |  21 ++
 meson.build                               |  91 ++++++++
 meson_options.txt                         |   9 +
 tests/Makefile.am                         |  34 ---
 tests/gpiosim/Makefile.am                 |  16 --
 tests/gpiosim/meson.build                 |  24 ++
 tests/meson.build                         |  30 +++
 tools/Makefile.am                         |  39 ----
 tools/meson.build                         |  69 ++++++
 45 files changed, 532 insertions(+), 786 deletions(-)
 delete mode 100644 Makefile.am
 delete mode 100755 autogen.sh
 delete mode 100644 bindings/Makefile.am
 delete mode 100644 bindings/cxx/Makefile.am
 delete mode 100644 bindings/cxx/examples/Makefile.am
 create mode 100644 bindings/cxx/examples/meson.build
 delete mode 100644 bindings/cxx/gpiodcxx/Makefile.am
 create mode 100644 bindings/cxx/gpiodcxx/meson.build
 create mode 100644 bindings/cxx/meson.build
 delete mode 100644 bindings/cxx/tests/Makefile.am
 create mode 100644 bindings/cxx/tests/meson.build
 create mode 100644 bindings/meson.build
 delete mode 100644 bindings/python/Makefile.am
 delete mode 100644 bindings/python/examples/Makefile.am
 create mode 100644 bindings/python/examples/meson.build
 delete mode 100644 bindings/python/gpiod/Makefile.am
 delete mode 100644 bindings/python/gpiod/ext/Makefile.am
 create mode 100644 bindings/python/gpiod/ext/meson.build
 create mode 100644 bindings/python/gpiod/meson.build
 create mode 100644 bindings/python/meson.build
 delete mode 100644 bindings/python/setup.py
 delete mode 100644 bindings/python/tests/Makefile.am
 delete mode 100644 bindings/python/tests/gpiosim/Makefile.am
 create mode 100644 bindings/python/tests/gpiosim/meson.build
 create mode 100644 bindings/python/tests/meson.build
 delete mode 100644 bindings/rust/Makefile.am
 create mode 100644 bindings/rust/meson.build
 delete mode 100644 configure.ac
 delete mode 100644 include/Makefile.am
 create mode 100644 include/meson.build
 delete mode 100644 lib/Makefile.am
 create mode 100644 lib/meson.build
 delete mode 100644 man/Makefile.am
 create mode 100644 man/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 delete mode 100644 tests/Makefile.am
 delete mode 100644 tests/gpiosim/Makefile.am
 create mode 100644 tests/gpiosim/meson.build
 create mode 100644 tests/meson.build
 delete mode 100644 tools/Makefile.am
 create mode 100644 tools/meson.build

-- 
2.37.2


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [libgpiod][WIP PATCH 1/2] Introduce meson as a build system
  2022-12-05 13:22 [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Andrew Jeffery
@ 2022-12-05 13:22 ` Andrew Jeffery
  2022-12-05 13:22 ` [libgpiod][WIP PATCH 2/2] Remove autotools in favour of meson Andrew Jeffery
  2022-12-05 18:55 ` [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Bartosz Golaszewski
  2 siblings, 0 replies; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-05 13:22 UTC (permalink / raw)
  To: linux-gpio

So far meson builds the core library, tools and tests, as well as the
C++, Python and Rust bindings.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 Doxyfile.in                               |  2 +-
 bindings/cxx/examples/meson.build         |  9 +++
 bindings/cxx/gpiodcxx/meson.build         | 19 +++++
 bindings/cxx/meson.build                  | 49 ++++++++++++
 bindings/cxx/tests/meson.build            | 26 +++++++
 bindings/meson.build                      | 14 ++++
 bindings/python/examples/meson.build      | 12 +++
 bindings/python/gpiod/ext/meson.build     | 14 ++++
 bindings/python/gpiod/meson.build         | 17 +++++
 bindings/python/meson.build               | 16 ++++
 bindings/python/tests/gpiosim/meson.build | 12 +++
 bindings/python/tests/meson.build         | 17 +++++
 bindings/rust/gpiosim-sys/build.rs        |  9 ++-
 bindings/rust/libgpiod-sys/build.rs       |  9 ++-
 bindings/rust/meson.build                 | 30 ++++++++
 include/meson.build                       |  7 ++
 lib/meson.build                           | 30 ++++++++
 man/meson.build                           | 21 ++++++
 meson.build                               | 91 +++++++++++++++++++++++
 meson_options.txt                         |  9 +++
 tests/gpiosim/meson.build                 | 24 ++++++
 tests/meson.build                         | 30 ++++++++
 tools/meson.build                         | 69 +++++++++++++++++
 23 files changed, 529 insertions(+), 7 deletions(-)
 create mode 100644 bindings/cxx/examples/meson.build
 create mode 100644 bindings/cxx/gpiodcxx/meson.build
 create mode 100644 bindings/cxx/meson.build
 create mode 100644 bindings/cxx/tests/meson.build
 create mode 100644 bindings/meson.build
 create mode 100644 bindings/python/examples/meson.build
 create mode 100644 bindings/python/gpiod/ext/meson.build
 create mode 100644 bindings/python/gpiod/meson.build
 create mode 100644 bindings/python/meson.build
 create mode 100644 bindings/python/tests/gpiosim/meson.build
 create mode 100644 bindings/python/tests/meson.build
 create mode 100644 bindings/rust/meson.build
 create mode 100644 include/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 man/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 tests/gpiosim/meson.build
 create mode 100644 tests/meson.build
 create mode 100644 tools/meson.build

diff --git a/Doxyfile.in b/Doxyfile.in
index 9c85e2113edc..5e2b59c3631b 100644
--- a/Doxyfile.in
+++ b/Doxyfile.in
@@ -6,7 +6,7 @@
 # General configuration
 PROJECT_NAME           = libgpiod
 PROJECT_NUMBER         = @VERSION_STR@
-OUTPUT_DIRECTORY       = doc
+OUTPUT_DIRECTORY       = @DOC_DIR@
 OUTPUT_LANGUAGE        = English
 EXTRACT_ALL            = NO
 EXTRACT_PRIVATE        = NO
diff --git a/bindings/cxx/examples/meson.build b/bindings/cxx/examples/meson.build
new file mode 100644
index 000000000000..ffbd6c009ae8
--- /dev/null
+++ b/bindings/cxx/examples/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+executable('gpiodetectcxx', 'gpiodetectcxx.cpp', dependencies: gpiodcxx_dep)
+executable('gpiofindcxx', 'gpiofindcxx.cpp', dependencies: gpiodcxx_dep)
+executable('gpiogetcxx', 'gpiogetcxx.cpp', dependencies: gpiodcxx_dep)
+executable('gpioinfocxx', 'gpioinfocxx.cpp', dependencies: gpiodcxx_dep)
+executable('gpiomoncxx', 'gpiomoncxx.cpp', dependencies: gpiodcxx_dep)
+executable('gpiosetcxx', 'gpiosetcxx.cpp', dependencies: gpiodcxx_dep)
diff --git a/bindings/cxx/gpiodcxx/meson.build b/bindings/cxx/gpiodcxx/meson.build
new file mode 100644
index 000000000000..a0f416ba8a74
--- /dev/null
+++ b/bindings/cxx/gpiodcxx/meson.build
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+install_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',
+		subdir: 'gpiodcxx')
diff --git a/bindings/cxx/meson.build b/bindings/cxx/meson.build
new file mode 100644
index 000000000000..4bb43111ce18
--- /dev/null
+++ b/bindings/cxx/meson.build
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+add_languages('cpp', native: false)
+
+gpiodcxx_abi_version = '1.1.1'
+
+gpiodcxx = library('gpiodcxx',
+		   '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',
+		   cpp_args: '-DGPIOD_CXX_BUILD',
+		   include_directories: gpiod_includes,
+		   gnu_symbol_visibility: 'hidden',
+		   version: gpiodcxx_abi_version,
+		   dependencies: gpiod_dep,
+	           install: true)
+
+pkg.generate(gpiodcxx,
+	     name: 'libgpiodcxx',
+	     description: 'C++ bindings for libgpiod')
+
+gpiodcxx_dep = declare_dependency(link_with: gpiodcxx,
+				  include_directories: include_directories('.'),
+				  dependencies: gpiod_dep,
+				  version: gpiodcxx_abi_version)
+
+install_headers('gpiod.hpp')
+subdir('gpiodcxx')
+
+if get_option('examples')
+    subdir('examples')
+endif
+
+if get_option('tests')
+    subdir('tests')
+endif
diff --git a/bindings/cxx/tests/meson.build b/bindings/cxx/tests/meson.build
new file mode 100644
index 000000000000..9dc8fdf491c5
--- /dev/null
+++ b/bindings/cxx/tests/meson.build
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+catch2_dep = dependency('catch2')
+
+executable('gpiod-cxx-test',
+	   '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',
+	   dependencies: [ catch2_dep,
+			   gpiodcxx_dep,
+			   gpiosim_dep,
+			   threads_dep ],
+	   install: true)
diff --git a/bindings/meson.build b/bindings/meson.build
new file mode 100644
index 000000000000..bf7ad3669b5b
--- /dev/null
+++ b/bindings/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+if get_option('bindings').contains('cxx')
+    subdir('cxx')
+endif
+
+if get_option('bindings').contains('python')
+    subdir('python')
+endif
+
+if get_option('bindings').contains('rust')
+    subdir('rust')
+endif
diff --git a/bindings/python/examples/meson.build b/bindings/python/examples/meson.build
new file mode 100644
index 000000000000..f8cd2455fbcd
--- /dev/null
+++ b/bindings/python/examples/meson.build
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+install_data('gpiodetect.py',
+	     'gpiofind.py',
+	     'gpioget.py',
+	     'gpioinfo.py',
+	     'gpiomon.py',
+	     'gpioset.py',
+	     'helpers.py',
+	     install_dir: get_option('datadir') / meson.project_name(),
+	     install_mode: 'rwxr-xr-x')
diff --git a/bindings/python/gpiod/ext/meson.build b/bindings/python/gpiod/ext/meson.build
new file mode 100644
index 000000000000..0128ae26a085
--- /dev/null
+++ b/bindings/python/gpiod/ext/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+gpiodpyext = python3.extension_module('_ext',
+				      'chip.c',
+				      'common.c',
+				      'line-config.c',
+				      'line-settings.c',
+				      'module.c',
+				      'request.c',
+				      c_args: '-D_GNU_SOURCE',
+				      dependencies: [gpiod_dep, python3_dep],
+				      subdir: 'gpiod',
+				      install: true)
diff --git a/bindings/python/gpiod/meson.build b/bindings/python/gpiod/meson.build
new file mode 100644
index 000000000000..90d4517d5361
--- /dev/null
+++ b/bindings/python/gpiod/meson.build
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+subdir('ext')
+
+python3.install_sources('chip_info.py',
+			'chip.py',
+			'edge_event.py',
+			'exception.py',
+			'info_event.py',
+			'__init__.py',
+			'internal.py',
+			'line_info.py',
+			'line.py',
+			'line_request.py',
+			'line_settings.py',
+			subdir: 'gpiod')
diff --git a/bindings/python/meson.build b/bindings/python/meson.build
new file mode 100644
index 000000000000..26f7ff13e0dd
--- /dev/null
+++ b/bindings/python/meson.build
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+python = import('python')
+python3 = python.find_installation('python3')
+python3_dep = python3.dependency()
+
+subdir('gpiod')
+
+if get_option('examples')
+    subdir('examples')
+endif
+
+if get_option('tests')
+    subdir('tests')
+endif
diff --git a/bindings/python/tests/gpiosim/meson.build b/bindings/python/tests/gpiosim/meson.build
new file mode 100644
index 000000000000..82ea6d07df4d
--- /dev/null
+++ b/bindings/python/tests/gpiosim/meson.build
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+gpiodsimpyext = python3.extension_module('_ext',
+					 'ext.c',
+					 c_args: '-D_GNU_SOURCE',
+					 dependencies: [gpiosim_dep, python3_dep],
+					 subdir: 'gpiod/tests/gpiosim',
+					 install: true)
+python3.install_sources('chip.py',
+		        '__init__.py',
+		        subdir: 'gpiod/tests/gpiosim')
diff --git a/bindings/python/tests/meson.build b/bindings/python/tests/meson.build
new file mode 100644
index 000000000000..e33a24e7da0f
--- /dev/null
+++ b/bindings/python/tests/meson.build
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+subdir('gpiosim')
+
+python3.install_sources('helpers.py',
+			'__init__.py',
+			'__main__.py',
+			'tests_chip_info.py',
+			'tests_chip.py',
+			'tests_edge_event.py',
+			'tests_info_event.py',
+			'tests_line_info.py',
+			'tests_line_request.py',
+			'tests_line_settings.py',
+			'tests_module.py',
+			subdir: 'gpiod/tests')
diff --git a/bindings/rust/gpiosim-sys/build.rs b/bindings/rust/gpiosim-sys/build.rs
index 0651c6115322..86312af20e36 100644
--- a/bindings/rust/gpiosim-sys/build.rs
+++ b/bindings/rust/gpiosim-sys/build.rs
@@ -9,15 +9,17 @@ use std::path::PathBuf;
 
 fn generate_bindings() {
     // Tell cargo to invalidate the built crate whenever following files change
-    println!("cargo:rerun-if-changed=../../../tests/gpiosim/gpiosim.h");
+    let source_dep = env::var("GPIOD_CARGO_SIM_SOURCE_DEP").unwrap();
+    println!("cargo:rerun-if-changed={source_dep}");
 
     // The bindgen::Builder is the main entry point
     // to bindgen, and lets you build up options for
     // the resulting bindings.
+    let header_dep = env::var("GPIOD_CARGO_SIM_HEADER_DEP").unwrap();
     let bindings = bindgen::Builder::default()
         // The input header we would like to generate
         // bindings for.
-        .header("../../../tests/gpiosim/gpiosim.h")
+        .header(header_dep)
         // Tell cargo to invalidate the built crate whenever any of the
         // included header files changed.
         .parse_callbacks(Box::new(bindgen::CargoCallbacks))
@@ -38,6 +40,7 @@ fn main() {
 
     println!("cargo:rustc-link-lib=kmod");
     println!("cargo:rustc-link-lib=mount");
-    println!("cargo:rustc-link-search=./../../tests/gpiosim/.libs/");
+    let link_dir = env::var("GPIOD_CARGO_SIM_LINK_DIR").unwrap();
+    println!("cargo:rustc-link-search={link_dir}");
     println!("cargo:rustc-link-lib=static=gpiosim");
 }
diff --git a/bindings/rust/libgpiod-sys/build.rs b/bindings/rust/libgpiod-sys/build.rs
index 274069eb9e9d..4dd6c54c935f 100644
--- a/bindings/rust/libgpiod-sys/build.rs
+++ b/bindings/rust/libgpiod-sys/build.rs
@@ -9,15 +9,17 @@ use std::path::PathBuf;
 
 fn generate_bindings() {
     // Tell cargo to invalidate the built crate whenever following files change
-    println!("cargo:rerun-if-changed=../../../include/gpiod.h");
+    let source_dep = env::var("GPIOD_CARGO_LIB_SOURCE_DEP").unwrap();
+    println!("cargo:rerun-if-changed={source_dep}");
 
     // The bindgen::Builder is the main entry point
     // to bindgen, and lets you build up options for
     // the resulting bindings.
+    let header_dep = env::var("GPIOD_CARGO_LIB_HEADER_DEP").unwrap();
     let bindings = bindgen::Builder::default()
         // The input header we would like to generate
         // bindings for.
-        .header("../../../include/gpiod.h")
+        .header(header_dep)
         // Tell cargo to invalidate the built crate whenever any of the
         // included header files changed.
         .parse_callbacks(Box::new(bindgen::CargoCallbacks))
@@ -36,6 +38,7 @@ fn generate_bindings() {
 fn main() {
     generate_bindings();
 
-    println!("cargo:rustc-link-search=./../../lib/.libs/");
+    let link_dir = env::var("GPIOD_CARGO_LIB_LINK_DIR").unwrap();
+    println!("cargo:rustc-link-search={link_dir}");
     println!("cargo:rustc-link-lib=static=gpiod");
 }
diff --git a/bindings/rust/meson.build b/bindings/rust/meson.build
new file mode 100644
index 000000000000..68f27f473282
--- /dev/null
+++ b/bindings/rust/meson.build
@@ -0,0 +1,30 @@
+cargo = find_program('cargo')
+cargo_manifest = files('Cargo.toml')
+cargo_build_dir = meson.project_build_root() / 'cargo-build'
+cargo_build_cmd = [cargo, 'build', '--manifest-path', cargo_manifest, '--target-dir', cargo_build_dir, '--release', '--lib']
+
+if get_option('tests')
+    cargo_build_cmd += '--tests'
+endif
+
+if get_option('examples')
+    cargo_build_cmd += '--examples'
+endif
+
+cargo_env = environment()
+gpiod_h_p = meson.project_source_root() / '@0@'.format(gpiod_h[0])
+cargo_env.set('GPIOD_CARGO_LIB_SOURCE_DEP', gpiod_h_p)
+cargo_env.set('GPIOD_CARGO_LIB_HEADER_DEP', gpiod_h_p)
+cargo_env.set('GPIOD_CARGO_LIB_LINK_DIR', meson.project_build_root() / 'lib')
+gpiosim_h_p = meson.project_source_root() / '@0@'.format(gpiosim_h[0])
+cargo_env.set('GPIOD_CARGO_SIM_SOURCE_DEP', gpiosim_h_p)
+cargo_env.set('GPIOD_CARGO_SIM_HEADER_DEP', gpiosim_h_p)
+cargo_env.set('GPIOD_CARGO_SIM_LINK_DIR', meson.project_build_root() / 'tests' / 'gpiosim')
+
+cargo_build = custom_target('cargo-build',
+			    input: 'Cargo.toml',
+			    output: 'cargo-build',
+			    env: cargo_env,
+			    command: cargo_build_cmd,
+			    build_by_default: true,
+			    install: false)
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 000000000000..ca3337e5990f
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+gpiod_includes = include_directories('.')
+
+gpiod_h = files('gpiod.h')
+install_headers(gpiod_h)
diff --git a/lib/meson.build b/lib/meson.build
new file mode 100644
index 000000000000..159a176b0130
--- /dev/null
+++ b/lib/meson.build
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+gpiod_abi_version = '2.2.1'
+
+gpiod = library('gpiod',
+		'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',
+		c_args: ['-include', '@0@'.format(config_h)],
+		include_directories: gpiod_includes,
+		gnu_symbol_visibility: 'hidden',
+		version: gpiod_abi_version,
+		install: true)
+
+pkg.generate(gpiod,
+	     name: 'libgpiod',
+	     description: 'Library and tools for the Linux GPIO chardev')
+
+gpiod_dep = declare_dependency(link_with: gpiod,
+			       include_directories: gpiod_includes,
+			       version: gpiod_abi_version)
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 000000000000..8430429932e9
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+if get_option('documentation').contains('man')
+    help2man = find_program('help2man')
+    genmanpage = [ help2man,
+		   '@INPUT@',
+		   '--include=@CURRENT_SOURCE_DIR@/template',
+		   '--output=@OUTPUT@',
+		   '--no-info' ]
+    man1 = get_option('prefix') / get_option('mandir') / 'man1'
+    foreach t : tools
+	custom_target('@0@.1'.format(t.name()),
+		      input: t,
+		      output: '@BASENAME@.1',
+		      depend_files: 'template',
+		      command: genmanpage,
+		      install: true,
+		      install_dir: man1)
+    endforeach
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 000000000000..02f355aae50b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+project('libgpiod', 'c',
+	default_options: [ 'buildtype=debugoptimized',
+			   'warning_level=2',
+			   'c_std=gnu99',
+			   'cpp_std=gnu++17',
+			   'default_library=both' ],
+	version: '2.0.0',
+	license: 'LGPL-2.1-or-later',
+	meson_version: '>=0.58.2')
+
+add_project_arguments('-D_GNU_SOURCE', language: 'c')
+
+pkg = import('pkgconfig')
+
+cc = meson.get_compiler('c')
+
+version = meson.project_version().split('.')
+extra_version = '.'.join([version[0], version[1]]) + '-devel'
+config = configuration_data()
+config.set_quoted('GPIOD_VERSION_STR', extra_version)
+config_h = configure_file(output: 'config.h', configuration: config)
+
+# TODO: Deal with AC_FUNC_MALLOC
+
+lib_header_deps = [ 'getopt.h',
+		    'dirent.h',
+		    'sys/poll.h',
+		    'sys/sysmacros.h',
+		    'linux/version.h',
+		    'linux/const.h',
+		    'linux/ioctl.h',
+		    'linux/types.h' ]
+
+foreach h : lib_header_deps
+    if not cc.has_header(h)
+	error(f'@h@ not found (needed to build the library)')
+    endif
+endforeach
+
+lib_function_deps = { 'ioctl' : '#include <sys/ioctl.h>',
+		      'asprintf' : '#include <stdio.h>',
+		      'scandir' : '#include <dirent.h>',
+		      'alphasort' : '#include <dirent.h>',
+		      'ppoll' : '#include <poll.h>',
+		      'realpath' : '#include <stdlib.h>' }
+
+foreach fn, prefix : lib_function_deps
+    if not cc.has_function(fn, prefix: prefix, args: '-D_GNU_SOURCE')
+	error(f'@fn@ not found (needed to build the library)')
+    endif
+endforeach
+
+subdir('include')
+subdir('lib')
+
+if get_option('documentation').contains('inline')
+    doxygen = find_program('doxygen')
+    find_program('dot') # Required by doxygen
+    doc_dir = meson.current_build_dir()
+    doxyconf = configuration_data()
+    doxyconf.set('VERSION_STR', extra_version)
+    doxyconf.set('DOC_DIR', doc_dir)
+    doxyconf.set('top_srcdir', meson.current_source_dir())
+    doxyfile = configure_file(input: 'Doxyfile.in',
+			      output: 'Doxyfile',
+			      configuration: doxyconf)
+    doxygen_install_dir = get_option('datadir') / 'doc' / meson.project_name()
+    custom_target('doxygen',
+		  input: doxyfile,
+		  output: ['html', 'man', 'xml'],
+		  command: [doxygen, doxyfile],
+		  install: true,
+	          install_dir: doxygen_install_dir)
+endif
+
+if get_option('tests')
+    threads_dep = dependency('threads')
+    subdir('tests')
+endif
+
+foreach b : get_option('bindings')
+    subdir('bindings' / b)
+endforeach
+
+if get_option('tools')
+    subdir('tools')
+    subdir('man')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 000000000000..1df374b4a6eb
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2021 IBM Corp.
+
+option('bindings', type: 'array', choices: ['cxx', 'python', 'rust'], description: 'Language bindings for libgpiod', value: [])
+option('documentation', type: 'array', choices: ['man', 'inline'], description: 'Generate documentation for the tools and library', value: ['man'])
+option('examples', type: 'boolean', description: 'enabling building code examples', value: 'false')
+option('gpioset-interactive', type: 'feature', description: 'enable gpioset interactive mode', value: 'auto')
+option('tests', type: 'boolean', description: 'enable libgpiod tests', value: 'false')
+option('tools', type: 'boolean', description: 'enable libgpiod command-line tools', value: 'false')
diff --git a/tests/gpiosim/meson.build b/tests/gpiosim/meson.build
new file mode 100644
index 000000000000..4b99452dc12e
--- /dev/null
+++ b/tests/gpiosim/meson.build
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+kmod_dep = dependency('libkmod', version: '>=18')
+mount_dep = dependency('mount', version: '>=2.33.1')
+
+gpiosim_includes = include_directories('.')
+
+gpiosim_abi_version = '0.0.1'
+gpiosim = library('gpiosim',
+                  'gpiosim.c',
+                  c_args: ['-include', '@0@'.format(config_h)],
+                  dependencies: [kmod_dep, mount_dep],
+                  include_directories: gpiod_includes,
+                  gnu_symbol_visibility: 'hidden',
+                  version: gpiosim_abi_version,
+                  install: true)
+
+gpiosim_dep = declare_dependency(link_with: gpiosim,
+                                 include_directories: gpiosim_includes,
+                                 version: gpiosim_abi_version)
+
+gpiosim_h = files('gpiosim.h')
+install_headers(gpiosim_h)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 000000000000..32f7e6c42f12
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+subdir('gpiosim')
+
+glib_dep = dependency('glib-2.0', version: '>=2.50')
+gobject_dep = dependency('gobject-2.0', version: '>=2.50')
+
+executable('gpiod-test',
+	   'gpiod-test.c',
+	   'gpiod-test-helpers.c',
+	   'gpiod-test-sim.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',
+	   c_args: '-DG_LOG_DOMAIN="gpiod-test"',
+	   dependencies: [ glib_dep,
+			   gobject_dep,
+			   gpiod_dep,
+			   gpiosim_dep,
+			   kmod_dep,
+			   threads_dep ],
+	   install: true)
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 000000000000..f7f1fc9b10c0
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
+if not cc.has_function('daemon', prefix: '#include <unistd.h>', args: '-D_GNU_SOURCE')
+    error(f'@fn@ not found (needed to build tools')
+endif
+
+tools_common_dep = declare_dependency(sources: ['tools-common.c', 'tools-common.h'])
+
+tools_c_args = ['-include', '@0@'.format(config_h)]
+tools_deps = [ gpiod_dep, tools_common_dep ]
+
+tools = []
+
+gpiodetect = executable('gpiodetect',
+			'gpiodetect.c',
+			c_args: tools_c_args,
+			dependencies: tools_deps,
+			install: true)
+tools += gpiodetect
+
+gpioinfo = executable('gpioinfo',
+		      'gpioinfo.c',
+		      c_args: tools_c_args,
+		      dependencies: tools_deps,
+		      install: true)
+tools += gpioinfo
+
+gpioget = executable('gpioget',
+		     'gpioget.c',
+		     c_args: tools_c_args,
+		     dependencies: tools_deps,
+		     install: true)
+tools += gpioget
+
+gpioset_c_args = tools_c_args
+gpioset_deps = tools_deps
+edit_dep = dependency('libedit', version: '>=3.1', required: get_option('gpioset-interactive'))
+if edit_dep.found()
+    gpioset_c_args += '-DGPIOSET_INTERACTIVE'
+    gpioset_deps += edit_dep
+endif
+gpioset = executable('gpioset',
+		     'gpioset.c',
+		     c_args: gpioset_c_args,
+		     dependencies: gpioset_deps,
+		     install: true)
+tools += gpioset
+
+gpiomon = executable('gpiomon',
+		     'gpiomon.c',
+		     c_args: tools_c_args,
+		     dependencies: tools_deps,
+		     install: true)
+tools += gpiomon
+
+gpionotify = executable('gpionotify',
+			'gpionotify.c',
+			c_args: tools_c_args,
+			dependencies: tools_deps,
+			install: true)
+tools += gpionotify
+
+if get_option('tests')
+    install_data('gpio-tools-test',
+		 'gpio-tools-test.bats',
+		 install_dir: get_option('bindir'),
+		 install_mode: 'rwxr-xr-x')
+endif
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [libgpiod][WIP PATCH 2/2] Remove autotools in favour of meson
  2022-12-05 13:22 [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Andrew Jeffery
  2022-12-05 13:22 ` [libgpiod][WIP PATCH 1/2] Introduce meson as a build system Andrew Jeffery
@ 2022-12-05 13:22 ` Andrew Jeffery
  2022-12-05 18:55 ` [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Bartosz Golaszewski
  2 siblings, 0 replies; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-05 13:22 UTC (permalink / raw)
  To: linux-gpio

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
---
 Makefile.am                               |  43 ----
 autogen.sh                                |  17 --
 bindings/Makefile.am                      |  22 --
 bindings/cxx/Makefile.am                  |  48 ----
 bindings/cxx/examples/Makefile.am         |  26 ---
 bindings/cxx/gpiodcxx/Makefile.am         |  20 --
 bindings/cxx/tests/Makefile.am            |  32 ---
 bindings/python/Makefile.am               |  35 ---
 bindings/python/examples/Makefile.am      |  10 -
 bindings/python/gpiod/Makefile.am         |  17 --
 bindings/python/gpiod/ext/Makefile.am     |  11 -
 bindings/python/setup.py                  |  47 ----
 bindings/python/tests/Makefile.am         |  17 --
 bindings/python/tests/gpiosim/Makefile.am |   7 -
 bindings/rust/Makefile.am                 |  19 --
 bindings/rust/meson.build                 |   3 +
 configure.ac                              | 272 ----------------------
 include/Makefile.am                       |   4 -
 lib/Makefile.am                           |  27 ---
 man/Makefile.am                           |  16 --
 tests/Makefile.am                         |  34 ---
 tests/gpiosim/Makefile.am                 |  16 --
 tools/Makefile.am                         |  39 ----
 23 files changed, 3 insertions(+), 779 deletions(-)
 delete mode 100644 Makefile.am
 delete mode 100755 autogen.sh
 delete mode 100644 bindings/Makefile.am
 delete mode 100644 bindings/cxx/Makefile.am
 delete mode 100644 bindings/cxx/examples/Makefile.am
 delete mode 100644 bindings/cxx/gpiodcxx/Makefile.am
 delete mode 100644 bindings/cxx/tests/Makefile.am
 delete mode 100644 bindings/python/Makefile.am
 delete mode 100644 bindings/python/examples/Makefile.am
 delete mode 100644 bindings/python/gpiod/Makefile.am
 delete mode 100644 bindings/python/gpiod/ext/Makefile.am
 delete mode 100644 bindings/python/setup.py
 delete mode 100644 bindings/python/tests/Makefile.am
 delete mode 100644 bindings/python/tests/gpiosim/Makefile.am
 delete mode 100644 bindings/rust/Makefile.am
 delete mode 100644 configure.ac
 delete mode 100644 include/Makefile.am
 delete mode 100644 lib/Makefile.am
 delete mode 100644 man/Makefile.am
 delete mode 100644 tests/Makefile.am
 delete mode 100644 tests/gpiosim/Makefile.am
 delete mode 100644 tools/Makefile.am

diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index dfc6c95b76cd..000000000000
--- a/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
-
-ACLOCAL_AMFLAGS = -I m4
-AUTOMAKE_OPTIONS = foreign
-SUBDIRS = include lib
-
-EXTRA_DIST = \
-	LICENSES/CC-BY-SA-4.0.txt \
-	LICENSES/GPL-2.0-only.txt \
-	LICENSES/GPL-2.0-or-later.txt \
-	LICENSES/LGPL-2.1-or-later.txt \
-	LICENSES/LGPL-3.0-or-later.txt \
-	LICENSES/Linux-syscall-note.txt
-
-if WITH_TOOLS
-
-SUBDIRS += tools man
-
-endif
-
-if WITH_TESTS
-
-SUBDIRS += tests
-
-endif
-
-# Build bindings after core tests. When building tests for bindings, we need
-# libgpiomockup to be already present.
-SUBDIRS += bindings
-
-if HAS_DOXYGEN
-
-doc: Doxyfile
-	@doxygen Doxyfile
-.PHONY: doc
-
-clean-local:
-	rm -rf doc
-
-EXTRA_DIST += Doxyfile
-
-endif
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 420b821b7837..000000000000
--- a/autogen.sh
+++ /dev/null
@@ -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
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
deleted file mode 100644
index 004ae23dbc58..000000000000
--- a/bindings/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
-
-SUBDIRS = .
-
-if WITH_BINDINGS_CXX
-
-SUBDIRS += cxx
-
-endif
-
-if WITH_BINDINGS_PYTHON
-
-SUBDIRS += python
-
-endif
-
-if WITH_BINDINGS_RUST
-
-SUBDIRS += rust
-
-endif
diff --git a/bindings/cxx/Makefile.am b/bindings/cxx/Makefile.am
deleted file mode 100644
index f719072bb30e..000000000000
--- a/bindings/cxx/Makefile.am
+++ /dev/null
@@ -1,48 +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_CXXFLAGS += -DGPIOD_CXX_BUILD
-libgpiodcxx_la_LDFLAGS = -version-info $(subst .,:,$(ABI_CXX_VERSION))
-libgpiodcxx_la_LDFLAGS += -lgpiod -L$(top_builddir)/lib
-libgpiodcxx_la_LDFLAGS += $(PROFILING_LDFLAGS)
-
-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
diff --git a/bindings/cxx/examples/Makefile.am b/bindings/cxx/examples/Makefile.am
deleted file mode 100644
index c7ec3cfa8349..000000000000
--- a/bindings/cxx/examples/Makefile.am
+++ /dev/null
@@ -1,26 +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
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
-
-noinst_PROGRAMS = \
-		gpiodetectcxx \
-		gpiofindcxx \
-		gpiogetcxx \
-		gpioinfocxx \
-		gpiomoncxx \
-		gpiosetcxx
-
-gpiodetectcxx_SOURCES = gpiodetectcxx.cpp
-
-gpiofindcxx_SOURCES = gpiofindcxx.cpp
-
-gpiogetcxx_SOURCES = gpiogetcxx.cpp
-
-gpioinfocxx_SOURCES = gpioinfocxx.cpp
-
-gpiomoncxx_SOURCES = gpiomoncxx.cpp
-
-gpiosetcxx_SOURCES = gpiosetcxx.cpp
diff --git a/bindings/cxx/gpiodcxx/Makefile.am b/bindings/cxx/gpiodcxx/Makefile.am
deleted file mode 100644
index e3a3b9b38e61..000000000000
--- a/bindings/cxx/gpiodcxx/Makefile.am
+++ /dev/null
@@ -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
diff --git a/bindings/cxx/tests/Makefile.am b/bindings/cxx/tests/Makefile.am
deleted file mode 100644
index 4971dd469290..000000000000
--- a/bindings/cxx/tests/Makefile.am
+++ /dev/null
@@ -1,32 +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_CXXFLAGS += $(PROFILING_CFLAGS)
-AM_LDFLAGS = -lgpiodcxx -L$(top_builddir)/bindings/cxx/
-AM_LDFLAGS += -lgpiosim -L$(top_builddir)/tests/gpiosim/
-AM_LDFLAGS += $(PROFILING_LDFLAGS)
-AM_LDFLAGS += -pthread
-
-bin_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
\ No newline at end of file
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
deleted file mode 100644
index 3212a8fcec3c..000000000000
--- a/bindings/python/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-EXTRA_DIST = setup.py
-
-if WITH_TESTS
-
-BUILD_TESTS = 1
-
-endif
-
-all-local:
-	GPIOD_VERSION_STRING=$(VERSION_STR) \
-	GPIOD_WITH_TESTS=$(BUILD_TESTS) \
-	$(PYTHON) setup.py build_ext --inplace \
-		--include-dirs=$(top_srcdir)/include/:$(top_srcdir)/tests/gpiosim/ \
-		--library-dirs=$(top_builddir)/lib/.libs/:$(top_srcdir)/tests/gpiosim/.libs/
-
-install-exec-local:
-	GPIOD_WITH_TESTS= \
-	$(PYTHON) setup.py install --prefix=$(prefix)
-
-SUBDIRS = gpiod
-
-if WITH_TESTS
-
-SUBDIRS += tests
-
-endif
-
-if WITH_EXAMPLES
-
-SUBDIRS += examples
-
-endif
diff --git a/bindings/python/examples/Makefile.am b/bindings/python/examples/Makefile.am
deleted file mode 100644
index f42b80e900a8..000000000000
--- a/bindings/python/examples/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-EXTRA_DIST = \
-	gpiodetect.py \
-	gpiofind.py \
-	gpioget.py \
-	gpioinfo.py \
-	gpiomon.py \
-	gpioset.py
diff --git a/bindings/python/gpiod/Makefile.am b/bindings/python/gpiod/Makefile.am
deleted file mode 100644
index 278f823972d8..000000000000
--- a/bindings/python/gpiod/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-SUBDIRS = ext
-
-EXTRA_DIST = \
-	chip_info.py \
-	chip.py \
-	edge_event.py \
-	exception.py \
-	info_event.py \
-	__init__.py \
-	internal.py \
-	line_info.py \
-	line.py \
-	line_request.py \
-	line_settings.py
diff --git a/bindings/python/gpiod/ext/Makefile.am b/bindings/python/gpiod/ext/Makefile.am
deleted file mode 100644
index 9c81b1790bc4..000000000000
--- a/bindings/python/gpiod/ext/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-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
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
deleted file mode 100644
index ec8f99d4013d..000000000000
--- a/bindings/python/setup.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-from os import environ
-from setuptools import setup, Extension, find_packages
-
-gpiod_ext = Extension(
-    "gpiod._ext",
-    sources=[
-        "gpiod/ext/chip.c",
-        "gpiod/ext/common.c",
-        "gpiod/ext/line-config.c",
-        "gpiod/ext/line-settings.c",
-        "gpiod/ext/module.c",
-        "gpiod/ext/request.c",
-    ],
-    define_macros=[("_GNU_SOURCE", "1")],
-    libraries=["gpiod"],
-    extra_compile_args=["-Wall", "-Wextra"],
-)
-
-gpiosim_ext = Extension(
-    "tests.gpiosim._ext",
-    sources=["tests/gpiosim/ext.c"],
-    define_macros=[("_GNU_SOURCE", "1")],
-    libraries=["gpiosim"],
-    extra_compile_args=["-Wall", "-Wextra"],
-)
-
-extensions = [gpiod_ext]
-with_tests = bool(environ["GPIOD_WITH_TESTS"])
-if with_tests:
-    extensions.append(gpiosim_ext)
-
-# FIXME Find a better way to get the version
-version = None
-try:
-    version = environ["GPIOD_VERSION_STR"]
-except KeyError:
-    pass
-
-setup(
-    name="gpiod",
-    packages=find_packages(include=["gpiod"]),
-    ext_modules=extensions,
-    version=version,
-)
diff --git a/bindings/python/tests/Makefile.am b/bindings/python/tests/Makefile.am
deleted file mode 100644
index 7dcdebb28d09..000000000000
--- a/bindings/python/tests/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-SUBDIRS = gpiosim
-
-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_info.py \
-	tests_line_request.py \
-	tests_line_settings.py \
-	tests_module.py
diff --git a/bindings/python/tests/gpiosim/Makefile.am b/bindings/python/tests/gpiosim/Makefile.am
deleted file mode 100644
index 7004f3af7568..000000000000
--- a/bindings/python/tests/gpiosim/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-EXTRA_DIST = \
-	chip.py \
-	ext.c \
-	__init__.py
diff --git a/bindings/rust/Makefile.am b/bindings/rust/Makefile.am
deleted file mode 100644
index a0d0772b01cb..000000000000
--- a/bindings/rust/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2022 Linaro Ltd.
-# SPDX-FileCopyrightTest: 2022 Viresh Kumar <viresh.kumar@linaro.org>
-
-command = cargo build --release --lib
-
-if WITH_TESTS
-command += --tests
-endif
-
-if WITH_EXAMPLES
-command += --examples
-endif
-
-all:
-	$(command)
-
-clean:
-	cargo clean
diff --git a/bindings/rust/meson.build b/bindings/rust/meson.build
index 68f27f473282..07831b31c3cd 100644
--- a/bindings/rust/meson.build
+++ b/bindings/rust/meson.build
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# Copyright 2022 IBM Corp.
+
 cargo = find_program('cargo')
 cargo_manifest = files('Cargo.toml')
 cargo_build_dir = meson.project_build_root() / 'cargo-build'
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index ccbb88a511cb..000000000000
--- a/configure.ac
+++ /dev/null
@@ -1,272 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-AC_PREREQ([2.69])
-
-AC_INIT([libgpiod], [2.0])
-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.2])
-# Have a separate ABI version for C++ bindings:
-AC_SUBST(ABI_CXX_VERSION, [2.1.1])
-# ABI version for libgpiosim (we need this since it can be installed if we
-# enable install-tests).
-AC_SUBST(ABI_GPIOSIM_VERSION, [0.1.0])
-
-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_ARG_VAR([PYTHON_CPPFLAGS],
-	[Compiler flags to find Python headers [default: auto-detect]])
-AC_ARG_VAR([PYTHON_LIBS],
-	[Libraries to link into Python extensions [default: auto-detect]])
-
-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
-
-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])])
-
-AC_DEFUN([HEADER_NOT_FOUND_TESTS],
-	[ERR_NOT_FOUND([$1 header], [the test suite])])
-
-AC_DEFUN([HEADER_NOT_FOUND_CXX],
-	[ERR_NOT_FOUND([$1 header], [C++ bindings])])
-
-# This is always checked (library needs this)
-AC_HEADER_STDC
-AC_FUNC_MALLOC
-AC_CHECK_FUNC([ioctl], [], [FUNC_NOT_FOUND_LIB([ioctl])])
-AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_LIB([asprintf])])
-AC_CHECK_FUNC([scandir], [], [FUNC_NOT_FOUND_LIB([scandir])])
-AC_CHECK_FUNC([alphasort], [], [FUNC_NOT_FOUND_LIB([alphasort])])
-AC_CHECK_FUNC([ppoll], [], [FUNC_NOT_FOUND_LIB([ppoll])])
-AC_CHECK_FUNC([realpath], [], [FUNC_NOT_FOUND_LIB([realpath])])
-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([sys/poll.h], [], [HEADER_NOT_FOUND_LIB([sys/poll.h])])
-AC_CHECK_HEADERS([sys/sysmacros.h], [], [HEADER_NOT_FOUND_LIB([sys/sysmacros.h])])
-AC_CHECK_HEADERS([linux/version.h], [], [HEADER_NOT_FOUND_LIB([linux/version.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])
-
-AS_IF([test "x$with_tools" = xtrue],
-	[# These are only needed to build tools
-	AC_CHECK_FUNC([daemon], [], [FUNC_NOT_FOUND_TOOLS([daemon])])
-	AS_IF([test "x$with_gpioset_interactive" = xtrue],
-		[PKG_CHECK_MODULES([LIBEDIT], [libedit >= 3.1])])
-	])
-
-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])])
-
-if test "x$with_tests" = xtrue
-then
-	# For libgpiosim
-	AC_CHECK_FUNC([qsort], [], [FUNC_NOT_FOUND_TESTS([qsort])])
-	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.50])
-	PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.50])
-
-	if test "x$with_tools" = xtrue
-	then
-		AC_CHECK_PROG([has_bats], [bats], [true], [false])
-		if test "x$has_bats" = "xfalse"
-		then
-			AC_MSG_NOTICE([bats 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])
-
-if test "x$with_bindings_cxx" = xtrue
-then
-	LT_LANG([C++])
-	# This needs autoconf-archive
-	AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
-
-	if test "x$with_tests" = xtrue
-	then
-		PKG_CHECK_MODULES([CATCH2], [catch2],, [
-			AC_LANG_PUSH([C++])
-			AC_CHECK_HEADERS([catch2/catch.hpp], [], [HEADER_NOT_FOUND_CXX([catch2/catch.hpp])])
-			AC_LANG_POP([C++])
-		])
-	fi
-
-	if test "x$with_examples" = xtrue
-	then
-		# Examples use C++17 features
-		AX_CXX_COMPILE_STDCXX([17], [ext], [mandatory])
-	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.0], [],
-		[AC_MSG_ERROR([python3 not found - needed for python bindings])])
-	AC_CHECK_PROG([has_python_config], [python3-config], [true], [false])
-	if test "x$has_python_config" = xfalse
-	then
-		AC_MSG_ERROR([python3-config not found - needed for python bindings])
-	fi
-	AS_IF([test -z "$PYTHON_CPPFLAGS"],
-		[AC_SUBST(PYTHON_CPPFLAGS, [`$PYTHON-config --includes`])])
-	AS_IF([test -z "$PYTHON_LIBS"],
-		[AC_SUBST(PYTHON_LIBS, [`$PYTHON-config --libs`])])
-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_CHECK_PROG([has_doxygen], [doxygen], [true], [false])
-AM_CONDITIONAL([HAS_DOXYGEN], [test "x$has_doxygen" = xtrue])
-if test "x$has_doxygen" = xfalse
-then
-	AC_MSG_NOTICE([doxygen not found - documentation cannot be generated])
-fi
-AM_COND_IF([HAS_DOXYGEN], [AC_CONFIG_FILES([Doxyfile])])
-
-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 cannot be generated automatically])
-fi
-
-AC_CONFIG_FILES([Makefile
-		 include/Makefile
-		 lib/Makefile
-		 lib/libgpiod.pc
-		 tools/Makefile
-		 tests/Makefile
-		 tests/gpiosim/Makefile
-		 bindings/cxx/libgpiodcxx.pc
-		 bindings/Makefile
-		 bindings/cxx/Makefile
-		 bindings/cxx/gpiodcxx/Makefile
-		 bindings/cxx/examples/Makefile
-		 bindings/cxx/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/rust/Makefile
-		 man/Makefile])
-
-AC_OUTPUT
diff --git a/include/Makefile.am b/include/Makefile.am
deleted file mode 100644
index 7f986ec61169..000000000000
--- a/include/Makefile.am
+++ /dev/null
@@ -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
diff --git a/lib/Makefile.am b/lib/Makefile.am
deleted file mode 100644
index dd90abd130b1..000000000000
--- a/lib/Makefile.am
+++ /dev/null
@@ -1,27 +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
diff --git a/man/Makefile.am b/man/Makefile.am
deleted file mode 100644
index 201a52b5bfd8..000000000000
--- a/man/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
-
-if WITH_MANPAGES
-
-dist_man1_MANS = gpiodetect.man gpioinfo.man gpioget.man gpioset.man gpiomon.man gpionotify.man
-
-%.man: $(top_builddir)/tools/$(*F)
-	help2man $(top_builddir)/tools/$(*F) --include=$(srcdir)/template --output=$(builddir)/$@ --no-info
-
-clean-local:
-	rm -f $(dist_man1_MANS)
-
-endif
-
-EXTRA_DIST = template
diff --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644
index 392f03c641cf..000000000000
--- a/tests/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <brgl@bgdev.pl>
-
-SUBDIRS = gpiosim
-
-AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/tests/gpiosim/
-AM_CFLAGS += -include $(top_builddir)/config.h
-AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
-AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-test\"
-AM_CFLAGS += $(PROFILING_CFLAGS)
-AM_LDFLAGS = -pthread
-LDADD = $(top_builddir)/lib/libgpiod.la
-LDADD += $(top_builddir)/tests/gpiosim/libgpiosim.la
-LDADD += $(GLIB_LIBS) $(GOBJECT_LIBS)
-
-bin_PROGRAMS = gpiod-test
-
-gpiod_test_SOURCES =			\
-		gpiod-test.c		\
-		gpiod-test.h		\
-		gpiod-test-helpers.c	\
-		gpiod-test-helpers.h	\
-		gpiod-test-sim.c	\
-		gpiod-test-sim.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
\ No newline at end of file
diff --git a/tests/gpiosim/Makefile.am b/tests/gpiosim/Makefile.am
deleted file mode 100644
index 05dce7919477..000000000000
--- a/tests/gpiosim/Makefile.am
+++ /dev/null
@@ -1,16 +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_SOURCES = gpiosim-selftest.c
-gpiosim_selftest_LDADD = libgpiosim.la
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index defe1b025201..000000000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,39 +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
-LDADD += $(LIBEDIT_LIBS)
-
-endif
-
-bin_PROGRAMS = gpiodetect gpioinfo gpioget gpioset gpiomon gpionotify
-
-gpiodetect_SOURCES = gpiodetect.c
-
-gpioinfo_SOURCES = gpioinfo.c
-
-gpioget_SOURCES = gpioget.c
-
-gpioset_SOURCES = gpioset.c
-
-gpiomon_SOURCES = gpiomon.c
-
-gpionotify_SOURCES = gpionotify.c
-
-EXTRA_DIST = gpio-tools-test gpio-tools-test.bats
-
-if WITH_TESTS
-
-bin_SCRIPTS = gpio-tools-test gpio-tools-test.bats
-
-endif
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-05 13:22 [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Andrew Jeffery
  2022-12-05 13:22 ` [libgpiod][WIP PATCH 1/2] Introduce meson as a build system Andrew Jeffery
  2022-12-05 13:22 ` [libgpiod][WIP PATCH 2/2] Remove autotools in favour of meson Andrew Jeffery
@ 2022-12-05 18:55 ` Bartosz Golaszewski
  2022-12-05 23:42   ` Andrew Jeffery
                     ` (3 more replies)
  2 siblings, 4 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2022-12-05 18:55 UTC (permalink / raw)
  To: Andrew Jeffery, Viresh Kumar, Kent Gibson, Andy Shevchenko,
	Linus Walleij
  Cc: linux-gpio

On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>
> Hello,
>
> Based on a recent poke [1] and in-between meetings I've put together a
> WIP series that converts libgpiod's build from autotools to meson. As
> far as I'm aware the meson build supports all the significant options to
> enable or disable features exposed by the autotools build:
>
> * Tests
> * Tools
>   * Interactive gpioset
> * Bindings
>   * C++
>   * Python
>   * Rust
> * Documentation
>   * Manpages
>   * Doxygen
>
> [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
>
> Meson has pretty good support for handling python and so the patch does
> away with setup.py entirely.

Eek! No, please do keep setup.py. Autotools too is capable of building
python C extensions on its own and it's what we use in v1 but I want
the python code to be built the standard python way. I actually plan
to post libgpiod v2 on pypi and split out building python bindings
into a separate bitbake recipe in meta-openembedded using the
setuptools3 class.

So let's keep setup.py and just call it from meson.

> However, the rust case isn't quite so
> simple. In order to handle the dependencies of the rust bindings I've
> called out to cargo through a custom target. It's not great, but from
> what I could see it seems to be the path of least resistance given
> meson's support for rust.
>
> There's no support for installing the rust bindings through meson, but
> this is not worse than the support we appeared to have under autotools.
>

I think Viresh too wants to keep cargo as the building agent for the rust code.

> It's worth noting that you'll probably want to disable the rust bindings
> if you need to run the install phase for libgpiod under e.g. sudo but
> have used rustup to install cargo for your unpriviledged user.
>

Current autotools setup doesn't install rust bindings at all, can we
keep it this way?

> Also, if you've used rustup to install the rust toolchain you may also
> need to install clang in order to pick up C toolchain headers for
> consumption by bindgen.
>
> Anyway, feedback on the rust part is definitely appreciated. Maybe
> there's a better approach?
>

Cc'ed Viresh and Kent.

> Moving along, the following tests pass in their entirety in my test VM:
>
> * gpiod-test
> * gpiod-cxx-test
> * python -m gpiod.test
>
> I've also briefly compared the install trees for the autotools and meson
> builds under some configurations. The differences are accounted for by
> meson defaulting to multi-arch installation paths for shared objects and
> picking the generic rather than interpreter-version-specific python3
> dist-packages directory under $PREFIX. Let me know if those seem
> problematic.
>
> A complete meson setup invocation looks as follows:
>
> ```
> $ meson setup -Dbindings=cxx,python,rust -Ddocumentation=man,inline -Dexamples=true -Dtests=true -Dtools=true build
> ```
>
> Subsequently the build can be performed with:
>
> ```
> $ meson compile -C build
> ```
>
> Meson defaults to using ninja as its backend, and automatically exploits
> ccache[2] when available to keep repeated builds speedy.
>

It does show! Full rebuild with autotools:

real 0m43,902s
user 2m40,010s
sys 0m20,172s

Full rebuild with meson:

real 0m10,001s
user 1m1,334s
sys 0m12,205s

More than 4x faster now.

> [2] https://ccache.dev/
>
> We end up with a net reduction of 254 LOC for the build system, and,
> IMO, a single and fairly readable language to express it. Along with
> that comes easy integration as a dependency in other (meson) projects
> and a straight-forward path for their cross-compilation.
>
> Let me know what you think.

Meson has a steep learning curve but I really want to move over to it
now and will put in the time to learn it. Thanks for doing it. The
patches are functional from what I tested so far.

One thing I'd love to see changed is: put all API and ABI version
number next to each other in a single place so that there's less risk
of forgetting to update one of them when making a release. Is that
possible?

Bart

>
> Andrew
>
> Andrew Jeffery (2):
>   Introduce meson as a build system
>   Remove autotools in favour of meson
>
>  Doxyfile.in                               |   2 +-
>  Makefile.am                               |  43 ----
>  autogen.sh                                |  17 --
>  bindings/Makefile.am                      |  22 --
>  bindings/cxx/Makefile.am                  |  48 ----
>  bindings/cxx/examples/Makefile.am         |  26 ---
>  bindings/cxx/examples/meson.build         |   9 +
>  bindings/cxx/gpiodcxx/Makefile.am         |  20 --
>  bindings/cxx/gpiodcxx/meson.build         |  19 ++
>  bindings/cxx/meson.build                  |  49 ++++
>  bindings/cxx/tests/Makefile.am            |  32 ---
>  bindings/cxx/tests/meson.build            |  26 +++
>  bindings/meson.build                      |  14 ++
>  bindings/python/Makefile.am               |  35 ---
>  bindings/python/examples/Makefile.am      |  10 -
>  bindings/python/examples/meson.build      |  12 +
>  bindings/python/gpiod/Makefile.am         |  17 --
>  bindings/python/gpiod/ext/Makefile.am     |  11 -
>  bindings/python/gpiod/ext/meson.build     |  14 ++
>  bindings/python/gpiod/meson.build         |  17 ++
>  bindings/python/meson.build               |  16 ++
>  bindings/python/setup.py                  |  47 ----
>  bindings/python/tests/Makefile.am         |  17 --
>  bindings/python/tests/gpiosim/Makefile.am |   7 -
>  bindings/python/tests/gpiosim/meson.build |  12 +
>  bindings/python/tests/meson.build         |  17 ++
>  bindings/rust/Makefile.am                 |  19 --
>  bindings/rust/gpiosim-sys/build.rs        |   9 +-
>  bindings/rust/libgpiod-sys/build.rs       |   9 +-
>  bindings/rust/meson.build                 |  33 +++
>  configure.ac                              | 272 ----------------------
>  include/Makefile.am                       |   4 -
>  include/meson.build                       |   7 +
>  lib/Makefile.am                           |  27 ---
>  lib/meson.build                           |  30 +++
>  man/Makefile.am                           |  16 --
>  man/meson.build                           |  21 ++
>  meson.build                               |  91 ++++++++
>  meson_options.txt                         |   9 +
>  tests/Makefile.am                         |  34 ---
>  tests/gpiosim/Makefile.am                 |  16 --
>  tests/gpiosim/meson.build                 |  24 ++
>  tests/meson.build                         |  30 +++
>  tools/Makefile.am                         |  39 ----
>  tools/meson.build                         |  69 ++++++
>  45 files changed, 532 insertions(+), 786 deletions(-)
>  delete mode 100644 Makefile.am
>  delete mode 100755 autogen.sh
>  delete mode 100644 bindings/Makefile.am
>  delete mode 100644 bindings/cxx/Makefile.am
>  delete mode 100644 bindings/cxx/examples/Makefile.am
>  create mode 100644 bindings/cxx/examples/meson.build
>  delete mode 100644 bindings/cxx/gpiodcxx/Makefile.am
>  create mode 100644 bindings/cxx/gpiodcxx/meson.build
>  create mode 100644 bindings/cxx/meson.build
>  delete mode 100644 bindings/cxx/tests/Makefile.am
>  create mode 100644 bindings/cxx/tests/meson.build
>  create mode 100644 bindings/meson.build
>  delete mode 100644 bindings/python/Makefile.am
>  delete mode 100644 bindings/python/examples/Makefile.am
>  create mode 100644 bindings/python/examples/meson.build
>  delete mode 100644 bindings/python/gpiod/Makefile.am
>  delete mode 100644 bindings/python/gpiod/ext/Makefile.am
>  create mode 100644 bindings/python/gpiod/ext/meson.build
>  create mode 100644 bindings/python/gpiod/meson.build
>  create mode 100644 bindings/python/meson.build
>  delete mode 100644 bindings/python/setup.py
>  delete mode 100644 bindings/python/tests/Makefile.am
>  delete mode 100644 bindings/python/tests/gpiosim/Makefile.am
>  create mode 100644 bindings/python/tests/gpiosim/meson.build
>  create mode 100644 bindings/python/tests/meson.build
>  delete mode 100644 bindings/rust/Makefile.am
>  create mode 100644 bindings/rust/meson.build
>  delete mode 100644 configure.ac
>  delete mode 100644 include/Makefile.am
>  create mode 100644 include/meson.build
>  delete mode 100644 lib/Makefile.am
>  create mode 100644 lib/meson.build
>  delete mode 100644 man/Makefile.am
>  create mode 100644 man/meson.build
>  create mode 100644 meson.build
>  create mode 100644 meson_options.txt
>  delete mode 100644 tests/Makefile.am
>  delete mode 100644 tests/gpiosim/Makefile.am
>  create mode 100644 tests/gpiosim/meson.build
>  create mode 100644 tests/meson.build
>  delete mode 100644 tools/Makefile.am
>  create mode 100644 tools/meson.build
>
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-05 18:55 ` [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Bartosz Golaszewski
@ 2022-12-05 23:42   ` Andrew Jeffery
  2022-12-06  0:06   ` Viresh Kumar
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-05 23:42 UTC (permalink / raw)
  To: Bartosz Golaszewski, Viresh Kumar, Kent Gibson, Andy Shevchenko,
	Linus Walleij
  Cc: linux-gpio

On Tue, 6 Dec 2022, at 05:25, Bartosz Golaszewski wrote:
> On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>>
>> Hello,
>>
>> Based on a recent poke [1] and in-between meetings I've put together a
>> WIP series that converts libgpiod's build from autotools to meson. As
>> far as I'm aware the meson build supports all the significant options to
>> enable or disable features exposed by the autotools build:
>>
>> * Tests
>> * Tools
>>   * Interactive gpioset
>> * Bindings
>>   * C++
>>   * Python
>>   * Rust
>> * Documentation
>>   * Manpages
>>   * Doxygen
>>
>> [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
>>
>> Meson has pretty good support for handling python and so the patch does
>> away with setup.py entirely.
>
> Eek! No, please do keep setup.py. Autotools too is capable of building
> python C extensions on its own and it's what we use in v1 but I want
> the python code to be built the standard python way. I actually plan
> to post libgpiod v2 on pypi and split out building python bindings
> into a separate bitbake recipe in meta-openembedded using the
> setuptools3 class.
>
> So let's keep setup.py and just call it from meson.

Okay. As I was working my way thought I did wonder whether it might be 
better to split out the bindings where they have their own build 
systems (python, rust) so the relationships go one direction. Currently 
we have the library build system referring to the bindings referring to 
the library which seems like a kinda awful sandwich. This is evident in 
the build.rs files for the rust libraries.

>
>> However, the rust case isn't quite so
>> simple. In order to handle the dependencies of the rust bindings I've
>> called out to cargo through a custom target. It's not great, but from
>> what I could see it seems to be the path of least resistance given
>> meson's support for rust.
>>
>> There's no support for installing the rust bindings through meson, but
>> this is not worse than the support we appeared to have under autotools.
>>
>
> I think Viresh too wants to keep cargo as the building agent for the rust code.

Right; I think this is the only sensible approach given current rust 
support in meson.

>
>> It's worth noting that you'll probably want to disable the rust bindings
>> if you need to run the install phase for libgpiod under e.g. sudo but
>> have used rustup to install cargo for your unpriviledged user.
>>
>
> Current autotools setup doesn't install rust bindings at all, can we
> keep it this way?

It is that way in what I've posted, but `meson install` re-runs part of the
build phase which is what causes complications in this specific scenario. If
you can run cargo as root then it shouldn't interfere (... setting aside
potential issues running cargo as root). I didn't figure out whether I could
*avoid* re-building the custom target in the install phase.

>>
>> We end up with a net reduction of 254 LOC for the build system, and,
>> IMO, a single and fairly readable language to express it. Along with
>> that comes easy integration as a dependency in other (meson) projects
>> and a straight-forward path for their cross-compilation.
>>
>> Let me know what you think.
>
> Meson has a steep learning curve but I really want to move over to it
> now and will put in the time to learn it. Thanks for doing it. The
> patches are functional from what I tested so far.

Great!

>
> One thing I'd love to see changed is: put all API and ABI version
> number next to each other in a single place so that there's less risk
> of forgetting to update one of them when making a release. Is that
> possible?

Absolutely. In the spirit of keeping things that are together together 
I distributed them into the meson.build file containing the 
specification of the associated library target. But we can just move 
those variables into the root meson.build file without any problems.

Andrew

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-05 18:55 ` [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Bartosz Golaszewski
  2022-12-05 23:42   ` Andrew Jeffery
@ 2022-12-06  0:06   ` Viresh Kumar
  2022-12-06  0:26     ` Andrew Jeffery
  2022-12-06 14:54   ` Andy Shevchenko
  2022-12-08  4:23   ` Andrew Jeffery
  3 siblings, 1 reply; 18+ messages in thread
From: Viresh Kumar @ 2022-12-06  0:06 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andrew Jeffery, Kent Gibson, Andy Shevchenko, Linus Walleij,
	linux-gpio, Miguel Ojeda, Björn Roy Baron

+ Miguel/Bjorn.

On 05-12-22, 19:55, Bartosz Golaszewski wrote:
> On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
> >
> > Hello,
> >
> > Based on a recent poke [1] and in-between meetings I've put together a
> > WIP series that converts libgpiod's build from autotools to meson. As
> > far as I'm aware the meson build supports all the significant options to
> > enable or disable features exposed by the autotools build:
> >
> > * Tests
> > * Tools
> >   * Interactive gpioset
> > * Bindings
> >   * C++
> >   * Python
> >   * Rust
> > * Documentation
> >   * Manpages
> >   * Doxygen
> >
> > [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
> >
> > Meson has pretty good support for handling python and so the patch does
> > away with setup.py entirely.
> 
> Eek! No, please do keep setup.py. Autotools too is capable of building
> python C extensions on its own and it's what we use in v1 but I want
> the python code to be built the standard python way. I actually plan
> to post libgpiod v2 on pypi and split out building python bindings
> into a separate bitbake recipe in meta-openembedded using the
> setuptools3 class.
> 
> So let's keep setup.py and just call it from meson.
> 
> > However, the rust case isn't quite so
> > simple. In order to handle the dependencies of the rust bindings I've
> > called out to cargo through a custom target. It's not great, but from
> > what I could see it seems to be the path of least resistance given
> > meson's support for rust.
> >
> > There's no support for installing the rust bindings through meson, but
> > this is not worse than the support we appeared to have under autotools.
> >
> 
> I think Viresh too wants to keep cargo as the building agent for the rust code.

I am not the best guy to ask around Rust tooling in general and
probably Kent / Miguel can help here.

Sorry for the stupid question, but what does "installing the rust
bindings" mean here ? FWIW, for me the only thing that matters is that
we are able to build the rust bindings, along with Make, and run tests
somehow to make sure nothing broke. Since this is a library crate, the
user crate will mark its dependency and do the build itself too.

> > It's worth noting that you'll probably want to disable the rust bindings
> > if you need to run the install phase for libgpiod under e.g. sudo but
> > have used rustup to install cargo for your unpriviledged user.
> >
> 
> Current autotools setup doesn't install rust bindings at all, can we
> keep it this way?
> 
> > Also, if you've used rustup to install the rust toolchain you may also
> > need to install clang in order to pick up C toolchain headers for
> > consumption by bindgen.

Yeah, from what I remember, we do need clang support for bindgen.

> > Anyway, feedback on the rust part is definitely appreciated. Maybe
> > there's a better approach?

-- 
viresh

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-06  0:06   ` Viresh Kumar
@ 2022-12-06  0:26     ` Andrew Jeffery
  2022-12-06  3:40       ` Viresh Kumar
  0 siblings, 1 reply; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-06  0:26 UTC (permalink / raw)
  To: Viresh Kumar, Bartosz Golaszewski
  Cc: Kent Gibson, Andy Shevchenko, Linus Walleij, linux-gpio,
	Miguel Ojeda, Björn Roy Baron



On Tue, 6 Dec 2022, at 10:36, Viresh Kumar wrote:
> + Miguel/Bjorn.
>
> On 05-12-22, 19:55, Bartosz Golaszewski wrote:
>> On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>> > However, the rust case isn't quite so
>> > simple. In order to handle the dependencies of the rust bindings I've
>> > called out to cargo through a custom target. It's not great, but from
>> > what I could see it seems to be the path of least resistance given
>> > meson's support for rust.
>> >
>> > There's no support for installing the rust bindings through meson, but
>> > this is not worse than the support we appeared to have under autotools.
>> >
>> 
>> I think Viresh too wants to keep cargo as the building agent for the rust code.
>
> I am not the best guy to ask around Rust tooling in general and
> probably Kent / Miguel can help here.
>
> Sorry for the stupid question, but what does "installing the rust
> bindings" mean here ?

There's probably no useful meaning given what you've said below :)

> FWIW, for me the only thing that matters is that
> we are able to build the rust bindings, along with Make, and run tests
> somehow to make sure nothing broke. Since this is a library crate, the
> user crate will mark its dependency and do the build itself too.

My experience with rust is (unfortunately) superficial; the meson
conversion achieves the same outcome as the autotools integration (runs
`cargo build ...`). If that's enough then I don't think there are any
further issues.

Andrew

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-06  0:26     ` Andrew Jeffery
@ 2022-12-06  3:40       ` Viresh Kumar
  2022-12-06  3:54         ` Kent Gibson
  0 siblings, 1 reply; 18+ messages in thread
From: Viresh Kumar @ 2022-12-06  3:40 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: Bartosz Golaszewski, Kent Gibson, Andy Shevchenko, Linus Walleij,
	linux-gpio, Miguel Ojeda, Björn Roy Baron

On 06-12-22, 10:56, Andrew Jeffery wrote:
> My experience with rust is (unfortunately) superficial; the meson
> conversion achieves the same outcome as the autotools integration (runs
> `cargo build ...`). If that's enough then I don't think there are any
> further issues.

That's all I care about at the moment. Lets see if Kent have something
to add to this, else it looks okay.

-- 
viresh

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-06  3:40       ` Viresh Kumar
@ 2022-12-06  3:54         ` Kent Gibson
  2022-12-06 12:15           ` Miguel Ojeda
  0 siblings, 1 reply; 18+ messages in thread
From: Kent Gibson @ 2022-12-06  3:54 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Andrew Jeffery, Bartosz Golaszewski, Andy Shevchenko,
	Linus Walleij, linux-gpio, Miguel Ojeda, Björn Roy Baron

On Tue, Dec 06, 2022 at 09:10:34AM +0530, Viresh Kumar wrote:
> On 06-12-22, 10:56, Andrew Jeffery wrote:
> > My experience with rust is (unfortunately) superficial; the meson
> > conversion achieves the same outcome as the autotools integration (runs
> > `cargo build ...`). If that's enough then I don't think there are any
> > further issues.
> 
> That's all I care about at the moment. Lets see if Kent have something
> to add to this, else it looks okay.
> 

I've got nothing to add - calling cargo makes sense to me.

Cheers,
Kent.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-06  3:54         ` Kent Gibson
@ 2022-12-06 12:15           ` Miguel Ojeda
  0 siblings, 0 replies; 18+ messages in thread
From: Miguel Ojeda @ 2022-12-06 12:15 UTC (permalink / raw)
  To: Kent Gibson
  Cc: Viresh Kumar, Andrew Jeffery, Bartosz Golaszewski,
	Andy Shevchenko, Linus Walleij, linux-gpio, Björn Roy Baron

On Tue, Dec 6, 2022 at 4:55 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> I've got nothing to add - calling cargo makes sense to me.

We do that too in Kbuild in some cases (though not for building). I
think it is fine to delegate where it makes sense.

One concern may be handling `-j` properly between different build
systems. Not sure what Meson provides there. Cargo supports the GNU
Make jobserver as a client.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-05 18:55 ` [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Bartosz Golaszewski
  2022-12-05 23:42   ` Andrew Jeffery
  2022-12-06  0:06   ` Viresh Kumar
@ 2022-12-06 14:54   ` Andy Shevchenko
  2022-12-06 22:04     ` Andrew Jeffery
  2022-12-08  4:23   ` Andrew Jeffery
  3 siblings, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2022-12-06 14:54 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andrew Jeffery, Viresh Kumar, Kent Gibson, Linus Walleij, linux-gpio

On Mon, Dec 05, 2022 at 07:55:29PM +0100, Bartosz Golaszewski wrote:
> On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:

...

> > Meson defaults to using ninja as its backend, and automatically exploits
> > ccache[2] when available to keep repeated builds speedy.

...which is a bad idea for a clean build.

> It does show! Full rebuild with autotools:
> 
> real 0m43,902s
> user 2m40,010s
> sys 0m20,172s
> 
> Full rebuild with meson:
> 
> real 0m10,001s
> user 1m1,334s
> sys 0m12,205s
> 
> More than 4x faster now.

And risk to have a badly formed binaries (yes, very little risk, but > 0).

> > [2] https://ccache.dev/

ccache has downside of its own use. If we have a common storage for ccache --
the collision is just matter of time (yes, have seen that in real life).

OTOH requiring per-project ccache storage makes a little sense for the end user
as they quite likely won't rebuild it many times.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-06 14:54   ` Andy Shevchenko
@ 2022-12-06 22:04     ` Andrew Jeffery
  2022-12-06 22:21       ` Andy Shevchenko
  0 siblings, 1 reply; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-06 22:04 UTC (permalink / raw)
  To: Andy Shevchenko, Bartosz Golaszewski
  Cc: Viresh Kumar, Kent Gibson, Linus Walleij, linux-gpio

Hi Andy,

On Wed, 7 Dec 2022, at 01:24, Andy Shevchenko wrote:
> On Mon, Dec 05, 2022 at 07:55:29PM +0100, Bartosz Golaszewski wrote:
>> On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>
> ...
>
>> > Meson defaults to using ninja as its backend, and automatically exploits
>> > ccache[2] when available to keep repeated builds speedy.
>
> ...which is a bad idea for a clean build.
>
>> It does show! Full rebuild with autotools:
>> 
>> real 0m43,902s
>> user 2m40,010s
>> sys 0m20,172s
>> 
>> Full rebuild with meson:
>> 
>> real 0m10,001s
>> user 1m1,334s
>> sys 0m12,205s
>> 
>> More than 4x faster now.
>
> And risk to have a badly formed binaries (yes, very little risk, but > 0).
>
>> > [2] https://ccache.dev/
>
> ccache has downside of its own use. If we have a common storage for ccache --
> the collision is just matter of time (yes, have seen that in real life).
>
> OTOH requiring per-project ccache storage makes a little sense for the end user
> as they quite likely won't rebuild it many times.

Valid points. However I think they're addressed by:

1. Not installing ccache on the system, or
2. Overriding the auto-detection behaviour of `meson setup ...` 

Regarding 2, you can specify the CC and CXX environment variables to force its hand:

```
$ command -v ccache
/usr/bin/ccache
$ CC=cc CXX=c++ meson setup -Dbindings=cxx build
The Meson build system
Version: 0.63.0
...
C compiler for the host machine: cc (gcc 12.2.0 "cc (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
...
C++ compiler for the host machine: c++ (gcc 12.2.0 "c++ (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
...
```

Compared to the default behaviour:

```
$ meson setup -Dbindings=cxx build
The Meson build system
Version: 0.63.0
...
C compiler for the host machine: ccache cc (gcc 12.2.0 "cc (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
...
C++ compiler for the host machine: ccache c++ (gcc 12.2.0 "c++ (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
...
```

This use of the CC and CXX variables is covered in the documentation:

https://mesonbuild.com/Feature-autodetection.html#ccache

Andrew

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-06 22:04     ` Andrew Jeffery
@ 2022-12-06 22:21       ` Andy Shevchenko
  0 siblings, 0 replies; 18+ messages in thread
From: Andy Shevchenko @ 2022-12-06 22:21 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: Bartosz Golaszewski, Viresh Kumar, Kent Gibson, Linus Walleij,
	linux-gpio

On Wed, Dec 07, 2022 at 08:34:20AM +1030, Andrew Jeffery wrote:
> On Wed, 7 Dec 2022, at 01:24, Andy Shevchenko wrote:
> > On Mon, Dec 05, 2022 at 07:55:29PM +0100, Bartosz Golaszewski wrote:
> >> On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:

...

> >> > Meson defaults to using ninja as its backend, and automatically exploits
> >> > ccache[2] when available to keep repeated builds speedy.
> >
> > ...which is a bad idea for a clean build.
> >
> >> It does show! Full rebuild with autotools:
> >> 
> >> real 0m43,902s
> >> user 2m40,010s
> >> sys 0m20,172s
> >> 
> >> Full rebuild with meson:
> >> 
> >> real 0m10,001s
> >> user 1m1,334s
> >> sys 0m12,205s
> >> 
> >> More than 4x faster now.
> >
> > And risk to have a badly formed binaries (yes, very little risk, but > 0).
> >
> >> > [2] https://ccache.dev/
> >
> > ccache has downside of its own use. If we have a common storage for ccache --
> > the collision is just matter of time (yes, have seen that in real life).
> >
> > OTOH requiring per-project ccache storage makes a little sense for the end user
> > as they quite likely won't rebuild it many times.
> 
> Valid points. However I think they're addressed by:
> 
> 1. Not installing ccache on the system, or
> 2. Overriding the auto-detection behaviour of `meson setup ...` 
> 
> Regarding 2, you can specify the CC and CXX environment variables to force its hand:
> 
> ```
> $ command -v ccache
> /usr/bin/ccache
> $ CC=cc CXX=c++ meson setup -Dbindings=cxx build
> The Meson build system
> Version: 0.63.0
> ...
> C compiler for the host machine: cc (gcc 12.2.0 "cc (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
> ...
> C++ compiler for the host machine: c++ (gcc 12.2.0 "c++ (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
> ...
> ```
> 
> Compared to the default behaviour:
> 
> ```
> $ meson setup -Dbindings=cxx build
> The Meson build system
> Version: 0.63.0
> ...
> C compiler for the host machine: ccache cc (gcc 12.2.0 "cc (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
> ...
> C++ compiler for the host machine: ccache c++ (gcc 12.2.0 "c++ (Ubuntu 12.2.0-3ubuntu1) 12.2.0")
> ...
> ```
> 
> This use of the CC and CXX variables is covered in the documentation:
> 
> https://mesonbuild.com/Feature-autodetection.html#ccache

Right, my point that ccache should be opt-in and not opt-out.
For example, Buidroot project has ccache support (as opt-in).

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-05 18:55 ` [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Bartosz Golaszewski
                     ` (2 preceding siblings ...)
  2022-12-06 14:54   ` Andy Shevchenko
@ 2022-12-08  4:23   ` Andrew Jeffery
  2022-12-08  9:27     ` Bartosz Golaszewski
  3 siblings, 1 reply; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-08  4:23 UTC (permalink / raw)
  To: Bartosz Golaszewski, Viresh Kumar, Kent Gibson, Andy Shevchenko,
	Linus Walleij
  Cc: linux-gpio



On Tue, 6 Dec 2022, at 05:25, Bartosz Golaszewski wrote:
> On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>>
>> Hello,
>>
>> Based on a recent poke [1] and in-between meetings I've put together a
>> WIP series that converts libgpiod's build from autotools to meson. As
>> far as I'm aware the meson build supports all the significant options to
>> enable or disable features exposed by the autotools build:
>>
>> * Tests
>> * Tools
>>   * Interactive gpioset
>> * Bindings
>>   * C++
>>   * Python
>>   * Rust
>> * Documentation
>>   * Manpages
>>   * Doxygen
>>
>> [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
>>
>> Meson has pretty good support for handling python and so the patch does
>> away with setup.py entirely.
>
> Eek! No, please do keep setup.py. Autotools too is capable of building
> python C extensions on its own and it's what we use in v1 but I want
> the python code to be built the standard python way. I actually plan
> to post libgpiod v2 on pypi and split out building python bindings
> into a separate bitbake recipe in meta-openembedded using the
> setuptools3 class.
>
> So let's keep setup.py and just call it from meson.

I've poked at this for a little while and it's not a great experience.
Meson's design pushes back against calling out in this way, and I don't
really have the motivation to carry on fighting it to make it do what
you request. Unless someone else has that motivation, I think there are
two options if meson is still desired:

1. Use the meson python support as posted in this series
2. Split out the python (and probably rust) bindings, keeping the
   dependency relationships pointing in one direction and using the
   language's own package management tooling.

Given there's nothing to do in the install phase for rust we don't have
as big of an issue there, but it is problematic for python.

Let me know which way you want to go, including if you want to abandon
meson :)

Andrew

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-08  4:23   ` Andrew Jeffery
@ 2022-12-08  9:27     ` Bartosz Golaszewski
  2022-12-08 11:09       ` Andrew Jeffery
  0 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2022-12-08  9:27 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: Viresh Kumar, Kent Gibson, Andy Shevchenko, Linus Walleij, linux-gpio

On Thu, Dec 8, 2022 at 5:23 AM Andrew Jeffery <andrew@aj.id.au> wrote:
>
>
>
> On Tue, 6 Dec 2022, at 05:25, Bartosz Golaszewski wrote:
> > On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
> >>
> >> Hello,
> >>
> >> Based on a recent poke [1] and in-between meetings I've put together a
> >> WIP series that converts libgpiod's build from autotools to meson. As
> >> far as I'm aware the meson build supports all the significant options to
> >> enable or disable features exposed by the autotools build:
> >>
> >> * Tests
> >> * Tools
> >>   * Interactive gpioset
> >> * Bindings
> >>   * C++
> >>   * Python
> >>   * Rust
> >> * Documentation
> >>   * Manpages
> >>   * Doxygen
> >>
> >> [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
> >>
> >> Meson has pretty good support for handling python and so the patch does
> >> away with setup.py entirely.
> >
> > Eek! No, please do keep setup.py. Autotools too is capable of building
> > python C extensions on its own and it's what we use in v1 but I want
> > the python code to be built the standard python way. I actually plan
> > to post libgpiod v2 on pypi and split out building python bindings
> > into a separate bitbake recipe in meta-openembedded using the
> > setuptools3 class.
> >
> > So let's keep setup.py and just call it from meson.
>
> I've poked at this for a little while and it's not a great experience.
> Meson's design pushes back against calling out in this way, and I don't
> really have the motivation to carry on fighting it to make it do what
> you request. Unless someone else has that motivation, I think there are
> two options if meson is still desired:
>
> 1. Use the meson python support as posted in this series
> 2. Split out the python (and probably rust) bindings, keeping the
>    dependency relationships pointing in one direction and using the
>    language's own package management tooling.
>
> Given there's nothing to do in the install phase for rust we don't have
> as big of an issue there, but it is problematic for python.
>
> Let me know which way you want to go, including if you want to abandon
> meson :)
>

No, I don't want to abandon it. What is the problem exactly? Is meson
unable to simply add external commands to its ninja output?

Bart

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-08  9:27     ` Bartosz Golaszewski
@ 2022-12-08 11:09       ` Andrew Jeffery
  2022-12-08 18:48         ` Bartosz Golaszewski
  0 siblings, 1 reply; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-08 11:09 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Viresh Kumar, Kent Gibson, Andy Shevchenko, Linus Walleij, linux-gpio



On Thu, 8 Dec 2022, at 19:57, Bartosz Golaszewski wrote:
> On Thu, Dec 8, 2022 at 5:23 AM Andrew Jeffery <andrew@aj.id.au> wrote:
>>
>>
>>
>> On Tue, 6 Dec 2022, at 05:25, Bartosz Golaszewski wrote:
>> > On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>> >>
>> >> Hello,
>> >>
>> >> Based on a recent poke [1] and in-between meetings I've put together a
>> >> WIP series that converts libgpiod's build from autotools to meson. As
>> >> far as I'm aware the meson build supports all the significant options to
>> >> enable or disable features exposed by the autotools build:
>> >>
>> >> * Tests
>> >> * Tools
>> >>   * Interactive gpioset
>> >> * Bindings
>> >>   * C++
>> >>   * Python
>> >>   * Rust
>> >> * Documentation
>> >>   * Manpages
>> >>   * Doxygen
>> >>
>> >> [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
>> >>
>> >> Meson has pretty good support for handling python and so the patch does
>> >> away with setup.py entirely.
>> >
>> > Eek! No, please do keep setup.py. Autotools too is capable of building
>> > python C extensions on its own and it's what we use in v1 but I want
>> > the python code to be built the standard python way. I actually plan
>> > to post libgpiod v2 on pypi and split out building python bindings
>> > into a separate bitbake recipe in meta-openembedded using the
>> > setuptools3 class.
>> >
>> > So let's keep setup.py and just call it from meson.
>>
>> I've poked at this for a little while and it's not a great experience.
>> Meson's design pushes back against calling out in this way, and I don't
>> really have the motivation to carry on fighting it to make it do what
>> you request. Unless someone else has that motivation, I think there are
>> two options if meson is still desired:
>>
>> 1. Use the meson python support as posted in this series
>> 2. Split out the python (and probably rust) bindings, keeping the
>>    dependency relationships pointing in one direction and using the
>>    language's own package management tooling.
>>
>> Given there's nothing to do in the install phase for rust we don't have
>> as big of an issue there, but it is problematic for python.
>>
>> Let me know which way you want to go, including if you want to abandon
>> meson :)
>>
>
> No, I don't want to abandon it. What is the problem exactly? Is meson
> unable to simply add external commands to its ninja output?

Not as far as I'm aware. I think it's best covered by this policy 
description:

https://mesonbuild.com/Mixing-build-systems.html

There are some things that might make it sound feasible but aren't 
actually appropriate:

1. run_command(): https://mesonbuild.com/Reference-manual_functions.html#run_command
2. run_target(): https://mesonbuild.com/Reference-manual_functions.html#run_target
3. custom_target(): https://mesonbuild.com/Reference-manual_functions.html#custom_target

run_command() isn't appropriate as it executes in the `meson setup`
phase. run_target() isn't appropriate as it disregards any output
artifacts and so has no impact in the `meson install` phase.

custom_target() is probably closest to what is required, but there's a
lot of pain in trying to get the artifacts to line up for correct
deployment in the `meson install` phase. This is exacerbated by the
requirement that setup.py be run from its containing directory in the
source tree. Further, I couldn't get all the options to line up such
that setuptools would relocate its output into meson's own build tree
(and out of the source tree). Here's a not entirely working attempt at
abusing custom_target() to that end:

```
diff --git a/bindings/python/meson.build b/bindings/python/meson.build
index 26f7ff13e0dd..136d10824345 100644
--- a/bindings/python/meson.build
+++ b/bindings/python/meson.build
@@ -3,14 +3,31 @@
 
 python = import('python')
 python3 = python.find_installation('python3')
-python3_dep = python3.dependency()
 
-subdir('gpiod')
+python_build_dir = 'python-build'
+python_install_dir = 'python-install'
+python_include_dirs = '../../include:../../tests/gpiosim'
+python_lib_dirs = '@0@/lib:@0@/tests/gpiosim'.format(meson.project_build_root())
+python_install_cmd = [ python3.full_path(), '@INPUT@', '--no-user-cfg',
+                      'build_ext', '--include-dirs', python_include_dirs, '--library-dirs', python_lib_dirs,
+                      'install', '--root', python_build_dir, '--prefix', get_option('prefix')]
 
-if get_option('examples')
-    subdir('examples')
-endif
+python_env = environment()
+python_env.set('GPIOD_WITH_TESTS', get_option('tests').to_string())
 
-if get_option('tests')
-    subdir('tests')
-endif
+python_setuptools = custom_target('python-setuptools',
+                                 input: 'setup.py',
+                                 output: python_build_dir,
+                                 depends: [gpiod, gpiosim],
+                                 env: python_env,
+                                 command: python_install_cmd)
+
+cp = find_program('cp')
+
+custom_target('python-install',
+             input: 'setup.py',
+             output: python_install_dir,
+             depends: python_setuptools,
+             command: [ cp, '-r', meson.current_source_dir() / python_build_dir, meson.current_build_dir() / python_install_dir ],
+             install: true,
+             install_dir: get_option('prefix'))
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index ec8f99d4013d..9eddae7466a1 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -1,9 +1,14 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
 
-from os import environ
+import os
+import sys
+
+from os import environ, path
 from setuptools import setup, Extension, find_packages
 
+os.chdir(path.dirname(sys.argv[0]) or '.')
+
 gpiod_ext = Extension(
     "gpiod._ext",
     sources=[
```

This commits a bunch of crimes:

1. Assumes the structure of the meson build directory via the paths in
   python_lib_dirs
2. Adds a chdir() in setup.py to relocate the process out of the meson
   build directory back into the source tree
3. Assumes the chdir() operation in the setup of python_include_dirs
   rather than relying on meson's built-in dependency tracking as the
   inc objects are opaque[1]
4. Hacks the setuptools output back into the meson build directory using
   a crufty target invoking `cp` so meson can locate the artifacts in the
   `meson install` phase 
5. Still doesn't correctly install the artifacts in the end due to
   restrictions on path mangling (can't strip off the parent directory)
   and the fact that we're trying to install an entire tree rather than
   specific files.

[1] https://mesonbuild.com/Reference-manual_returned_inc.html

It might feel like install_data() or install_subdir() could be used
here, but from experiment their behaviour also seems unfit to be used
in this context.

At least, that's what I've experimented with. Maybe others can see the 
way through here, but it really is fighting against the policy linked 
earlier.

Andrew

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-08 11:09       ` Andrew Jeffery
@ 2022-12-08 18:48         ` Bartosz Golaszewski
  2022-12-08 21:51           ` Andrew Jeffery
  0 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2022-12-08 18:48 UTC (permalink / raw)
  To: Andrew Jeffery
  Cc: Viresh Kumar, Kent Gibson, Andy Shevchenko, Linus Walleij, linux-gpio

On Thu, Dec 8, 2022 at 12:11 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>
>
>
> On Thu, 8 Dec 2022, at 19:57, Bartosz Golaszewski wrote:
> > On Thu, Dec 8, 2022 at 5:23 AM Andrew Jeffery <andrew@aj.id.au> wrote:
> >>
> >>
> >>
> >> On Tue, 6 Dec 2022, at 05:25, Bartosz Golaszewski wrote:
> >> > On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
> >> >>
> >> >> Hello,
> >> >>
> >> >> Based on a recent poke [1] and in-between meetings I've put together a
> >> >> WIP series that converts libgpiod's build from autotools to meson. As
> >> >> far as I'm aware the meson build supports all the significant options to
> >> >> enable or disable features exposed by the autotools build:
> >> >>
> >> >> * Tests
> >> >> * Tools
> >> >>   * Interactive gpioset
> >> >> * Bindings
> >> >>   * C++
> >> >>   * Python
> >> >>   * Rust
> >> >> * Documentation
> >> >>   * Manpages
> >> >>   * Doxygen
> >> >>
> >> >> [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
> >> >>
> >> >> Meson has pretty good support for handling python and so the patch does
> >> >> away with setup.py entirely.
> >> >
> >> > Eek! No, please do keep setup.py. Autotools too is capable of building
> >> > python C extensions on its own and it's what we use in v1 but I want
> >> > the python code to be built the standard python way. I actually plan
> >> > to post libgpiod v2 on pypi and split out building python bindings
> >> > into a separate bitbake recipe in meta-openembedded using the
> >> > setuptools3 class.
> >> >
> >> > So let's keep setup.py and just call it from meson.
> >>
> >> I've poked at this for a little while and it's not a great experience.
> >> Meson's design pushes back against calling out in this way, and I don't
> >> really have the motivation to carry on fighting it to make it do what
> >> you request. Unless someone else has that motivation, I think there are
> >> two options if meson is still desired:
> >>
> >> 1. Use the meson python support as posted in this series
> >> 2. Split out the python (and probably rust) bindings, keeping the
> >>    dependency relationships pointing in one direction and using the
> >>    language's own package management tooling.
> >>
> >> Given there's nothing to do in the install phase for rust we don't have
> >> as big of an issue there, but it is problematic for python.
> >>
> >> Let me know which way you want to go, including if you want to abandon
> >> meson :)
> >>
> >
> > No, I don't want to abandon it. What is the problem exactly? Is meson
> > unable to simply add external commands to its ninja output?
>
> Not as far as I'm aware. I think it's best covered by this policy
> description:
>
> https://mesonbuild.com/Mixing-build-systems.html
>
> There are some things that might make it sound feasible but aren't
> actually appropriate:
>
> 1. run_command(): https://mesonbuild.com/Reference-manual_functions.html#run_command
> 2. run_target(): https://mesonbuild.com/Reference-manual_functions.html#run_target
> 3. custom_target(): https://mesonbuild.com/Reference-manual_functions.html#custom_target
>
> run_command() isn't appropriate as it executes in the `meson setup`
> phase. run_target() isn't appropriate as it disregards any output
> artifacts and so has no impact in the `meson install` phase.
>
> custom_target() is probably closest to what is required, but there's a
> lot of pain in trying to get the artifacts to line up for correct
> deployment in the `meson install` phase. This is exacerbated by the
> requirement that setup.py be run from its containing directory in the
> source tree. Further, I couldn't get all the options to line up such
> that setuptools would relocate its output into meson's own build tree
> (and out of the source tree). Here's a not entirely working attempt at
> abusing custom_target() to that end:
>
> ```
> diff --git a/bindings/python/meson.build b/bindings/python/meson.build
> index 26f7ff13e0dd..136d10824345 100644
> --- a/bindings/python/meson.build
> +++ b/bindings/python/meson.build
> @@ -3,14 +3,31 @@
>
>  python = import('python')
>  python3 = python.find_installation('python3')
> -python3_dep = python3.dependency()
>
> -subdir('gpiod')
> +python_build_dir = 'python-build'
> +python_install_dir = 'python-install'
> +python_include_dirs = '../../include:../../tests/gpiosim'
> +python_lib_dirs = '@0@/lib:@0@/tests/gpiosim'.format(meson.project_build_root())
> +python_install_cmd = [ python3.full_path(), '@INPUT@', '--no-user-cfg',
> +                      'build_ext', '--include-dirs', python_include_dirs, '--library-dirs', python_lib_dirs,
> +                      'install', '--root', python_build_dir, '--prefix', get_option('prefix')]
>
> -if get_option('examples')
> -    subdir('examples')
> -endif
> +python_env = environment()
> +python_env.set('GPIOD_WITH_TESTS', get_option('tests').to_string())
>
> -if get_option('tests')
> -    subdir('tests')
> -endif
> +python_setuptools = custom_target('python-setuptools',
> +                                 input: 'setup.py',
> +                                 output: python_build_dir,
> +                                 depends: [gpiod, gpiosim],
> +                                 env: python_env,
> +                                 command: python_install_cmd)
> +
> +cp = find_program('cp')
> +
> +custom_target('python-install',
> +             input: 'setup.py',
> +             output: python_install_dir,
> +             depends: python_setuptools,
> +             command: [ cp, '-r', meson.current_source_dir() / python_build_dir, meson.current_build_dir() / python_install_dir ],
> +             install: true,
> +             install_dir: get_option('prefix'))
> diff --git a/bindings/python/setup.py b/bindings/python/setup.py
> index ec8f99d4013d..9eddae7466a1 100644
> --- a/bindings/python/setup.py
> +++ b/bindings/python/setup.py
> @@ -1,9 +1,14 @@
>  # SPDX-License-Identifier: GPL-2.0-or-later
>  # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
>
> -from os import environ
> +import os
> +import sys
> +
> +from os import environ, path
>  from setuptools import setup, Extension, find_packages
>
> +os.chdir(path.dirname(sys.argv[0]) or '.')
> +
>  gpiod_ext = Extension(
>      "gpiod._ext",
>      sources=[
> ```
>
> This commits a bunch of crimes:
>
> 1. Assumes the structure of the meson build directory via the paths in
>    python_lib_dirs
> 2. Adds a chdir() in setup.py to relocate the process out of the meson
>    build directory back into the source tree
> 3. Assumes the chdir() operation in the setup of python_include_dirs
>    rather than relying on meson's built-in dependency tracking as the
>    inc objects are opaque[1]
> 4. Hacks the setuptools output back into the meson build directory using
>    a crufty target invoking `cp` so meson can locate the artifacts in the
>    `meson install` phase
> 5. Still doesn't correctly install the artifacts in the end due to
>    restrictions on path mangling (can't strip off the parent directory)
>    and the fact that we're trying to install an entire tree rather than
>    specific files.
>
> [1] https://mesonbuild.com/Reference-manual_returned_inc.html
>
> It might feel like install_data() or install_subdir() could be used
> here, but from experiment their behaviour also seems unfit to be used
> in this context.
>
> At least, that's what I've experimented with. Maybe others can see the
> way through here, but it really is fighting against the policy linked
> earlier.
>
> Andrew

I see. I understand that meson doesn't like dealing with other build-systems.

The thing I like about the current autotools setup is that with the
following one-liner:

./autogen.sh --prefix=/tmp/gpio/inst --enable-bindings-cxx
--enable-examples --enable-tests --enable-tools
--enable-gpioset-interactive --enable-bindings-python
--enable-bindings-rust && make -j16 && sudo ./tests/gpiod-test && sudo
./bindings/cxx/tests/gpiod-cxx-test && sudo
PYTHONPATH=./bindings/python
LD_LIBRARY_PATH=./lib/.libs/:./tests/gpiosim/.libs/:bindings/python/
python -B -m tests && cd bindings/rust/; sudo
CARGO_TARGET_DIR=/tmp/libgpiod-rust PATH=/home/brgl/.cargo/bin/:$PATH
/home/brgl/.cargo/bin/cargo test; cd ../.. && sudo
./tools/gpio-tools-test

I can configure, build and test the entire code base while also using
the language specific build tools for python and rust.

I will try to play with your patches and maybe figure it out or even a
close approximation of the current functionality but then again: I'm
not well versed with meson yet. Between it and rust and dayjob my cup
runneth over...

Bartosz

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson
  2022-12-08 18:48         ` Bartosz Golaszewski
@ 2022-12-08 21:51           ` Andrew Jeffery
  0 siblings, 0 replies; 18+ messages in thread
From: Andrew Jeffery @ 2022-12-08 21:51 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Viresh Kumar, Kent Gibson, Andy Shevchenko, Linus Walleij, linux-gpio



On Fri, 9 Dec 2022, at 05:18, Bartosz Golaszewski wrote:
> On Thu, Dec 8, 2022 at 12:11 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>>
>>
>>
>> On Thu, 8 Dec 2022, at 19:57, Bartosz Golaszewski wrote:
>> > On Thu, Dec 8, 2022 at 5:23 AM Andrew Jeffery <andrew@aj.id.au> wrote:
>> >>
>> >>
>> >>
>> >> On Tue, 6 Dec 2022, at 05:25, Bartosz Golaszewski wrote:
>> >> > On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@aj.id.au> wrote:
>> >> >>
>> >> >> Hello,
>> >> >>
>> >> >> Based on a recent poke [1] and in-between meetings I've put together a
>> >> >> WIP series that converts libgpiod's build from autotools to meson. As
>> >> >> far as I'm aware the meson build supports all the significant options to
>> >> >> enable or disable features exposed by the autotools build:
>> >> >>
>> >> >> * Tests
>> >> >> * Tools
>> >> >>   * Interactive gpioset
>> >> >> * Bindings
>> >> >>   * C++
>> >> >>   * Python
>> >> >>   * Rust
>> >> >> * Documentation
>> >> >>   * Manpages
>> >> >>   * Doxygen
>> >> >>
>> >> >> [1] https://lore.kernel.org/all/CAMRc=Mda8UnyH+_GxeX_4MyKd+DPN0BVH5K+J+VWnMJNC1vwTQ@mail.gmail.com/
>> >> >>
>> >> >> Meson has pretty good support for handling python and so the patch does
>> >> >> away with setup.py entirely.
>> >> >
>> >> > Eek! No, please do keep setup.py. Autotools too is capable of building
>> >> > python C extensions on its own and it's what we use in v1 but I want
>> >> > the python code to be built the standard python way. I actually plan
>> >> > to post libgpiod v2 on pypi and split out building python bindings
>> >> > into a separate bitbake recipe in meta-openembedded using the
>> >> > setuptools3 class.
>> >> >
>> >> > So let's keep setup.py and just call it from meson.
>> >>
>> >> I've poked at this for a little while and it's not a great experience.
>> >> Meson's design pushes back against calling out in this way, and I don't
>> >> really have the motivation to carry on fighting it to make it do what
>> >> you request. Unless someone else has that motivation, I think there are
>> >> two options if meson is still desired:
>> >>
>> >> 1. Use the meson python support as posted in this series
>> >> 2. Split out the python (and probably rust) bindings, keeping the
>> >>    dependency relationships pointing in one direction and using the
>> >>    language's own package management tooling.
>> >>
>> >> Given there's nothing to do in the install phase for rust we don't have
>> >> as big of an issue there, but it is problematic for python.
>> >>
>> >> Let me know which way you want to go, including if you want to abandon
>> >> meson :)
>> >>
>> >
>> > No, I don't want to abandon it. What is the problem exactly? Is meson
>> > unable to simply add external commands to its ninja output?
>>
>> Not as far as I'm aware. I think it's best covered by this policy
>> description:
>>
>> https://mesonbuild.com/Mixing-build-systems.html
>>
>> There are some things that might make it sound feasible but aren't
>> actually appropriate:
>>
>> 1. run_command(): https://mesonbuild.com/Reference-manual_functions.html#run_command
>> 2. run_target(): https://mesonbuild.com/Reference-manual_functions.html#run_target
>> 3. custom_target(): https://mesonbuild.com/Reference-manual_functions.html#custom_target
>>
>> run_command() isn't appropriate as it executes in the `meson setup`
>> phase. run_target() isn't appropriate as it disregards any output
>> artifacts and so has no impact in the `meson install` phase.
>>
>> custom_target() is probably closest to what is required, but there's a
>> lot of pain in trying to get the artifacts to line up for correct
>> deployment in the `meson install` phase. This is exacerbated by the
>> requirement that setup.py be run from its containing directory in the
>> source tree. Further, I couldn't get all the options to line up such
>> that setuptools would relocate its output into meson's own build tree
>> (and out of the source tree). Here's a not entirely working attempt at
>> abusing custom_target() to that end:
>>
>> ```
>> diff --git a/bindings/python/meson.build b/bindings/python/meson.build
>> index 26f7ff13e0dd..136d10824345 100644
>> --- a/bindings/python/meson.build
>> +++ b/bindings/python/meson.build
>> @@ -3,14 +3,31 @@
>>
>>  python = import('python')
>>  python3 = python.find_installation('python3')
>> -python3_dep = python3.dependency()
>>
>> -subdir('gpiod')
>> +python_build_dir = 'python-build'
>> +python_install_dir = 'python-install'
>> +python_include_dirs = '../../include:../../tests/gpiosim'
>> +python_lib_dirs = '@0@/lib:@0@/tests/gpiosim'.format(meson.project_build_root())
>> +python_install_cmd = [ python3.full_path(), '@INPUT@', '--no-user-cfg',
>> +                      'build_ext', '--include-dirs', python_include_dirs, '--library-dirs', python_lib_dirs,
>> +                      'install', '--root', python_build_dir, '--prefix', get_option('prefix')]
>>
>> -if get_option('examples')
>> -    subdir('examples')
>> -endif
>> +python_env = environment()
>> +python_env.set('GPIOD_WITH_TESTS', get_option('tests').to_string())
>>
>> -if get_option('tests')
>> -    subdir('tests')
>> -endif
>> +python_setuptools = custom_target('python-setuptools',
>> +                                 input: 'setup.py',
>> +                                 output: python_build_dir,
>> +                                 depends: [gpiod, gpiosim],
>> +                                 env: python_env,
>> +                                 command: python_install_cmd)
>> +
>> +cp = find_program('cp')
>> +
>> +custom_target('python-install',
>> +             input: 'setup.py',
>> +             output: python_install_dir,
>> +             depends: python_setuptools,
>> +             command: [ cp, '-r', meson.current_source_dir() / python_build_dir, meson.current_build_dir() / python_install_dir ],
>> +             install: true,
>> +             install_dir: get_option('prefix'))
>> diff --git a/bindings/python/setup.py b/bindings/python/setup.py
>> index ec8f99d4013d..9eddae7466a1 100644
>> --- a/bindings/python/setup.py
>> +++ b/bindings/python/setup.py
>> @@ -1,9 +1,14 @@
>>  # SPDX-License-Identifier: GPL-2.0-or-later
>>  # SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
>>
>> -from os import environ
>> +import os
>> +import sys
>> +
>> +from os import environ, path
>>  from setuptools import setup, Extension, find_packages
>>
>> +os.chdir(path.dirname(sys.argv[0]) or '.')
>> +
>>  gpiod_ext = Extension(
>>      "gpiod._ext",
>>      sources=[
>> ```
>>
>> This commits a bunch of crimes:
>>
>> 1. Assumes the structure of the meson build directory via the paths in
>>    python_lib_dirs
>> 2. Adds a chdir() in setup.py to relocate the process out of the meson
>>    build directory back into the source tree
>> 3. Assumes the chdir() operation in the setup of python_include_dirs
>>    rather than relying on meson's built-in dependency tracking as the
>>    inc objects are opaque[1]
>> 4. Hacks the setuptools output back into the meson build directory using
>>    a crufty target invoking `cp` so meson can locate the artifacts in the
>>    `meson install` phase
>> 5. Still doesn't correctly install the artifacts in the end due to
>>    restrictions on path mangling (can't strip off the parent directory)
>>    and the fact that we're trying to install an entire tree rather than
>>    specific files.
>>
>> [1] https://mesonbuild.com/Reference-manual_returned_inc.html
>>
>> It might feel like install_data() or install_subdir() could be used
>> here, but from experiment their behaviour also seems unfit to be used
>> in this context.
>>
>> At least, that's what I've experimented with. Maybe others can see the
>> way through here, but it really is fighting against the policy linked
>> earlier.
>>
>> Andrew
>
> I see. I understand that meson doesn't like dealing with other build-systems.
>
> The thing I like about the current autotools setup is that with the
> following one-liner:
>
> ./autogen.sh --prefix=/tmp/gpio/inst --enable-bindings-cxx
> --enable-examples --enable-tests --enable-tools
> --enable-gpioset-interactive --enable-bindings-python
> --enable-bindings-rust && make -j16 && sudo ./tests/gpiod-test && sudo
> ./bindings/cxx/tests/gpiod-cxx-test && sudo
> PYTHONPATH=./bindings/python
> LD_LIBRARY_PATH=./lib/.libs/:./tests/gpiosim/.libs/:bindings/python/
> python -B -m tests && cd bindings/rust/; sudo
> CARGO_TARGET_DIR=/tmp/libgpiod-rust PATH=/home/brgl/.cargo/bin/:$PATH
> /home/brgl/.cargo/bin/cargo test; cd ../.. && sudo
> ./tools/gpio-tools-test
>
> I can configure, build and test the entire code base while also using
> the language specific build tools for python and rust.

Right; I agree it's desirable to retain that capability.

>
> I will try to play with your patches and maybe figure it out or even a
> close approximation of the current functionality but then again: I'm
> not well versed with meson yet. Between it and rust and dayjob my cup
> runneth over...

I recognise that feeling :)

Happy to bounce ideas around if you experiment with it.

Andrew

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-12-08 21:51 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 13:22 [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Andrew Jeffery
2022-12-05 13:22 ` [libgpiod][WIP PATCH 1/2] Introduce meson as a build system Andrew Jeffery
2022-12-05 13:22 ` [libgpiod][WIP PATCH 2/2] Remove autotools in favour of meson Andrew Jeffery
2022-12-05 18:55 ` [libgpiod][WIP PATCH 0/2] Convert the build from autotools to meson Bartosz Golaszewski
2022-12-05 23:42   ` Andrew Jeffery
2022-12-06  0:06   ` Viresh Kumar
2022-12-06  0:26     ` Andrew Jeffery
2022-12-06  3:40       ` Viresh Kumar
2022-12-06  3:54         ` Kent Gibson
2022-12-06 12:15           ` Miguel Ojeda
2022-12-06 14:54   ` Andy Shevchenko
2022-12-06 22:04     ` Andrew Jeffery
2022-12-06 22:21       ` Andy Shevchenko
2022-12-08  4:23   ` Andrew Jeffery
2022-12-08  9:27     ` Bartosz Golaszewski
2022-12-08 11:09       ` Andrew Jeffery
2022-12-08 18:48         ` Bartosz Golaszewski
2022-12-08 21:51           ` Andrew Jeffery

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.