Skip to contentSkip to conversation

Add initial support for meson

PATCH Superseded Daniel Wagner 2 participants 8 messages Dec 21, 2022 – Dec 24, 2022

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover Add initial support for meson

A first rough version of mesioning libtracecmd and trace-cmd. I've created to meson project for this, as I understood the goal is to split the code base into two pieces eventually. I think it would also possible just to have one meson project which creates the binaries which would propably make a few awkard hacks in this attempt go away, e.g. trace-cmd wants statically build libtracecmd.

Daniel Wagner (2):
libtracecmd: Add initial support for meson
trace-cmd: Add initial support for meson

 Documentation/libtracecmd/list-txt.sh     |   5 +
 Documentation/libtracecmd/meson.build     | 115 ++++++++++++++++++++++
 Documentation/trace-cmd/list-txt.sh       |   5 +
 Documentation/trace-cmd/meson.build       | 115 ++++++++++++++++++++++
 lib/Documentation                         |   1 +
 lib/meson.build                           | 107 ++++++++++++++++++++
 lib/meson_options.txt                     |  23 +++++
 lib/trace-cmd/include/meson.build         |   5 +
 lib/trace-cmd/include/private/meson.build |  14 +++
 lib/trace-cmd/meson.build                 |  61 ++++++++++++
 meson.build                               | 112 +++++++++++++++++++++
 meson_options.txt                         |  25 +++++
 python/meson.build                        |  40 ++++++++
 tracecmd/meson.build                      |  47 +++++++++
 utest/meson.build                         |  18 ++++
 15 files changed, 693 insertions(+)
 create mode 100644 Documentation/libtracecmd/list-txt.sh
 create mode 100644 Documentation/libtracecmd/meson.build
 create mode 100644 Documentation/trace-cmd/list-txt.sh
 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 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 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/list-txt.sh     |   5 +
 Documentation/libtracecmd/meson.build     | 115 ++++++++++++++++++++++
 lib/Documentation                         |   1 +
 lib/meson.build                           | 107 ++++++++++++++++++++
 lib/meson_options.txt                     |  23 +++++
 lib/trace-cmd/include/meson.build         |   5 +
 lib/trace-cmd/include/private/meson.build |  14 +++
 lib/trace-cmd/meson.build                 |  61 ++++++++++++
 8 files changed, 331 insertions(+)
 create mode 100644 Documentation/libtracecmd/list-txt.sh
 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/list-txt.sh new file +5 -0
new file mode 100644
index 000000000000..373e5551ae63
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+TXT_PATH=$1
+
+ls -1 ${TXT_PATH}/libtracecmd-*.txt
Documentation/libtracecmd/meson.build new file +115 -0

115 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/meson.build new file +107 -0

107 lines not on this page · raw message

lib/meson_options.txt new file +23 -0
new file mode 100644
index 000000000000..5dc031acbf54
@@ -0,0 +1,23 @@
+# -*- 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('audit', type : 'boolean', value : true,
+       description : 'build with audit 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
new file mode 100644
index 000000000000..e85ba4771b22
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+incdir = include_directories(['.'])
lib/trace-cmd/include/private/meson.build new file +14 -0
new file mode 100644
index 000000000000..ef4f9b0a5d02
@@ -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
+)
+
+private_incdir = include_directories(['.'])
+
+config_dep = declare_dependency(
+  include_directories : private_incdir,
+  sources: config_h)
lib/trace-cmd/meson.build new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.39.0
#2 lore raw

PATCH 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).

That means before kicking off the trace-cmd build a statically build libtracecmd needs to be available:

  cd lib
  meson setup --prefix=/tmp/trace-cmd --default-library=static .build
  meson compile -C .build
  meson install -C .build

then

cd ..
export PKG_PATH_PATH=/tmp/trace-cmd/lib64/pkgconfig meson setup .build

---
 Documentation/trace-cmd/list-txt.sh |   5 ++
 Documentation/trace-cmd/meson.build | 115 ++++++++++++++++++++++++++++
 meson.build                         | 112 +++++++++++++++++++++++++++
 meson_options.txt                   |  25 ++++++
 python/meson.build                  |  40 ++++++++++
 tracecmd/meson.build                |  47 ++++++++++++
 utest/meson.build                   |  18 +++++
 7 files changed, 362 insertions(+)
 create mode 100644 Documentation/trace-cmd/list-txt.sh
 create mode 100644 Documentation/trace-cmd/meson.build
 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/list-txt.sh new file +5 -0
new file mode 100644
index 000000000000..e603b536ff8b
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+TXT_PATH=$1
+
+ls -1 ${TXT_PATH}/trace-cmd*.txt
Documentation/trace-cmd/meson.build new file +115 -0

115 lines not on this page · raw message

meson.build new file +112 -0

112 lines not on this page · raw message

meson_options.txt new file +25 -0
new file mode 100644
index 000000000000..808b0d06908d
@@ -0,0 +1,25 @@
+# -*- mode: meson -*-
+# SPDX-License-Identifier: GPL-2.0
+
+option('vsock', type : 'boolean', value : true,
+       description : 'build with vsock support')
+option('ptrace', type : 'boolean', value : true,
+       description : 'build with ptrace support')
+option('audit', type : 'boolean', value : true,
+       description : 'build with audit 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
new file mode 100644
index 000000000000..dab3fab72994
@@ -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 +47 -0

47 lines not on this page · raw message

utest/meson.build new file +18 -0
new file mode 100644
index 000000000000..d1f3d29d41cf
@@ -0,0 +1,18 @@
+# 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],
+   dependencies: [libtraceevent_dep, libtracefs_dep, libtracecmd_dep,
+                  zlib_dep, libzstd_dep, cunit_dep],
+)
+
+test('trace-utest', e)
Signature · 1 line
2.39.0
#3 lore raw

Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson

Quoted 5 lines · On Wed, 21 Dec 2022 18:08:44 +0100 Daniel Wagner <[email protected]> wrote:

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).

Quoted 8 lines

That means before kicking off the trace-cmd build a statically build libtracecmd needs to be available:

  cd lib
  meson setup --prefix=/tmp/trace-cmd --default-library=static .build
  meson compile -C .build
  meson install -C .build

I get this:

Run-time dependency audit found: NO (tried pkgconfig and cmake)

meson.build:77:0: ERROR: Dependency "audit" not found, tried pkgconfig and cmake

audit is an optional dependency. Is there a way to do that? And add defines set if it is not?

What's the reason for the "get_option('audit')"?

Doesn't seem to be working as expected.

Quoted 9 lines

then

cd ..
export PKG_PATH_PATH=/tmp/trace-cmd/lib64/pkgconfig meson setup .build

meson.build new file +2 -0
+cc = meson.get_compiler('c')
+

meson.build line 29

Quoted 10 lines
meson.build new file +10 -0
+prefixdir = get_option('prefix')
+bindir    = join_paths(prefixdir, get_option('bindir'))
+mandir    = join_paths(prefixdir, get_option('mandir'))
+htmldir   = join_paths(prefixdir, get_option('htmldir'))
+
+conf = configuration_data()
+
+libtraceevent_dep = dependency('libtraceevent', version: '>= 1.7.0', required: true)
+libtracefs_dep = dependency('libtracefs', version: '>= 1.6.3', required: true)
+libtracecmd_dep = dependency('libtracecmd', version: '>= 1.3.0', required: true,

I'm guessing you just looked at the latest version and added them?

Min versions are:

libtraceevent is 1.5
libtracefs 1.6

And since this holds libtracecmd, does it really need a dependency?

-- Steve

#4 lore raw

Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson

Quoted 17 lines · Steven Rostedt
Quoted 5 lines · On Wed, 21 Dec 2022 18:08:44 +0100 Daniel Wagner <[email protected]> wrote:

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).

Quoted 8 lines

That means before kicking off the trace-cmd build a statically build libtracecmd needs to be available:

  cd lib
  meson setup --prefix=/tmp/trace-cmd --default-library=static .build
  meson compile -C .build
  meson install -C .build
Quoted 8 lines

I get this:

Run-time dependency audit found: NO (tried pkgconfig and cmake)

meson.build:77:0: ERROR: Dependency "audit" not found, tried pkgconfig and cmake

audit is an optional dependency. Is there a way to do that? And add defines set if it is not?

Yes sure. I've just got it wrong in the meson_option.txt file:

instead

option('audit', type : 'boolean', value : true,
description : 'build with audit support')

it should be

option('audit', type : 'boolean', value : false,
description : 'build with audit support')

Then this here

audit_dep = dependency('audit', required: get_option('audit'))

will not fail. Though if the system has audit-devel install it will still use it (this is a Meson feature).

Quoted 1 line

What's the reason for the "get_option('audit')"?

Oh, you are right. we could just do

audit_dep = dependency('audit', required: false)

here.

Quoted 1 line

Doesn't seem to be working as expected.

There is one thing to keep in mind. If you don't want Meson to use a dependency 'required: false' will not do the trick. This has been discussed in github issues in the Meson project many times and the outcome is that is on purpose. There are workaround for this but I expect that Meson's developer would tell us it's wrong to workaround :)

Quoted 5 lines

meson.build line 29

Quoted 3 lines
meson.build new file +3 -0
+libtraceevent_dep = dependency('libtraceevent', version: '>= 1.7.0', required: true)
+libtracefs_dep = dependency('libtracefs', version: '>= 1.6.3', required: true)
+libtracecmd_dep = dependency('libtracecmd', version: '>= 1.3.0', required: true,

I'm guessing you just looked at the latest version and added them?

Yes, that's correct.

Quoted 4 lines

Min versions are:

libtraceevent is 1.5
libtracefs 1.6

Okay, I'll change this accordingly.

Quoted 1 line

And since this holds libtracecmd, does it really need a dependency?

IIRC, I saw that the CFLAGS from libtraceevent are used for the trace-cmd, but I might just miss something. If trace-cmd doesn't use libtraceevent or libtracefs directly than it should be possible to drop these direct dependencies.

Daniel

#5 lore raw

Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson

Quoted 6 lines · On Fri, 23 Dec 2022 08:32:43 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 1 line

And since this holds libtracecmd, does it really need a dependency?

IIRC, I saw that the CFLAGS from libtraceevent are used for the trace-cmd, but I might just miss something. If trace-cmd doesn't use libtraceevent or libtracefs directly than it should be possible to drop these direct dependencies.

No, I believe that trace-cmd still uses libtracefs and libtraceevent directly.

-- Steve

#6 lore raw

Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson

Quoted 5 lines · Steven Rostedt
Quoted 2 lines · On Fri, 23 Dec 2022 08:32:43 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 1 line

And since this holds libtracecmd, does it really need a dependency?

Quoted 7 lines
Quoted 4 lines

IIRC, I saw that the CFLAGS from libtraceevent are used for the trace-cmd, but I might just miss something. If trace-cmd doesn't use libtraceevent or libtracefs directly than it should be possible to drop these direct dependencies.

No, I believe that trace-cmd still uses libtracefs and libtraceevent directly.

I did try to build without listing the direct dependency, the build failed because the compiler didn't find the libraries header files. I think we need to leave them. Though with the current approach to trigger the static libtraceevent directly from trace-cmd we need it those anyway.

#7 lore raw

Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson

Quoted 11 lines · On Sat, 24 Dec 2022 11:36:50 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 10 lines · Steven Rostedt
Quoted 6 lines · On Fri, 23 Dec 2022 08:32:43 +0100 Daniel Wagner <[email protected]> wrote:
Quoted 1 line

And since this holds libtracecmd, does it really need a dependency?

IIRC, I saw that the CFLAGS from libtraceevent are used for the trace-cmd, but I might just miss something. If trace-cmd doesn't use libtraceevent or libtracefs directly than it should be possible to drop these direct dependencies.

Quoted 7 lines
Quoted 2 lines

No, I believe that trace-cmd still uses libtracefs and libtraceevent directly.

I did try to build without listing the direct dependency, the build failed because the compiler didn't find the libraries header files. I think we need to leave them. Though with the current approach to trigger the static libtraceevent directly from trace-cmd we need it those anyway.

Just to clarify, I wasn't talking about the libtracefs/event libraries. I was talking about the libtracecmd library that was listed as a dependency. Why do we need to check the version of that, as we are going to be using the one in the repo regardless?

Also, how do you install the libraries? When I do a

ninja -C build install

it only installs the trace-cmd executable.

-- Steve