Skip to contentSkip to conversation

Add initial support for meson

PATCH Superseded Daniel Wagner 1 participant 3 messages Jan 10, 2023

Subsystems (3)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add initial support for meson

This version brings a few cleanups on the documentation intallation path and pkg-config depenedency updates.

Changes:

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                    |  87 +++++++++
 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, 950 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.0
#1 lore raw

PATCH v5 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                    |  87 ++++++++++
 9 files changed, 429 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
new file mode 100755
index 000000000000..eca9b1f42dcc
@@ -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
new file mode 120000
index 000000000000..fb996f28ab31
@@ -0,0 +1 @@
+../Documentation
\ No newline at end of file
lib/check-manpages.sh new file +1 -0
new file mode 120000
index 000000000000..d9416662eaed
@@ -0,0 +1 @@
+../check-manpages.sh
\ No newline at end of file
lib/meson.build new file +114 -0

114 lines not on this page · raw message

lib/meson_options.txt new file +19 -0
new file mode 100644
index 000000000000..9f5ed6d486d8
@@ -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
new file mode 100644
index 000000000000..c1c83884948f
@@ -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
new file mode 100644
index 000000000000..0f36339a9cc3
@@ -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 +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.39.0
#2 lore raw

PATCH v5 2/2 trace-cmd: Add initial support for meson

In reply to Daniel Wagner

Add 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
new file mode 100755
index 000000000000..eca9b1f42dcc
@@ -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
new file mode 100755
index 000000000000..8ce692498ada
@@ -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
new file mode 100644
index 000000000000..2d5d7457bed5
@@ -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
new file mode 100644
index 000000000000..5a91ff63a326
@@ -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
new file mode 100644
index 000000000000..c1cc837c7639
@@ -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.0