Add initial support for meson
Subsystems (3)
v2 cover Add initial support for meson
This version is intergrating the libtracecmd static build directly inside trace-cmd build. That means you don't need to build and install libtracecmd first to be able to build trace-cmd. This should simplify the development workflow.
The shared libtracecmd build is still possible and modelled as it's own project (lib/meson.build).
With this, there is no need to change anything in the current project layout or development work flow, which I assume is helping getting meson added :)
Changes:
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/meson.build | 117 +++++++++++++++++++++ Documentation/list-txt.sh | 5 + Documentation/trace-cmd/meson.build | 117 +++++++++++++++++++++ lib/Documentation | 1 + lib/meson.build | 109 ++++++++++++++++++++ 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 | 81 +++++++++++++++ meson.build | 119 ++++++++++++++++++++++ meson_options.txt | 23 +++++ python/meson.build | 40 ++++++++ tracecmd/meson.build | 55 ++++++++++ utest/meson.build | 25 +++++ 14 files changed, 732 insertions(+) create mode 100644 Documentation/libtracecmd/meson.build create mode 100644 Documentation/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
PATCH v2 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/meson.build | 117 ++++++++++++++++++++++ Documentation/list-txt.sh | 5 + lib/Documentation | 1 + lib/meson.build | 109 ++++++++++++++++++++ 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 | 81 +++++++++++++++ 8 files changed, 353 insertions(+) create mode 100644 Documentation/libtracecmd/meson.build create mode 100644 Documentation/list-txt.sh 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/meson.build new file +117 -0
@@ -0,0 +1,117 @@ +# 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() + '/libtracecmd-*.txt', + check: true) +sources = 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: '@[email protected]', + arguments: [ + '-b', 'docbook', + '-d', 'manpage', + '-a', 'libtraceevent_version=' + meson.project_version(), + '-o', '@OUTPUT@'] + + asciidoc_extra + + ['@INPUT@']) + +foreach src : sources + # build man pages + xml = gen.process(src) + custom_target( + src.underscorify() + '_man', + input: xml, + output: '@[email protected]', + 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: '@[email protected]', + command: [asciidoc, + '-b', asciidoc_html, + '-d', 'manpage', + '-a', 'libtraceevent_version=' + meson.project_version(), + '-o', '@OUTPUT@'] + + asciidoc_extra + + ['@INPUT@'], + install: true, + install_dir: htmldir) +endforeach
Documentation/list-txt.sh new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/bash + +PATTERN=$1 + +ls -1 $PATTERN
lib/Documentation new file +1 -0
@@ -0,0 +1 @@ +../Documentation
lib/meson.build new file +109 -0
109 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 +81 -0
81 lines not on this page · raw message
Signature · 1 line
2.39.0
Re: [PATCH v2 1/2] libtracecmd: Add initial support for meson
Quoted 4 lines · On Fri, 23 Dec 2022 11:15:01 +0100 Daniel Wagner <[email protected]> wrote:
+++ b/lib/meson.build
lib/meson.build new file +2
-0@@ -0,0 +1,109 @@ +# SPDX-License-Identifier: LGPL-2.1 +#
lib/meson.build line 12
Quoted 10 lines
lib/meson.build new file +10
-0+# 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',
The default buildtype should be debug. If someone downloads the source, they are probably going to debug it. I found this annoying when I went to use gdb, and there were no symbols present.
-- Steve
Quoted 4 lines
lib/meson.build new file +4
-0+ 'prefix=/usr/local', + 'warning_level=1', + ] +)
Re: [PATCH v2 1/2] libtracecmd: Add initial support for meson
Quoted 13 lines · Steven Rostedt
Quoted 10 lines · On Fri, 23 Dec 2022 11:15:01 +0100 Daniel Wagner <[email protected]> wrote:
+++ b/lib/meson.build
lib/meson.build new file +8
-0@@ -0,0 +1,109 @@ +# 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',
Quoted 8 lines
lib/meson.build line 12
Quoted 4 lines
lib/meson.build new file +4
-0+ version: '1.3.0', + default_options: [ + 'c_std=gnu99', + 'buildtype=release',The default buildtype should be debug. If someone downloads the source, they are probably going to debug it. I found this annoying when I went to use gdb, and there were no symbols present.
Makes sense. I'll update it accordingly.
PATCH v2 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/meson.build | 117 +++++++++++++++++++++++++++ meson.build | 119 ++++++++++++++++++++++++++++ meson_options.txt | 23 ++++++ python/meson.build | 40 ++++++++++ tracecmd/meson.build | 55 +++++++++++++ utest/meson.build | 25 ++++++ 6 files changed, 379 insertions(+) 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/meson.build new file +117 -0
@@ -0,0 +1,117 @@ +# 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() + '/trace-cmd*.txt', + check: true) +sources = 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: '@[email protected]', + arguments: [ + '-b', 'docbook', + '-d', 'manpage', + '-a', 'libtraceevent_version=' + meson.project_version(), + '-o', '@OUTPUT@'] + + asciidoc_extra + + ['@INPUT@']) + +foreach src : sources + # build man pages + xml = gen.process(src) + custom_target( + src.underscorify() + '_man', + input: xml, + output: '@[email protected]', + 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: '@[email protected]', + command: [asciidoc, + '-b', asciidoc_html, + '-d', 'manpage', + '-a', 'libtraceevent_version=' + meson.project_version(), + '-o', '@OUTPUT@'] + + asciidoc_extra + + ['@INPUT@'], + install: true, + install_dir: htmldir) +endforeach
meson.build new file +119 -0
119 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('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 +55 -0
55 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
Re: [PATCH v2 2/2] trace-cmd: Add initial support for meson
Quoted 9 lines · On Fri, 23 Dec 2022 11:15:02 +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).Instead depending libtracecmd to be compiled and installed separately add libtracecmd directly to trace-cmd build. This avoids an additional step.
Quoted 5 lines
We still are able to build libtracecmd as stand alone project. The top meson.build file just lives in the lib directory.
Signed-off-by Daniel Wagner <[email protected]>---
I forgot to mention last time, I hit this:
meson.build:79:11: ERROR: Unknown variable "conf10".
But I added this:
meson.build +1 -0
@@ -23,6 +23,7 @@ mandir = join_paths(prefixdir, get_option('mandir')) htmldir = join_paths(prefixdir, get_option('htmldir')) conf = configuration_data() +conf10 = configuration_data() libtraceevent_dep = dependency('libtraceevent', version: '>= 1.5.0', required: true) libtracefs_dep = dependency('libtracefs', version: '>= 1.6.0', required: true)
As a work around. But now I get this:
../tracecmd/trace-profile.c:13:10: fatal error: libaudit.h: No such file or directory
13 | #include <libaudit.h>
| ^~~~~~~~~~~~
We're missing the -DNO_AUDIT added when not there, as that file has:
#ifndef NO_AUDIT
#include <libaudit.h>
#endif
-- Steve
Re: [PATCH v2 2/2] trace-cmd: Add initial support for meson
Quoted 8 lines · On Fri, 23 Dec 2022 11:18:20 -0500 Steven Rostedt <[email protected]> wrote:
As a work around. But now I get this:
../tracecmd/trace-profile.c:13:10: fatal error:libaudit.h: No such file or directory
13 | #include <libaudit.h>| ^~~~~~~~~~~~We're missing the -DNO_AUDIT added when not there, as that file has:
I guess something like this is needed?
meson.build +6 -0
@@ -78,6 +79,12 @@ audit_dep = dependency('audit', required: false) 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?') + add_project_arguments( + [ + '-DNO_AUDIT' + ], + language : 'c', + ) endif config_h = configure_file(
-- Steve
Re: [PATCH v2 2/2] trace-cmd: Add initial support for meson
Quoted 5 lines · Steven Rostedt
Quoted 2 lines · On Fri, 23 Dec 2022 11:18:20 -0500 Steven Rostedt <[email protected]> wrote:
As a work around. But now I get this:
Quoted 8 lines
Quoted 6 lines
../tracecmd/trace-profile.c:13:10: fatal error:libaudit.h: No such file or directory
13 | #include <libaudit.h>| ^~~~~~~~~~~~We're missing the -DNO_AUDIT added when not there, as that file has:
I guess something like this is needed?
As we write the config.h file and include it via -I<path>/config.h per command line as it should be enough. I look into it why it doesn't work here.