Add initial support for meson
Subsystems (3)
v3 cover Add initial support for meson
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
Changes:
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-man.sh.in | 15 ++ Documentation/libtracecmd/meson.build | 148 +++++++++++++++++ Documentation/trace-cmd/install-man.sh.in | 10 ++ Documentation/trace-cmd/meson.build | 167 ++++++++++++++++++++ lib/Documentation | 1 + lib/meson.build | 112 +++++++++++++ lib/meson_options.txt | 21 +++ lib/trace-cmd/include/meson.build | 5 + lib/trace-cmd/include/private/meson.build | 14 ++ lib/trace-cmd/meson.build | 83 ++++++++++ meson-vcs-tag.sh | 17 ++ meson.build | 144 +++++++++++++++++ meson_options.txt | 25 +++ python/meson.build | 40 +++++ tracecmd/meson.build | 57 +++++++ utest/meson.build | 25 +++ 16 files changed, 884 insertions(+) create mode 100755 Documentation/libtracecmd/install-man.sh.in create mode 100644 Documentation/libtracecmd/meson.build create mode 100755 Documentation/trace-cmd/install-man.sh.in create mode 100644 Documentation/trace-cmd/meson.build create mode 120000 lib/Documentation 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.0
PATCH v3 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-man.sh.in | 15 ++ Documentation/libtracecmd/meson.build | 148 ++++++++++++++++++++ lib/Documentation | 1 + lib/meson.build | 112 +++++++++++++++ lib/meson_options.txt | 21 +++ lib/trace-cmd/include/meson.build | 5 + lib/trace-cmd/include/private/meson.build | 14 ++ lib/trace-cmd/meson.build | 83 +++++++++++ 8 files changed, 399 insertions(+) create mode 100755 Documentation/libtracecmd/install-man.sh.in create mode 100644 Documentation/libtracecmd/meson.build create mode 120000 lib/Documentation 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-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/libtracecmd/meson.build new file +148 -0
148 lines not on this page · raw message
lib/Documentation new file +1 -0
@@ -0,0 +1 @@ +../Documentation
lib/meson.build new file +112 -0
112 lines not on this page · raw message
lib/meson_options.txt new file +21 -0
@@ -0,0 +1,21 @@ +# -*- 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('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')
lib/trace-cmd/include/meson.build new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1 +# +# Copyright (c) 2022 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) 2022 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 +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.39.0
PATCH v3 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-man.sh.in | 10 ++ Documentation/trace-cmd/meson.build | 167 ++++++++++++++++++++++ meson-vcs-tag.sh | 17 +++ meson.build | 144 +++++++++++++++++++ meson_options.txt | 25 ++++ python/meson.build | 40 ++++++ tracecmd/meson.build | 57 ++++++++ utest/meson.build | 25 ++++ 8 files changed, 485 insertions(+) create mode 100755 Documentation/trace-cmd/install-man.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-man.sh.in new file +10 -0
@@ -0,0 +1,10 @@ +#!/bin/bash + +for section in 1 2 3 4 5 6 7 8; do + for man in $(find @SRCDIR@ -name "*\.${section}" -type f); 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 +done
Documentation/trace-cmd/meson.build new file +167 -0
167 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 +144 -0
144 lines not on this page · raw message
meson_options.txt new file +25 -0
@@ -0,0 +1,25 @@ +# -*- 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('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') +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) 2022 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 +57 -0
57 lines not on this page · raw message
utest/meson.build new file +25 -0
@@ -0,0 +1,25 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (c) 2022 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.0