linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] libtracefs: Add initial support for meson
@ 2022-12-28  8:29 Daniel Wagner
  2023-01-04 16:09 ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Wagner @ 2022-12-28  8:29 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: Steven Rostedt, Daniel Wagner

Introduce Meson as build framework for building libtracefs. This
lives besides the Makefiles until all the expected initial fallouts
have been dealed with.

The build steps are:

  # configure using .build as build directory and install destination
  # /tmp/test
  meson --prefix=/tmp/libtracefs .build

  # trigger the build
  ninja -C .build

  # install the library
  ninja -C .build install

In case you want to build/install the documentation the setup is

  meson -Ddocs-build=true .build

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---

I had to fallback to use a workaround to install the man pages to the
correct directory. Meson insistet to install them into subdirs and
failed to install them when I forced Meson not to do this. I am sure I
am doing something wrong but couldn't figure out what. I think
it's okay to use the workaround until we figured how to do this
'correct'.

Tested this by packaging it up for OpenSUSE and the it looks
reasonable:

https://build.opensuse.org/project/show/home:wagi:branches:devel:tools

 v5:
  - build unit test only if CUnit is found
  - default build target is debug
  - do not install man pages into subdirs
  - install sqlhist (because we install the man page too, so why not the tool?)
 
 v4:
  - add subdir include path to cflags in pkgconfg file
  - refactoring build instruction for section 1 and section 3 documentation
    into one loop (reduce code duplication)

 v3:
  - build documetation
  - build samples
  - set default location to /usr/local

 v2:
  - updated commit message
  - dropped the include path patch, the pkg-config
    from libtraceevent is including them

 v1:
  - initial version

 Documentation/install-man.sh.in |  15 +++
 Documentation/meson.build       | 177 ++++++++++++++++++++++++++++++++
 include/meson.build             |   9 ++
 meson.build                     |  50 +++++++++
 meson_options.txt               |  18 ++++
 samples/extract-example.sh      |   3 +
 samples/meson.build             |  46 +++++++++
 src/meson.build                 |  65 ++++++++++++
 utest/meson.build               |  17 +++
 9 files changed, 400 insertions(+)
 create mode 100755 Documentation/install-man.sh.in
 create mode 100644 Documentation/meson.build
 create mode 100644 include/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 samples/extract-example.sh
 create mode 100644 samples/meson.build
 create mode 100644 src/meson.build
 create mode 100644 utest/meson.build

diff --git a/Documentation/install-man.sh.in b/Documentation/install-man.sh.in
new file mode 100755
index 000000000000..8ab2cb982e1d
--- /dev/null
+++ b/Documentation/install-man.sh.in
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+for man in $(find @SRCDIR@ -name '*\.1' -type f); do
+    [ ! -d ${DESTDIR}/@MANDIR@/man1/ ] && install -d ${DESTDIR}/@MANDIR@/man1/
+
+    echo Installing $man to ${DESTDIR}/@MANDIR@/man1/
+    install -m 0644 $man ${DESTDIR}/@MANDIR@/man1/
+done
+
+for man in $(find @SRCDIR@ -name '*\.3' -type f); do
+    [ ! -d ${DESTDIR}/@MANDIR@/man3/ ] && install -d ${DESTDIR}/@MANDIR@/man3/
+
+    echo Installing $man to ${DESTDIR}/@MANDIR@/man3/
+    install -m 0644 $man ${DESTDIR}/@MANDIR@/man3/
+done
diff --git a/Documentation/meson.build b/Documentation/meson.build
new file mode 100644
index 000000000000..07ac222201b8
--- /dev/null
+++ b/Documentation/meson.build
@@ -0,0 +1,177 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+# input text file: man page section
+sources = {
+    'libtracefs-sqlhist.txt.1': '1',
+    'libtracefs-cpu-open.txt': '3',
+    'libtracefs-cpu.txt': '3',
+    'libtracefs-dynevents.txt': '3',
+    'libtracefs-eprobes.txt': '3',
+    'libtracefs-error.txt': '3',
+    'libtracefs-events-file.txt': '3',
+    'libtracefs-events-tep.txt': '3',
+    'libtracefs-events.txt': '3',
+    'libtracefs-files.txt': '3',
+    'libtracefs-filter.txt': '3',
+    'libtracefs-function-filter.txt': '3',
+    'libtracefs-hist-cont.txt': '3',
+    'libtracefs-hist-mod.txt': '3',
+    'libtracefs-hist.txt': '3',
+    'libtracefs-instances-affinity.txt': '3',
+    'libtracefs-instances-file-manip.txt': '3',
+    'libtracefs-instances-files.txt': '3',
+    'libtracefs-instances-manage.txt': '3',
+    'libtracefs-instances-utils.txt': '3',
+    'libtracefs-iterator.txt': '3',
+    'libtracefs-kprobes.txt': '3',
+    'libtracefs-log.txt': '3',
+    'libtracefs-marker_raw.txt': '3',
+    'libtracefs-marker.txt': '3',
+    'libtracefs-option-get.txt': '3',
+    'libtracefs-option-misc.txt': '3',
+    'libtracefs-options.txt': '3',
+    'libtracefs-sql.txt': '3',
+    'libtracefs-stream.txt': '3',
+    'libtracefs-synth2.txt': '3',
+    'libtracefs-synth-info.txt': '3',
+    'libtracefs-synth.txt': '3',
+    'libtracefs-traceon.txt': '3',
+    'libtracefs-tracer.txt': '3',
+    'libtracefs.txt': '3',
+    'libtracefs-uprobes.txt': '3',
+    'libtracefs-utils.txt': '3',
+}
+
+#
+# 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 txt, section : sources
+    # build man page(s)
+    xml = gen.process(txt)
+    man = custom_target(txt.underscorify() + '_man',
+                        input: xml,
+                        output: '@BASENAME@.' + section,
+                        command: [xmlto,
+                        '-m', manpage_xsl,
+                        'man',
+                        '-o', '@OUTPUT@']
+                        + xmlto_extra
+                        + ['@INPUT@'],
+                        build_by_default : true)
+
+    # build html pages
+    custom_target(
+       txt.underscorify() + '_html',
+       input: txt,
+       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
+
+# Install path workaround because:
+#
+# - xmlto might generate more than one file and we would to tell meson
+#   about those output files. We could figure out which files are generated
+#   (see sed match in check-manpages.sh).
+#
+# - The man page generation puts all the generated files under sub dirs
+#   and it's not obvious how to tell Meson it should not do this without
+#   causing the install step to fail (confusion where the generated files
+#   are stored)
+#
+# Thus just use a plain old shell script to move the generated files to the
+# right location.
+
+conf = configuration_data()
+conf.set('SRCDIR', meson.current_build_dir())
+conf.set('MANDIR', mandir)
+configure_file(
+    input:         'install-man.sh.in',
+    output:        'install-man.sh',
+    configuration: conf,
+)
+
+meson.add_install_script(
+    join_paths(meson.current_build_dir(), 'install-man.sh'))
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 000000000000..1bbfe8afb280
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+headers = [
+   'tracefs.h',
+]
+
+foreach h : headers
+	install_headers(h, subdir : 'libtracefs')
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 000000000000..1ef7969d655a
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+project(
+    'libtracefs', ['c'],
+    meson_version: '>= 0.50.0',
+    license: 'LGPL-2.1',
+    version: '1.6.3',
+    default_options: [
+      'c_std=gnu99',
+      'buildtype=debug',
+      'prefix=/usr/local',
+      'warning_level=1',
+    ]
+)
+
+library_version = meson.project_version()
+
+libtraceevent_dep = dependency('libtraceevent', version: '>= 1.7.0', required: true)
+cunit_dep = dependency('cunit', required : false)
+
+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'))
+
+add_project_arguments(
+    [
+      '-D_GNU_SOURCE',
+    ],
+    language : 'c',
+)
+
+incdir = include_directories(['include'])
+
+subdir('src')
+subdir('include')
+if cunit_dep.found()
+    subdir('utest')
+endif
+subdir('samples')
+if get_option('docs-build')
+    custom_target('check-doc',
+                   output: 'dummy',
+                   command : ['check-manpages.sh',
+                              meson.current_source_dir() + '/Documentation'],
+	           build_by_default : true)
+    subdir('Documentation')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 000000000000..9bcd66f49f06
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+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/samples/extract-example.sh b/samples/extract-example.sh
new file mode 100644
index 000000000000..c5c0f702e7f0
--- /dev/null
+++ b/samples/extract-example.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+cat $1 | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ;  /^--/d ; p}' > $2
diff --git a/samples/meson.build b/samples/meson.build
new file mode 100644
index 000000000000..0c36231ef29a
--- /dev/null
+++ b/samples/meson.build
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+examples = [
+    'dynevents',
+    'kprobes',
+    'eprobes',
+    'uprobes',
+    'synth',
+    'error',
+    'filter',
+    'function-filter',
+    'hist',
+    'hist-cont',
+    'tracer',
+    'stream',
+    'instances-affinity',
+    'cpu',
+]
+
+extract_examples = find_program('extract-example.sh')
+gen = generator(extract_examples,
+                output: '@BASENAME@.c',
+                arguments: ['@INPUT@', '@OUTPUT@'])
+
+foreach ex : examples
+    src = gen.process(meson.current_source_dir() + '/../Documentation/libtracefs-@0@.txt'.format(ex))
+    executable(
+        ex.underscorify(),
+        src,
+        dependencies: [libtracefs_dep, libtraceevent_dep],
+        include_directories: [incdir]
+     )
+endforeach
+
+# sqlhist is unique and stands on its own
+src = gen.process(meson.current_source_dir() + '/../Documentation/libtracefs-sql.txt')
+executable(
+   'sqlhist',
+   src,
+   dependencies: [libtracefs_dep, libtraceevent_dep],
+   include_directories: [incdir],
+   install: true,
+   install_dir: bindir,
+)
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 000000000000..43139b6de268
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+sources= [
+   'tracefs-dynevents.c',
+   'tracefs-eprobes.c',
+   'tracefs-events.c',
+   'tracefs-filter.c',
+   'tracefs-hist.c',
+   'tracefs-instance.c',
+   'tracefs-kprobes.c',
+   'tracefs-marker.c',
+   'tracefs-record.c',
+   'tracefs-sqlhist.c',
+   'tracefs-tools.c',
+   'tracefs-uprobes.c',
+   'tracefs-utils.c',
+]
+
+flex = find_program('flex', required: true)
+bison = find_program('bison', required: true)
+
+lgen = generator(flex,
+output : '@PLAINNAME@.yy.c',
+arguments : ['-o', '@OUTPUT@', '@INPUT@'])
+
+pgen = generator(bison,
+output : ['@BASENAME@.tab.c', '@BASENAME@.tab.h'],
+arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'])
+
+lfiles = lgen.process('sqlhist.l')
+pfiles = pgen.process('sqlhist.y')
+
+libtracefs = library(
+    'tracefs',
+    sources, lfiles, pfiles,
+    version: library_version,
+    dependencies: [libtraceevent_dep],
+    include_directories: [incdir],
+    install: true,
+)
+
+libtracefs_static = static_library(
+    'tracefs_static',
+    sources, lfiles, pfiles,
+    dependencies: [libtraceevent_dep],
+    include_directories: [incdir],
+    install: false,
+)
+
+pkg = import('pkgconfig')
+pkg.generate(libtracefs,
+    subdirs: 'libtracefs',
+    filebase: meson.project_name(),
+    name: meson.project_name(),
+    version: meson.project_version(),
+    description: 'Manage trace fs',
+    url: 'https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/',
+)
+
+libtracefs_dep = declare_dependency(
+    include_directories: ['.'],
+    link_with: libtracefs,
+)
diff --git a/utest/meson.build b/utest/meson.build
new file mode 100644
index 000000000000..8c8caf37803d
--- /dev/null
+++ b/utest/meson.build
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: LGPL-2.1
+#
+# Copyright (c) 2022 Daniel Wagner, SUSE LLC
+
+source = [
+    'trace-utest.c',
+    'tracefs-utest.c',
+]
+
+e = executable(
+   'trace-utest',
+   source,
+   include_directories: [incdir],
+   dependencies: [libtraceevent_dep, cunit_dep],
+   link_with: libtracefs_static)
+
+test('trace-utest', e)
-- 
2.39.0


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

* Re: [PATCH v5] libtracefs: Add initial support for meson
  2022-12-28  8:29 [PATCH v5] libtracefs: Add initial support for meson Daniel Wagner
@ 2023-01-04 16:09 ` Steven Rostedt
  2023-01-04 17:19   ` Daniel Wagner
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2023-01-04 16:09 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-trace-devel

On Wed, 28 Dec 2022 09:29:27 +0100
Daniel Wagner <dwagner@suse.de> wrote:

> Introduce Meson as build framework for building libtracefs. This
> lives besides the Makefiles until all the expected initial fallouts
> have been dealed with.
> 
> The build steps are:
> 
>   # configure using .build as build directory and install destination
>   # /tmp/test
>   meson --prefix=/tmp/libtracefs .build
> 
>   # trigger the build
>   ninja -C .build
> 
>   # install the library
>   ninja -C .build install
> 
> In case you want to build/install the documentation the setup is
> 
>   meson -Ddocs-build=true .build
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>

This also doesn't build the static library libtracefs.a.

We have environments that we need to build trace-cmd statically. As
trace-cmd depends on libtraceevent and libtracefs, that means both need a
static library as well.

-- Steve

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

* Re: [PATCH v5] libtracefs: Add initial support for meson
  2023-01-04 16:09 ` Steven Rostedt
@ 2023-01-04 17:19   ` Daniel Wagner
  2023-01-04 17:44     ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Wagner @ 2023-01-04 17:19 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel

On Wed, Jan 04, 2023 at 11:09:16AM -0500, Steven Rostedt wrote:
 This also doesn't build the static library libtracefs.a.
> 
> We have environments that we need to build trace-cmd statically. As
> trace-cmd depends on libtraceevent and libtracefs, that means both need a
> static library as well.

Configure the build with

  'meson setup .build --default-library=both'

Though, we could add libtraceevent and libracefs as subprojects to trace-cmd
which avoids all the hassle to install libtraceevent and libtracefs
independenly from trace-cmd. It also takes care of all the dependency
setup. Basically with


  'meson setup .build --wrap-mode=forcefallback'

in trace-cmd meson would download, setup and build libtraceevent and libtracefs
within the trace-cmd build. This is makes the whole development process
between these project way smoother. And if you would configure the build
with

  'meson setup .build --wrap-mode=forcefallback --default-library=static'

would staticly link all subprojects into the trace-cmd binary.

I haven't added this part to the initial mesonizing of the projects. Keep
things simple to begin with.

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

* Re: [PATCH v5] libtracefs: Add initial support for meson
  2023-01-04 17:19   ` Daniel Wagner
@ 2023-01-04 17:44     ` Steven Rostedt
  2023-01-05  7:18       ` Daniel Wagner
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2023-01-04 17:44 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-trace-devel

On Wed, 4 Jan 2023 18:19:39 +0100
Daniel Wagner <dwagner@suse.de> wrote:

> On Wed, Jan 04, 2023 at 11:09:16AM -0500, Steven Rostedt wrote:
>  This also doesn't build the static library libtracefs.a.
> > 
> > We have environments that we need to build trace-cmd statically. As
> > trace-cmd depends on libtraceevent and libtracefs, that means both need a
> > static library as well.  
> 
> Configure the build with
> 
>   'meson setup .build --default-library=both'
> 
> Though, we could add libtraceevent and libracefs as subprojects to trace-cmd
> which avoids all the hassle to install libtraceevent and libtracefs
> independenly from trace-cmd. It also takes care of all the dependency
> setup. Basically with
> 
> 
>   'meson setup .build --wrap-mode=forcefallback'
> 
> in trace-cmd meson would download, setup and build libtraceevent and libtracefs
> within the trace-cmd build. This is makes the whole development process
> between these project way smoother. And if you would configure the build
> with

I'm not sure that would make it easier for me. I work on each separately.
And I don't always want them linked together, but sometimes I do! To
control what gets linked to trace-cmd, I use dynamic libraries, and only
install what I want to use there. That is, they really are three different
projects! I use libtracefs on several other tools, not just trace-cmd.

> 
>   'meson setup .build --wrap-mode=forcefallback --default-library=static'
> 
> would staticly link all subprojects into the trace-cmd binary.
> 
> I haven't added this part to the initial mesonizing of the projects. Keep
> things simple to begin with.

For the environment that we require a static build, that isn't really
needed. It would only make the initial setup easier, but that's a one time
deal. After that, everything is automated.

-- Steve

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

* Re: [PATCH v5] libtracefs: Add initial support for meson
  2023-01-04 17:44     ` Steven Rostedt
@ 2023-01-05  7:18       ` Daniel Wagner
  2023-01-05 13:51         ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Wagner @ 2023-01-05  7:18 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel

On Wed, Jan 04, 2023 at 12:44:14PM -0500, Steven Rostedt wrote:
> On Wed, 4 Jan 2023 18:19:39 +0100
> Daniel Wagner <dwagner@suse.de> wrote:
 > setup. Basically with
> > 
> > 
> >   'meson setup .build --wrap-mode=forcefallback'
> > 
> > in trace-cmd meson would download, setup and build libtraceevent and libtracefs
> > within the trace-cmd build. This is makes the whole development process
> > between these project way smoother. And if you would configure the build
> > with
> 
> I'm not sure that would make it easier for me. I work on each separately.
> And I don't always want them linked together, but sometimes I do!

Meson doesn't force you here how you prefer you workflow. If you want to
stick with your development steps all should be fine. I just recommend to give
those subproject a try. IMO it makes things simpler, e.g. building all code in
debug mode and being able to single step through is nice. And if you find a bug
or want to change a line in the libraries, just change the line recompile the
main project and that's all. No installing or fiddling with some $PATHs. All works
out of the box.

> To
> control what gets linked to trace-cmd, I use dynamic libraries, and only
> install what I want to use there. That is, they really are three different
> projects! I use libtracefs on several other tools, not just trace-cmd.

Depending on the default settings, the libraries are either dynamically or
statically linked. Meson takes care of all those path issues. For example for
the nmve-cli project I have following linking situation:

$ ldd .build/nvme
        linux-vdso.so.1 (0x00007ffd9975f000)
        libnvme.so.1 => /home/wagi/work/nvme-cli/.build/subprojects/libnvme/src/libnvme.so.1 (0x00007fb934141000)
        libnvme-mi.so.1 => /home/wagi/work/nvme-cli/.build/subprojects/libnvme/src/libnvme-mi.so.1 (0x00007fb934135000)
        libjson-c.so.5 => /lib64/libjson-c.so.5 (0x00007fb9340fe000)
        libz.so.1 => /lib64/libz.so.1 (0x00007fb9340e2000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fb933ee7000)
        libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007fb933a00000)
        libdbus-1.so.3 => /lib64/libdbus-1.so.3 (0x00007fb933e94000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fb934169000)
        libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007fb93392e000)
        libcap.so.2 => /lib64/libcap.so.2 (0x00007fb933e88000)
        libgcrypt.so.20 => /lib64/libgcrypt.so.20 (0x00007fb9337e5000)
        liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fb933e54000)
        libzstd.so.1 => /lib64/libzstd.so.1 (0x00007fb933733000)
        liblz4.so.1 => /lib64/liblz4.so.1 (0x00007fb93370f000)
        libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007fb9336e9000)

In this scenario libnvme is linked in as dynamic library.

> >   'meson setup .build --wrap-mode=forcefallback --default-library=static'
> > 
> > would staticly link all subprojects into the trace-cmd binary.
> > 
> > I haven't added this part to the initial mesonizing of the projects. Keep
> > things simple to begin with.
> 
> For the environment that we require a static build, that isn't really
> needed. It would only make the initial setup easier, but that's a one time
> deal. After that, everything is automated.

Before you spend too much time in writing scripts aroudn Meson, you should
really have a look at subproject. You get the dependencies management for little
costs.

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

* Re: [PATCH v5] libtracefs: Add initial support for meson
  2023-01-05  7:18       ` Daniel Wagner
@ 2023-01-05 13:51         ` Steven Rostedt
  2023-01-05 14:41           ` Daniel Wagner
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2023-01-05 13:51 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: linux-trace-devel

On Thu, 5 Jan 2023 08:18:51 +0100
Daniel Wagner <dwagner@suse.de> wrote:

> On Wed, Jan 04, 2023 at 12:44:14PM -0500, Steven Rostedt wrote:
> > On Wed, 4 Jan 2023 18:19:39 +0100
> > Daniel Wagner <dwagner@suse.de> wrote:
>  > setup. Basically with  
> > > 
> > > 
> > >   'meson setup .build --wrap-mode=forcefallback'
> > > 
> > > in trace-cmd meson would download, setup and build libtraceevent and libtracefs
> > > within the trace-cmd build. This is makes the whole development process
> > > between these project way smoother. And if you would configure the build
> > > with  
> > 
> > I'm not sure that would make it easier for me. I work on each separately.
> > And I don't always want them linked together, but sometimes I do!  
> 
> Meson doesn't force you here how you prefer you workflow. If you want to
> stick with your development steps all should be fine. I just recommend to give
> those subproject a try. IMO it makes things simpler, e.g. building all code in
> debug mode and being able to single step through is nice. And if you find a bug
> or want to change a line in the libraries, just change the line recompile the
> main project and that's all. No installing or fiddling with some $PATHs. All works
> out of the box.

I get that now with my current setup. I only install with debug options,
and use gdb in emacs. It walks through the library code, and will go into
different paths automatically. I only need to install the code I change
(sure, I need to go into that path to do so). But as I've been using
libtracefs and libtraceevent for other tooling, I really don't want it part
of the trace-cmd repo, or in the build path.

> 
> > For the environment that we require a static build, that isn't really
> > needed. It would only make the initial setup easier, but that's a one time
> > deal. After that, everything is automated.  
> 
> Before you spend too much time in writing scripts aroudn Meson, you should
> really have a look at subproject. You get the dependencies management for little
> costs.

The above mentioned static environment build is done via portage.

-- Steve

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

* Re: [PATCH v5] libtracefs: Add initial support for meson
  2023-01-05 13:51         ` Steven Rostedt
@ 2023-01-05 14:41           ` Daniel Wagner
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2023-01-05 14:41 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel

> > Meson doesn't force you here how you prefer you workflow. If you want to
> > stick with your development steps all should be fine. I just recommend to give
> > those subproject a try. IMO it makes things simpler, e.g. building all code in
> > debug mode and being able to single step through is nice. And if you find a bug
> > or want to change a line in the libraries, just change the line recompile the
> > main project and that's all. No installing or fiddling with some $PATHs. All works
> > out of the box.
> 
> I get that now with my current setup. I only install with debug options,
> and use gdb in emacs. It walks through the library code, and will go into
> different paths automatically. I only need to install the code I change
> (sure, I need to go into that path to do so). But as I've been using
> libtracefs and libtraceevent for other tooling, I really don't want it part
> of the trace-cmd repo, or in the build path.

Right, in this case I should avoid breaking your working setup :) Anyway, let's
get first the initial setup working before doing fancy stuff.

> > > For the environment that we require a static build, that isn't really
> > > needed. It would only make the initial setup easier, but that's a one time
> > > deal. After that, everything is automated.  
> > 
> > Before you spend too much time in writing scripts aroudn Meson, you should
> > really have a look at subproject. You get the dependencies management for little
> > costs.
> 
> The above mentioned static environment build is done via portage.

I've build the openSUSE packages using with Meson (just exchanged the build
instruction) and the tools didn't complain. So I think most of the problems
should be resolved. But experience tells me, there is always one bug more.

Daniel

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

end of thread, other threads:[~2023-01-05 14:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-28  8:29 [PATCH v5] libtracefs: Add initial support for meson Daniel Wagner
2023-01-04 16:09 ` Steven Rostedt
2023-01-04 17:19   ` Daniel Wagner
2023-01-04 17:44     ` Steven Rostedt
2023-01-05  7:18       ` Daniel Wagner
2023-01-05 13:51         ` Steven Rostedt
2023-01-05 14:41           ` Daniel Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).