Add initial support for meson
Subsystems (3)
v7 cover Add initial support for meson
The libtracecmd.pc didn't list the subdir 'trace-cmd' which caused our kernelshard builds to fail.
Changes:
v7:
- lib: list trace-cmd subdir in pkg-config file. Revert previous attempt to fix it.
v6:
- lib: isntall trace-cmd.h directly in /usr/include and not subdir trace-cmd. kernelshark builds breaks otherwise
v5:
- lib: set default html doc path to share/doc/libtracemd-doc
- lib: list libtraceevent and libtracefs in Required pkg-config section.
- lib: install (any) man5 pages (keep it in sync with other projects)
- trace-cmd: install (any) man5 pages (keep it in sync with other projects)
- trace-cmd: set default html doch patch to share/doc/trace-cmd-doc
v4:
- changed project defaults to --default-library=both
- code style consistency updates
- hardening doc install script (shellcheck)
- renamed install-man.sh.in to install-docs.sh.in
- install-docs.sh.in installs html pages too
- introduces docs target
- updated copyright year
- streamlined documentation meson build file
v3:
- generate tc_version.h file
- lib: cleaning up the standalone build vs trace-cmd build
- s/conf10.set/conf.set10/
- default build target is debug
- do not install man pages into subdirs
v2:
- make audit dependency optional as default
- integrate static libtracecmd build into trace-cmd directly
- remove check-manpages target in trace-cmd
v1:
- initial version
Daniel Wagner (2):
libtracecmd: Add initial support for meson
trace-cmd: Add initial support for meson
Documentation/libtracecmd/install-docs.sh.in | 20 ++ Documentation/libtracecmd/meson.build | 168 +++++++++++++++++ Documentation/trace-cmd/install-docs.sh.in | 20 ++ Documentation/trace-cmd/meson.build | 187 +++++++++++++++++++ lib/Documentation | 1 + lib/check-manpages.sh | 1 + lib/meson.build | 114 +++++++++++ lib/meson_options.txt | 19 ++ lib/trace-cmd/include/meson.build | 5 + lib/trace-cmd/include/private/meson.build | 14 ++ lib/trace-cmd/meson.build | 88 +++++++++ meson-vcs-tag.sh | 17 ++ meson.build | 149 +++++++++++++++ meson_options.txt | 23 +++ python/meson.build | 40 ++++ tracecmd/meson.build | 59 ++++++ utest/meson.build | 26 +++ 17 files changed, 951 insertions(+) create mode 100755 Documentation/libtracecmd/install-docs.sh.in create mode 100644 Documentation/libtracecmd/meson.build create mode 100755 Documentation/trace-cmd/install-docs.sh.in create mode 100644 Documentation/trace-cmd/meson.build create mode 120000 lib/Documentation create mode 120000 lib/check-manpages.sh create mode 100644 lib/meson.build create mode 100644 lib/meson_options.txt create mode 100644 lib/trace-cmd/include/meson.build create mode 100644 lib/trace-cmd/include/private/meson.build create mode 100644 lib/trace-cmd/meson.build create mode 100755 meson-vcs-tag.sh create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 python/meson.build create mode 100644 tracecmd/meson.build create mode 100644 utest/meson.build
Signature · 1 line
2.39.1
PATCH v7 1/2 libtracecmd: Add initial support for meson
Add support for building the project with meson.
As libtracecmd lives in the same source tree as trace-cmd, we have to place the 'top' meson.builld file under lib but we can't reference it from the root meson.build which controlling the main trace-cmd build.
This implies we can't access resources/path which are not below the library's main meson.build directly. Thus, to be able to build the documentation we have to use the symlink as workaround.
--- Documentation/libtracecmd/install-docs.sh.in | 20 +++ Documentation/libtracecmd/meson.build | 168 +++++++++++++++++++ lib/Documentation | 1 + lib/check-manpages.sh | 1 + lib/meson.build | 114 +++++++++++++ lib/meson_options.txt | 19 +++ lib/trace-cmd/include/meson.build | 5 + lib/trace-cmd/include/private/meson.build | 14 ++ lib/trace-cmd/meson.build | 88 ++++++++++ 9 files changed, 430 insertions(+) create mode 100755 Documentation/libtracecmd/install-docs.sh.in create mode 100644 Documentation/libtracecmd/meson.build create mode 120000 lib/Documentation create mode 120000 lib/check-manpages.sh create mode 100644 lib/meson.build create mode 100644 lib/meson_options.txt create mode 100644 lib/trace-cmd/include/meson.build create mode 100644 lib/trace-cmd/include/private/meson.build create mode 100644 lib/trace-cmd/meson.build
Documentation/libtracecmd/install-docs.sh.in new file +20 -0
@@ -0,0 +1,20 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2023 Daniel Wagner, SUSE LLC + +for section in 1 3 5; do + while IFS= read -r -d '' man; do + [ ! -d "${DESTDIR}@MANDIR@/man${section}" ] && install -d "${DESTDIR}@MANDIR@/man${section}" + + echo Installing "${man}" to "${DESTDIR}@MANDIR@/man${section}" + install -m 0644 "${man}" "${DESTDIR}@MANDIR@/man${section}/" + done< <(find "@SRCDIR@" -name "*\.${section}" -type f -print0) +done + +while IFS= read -r -d '' html; do + [ ! -d "${DESTDIR}@HTMLDIR@" ] && install -d "${DESTDIR}@HTMLDIR@" + + echo Installing "${html}" to "${DESTDIR}@HTMLDIR@" + install -m 0644 "${html}" "${DESTDIR}@HTMLDIR@" +done< <(find "@SRCDIR@" -name "*\.html" -type f -print0)
Documentation/libtracecmd/meson.build new file +168 -0
168 lines not on this page · raw message
lib/Documentation new file +1 -0
@@ -0,0 +1 @@ +../Documentation
lib/check-manpages.sh new file +1 -0
@@ -0,0 +1 @@ +../check-manpages.sh
lib/meson.build new file +114 -0
114 lines not on this page · raw message
lib/meson_options.txt new file +19 -0
@@ -0,0 +1,19 @@ +# -*- mode: meson -*- +# SPDX-License-Identifier: LGPL-2.1 + +option('vsock', type : 'boolean', value : true, + description : 'build with vsock support') +option('ptrace', type : 'boolean', value : true, + description : 'build with ptrace support') +option('htmldir', type : 'string', value : 'share/doc/libtracecmd-doc', + 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')
lib/trace-cmd/include/meson.build new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2023 Daniel Wagner, SUSE LLC + +libtracecmd_incdir = include_directories(['.'])
lib/trace-cmd/include/private/meson.build new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2023 Daniel Wagner, SUSE LLC + +config_h = configure_file( + output: 'config.h', + configuration: conf +) + +libtracecmd_private_incdir = include_directories(['.']) + +config_dep = declare_dependency( + include_directories : libtracecmd_private_incdir, + sources: config_h)
lib/trace-cmd/meson.build new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.39.1
PATCH v7 2/2 trace-cmd: Add initial support for meson
In reply to Daniel WagnerAdd support for building the project with meson.
trace-cmd depends on a statically linked libtracecmd (e.g. trace_perf_open, trace_perf_close, trace_perf_init).
Instead depending libtracecmd to be compiled and installed separately add libtracecmd directly to trace-cmd build. This avoids an additional step.
We still are able to build libtracecmd as stand alone project. The top meson.build file just lives in the lib directory.
--- Documentation/trace-cmd/install-docs.sh.in | 20 +++ Documentation/trace-cmd/meson.build | 187 +++++++++++++++++++++ meson-vcs-tag.sh | 17 ++ meson.build | 149 ++++++++++++++++ meson_options.txt | 23 +++ python/meson.build | 40 +++++ tracecmd/meson.build | 59 +++++++ utest/meson.build | 26 +++ 8 files changed, 521 insertions(+) create mode 100755 Documentation/trace-cmd/install-docs.sh.in create mode 100644 Documentation/trace-cmd/meson.build create mode 100755 meson-vcs-tag.sh create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 python/meson.build create mode 100644 tracecmd/meson.build create mode 100644 utest/meson.build
Documentation/trace-cmd/install-docs.sh.in new file +20 -0
@@ -0,0 +1,20 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2023 Daniel Wagner, SUSE LLC + +for section in 1 3 5; do + while IFS= read -r -d '' man; do + [ ! -d "${DESTDIR}@MANDIR@/man${section}" ] && install -d "${DESTDIR}@MANDIR@/man${section}" + + echo Installing "${man}" to "${DESTDIR}@MANDIR@/man${section}" + install -m 0644 "${man}" "${DESTDIR}@MANDIR@/man${section}/" + done< <(find "@SRCDIR@" -name "*\.${section}" -type f -print0) +done + +while IFS= read -r -d '' html; do + [ ! -d "${DESTDIR}@HTMLDIR@" ] && install -d "${DESTDIR}@HTMLDIR@" + + echo Installing "${html}" to "${DESTDIR}@HTMLDIR@" + install -m 0644 "${html}" "${DESTDIR}@HTMLDIR@" +done< <(find "@SRCDIR@" -name "*\.html" -type f -print0)
Documentation/trace-cmd/meson.build new file +187 -0
187 lines not on this page · raw message
meson-vcs-tag.sh new file +17 -0
@@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later + +set -eu +set -o pipefail + +dir="${1:?}" +fallback="${2:?}" + +# Apparently git describe has a bug where it always considers the work-tree +# dirty when invoked with --git-dir (even though 'git status' is happy). Work +# around this issue by cd-ing to the source directory. +cd "$dir" +# Check that we have either .git/ (a normal clone) or a .git file (a work-tree) +# and that we don't get confused if a tarball is extracted in a higher-level +# git repository. +[ -e .git ] && git describe --abbrev=7 --dirty=+ 2>/dev/null | sed 's/^v//' || echo "$fallback"
meson.build new file +149 -0
149 lines not on this page · raw message
meson_options.txt new file +23 -0
@@ -0,0 +1,23 @@ +# -*- mode: meson -*- +# SPDX-License-Identifier: GPL-2.0 + +option('version-tag', type : 'string', + description : 'override the git version string') +option('vsock', type : 'boolean', value : true, + description : 'build with vsock support') +option('ptrace', type : 'boolean', value : true, + description : 'build with ptrace support') +option('htmldir', type : 'string', value : 'share/doc/trace-cmd-doc', + 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') +option('python', type : 'combo', choices : ['auto', 'true', 'false'], + description : 'Generate trac-cmd Python bindings')
python/meson.build new file +40 -0
@@ -0,0 +1,40 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (c) 2023 Daniel Wagner, SUSE LLC + +want_python = get_option('python') +if want_python != 'false' + python3 = import('python').find_installation('python3') + py3_dep = python3.dependency(required: want_python == 'true') + swig = find_program('swig', required: want_python == 'true') + header_found = cc.has_header('Python.h', dependencies: py3_dep) + have_python_support = py3_dep.found() and swig.found() and header_found +else + have_python_support = false +endif + +if have_python_support + pymod_swig = custom_target( + 'ctracecmd.py', + input: ['ctracecmd.i'], + output: ['ctracecmd.py', 'ctracecmd_wrap.c'], + command: [ + swig, + '-python', + '-I' + meson.current_source_dir() + '/../include/trace-cmd', + '-I' + libtraceevent_dep.get_pkgconfig_variable('prefix') + '/include/traceevent', + '-o', '@OUTPUT1@', + '@INPUT0@'], + install: true, + install_dir: [ python3.get_install_dir(pure: false, subdir: 'trace-cmd'), false]) + + incdir_py = include_directories(['.', '../include/trace-cmd']) + + pyctracecmd_clib = python3.extension_module( + '_ctracecmd', + pymod_swig[1], + dependencies : [libtraceevent_dep, libtracefs_dep, py3_dep], + include_directories: [incdir, incdir_py], + install: true, + subdir: 'trace-cmd') +endif
tracecmd/meson.build new file +59 -0
59 lines not on this page · raw message
utest/meson.build new file +26 -0
@@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (c) 2023 Daniel Wagner, SUSE LLC + +sources = [ + 'tracecmd-utest.c', + 'trace-utest.c', +] + +e = executable( + 'trace-utest', + sources, + include_directories: [ + incdir, + libtracecmd_incdir, + libtracecmd_private_incdir, + libtracecmd_ext_incdir], + dependencies: [ + libtraceevent_dep, + libtracefs_dep, + zlib_dep, + libzstd_dep, + cunit_dep], + link_with: [static_libtracecmd]) + +test('trace-utest', e)
Signature · 1 line
2.39.1
Quoted 2 lines · Daniel Wagner
The libtracecmd.pc didn't list the subdir 'trace-cmd' which caused our kernelshard builds to fail.
FWIW, I've updated the Tumbleweed packages (libtraceevent, libtracefs, libtracecmd, trace-cmd) to build with Meson and everything looks good now. As indicated there was only small fallout in our kernelshark build but that is now fixed with this latest version of these patches here. So all v7 of the patches are also properly tested in a productive environment.
All these changes don't touch the existing Makefiles, so there is zero chance that existing build setups break with adding the Meson build files. Obviously, there will be additional work to keep both builds working, though I don't expect it should be much after this initial work to get it going.
Steven, any chance you are going to apply them any time soon?
Quoted 10 lines · On Thu, 9 Feb 2023 10:38:05 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 2 lines · Daniel Wagner
The libtracecmd.pc didn't list the subdir 'trace-cmd' which caused our kernelshard builds to fail.
FWIW, I've updated the Tumbleweed packages (libtraceevent, libtracefs, libtracecmd, trace-cmd) to build with Meson and everything looks good now. As indicated there was only small fallout in our kernelshark build but that is now fixed with this latest version of these patches here. So all v7 of the patches are also properly tested in a productive environment.
Quoted 6 lines
All these changes don't touch the existing Makefiles, so there is zero chance that existing build setups break with adding the Meson build files. Obviously, there will be additional work to keep both builds working, though I don't expect it should be much after this initial work to get it going.
Steven, any chance you are going to apply them any time soon?
I'll take a look. Sorry I didn't get to it on my trip (other things came up). Also, I'm still recovering from the flu now :-p
-- Steve
Quoted 2 lines · Steven Rostedt
I'll take a look. Sorry I didn't get to it on my trip (other things came up). Also, I'm still recovering from the flu now :-p
Thanks! No hurry, I don't have a problem if takes some more time if it moves forward eventually :)