On Mon, Dec 5, 2022 at 2:22 PM Andrew Jeffery <andrew@xxxxxxxx> 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@xxxxxxxxxxxxxx/ > > 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 >