libtraceevent: Add initial support for meson
Subsystems (2)
PATCH v5 1/1 libtraceevent: Add initial support for meson
Introduce Meson as build framework for building libtraceevent. 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/libtraceevent .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
v4:
- install man pages to correct section, in this case 3
- run check-doc when building the docs
v3:
- build documentation
- build samples
- changed default install to /usr/local
v2:
- changed include path exported in pkg-config
exports the same paths as per Makefile
v1:
- initial version
Documentation/install-man.sh.in | 15 +++ Documentation/meson.build | 177 ++++++++++++++++++++++++++++++++ include/traceevent/meson.build | 14 +++ meson.build | 55 ++++++++++ meson_options.txt | 20 ++++ plugins/dynamic_list.sh | 14 +++ plugins/meson.build | 44 ++++++++ samples/meson.build | 11 ++ src/meson.build | 37 +++++++ utest/meson.build | 16 +++ 10 files changed, 403 insertions(+) create mode 100755 Documentation/install-man.sh.in create mode 100644 Documentation/meson.build create mode 100644 include/traceevent/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100755 plugins/dynamic_list.sh create mode 100644 plugins/meson.build 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/traceevent/meson.build new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 Daniel Wagner, SUSE LLC + +headers = [ + 'event-parse.h', + 'event-utils.h', + 'kbuffer.h', + 'trace-seq.h', +] + +foreach h : headers + install_headers(h, subdir : 'traceevent') +endforeach
meson.build new file +55 -0
55 lines not on this page · raw message
meson_options.txt new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 Daniel Wagner, SUSE LLC + +option('plugindir', type : 'string', + description : 'set the plugin dir') +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')
plugins/dynamic_list.sh new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1 + +symbol_type=$(nm -u -D $@ | awk 'NF>1 {print $1}' | xargs echo "U w W" | + tr 'w ' 'W\n' | sort -u | xargs echo) + +if [ "$symbol_type" = "U W" ]; then + echo '{' + + nm -u -D $@ | awk 'NF>1 {sub("@.*", "", $2); print "\t"$2";"}' | + sort -u + + echo '};' +fi
plugins/meson.build new file +44 -0
44 lines not on this page · raw message
samples/meson.build new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 Daniel Wagner, SUSE LLC + +executable( + 'test-event', + ['test-event.c'], + dependencies: libtraceevent_dep, + include_directories: [incdir] +) +
src/meson.build new file +37 -0
@@ -0,0 +1,37 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 Daniel Wagner, SUSE LLC + +sources= [ + 'event-parse-api.c', + 'event-parse.c', + 'event-plugin.c', + 'kbuffer-parse.c', + 'parse-filter.c', + 'parse-utils.c', + 'tep_strerror.c', + 'trace-seq.c', +] + +libtraceevent = library( + 'traceevent', + sources, + version: library_version, + include_directories: [incdir], + install: true, +) + +pkg = import('pkgconfig') +pkg.generate(libtraceevent, + subdirs: 'traceevent', + filebase: meson.project_name(), + name: meson.project_name(), + version: meson.project_version(), + description: 'Manage trace event', + url: 'https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/', +) + +libtraceevent_dep = declare_dependency( + include_directories: ['.'], + link_with: libtraceevent, +)
utest/meson.build new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 Daniel Wagner, SUSE LLC + +source = [ + 'trace-utest.c', + 'traceevent-utest.c', +] + +e = executable( + 'trace-utest', + source, + include_directories: [incdir], + dependencies: [libtraceevent_dep, cunit_dep]) + +test('trace-utest', e)
Signature · 1 line
2.39.0
Quoted 16 lines · On Wed, 28 Dec 2022 09:29:06 +0100 Daniel Wagner <[email protected]> wrote:
Introduce Meson as build framework for building libtraceevent. 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/libtraceevent .build# trigger the build ninja -C .build# install the library ninja -C .build install
Quoted 6 lines
In case you want to build/install the documentation the setup is
meson -Ddocs-build=true .build
Signed-off-by Daniel Wagner <[email protected]>---
It's still missing the building of the static library libtraceevent.a.
-- Steve
Quoted 19 lines · Steven Rostedt
Quoted 16 lines · On Wed, 28 Dec 2022 09:29:06 +0100 Daniel Wagner <[email protected]> wrote:
Introduce Meson as build framework for building libtraceevent. 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/libtraceevent .build# trigger the build ninja -C .build# install the library ninja -C .build install
Quoted 8 lines
Quoted 6 lines
In case you want to build/install the documentation the setup is
meson -Ddocs-build=true .build
Signed-off-by Daniel Wagner <[email protected]>---
It's still missing the building of the static library libtraceevent.a.
This is controlled via 'meson setup --default-library {shared, static, both}'.
Quoted 3 lines · On Wed, 4 Jan 2023 18:05:59 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 1 line
It's still missing the building of the static library libtraceevent.a.
This is controlled via 'meson setup --default-library {shared, static, both}'.
Can we make it default to 'both' ?
-- Steve
Quoted 8 lines · On Wed, 4 Jan 2023 12:31:43 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Wed, 4 Jan 2023 18:05:59 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 1 line
It's still missing the building of the static library libtraceevent.a.
This is controlled via 'meson setup --default-library {shared, static, both}'.
Can we make it default to 'both' ?
Actually, I'm working on adding a Makefile that controls all this. I can make that do the "both"
-- Steve
Quoted 6 lines · Steven Rostedt
Quoted 3 lines · On Wed, 4 Jan 2023 12:31:43 -0500 Steven Rostedt <[email protected]> wrote:
On Wed, 4 Jan 2023 18:05:59 +0100
Daniel Wagner <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
It's still missing the building of the static library libtraceevent.a.
This is controlled via 'meson setup --default-library {shared, static, both}'.
Can we make it default to 'both' ?
Actually, I'm working on adding a
Makefilethat controls all this. I can make that do the "both"
Sure, the defaults are controlled via the project() command:
project(
'libtraceevent', ['c'],
meson_version: '>= 0.50.0',
license: 'LGPL-2.1',
version: '1.7.0',
default_options: [
'c_std=gnu99',
'buildtype=debug',
'default_library=both',
'prefix=/usr/local',
'warning_level=1',
])
Quoted 5 lines · On Wed, 28 Dec 2022 09:29:06 +0100 Daniel Wagner <[email protected]> wrote:
In case you want to build/install the documentation the setup is
meson -Ddocs-build=true .build
Signed-off-by Daniel Wagner <[email protected]>
Can we make this so that building docs does not require building the rest of the code?
-- Steve
Quoted 11 lines · Steven Rostedt
Quoted 5 lines · On Wed, 28 Dec 2022 09:29:06 +0100 Daniel Wagner <[email protected]> wrote:
In case you want to build/install the documentation the setup is
meson -Ddocs-build=true .build
Signed-off-by Daniel Wagner <[email protected]>Can we make this so that building docs does not require building the rest of the code?
Yes, it could be done by introducing a new target which is not run per default. Currently, the docs are not added to the build when '-Ddocs-build=true' is missing.
If I understood you correctly you prefer:
meson setup .build
meson compile -C .build
meson compile -C .build doc
and drop the '-Ddocs-build' option?
Quoted 11 lines · On Wed, 4 Jan 2023 18:10:18 +0100 Daniel Wagner <[email protected]> wrote:
Yes, it could be done by introducing a new target which is not run per default. Currently, the docs are not added to the build when '-Ddocs-build=true' is missing.
If I understood you correctly you prefer:
meson setup .build
meson compile -C .build
meson compile -C .build docand drop the '-Ddocs-build' option?
Yes.
Thanks!
-- Steve