All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Add initial support for meson
@ 2022-12-21 17:08 Daniel Wagner
  2022-12-21 17:08 ` [PATCH v1 1/2] libtracecmd: " Daniel Wagner
  2022-12-21 17:08 ` [PATCH v1 2/2] trace-cmd: " Daniel Wagner
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Wagner @ 2022-12-21 17:08 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Steven Rostedt, Daniel Wagner

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

-- 
2.39.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v1 1/2] libtracecmd: Add initial support for meson
  2022-12-21 17:08 [PATCH v1 0/2] Add initial support for meson Daniel Wagner
@ 2022-12-21 17:08 ` Daniel Wagner
  2022-12-21 17:08 ` [PATCH v1 2/2] trace-cmd: " Daniel Wagner
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Wagner @ 2022-12-21 17:08 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Steven Rostedt, Daniel Wagner

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.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 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

diff --git a/Documentation/libtracecmd/list-txt.sh b/Documentation/libtracecmd/list-txt.sh
new file mode 100644
index 000000000000..373e5551ae63
--- /dev/null
+++ b/Documentation/libtracecmd/list-txt.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+TXT_PATH=$1
+
+ls -1 ${TXT_PATH}/libtracecmd-*.txt
diff --git a/Documentation/libtracecmd/meson.build b/Documentation/libtracecmd/meson.build
new file mode 100644
index 000000000000..db7fca01f725
--- /dev/null
+++ b/Documentation/libtracecmd/meson.build
@@ -0,0 +1,115 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+list_txt = find_program('list-txt.sh')
+r = run_command(list_txt, meson.current_source_dir(), check: true)
+sources3 = r.stdout().strip().split('\n')
+
+#
+# For asciidoc ...
+#	-7.1.2,	no extra settings are needed.
+#	8.0-,	set ASCIIDOC8.
+#
+
+#
+# For docbook-xsl ...
+#	-1.68.1,	set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
+#	1.69.0,		no extra settings are needed?
+#	1.69.1-1.71.0,	set DOCBOOK_SUPPRESS_SP?
+#	1.71.1,		no extra settings are needed?
+#	1.72.0,		set DOCBOOK_XSL_172.
+#	1.73.0-,	set ASCIIDOC_NO_ROFF
+#
+
+#
+# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
+# of 'the ".ft C" problem' in your generated manpages, and you
+# instead ended up with weird characters around callouts, try
+# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
+#
+
+if get_option('asciidoctor')
+    asciidoc = find_program('asciidoctor')
+    asciidoc_extra  = ['-a', 'compat-mode']
+    asciidoc_extra += ['-I.']
+    asciidoc_extra += ['-r', 'asciidoctor-extensions']
+    asciidoc_extra += ['-a', 'mansource=libtraceevent']
+    asciidoc_extra += ['-a', 'manmanual="libtraceevent Manual"']
+    asciidoc_html = 'xhtml5'
+else
+    asciidoc = find_program('asciidoc')
+    asciidoc_extra  = ['--unsafe']
+    asciidoc_extra += ['-f', meson.current_source_dir() + '/../asciidoc.conf']
+    asciidoc_html = 'xhtml11'
+
+    r = run_command(asciidoc, '--version', check: true)
+    v = r.stdout().strip()
+    if v.version_compare('>=8.0')
+        asciidoc_extra += ['-a', 'asciidoc7compatible']
+    endif
+endif
+
+manpage_xsl = meson.current_source_dir() + '/../manpage-normal.xsl'
+
+if get_option('docbook-xls-172')
+    asciidoc_extra += ['-a', 'libtraceevent-asciidoc-no-roff']
+    manpage_xsl = meson.current_source_dir() + '/../manpage-1.72.xsl'
+elif get_option('asciidoc-no-roff')
+    # docbook-xsl after 1.72 needs the regular XSL, but will not
+    # pass-thru raw roff codes from asciidoc.conf, so turn them off.
+    asciidoc_extra += ['-a', 'libtraceevent-asciidoc-no-roff']
+endif
+
+xmlto = find_program('xmlto')
+xmlto_extra = []
+
+if get_option('man-bold-literal')
+    xmlto_extra += ['-m ', meson.current_source_dir() + '/../manpage-bold-literal.xsl']
+endif
+
+if get_option('docbook-suppress-sp')
+    xmlto_extra += ['-m ',  meson.current_source_dir() + '/../manpage-suppress-sp.xsl']
+endif
+
+gen = generator(asciidoc,
+                output: '@BASENAME@.xml',
+                arguments: [
+                    '-b', 'docbook',
+                    '-d', 'manpage',
+                    '-a', 'libtraceevent_version=' + meson.project_version(),
+                    '-o', '@OUTPUT@']
+                    + asciidoc_extra
+                    + ['@INPUT@'])
+
+foreach src : sources3
+    # build man pages
+    xml = gen.process(src)
+    custom_target(
+        src.underscorify() + '_man',
+        input: xml,
+        output: '@BASENAME@.3',
+        command: [xmlto,
+                 '-m', manpage_xsl,
+                 'man',
+                 '-o', '@OUTPUT@']
+                 + xmlto_extra
+                 + ['@INPUT@'],
+        install: true,
+        install_dir: join_paths(mandir, 'man3'))
+
+    # build html pages
+    custom_target(
+       src.underscorify() + '_html',
+       input: src,
+       output: '@BASENAME@.html',
+       command: [asciidoc,
+                '-b', asciidoc_html,
+                '-d', 'manpage',
+	        '-a', 'libtraceevent_version=' + meson.project_version(),
+                '-o', '@OUTPUT@']
+                + asciidoc_extra
+                + ['@INPUT@'],
+       install: true,
+       install_dir: htmldir)
+endforeach
diff --git a/lib/Documentation b/lib/Documentation
new file mode 120000
index 000000000000..fb996f28ab31
--- /dev/null
+++ b/lib/Documentation
@@ -0,0 +1 @@
+../Documentation
\ No newline at end of file
diff --git a/lib/meson.build b/lib/meson.build
new file mode 100644
index 000000000000..7de5f565bce1
--- /dev/null
+++ b/lib/meson.build
@@ -0,0 +1,107 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+project(
+    'libtrace-cmd', ['c'],
+    meson_version: '>= 0.50.0',
+    license: 'GPL-2.0',
+    version: '1.3.0',
+    default_options: [
+      'c_std=gnu99',
+      'buildtype=release',
+      'prefix=/usr/local',
+      'warning_level=1',
+    ]
+)
+
+cc = meson.get_compiler('c')
+
+prefixdir = get_option('prefix')
+mandir    = join_paths(prefixdir, get_option('mandir'))
+htmldir   = join_paths(prefixdir, get_option('htmldir'))
+
+library_version = meson.project_version()
+
+conf = configuration_data()
+
+libtraceevent_dep = dependency('libtraceevent', version: '>= 1.7.0', required: true)
+libtracefs_dep = dependency('libtracefs', version: '>= 1.6.3', required: true)
+
+zlib_dep = dependency('zlib', required: false)
+conf.set('HAVE_ZLIB', zlib_dep.found(), description: 'Is zlib avialable?')
+
+libzstd_dep = dependency('libzstd', version: '>= 1.4.0', required: false)
+conf.set('HAVE_ZSTD', libzstd_dep.found(), description: 'Is libzstd available?')
+
+cunit_dep = dependency('cunit', required : false)
+
+vsock_defined = get_option('vsock') and cc.has_header('linux/vm_sockets.h')
+conf.set('VSOCK', vsock_defined, description: 'Is vsock available?')
+
+perf_defined = cc.has_header('linux/perf_event.h')
+conf.set('PERF', perf_defined, description: 'Is perf available?')
+
+have_ptrace = get_option('ptrace') and cc.compiles(
+    '''
+    #include <stdio.h>
+    #include <sys/ptrace.h>
+
+    int main (void)
+    {
+            int ret;
+            ret = ptrace(PTRACE_ATTACH, 0, NULL, 0);
+            ptrace(PTRACE_TRACEME, 0, NULL, 0);
+            ptrace(PTRACE_GETSIGINFO, 0, NULL, NULL);
+            ptrace(PTRACE_GETEVENTMSG, 0, NULL, NULL);
+            ptrace(PTRACE_SETOPTIONS, NULL, NULL,
+                           PTRACE_O_TRACEFORK |
+                           PTRACE_O_TRACEVFORK |
+                           PTRACE_O_TRACECLONE |
+                           PTRACE_O_TRACEEXIT);
+            ptrace(PTRACE_CONT, NULL, NULL, 0);
+            ptrace(PTRACE_DETACH, 0, NULL, NULL);
+            ptrace(PTRACE_SETOPTIONS, 0, NULL,
+                   PTRACE_O_TRACEFORK |
+                   PTRACE_O_TRACEVFORK |
+                   PTRACE_O_TRACECLONE |
+                   PTRACE_O_TRACEEXIT);
+            return ret;
+    }
+    ''',
+    name: 'ptrace')
+if not have_ptrace
+    conf10.set('NO_PTRACE', true, description: 'Is ptrace missing?')
+    conf.set('WARN_NO_PTRACE', true, description: 'Issue no ptrace warning?')
+endif
+
+audit_dep = dependency('audit', required: get_option('audit'))
+if not audit_dep.found()
+    conf10.set('NO_AUDIT', true, description: 'Is audit missing?')
+    conf.set('WARN_NO_AUDIT', true, description: 'Issue no audit warning?')
+endif
+
+add_project_arguments(
+    [
+      '-D_GNU_SOURCE',
+      '-include', 'trace-cmd/include/private/config.h',
+    ],
+    language : 'c',
+)
+
+trace_cmd_incdir = include_directories(['../include',
+                                        '../include/trace-cmd',
+                                        '../tracecmd/include'])
+
+subdir('trace-cmd/include')
+subdir('trace-cmd/include/private')
+subdir('trace-cmd')
+if get_option('docs-build')
+    custom_target('check-doc',
+                   output: 'dummy',
+                   command : [meson.source_root() + '/../check-manpages.sh',
+                              meson.source_root() + '/../Documentation/libtracecmd'],
+	           build_by_default : true)
+    # subdir() doesn't allow '..' in the path
+    subdir('Documentation/libtracecmd')
+endif
diff --git a/lib/meson_options.txt b/lib/meson_options.txt
new file mode 100644
index 000000000000..5dc031acbf54
--- /dev/null
+++ b/lib/meson_options.txt
@@ -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')
diff --git a/lib/trace-cmd/include/meson.build b/lib/trace-cmd/include/meson.build
new file mode 100644
index 000000000000..e85ba4771b22
--- /dev/null
+++ b/lib/trace-cmd/include/meson.build
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+incdir = include_directories(['.'])
diff --git a/lib/trace-cmd/include/private/meson.build b/lib/trace-cmd/include/private/meson.build
new file mode 100644
index 000000000000..ef4f9b0a5d02
--- /dev/null
+++ b/lib/trace-cmd/include/private/meson.build
@@ -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)
diff --git a/lib/trace-cmd/meson.build b/lib/trace-cmd/meson.build
new file mode 100644
index 000000000000..124ea8e9fa49
--- /dev/null
+++ b/lib/trace-cmd/meson.build
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+sources = [
+    'trace-hash.c',
+    'trace-hooks.c',
+    'trace-input.c',
+    'trace-output.c',
+    'trace-recorder.c',
+    'trace-util.c',
+    'trace-filter-hash.c',
+    'trace-filter.c',
+    'trace-msg.c',
+    'trace-plugin.c',
+    'trace-maps.c',
+    'trace-timesync.c',
+    'trace-timesync-ptp.c',
+    'trace-compress.c',
+    'trace-blk-hack.c',
+    'trace-ftrace.c',
+]
+
+if perf_defined
+    sources += 'trace-perf.c'
+endif
+
+if vsock_defined
+    sources += 'trace-timesync-kvm.c'
+endif
+
+if zlib_dep.found()
+    sources += 'trace-compress-zlib.c'
+endif
+
+if libzstd_dep.found()
+    sources += 'trace-compress-zstd.c'
+endif
+
+libtracecmd = library(
+    'tracecmd',
+    sources,
+    version: library_version,
+    dependencies: [libtraceevent_dep, libtracefs_dep, zlib_dep, libzstd_dep, audit_dep],
+    include_directories: [incdir, private_incdir, trace_cmd_incdir],
+    install: true,
+)
+
+pkg = import('pkgconfig')
+pkg.generate(
+    libtracecmd,
+    filebase: meson.project_name(),
+    name: meson.project_name(),
+    version: meson.project_version(),
+    description: 'Library for creating and reading trace-cmd data files',
+    url: 'https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/'
+)
+
+libtracecmd_dep = declare_dependency(
+    include_directories: ['.'],
+    link_with: libtracecmd,
+)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v1 2/2] trace-cmd: Add initial support for meson
  2022-12-21 17:08 [PATCH v1 0/2] Add initial support for meson Daniel Wagner
  2022-12-21 17:08 ` [PATCH v1 1/2] libtracecmd: " Daniel Wagner
@ 2022-12-21 17:08 ` Daniel Wagner
  2022-12-23  5:03   ` Steven Rostedt
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2022-12-21 17:08 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Steven Rostedt, 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

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 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

diff --git a/Documentation/trace-cmd/list-txt.sh b/Documentation/trace-cmd/list-txt.sh
new file mode 100644
index 000000000000..e603b536ff8b
--- /dev/null
+++ b/Documentation/trace-cmd/list-txt.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+TXT_PATH=$1
+
+ls -1 ${TXT_PATH}/trace-cmd*.txt
diff --git a/Documentation/trace-cmd/meson.build b/Documentation/trace-cmd/meson.build
new file mode 100644
index 000000000000..2ff4271b4005
--- /dev/null
+++ b/Documentation/trace-cmd/meson.build
@@ -0,0 +1,115 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+list_txt = find_program('list-txt.sh')
+r = run_command(list_txt, meson.current_source_dir(), check: true)
+sources1 = r.stdout().strip().split('\n')
+
+#
+# For asciidoc ...
+#	-7.1.2,	no extra settings are needed.
+#	8.0-,	set ASCIIDOC8.
+#
+
+#
+# For docbook-xsl ...
+#	-1.68.1,	set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
+#	1.69.0,		no extra settings are needed?
+#	1.69.1-1.71.0,	set DOCBOOK_SUPPRESS_SP?
+#	1.71.1,		no extra settings are needed?
+#	1.72.0,		set DOCBOOK_XSL_172.
+#	1.73.0-,	set ASCIIDOC_NO_ROFF
+#
+
+#
+# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
+# of 'the ".ft C" problem' in your generated manpages, and you
+# instead ended up with weird characters around callouts, try
+# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
+#
+
+if get_option('asciidoctor')
+    asciidoc = find_program('asciidoctor')
+    asciidoc_extra  = ['-a', 'compat-mode']
+    asciidoc_extra += ['-I.']
+    asciidoc_extra += ['-r', 'asciidoctor-extensions']
+    asciidoc_extra += ['-a', 'mansource=libtraceevent']
+    asciidoc_extra += ['-a', 'manmanual="libtraceevent Manual"']
+    asciidoc_html = 'xhtml5'
+else
+    asciidoc = find_program('asciidoc')
+    asciidoc_extra  = ['--unsafe']
+    asciidoc_extra += ['-f', meson.current_source_dir() + '/../asciidoc.conf']
+    asciidoc_html = 'xhtml11'
+
+    r = run_command(asciidoc, '--version', check: true)
+    v = r.stdout().strip()
+    if v.version_compare('>=8.0')
+        asciidoc_extra += ['-a', 'asciidoc7compatible']
+    endif
+endif
+
+manpage_xsl = meson.current_source_dir() + '/../manpage-normal.xsl'
+
+if get_option('docbook-xls-172')
+    asciidoc_extra += ['-a', 'libtraceevent-asciidoc-no-roff']
+    manpage_xsl = meson.current_source_dir() + '/../manpage-1.72.xsl'
+elif get_option('asciidoc-no-roff')
+    # docbook-xsl after 1.72 needs the regular XSL, but will not
+    # pass-thru raw roff codes from asciidoc.conf, so turn them off.
+    asciidoc_extra += ['-a', 'libtraceevent-asciidoc-no-roff']
+endif
+
+xmlto = find_program('xmlto')
+xmlto_extra = []
+
+if get_option('man-bold-literal')
+    xmlto_extra += ['-m ', meson.current_source_dir() + '/../manpage-bold-literal.xsl']
+endif
+
+if get_option('docbook-suppress-sp')
+    xmlto_extra += ['-m ',  meson.current_source_dir() + '/../manpage-suppress-sp.xsl']
+endif
+
+gen = generator(asciidoc,
+                output: '@BASENAME@.xml',
+                arguments: [
+                    '-b', 'docbook',
+                    '-d', 'manpage',
+                    '-a', 'libtraceevent_version=' + meson.project_version(),
+                    '-o', '@OUTPUT@']
+                    + asciidoc_extra
+                    + ['@INPUT@'])
+
+foreach src : sources1
+    # build man pages
+    xml = gen.process(src)
+    custom_target(
+        src.underscorify() + '_man',
+        input: xml,
+        output: '@BASENAME@.1',
+        command: [xmlto,
+                 '-m', manpage_xsl,
+                 'man',
+                 '-o', '@OUTPUT@']
+                 + xmlto_extra
+                 + ['@INPUT@'],
+        install: true,
+        install_dir: join_paths(mandir, 'man1'))
+
+    # build html pages
+    custom_target(
+       src.underscorify() + '_html',
+       input: src,
+       output: '@BASENAME@.html',
+       command: [asciidoc,
+                '-b', asciidoc_html,
+                '-d', 'manpage',
+	        '-a', 'libtraceevent_version=' + meson.project_version(),
+                '-o', '@OUTPUT@']
+                + asciidoc_extra
+                + ['@INPUT@'],
+       install: true,
+       install_dir: htmldir)
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 000000000000..9ca178a82a5f
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,112 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+project(
+    'trace-cmd', ['c'],
+    meson_version: '>= 0.50.0',
+    license: 'GPL-2.0',
+    version: '3.1.5',
+    default_options: [
+      'c_std=gnu99',
+      'buildtype=release',
+      'prefix=/usr/local',
+      'warning_level=1',
+    ]
+)
+
+cc = meson.get_compiler('c')
+
+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,
+                             static: true)
+
+zlib_dep = dependency('zlib', required: false)
+conf.set('HAVE_ZLIB', zlib_dep.found(), description: 'Is zlib avialable?')
+
+libzstd_dep = dependency('libzstd', version: '>= 1.4.0', required: false)
+conf.set('HAVE_ZSTD', libzstd_dep.found(), description: 'Is libzstd available?')
+
+cunit_dep = dependency('cunit', required : false)
+
+vsock_defined = get_option('vsock') and cc.has_header('linux/vm_sockets.h')
+conf.set('VSOCK', vsock_defined, description: 'Is vsock available?')
+
+perf_defined = cc.has_header('linux/perf_event.h')
+conf.set('PERF', perf_defined, description: 'Is perf available?')
+
+have_ptrace = get_option('ptrace') and cc.compiles(
+    '''
+    #include <stdio.h>
+    #include <sys/ptrace.h>
+
+    int main (void)
+    {
+            int ret;
+            ret = ptrace(PTRACE_ATTACH, 0, NULL, 0);
+            ptrace(PTRACE_TRACEME, 0, NULL, 0);
+            ptrace(PTRACE_GETSIGINFO, 0, NULL, NULL);
+            ptrace(PTRACE_GETEVENTMSG, 0, NULL, NULL);
+            ptrace(PTRACE_SETOPTIONS, NULL, NULL,
+                           PTRACE_O_TRACEFORK |
+                           PTRACE_O_TRACEVFORK |
+                           PTRACE_O_TRACECLONE |
+                           PTRACE_O_TRACEEXIT);
+            ptrace(PTRACE_CONT, NULL, NULL, 0);
+            ptrace(PTRACE_DETACH, 0, NULL, NULL);
+            ptrace(PTRACE_SETOPTIONS, 0, NULL,
+                   PTRACE_O_TRACEFORK |
+                   PTRACE_O_TRACEVFORK |
+                   PTRACE_O_TRACECLONE |
+                   PTRACE_O_TRACEEXIT);
+            return ret;
+    }
+    ''',
+    name: 'ptrace')
+if not have_ptrace
+    conf10.set('NO_PTRACE', true, description: 'Is ptrace missing?')
+    conf.set('WARN_NO_PTRACE', true, description: 'Issue no ptrace warning?')
+endif
+
+audit_dep = dependency('audit', required: get_option('audit'))
+if not audit_dep.found()
+    conf10.set('NO_AUDIT', true, description: 'Is audit missing?')
+    conf.set('WARN_NO_AUDIT', true, description: 'Issue no audit warning?')
+endif
+
+config_h = configure_file(
+    output: 'config.h',
+    configuration: conf
+)
+
+add_project_arguments(
+    [
+      '-D_GNU_SOURCE',
+      '-include', 'config.h',
+    ],
+    language : 'c',
+)
+
+incdir = include_directories(['.', 'include',
+                              'lib/trace-cmd/include',
+                              'lib/trace-cmd/include/private'])
+
+subdir('tracecmd')
+subdir('python')
+subdir('utest')
+if get_option('docs-build')
+    custom_target('check-doc',
+                   output: 'dummy',
+                   command : ['check-manpages.sh',
+                              meson.current_source_dir() + '/Documentation/trace-cmd'],
+	           build_by_default : true)
+    subdir('Documentation/trace-cmd')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 000000000000..808b0d06908d
--- /dev/null
+++ b/meson_options.txt
@@ -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')
diff --git a/python/meson.build b/python/meson.build
new file mode 100644
index 000000000000..dab3fab72994
--- /dev/null
+++ b/python/meson.build
@@ -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
diff --git a/tracecmd/meson.build b/tracecmd/meson.build
new file mode 100644
index 000000000000..4f00445ae74c
--- /dev/null
+++ b/tracecmd/meson.build
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+sources = [
+    'trace-cmd.c',
+    'trace-record.c',
+    'trace-read.c',
+    'trace-split.c',
+    'trace-listen.c',
+    'trace-stack.c',
+    'trace-hist.c',
+    'trace-mem.c',
+    'trace-snapshot.c',
+    'trace-stat.c',
+    'trace-profile.c',
+    'trace-stream.c',
+    'trace-record.c',
+    'trace-restore.c',
+    'trace-check-events.c',
+    'trace-show.c',
+    'trace-list.c',
+    'trace-usage.c',
+    'trace-dump.c',
+    'trace-clear.c',
+    'trace-vm.c',
+    'trace-convert.c',
+    'trace-agent.c',
+    'trace-tsync.c',
+    'trace-setup-guest.c',
+]
+
+if vsock_defined
+    sources += 'trace-vsock.c'
+endif
+
+trace_cmd_incdir = include_directories(['.', 'include'])
+
+executable(
+    'trace-cmd',
+    sources,
+    dependencies: [libtraceevent_dep, libtracefs_dep, libtracecmd_dep,
+                   zlib_dep, libzstd_dep, audit_dep],
+    include_directories: [incdir, trace_cmd_incdir],
+    install: true,
+    install_dir: bindir,
+)
diff --git a/utest/meson.build b/utest/meson.build
new file mode 100644
index 000000000000..d1f3d29d41cf
--- /dev/null
+++ b/utest/meson.build
@@ -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)
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson
  2022-12-21 17:08 ` [PATCH v1 2/2] trace-cmd: " Daniel Wagner
@ 2022-12-23  5:03   ` Steven Rostedt
  2022-12-23  7:32     ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2022-12-23  5:03 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-trace-devel

On Wed, 21 Dec 2022 18:08:44 +0100
Daniel Wagner <dwagner@suse.de> 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).
> 
> 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.

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


> +cc = meson.get_compiler('c')
> +
> +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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson
  2022-12-23  5:03   ` Steven Rostedt
@ 2022-12-23  7:32     ` Daniel Wagner
  2022-12-23 17:08       ` Steven Rostedt
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2022-12-23  7:32 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel

On Fri, Dec 23, 2022 at 12:03:38AM -0500, Steven Rostedt wrote:
> On Wed, 21 Dec 2022 18:08:44 +0100
> Daniel Wagner <dwagner@suse.de> 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).
> > 
> > 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?

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

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

Oh, you are right. we could just do

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

here.

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

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

> Min versions are:
> 
>   libtraceevent is 1.5
>   libtracefs 1.6

Okay, I'll change this accordingly.

> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson
  2022-12-23  7:32     ` Daniel Wagner
@ 2022-12-23 17:08       ` Steven Rostedt
  2022-12-24 10:36         ` Daniel Wagner
  0 siblings, 1 reply; 8+ messages in thread
From: Steven Rostedt @ 2022-12-23 17:08 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-trace-devel

On Fri, 23 Dec 2022 08:32:43 +0100
Daniel Wagner <dwagner@suse.de> wrote:

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson
  2022-12-23 17:08       ` Steven Rostedt
@ 2022-12-24 10:36         ` Daniel Wagner
  2022-12-24 17:28           ` Steven Rostedt
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Wagner @ 2022-12-24 10:36 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel

On Fri, Dec 23, 2022 at 12:08:51PM -0500, Steven Rostedt wrote:
> On Fri, 23 Dec 2022 08:32:43 +0100
> Daniel Wagner <dwagner@suse.de> wrote:
> 
> > > 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.

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v1 2/2] trace-cmd: Add initial support for meson
  2022-12-24 10:36         ` Daniel Wagner
@ 2022-12-24 17:28           ` Steven Rostedt
  0 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2022-12-24 17:28 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-trace-devel

On Sat, 24 Dec 2022 11:36:50 +0100
Daniel Wagner <dwagner@suse.de> wrote:

> On Fri, Dec 23, 2022 at 12:08:51PM -0500, Steven Rostedt wrote:
> > On Fri, 23 Dec 2022 08:32:43 +0100
> > Daniel Wagner <dwagner@suse.de> wrote:
> >   
> > > > 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.  
> 
> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-24 17:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 17:08 [PATCH v1 0/2] Add initial support for meson Daniel Wagner
2022-12-21 17:08 ` [PATCH v1 1/2] libtracecmd: " Daniel Wagner
2022-12-21 17:08 ` [PATCH v1 2/2] trace-cmd: " Daniel Wagner
2022-12-23  5:03   ` Steven Rostedt
2022-12-23  7:32     ` Daniel Wagner
2022-12-23 17:08       ` Steven Rostedt
2022-12-24 10:36         ` Daniel Wagner
2022-12-24 17:28           ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.