libtracefs: Add initial support for meson
Subsystems (2)
PATCH v5 1/1 libtracefs: Add initial support for meson
Introduce Meson as build framework for building libtracefs. This lives besides the Makefiles until all the expected initial fallouts have been dealed with.
The build steps are:
# configure using .build as build directory and install destination # /tmp/test meson --prefix=/tmp/libtracefs .build
# trigger the build ninja -C .build
# install the library ninja -C .build install
In case you want to build/install the documentation the setup is
meson -Ddocs-build=true .build
---
I had to fallback to use a workaround to install the man pages to the correct directory. Meson insistet to install them into subdirs and failed to install them when I forced Meson not to do this. I am sure I am doing something wrong but couldn't figure out what. I think it's okay to use the workaround until we figured how to do this 'correct'.
Tested this by packaging it up for OpenSUSE and the it looks reasonable:
https://build.opensuse.org/project/show/home:wagi:branches:devel:tools
v5:
- build unit test only if CUnit is found
- default build target is debug
- do not install man pages into subdirs
- install sqlhist (because we install the man page too, so why not the tool?)
v4:
- add subdir include path to cflags in pkgconfg file
- refactoring build instruction for section 1 and section 3 documentation into one loop (reduce code duplication)
v3:
- build documetation
- build samples
- set default location to /usr/local
v2:
- updated commit message
- dropped the include path patch, the pkg-config from libtraceevent is including them
v1:
- initial version
Documentation/install-man.sh.in | 15 +++ Documentation/meson.build | 177 ++++++++++++++++++++++++++++++++ include/meson.build | 9 ++ meson.build | 50 +++++++++ meson_options.txt | 18 ++++ samples/extract-example.sh | 3 + samples/meson.build | 46 +++++++++ src/meson.build | 65 ++++++++++++ utest/meson.build | 17 +++ 9 files changed, 400 insertions(+) create mode 100755 Documentation/install-man.sh.in create mode 100644 Documentation/meson.build create mode 100644 include/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 samples/extract-example.sh create mode 100644 samples/meson.build create mode 100644 src/meson.build create mode 100644 utest/meson.build
Documentation/install-man.sh.in new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/bash + +for man in $(find @SRCDIR@ -name '*\.1' -type f); do + [ ! -d ${DESTDIR}/@MANDIR@/man1/ ] && install -d ${DESTDIR}/@MANDIR@/man1/ + + echo Installing $man to ${DESTDIR}/@MANDIR@/man1/ + install -m 0644 $man ${DESTDIR}/@MANDIR@/man1/ +done + +for man in $(find @SRCDIR@ -name '*\.3' -type f); do + [ ! -d ${DESTDIR}/@MANDIR@/man3/ ] && install -d ${DESTDIR}/@MANDIR@/man3/ + + echo Installing $man to ${DESTDIR}/@MANDIR@/man3/ + install -m 0644 $man ${DESTDIR}/@MANDIR@/man3/ +done
Documentation/meson.build new file +177 -0
177 lines not on this page · raw message
include/meson.build new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1 + +headers = [ + 'tracefs.h', +] + +foreach h : headers + install_headers(h, subdir : 'libtracefs') +endforeach
meson.build new file +50 -0
50 lines not on this page · raw message
meson_options.txt new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 Daniel Wagner, SUSE LLC + +option('docs-build', type : 'boolean', value : false, + description : 'build documentation') +option('htmldir', type : 'string', value : '', + description : 'directory for HTML documentation') +option('asciidoctor', type : 'boolean', value: false, + description : 'use asciidoctor instead of asciidoc') +option('docbook-xls-172', type : 'boolean', value : false, + description : 'enable docbook XLS 172 workaround') +option('asciidoc-no-roff', type : 'boolean', value : false, + description : 'enable no roff workaround') +option('man-bold-literal', type : 'boolean', value : false, + description : 'enable bold literals') +option('docbook-suppress-sp', type : 'boolean', value : false, + description : 'docbook suppress sp')
samples/extract-example.sh new file +3 -0
@@ -0,0 +1,3 @@ +#!/bin/bash + +cat $1 | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ; /^--/d ; p}' > $2
samples/meson.build new file +46 -0
46 lines not on this page · raw message
src/meson.build new file +65 -0
65 lines not on this page · raw message
utest/meson.build new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 Daniel Wagner, SUSE LLC + +source = [ + 'trace-utest.c', + 'tracefs-utest.c', +] + +e = executable( + 'trace-utest', + source, + include_directories: [incdir], + dependencies: [libtraceevent_dep, cunit_dep], + link_with: libtracefs_static) + +test('trace-utest', e)
Signature · 1 line
2.39.0
Quoted 13 lines · On Wed, 28 Dec 2022 09:29:27 +0100 Daniel Wagner <[email protected]> wrote:
Introduce Meson as build framework for building libtracefs. This lives besides the Makefiles until all the expected initial fallouts have been dealed with.
The build steps are:
# configure using .build as build directory and install destination # /tmp/test meson --prefix=/tmp/libtracefs .build# trigger the build ninja -C .build
Quoted 8 lines
# install the library ninja -C .build installIn case you want to build/install the documentation the setup is
meson -Ddocs-build=true .build
Signed-off-by Daniel Wagner <[email protected]>
This also doesn't build the static library libtracefs.a.
We have environments that we need to build trace-cmd statically. As trace-cmd depends on libtraceevent and libtracefs, that means both need a static library as well.
-- Steve
On Wed, Jan 04, 2023 at 11:09:16AM -0500, Steven Rostedt wrote:
This also doesn't build the static library libtracefs.a.
Quoted 4 lines
We have environments that we need to build trace-cmd statically. As trace-cmd depends on libtraceevent and libtracefs, that means both need a static library as well.
Configure the build with
'meson setup .build --default-library=both'
Though, we could add libtraceevent and libracefs as subprojects to trace-cmd which avoids all the hassle to install libtraceevent and libtracefs independenly from trace-cmd. It also takes care of all the dependency setup. Basically with
'meson setup .build --wrap-mode=forcefallback'
in trace-cmd meson would download, setup and build libtraceevent and libtracefs within the trace-cmd build. This is makes the whole development process between these project way smoother. And if you would configure the build with
'meson setup .build --wrap-mode=forcefallback --default-library=static'
would staticly link all subprojects into the trace-cmd binary.
I haven't added this part to the initial mesonizing of the projects. Keep things simple to begin with.
Quoted 17 lines · On Wed, 4 Jan 2023 18:19:39 +0100 Daniel Wagner <[email protected]> wrote:
On Wed, Jan 04, 2023 at 11:09:16AM -0500, Steven Rostedt wrote:
This also doesn't build the static library libtracefs.a.Quoted 4 lines
We have environments that we need to build trace-cmd statically. As trace-cmd depends on libtraceevent and libtracefs, that means both need a static library as well.
Configure the build with
'meson setup .build --default-library=both'Though, we could add libtraceevent and libracefs as subprojects to trace-cmd which avoids all the hassle to install libtraceevent and libtracefs independenly from trace-cmd. It also takes care of all the dependency setup. Basically with
Quoted 6 lines
'meson setup .build --wrap-mode=forcefallback'in trace-cmd meson would download, setup and build libtraceevent and libtracefs within the trace-cmd build. This is makes the whole development process between these project way smoother. And if you would configure the build with
I'm not sure that would make it easier for me. I work on each separately. And I don't always want them linked together, but sometimes I do! To control what gets linked to trace-cmd, I use dynamic libraries, and only install what I want to use there. That is, they really are three different projects! I use libtracefs on several other tools, not just trace-cmd.
Quoted 7 lines
'meson setup .build --wrap-mode=forcefallback --default-library=static'would staticly link all subprojects into the trace-cmd binary.
I haven't added this part to the initial mesonizing of the projects. Keep things simple to begin with.
For the environment that we require a static build, that isn't really needed. It would only make the initial setup easier, but that's a one time deal. After that, everything is automated.
-- Steve
Quoted 7 lines · Steven Rostedt
On Wed, 4 Jan 2023 18:19:39 +0100
Daniel Wagner <[email protected]> wrote:
setup. Basically withQuoted 4 lines
'meson setup .build --wrap-mode=forcefallback'
Quoted 7 lines
Quoted 4 lines
in trace-cmd meson would download, setup and build libtraceevent and libtracefs within the trace-cmd build. This is makes the whole development process between these project way smoother. And if you would configure the build with
I'm not sure that would make it easier for me. I work on each separately. And I don't always want them linked together, but sometimes I do!
Meson doesn't force you here how you prefer you workflow. If you want to stick with your development steps all should be fine. I just recommend to give those subproject a try. IMO it makes things simpler, e.g. building all code in debug mode and being able to single step through is nice. And if you find a bug or want to change a line in the libraries, just change the line recompile the main project and that's all. No installing or fiddling with some $PATHs. All works out of the box.
Quoted 4 lines
To
control what gets linked to trace-cmd, I use dynamic libraries, and only install what I want to use there. That is, they really are three different projects! I use libtracefs on several other tools, not just trace-cmd.
Depending on the default settings, the libraries are either dynamically or statically linked. Meson takes care of all those path issues. For example for the nmve-cli project I have following linking situation:
$ ldd .build/nvme
linux-vdso.so.1 (0x00007ffd9975f000)
libnvme.so.1 => /home/wagi/work/nvme-cli/.build/subprojects/libnvme/src/libnvme.so.1 (0x00007fb934141000)
libnvme-mi.so.1 => /home/wagi/work/nvme-cli/.build/subprojects/libnvme/src/libnvme-mi.so.1 (0x00007fb934135000)
libjson-c.so.5 => /lib64/libjson-c.so.5 (0x00007fb9340fe000)
libz.so.1 => /lib64/libz.so.1 (0x00007fb9340e2000)
libc.so.6 => /lib64/libc.so.6 (0x00007fb933ee7000)
libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007fb933a00000)
libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007fb933e94000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb934169000)
libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007fb93392e000)
libcap.so.2 => /lib64/libcap.so.2 (0x00007fb933e88000)
libgcrypt.so.20 => /lib64/libgcrypt.so.20 (0x00007fb9337e5000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fb933e54000)
libzstd.so.1 => /lib64/libzstd.so.1 (0x00007fb933733000)
liblz4.so.1 => /lib64/liblz4.so.1 (0x00007fb93370f000)
libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007fb9336e9000)In this scenario libnvme is linked in as dynamic library.
Quoted 10 lines
Quoted 6 lines
'meson setup .build --wrap-mode=forcefallback --default-library=static'would staticly link all subprojects into the trace-cmd binary.
I haven't added this part to the initial mesonizing of the projects. Keep things simple to begin with.
For the environment that we require a static build, that isn't really needed. It would only make the initial setup easier, but that's a one time deal. After that, everything is automated.
Before you spend too much time in writing scripts aroudn Meson, you should really have a look at subproject. You get the dependencies management for little costs.
Quoted 16 lines · On Thu, 5 Jan 2023 08:18:51 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 7 lines · Steven Rostedt
On Wed, 4 Jan 2023 18:19:39 +0100
Daniel Wagner <[email protected]> wrote:
setup. Basically withQuoted 4 lines
'meson setup .build --wrap-mode=forcefallback'Quoted 7 lines
Quoted 4 lines
in trace-cmd meson would download, setup and build libtraceevent and libtracefs within the trace-cmd build. This is makes the whole development process between these project way smoother. And if you would configure the build with
I'm not sure that would make it easier for me. I work on each separately. And I don't always want them linked together, but sometimes I do!
Quoted 7 lines
Meson doesn't force you here how you prefer you workflow. If you want to stick with your development steps all should be fine. I just recommend to give those subproject a try. IMO it makes things simpler, e.g. building all code in debug mode and being able to single step through is nice. And if you find a bug or want to change a line in the libraries, just change the line recompile the main project and that's all. No installing or fiddling with some $PATHs. All works out of the box.
I get that now with my current setup. I only install with debug options, and use gdb in emacs. It walks through the library code, and will go into different paths automatically. I only need to install the code I change (sure, I need to go into that path to do so). But as I've been using libtracefs and libtraceevent for other tooling, I really don't want it part of the trace-cmd repo, or in the build path.
Quoted 8 lines
Quoted 4 lines
For the environment that we require a static build, that isn't really needed. It would only make the initial setup easier, but that's a one time deal. After that, everything is automated.
Before you spend too much time in writing scripts aroudn Meson, you should really have a look at subproject. You get the dependencies management for little costs.
The above mentioned static environment build is done via portage.
-- Steve
Quoted 8 lines
Quoted 7 lines
Meson doesn't force you here how you prefer you workflow. If you want to stick with your development steps all should be fine. I just recommend to give those subproject a try. IMO it makes things simpler, e.g. building all code in debug mode and being able to single step through is nice. And if you find a bug or want to change a line in the libraries, just change the line recompile the main project and that's all. No installing or fiddling with some $PATHs. All works out of the box.
Quoted 6 lines
I get that now with my current setup. I only install with debug options, and use gdb in emacs. It walks through the library code, and will go into different paths automatically. I only need to install the code I change (sure, I need to go into that path to do so). But as I've been using libtracefs and libtraceevent for other tooling, I really don't want it part of the trace-cmd repo, or in the build path.
Right, in this case I should avoid breaking your working setup :) Anyway, let's get first the initial setup working before doing fancy stuff.
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
For the environment that we require a static build, that isn't really needed. It would only make the initial setup easier, but that's a one time deal. After that, everything is automated.
Before you spend too much time in writing scripts aroudn Meson, you should really have a look at subproject. You get the dependencies management for little costs.
The above mentioned static environment build is done via portage.
I've build the openSUSE packages using with Meson (just exchanged the build instruction) and the tools didn't complain. So I think most of the problems should be resolved. But experience tells me, there is always one bug more.
Daniel