* [RFC v1] libtraceevent: Add initial support for meson
@ 2022-07-07 12:14 Daniel Wagner
2022-07-07 13:44 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Wagner @ 2022-07-07 12:14 UTC (permalink / raw)
To: linux-trace-users; +Cc: Daniel Wagner
Add support for building the project with meson. It's not complete
yet, for example building and installing the documentation is missing.
The rest should work as expected. The only thing I was not really
clear what the purpose is the libtraceevent-dynamic-list which seems
not be used or installed. The meson build will also generate the file
but using the host nm and not the cross tool chain if any is used. I
didn't want to invest too much time figuring out this detail if it is
actually not used.
Obviously, meson is not make and there are some changes in how to use
this build system. The meson documentation is outstanding good and
usually has good tips and tricks to solve problems. But sure there is
learning curve but hopefully not so step.
Anyway, as pure user the build steps are (in source tree builds are
not supported):
# configure using .build as build directory and install destination
# /tmp/test
meson .build --prefix=/tmp/test
# trigger the build
ninja -C .build
# install the library
ninja -C .build install
I am using an alias for 'ninja -C .build' which is called 'ni'. This
makes way more convenient to use.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
include/traceevent/meson.build | 12 ++++++++++
meson.build | 38 ++++++++++++++++++++++++++++++++
meson_options.txt | 2 ++
plugins/dynamic_list.sh | 14 ++++++++++++
plugins/meson.build | 40 ++++++++++++++++++++++++++++++++++
src/meson.build | 34 +++++++++++++++++++++++++++++
utest/meson.build | 14 ++++++++++++
7 files changed, 154 insertions(+)
create mode 100644 include/traceevent/meson.build
create mode 100644 meson.build
create mode 100644 meson_options.txt
create mode 100755 plugins/dynamic_list.sh
create mode 100644 plugins/meson.build
create mode 100644 src/meson.build
create mode 100644 utest/meson.build
diff --git a/include/traceevent/meson.build b/include/traceevent/meson.build
new file mode 100644
index 000000000000..7be88bf3ab47
--- /dev/null
+++ b/include/traceevent/meson.build
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+headers = [
+ 'event-parse.h',
+ 'event-utils.h',
+ 'kbuffer.h',
+ 'trace-seq.h',
+]
+
+foreach h : headers
+ install_headers(h, subdir : 'libtraceevent')
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 000000000000..ef27a12fe76a
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+project(
+ 'libtraceevent', ['c'],
+ meson_version: '>= 0.47.0',
+ license: 'LGPL-2.1',
+ version: '1.5.3',
+ default_options: [
+ 'c_std=gnu99',
+ 'buildtype=release',
+ 'prefix=/usr',
+ 'warning_level=1',
+ ]
+)
+
+library_version = meson.project_version()
+
+cunit_dep = dependency('cunit', required : false)
+
+prefixdir = get_option('prefix')
+libdir = join_paths(prefixdir, get_option('libdir'))
+
+plugindir = get_option('plugindir') == '' ? join_paths(libdir, 'libtraceevent/plugins') : get_option('plugindir')
+
+add_project_arguments(
+ [
+ '-D_GNU_SOURCE',
+ '-DPLUGIN_DIR="@0@"'.format(plugindir),
+ ],
+ language : 'c',
+)
+
+incdir = include_directories(['include', 'include/traceevent'])
+
+subdir('src')
+subdir('include/traceevent')
+subdir('plugins')
+subdir('utest')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 000000000000..ee52f11799dd
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: LGPL-2.1
+option('plugindir', type : 'string', description : 'set the plugin dir')
diff --git a/plugins/dynamic_list.sh b/plugins/dynamic_list.sh
new file mode 100755
index 000000000000..e1480eaa694f
--- /dev/null
+++ b/plugins/dynamic_list.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# SPDX-License-Identifier: LGPL-2.1
+
+symbol_type=$(nm -u -D $@ | awk 'NF>1 {print $1}' | xargs echo "U w W" |
+ tr 'w ' 'W\n' | sort -u | xargs echo)
+
+if [ "$symbol_type" = "U W" ]; then
+ echo '{'
+
+ nm -u -D $@ | awk 'NF>1 {sub("@.*", "", $2); print "\t"$2";"}' |
+ sort -u
+
+ echo '};'
+fi
diff --git a/plugins/meson.build b/plugins/meson.build
new file mode 100644
index 000000000000..659f864581d0
--- /dev/null
+++ b/plugins/meson.build
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+plugins = [
+ 'plugin_jbd2.c',
+ 'plugin_hrtimer.c',
+ 'plugin_kmem.c',
+ 'plugin_kvm.c',
+ 'plugin_mac80211.c',
+ 'plugin_sched_switch.c',
+ 'plugin_function.c',
+ 'plugin_futex.c',
+ 'plugin_xen.c',
+ 'plugin_scsi.c',
+ 'plugin_cfg80211.c',
+ 'plugin_tlb.c',
+]
+
+pdeps = []
+foreach plugin : plugins
+ pdeps += library(
+ plugin.replace('.c', ''),
+ plugin,
+ name_prefix: '',
+ version: library_version,
+ dependencies: [libtraceevent_dep],
+ include_directories: [incdir],
+ install: true,
+ install_dir: plugindir)
+endforeach
+
+# not used?
+dynamic_list_file = find_program('dynamic_list.sh')
+custom_target(
+ 'dynamic_list',
+ depends: pdeps,
+ input: pdeps,
+ output: 'libtraceevent-dynamic-list',
+ command: [dynamic_list_file, '@INPUT@'],
+ capture: true,
+ build_by_default: true)
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 000000000000..20c1876b3e2d
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+sources= [
+ 'event-parse-api.c',
+ 'event-parse.c',
+ 'event-plugin.c',
+ 'kbuffer-parse.c',
+ 'parse-filter.c',
+ 'parse-utils.c',
+ 'tep_strerror.c',
+ 'trace-seq.c',
+]
+
+libtraceevent = library(
+ 'traceevent',
+ sources,
+ version: library_version,
+ include_directories: [incdir],
+ install: true,
+)
+
+pkg = import('pkgconfig')
+pkg.generate(libtraceevent,
+ filebase: meson.project_name(),
+ name: meson.project_name(),
+ version: meson.project_version(),
+ description: 'Manage trace evevent',
+ url: 'https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/',
+)
+
+libtraceevent_dep = declare_dependency(
+ include_directories: ['.'],
+ link_with: libtraceevent,
+)
diff --git a/utest/meson.build b/utest/meson.build
new file mode 100644
index 000000000000..e6ad5b50e9be
--- /dev/null
+++ b/utest/meson.build
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+source = [
+ 'trace-utest.c',
+ 'traceevent-utest.c',
+]
+
+e = executable(
+ 'trace-utest',
+ source,
+ include_directories: [incdir],
+ dependencies: [libtraceevent_dep, cunit_dep])
+
+test('trace-utest', e)
--
2.36.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC v1] libtraceevent: Add initial support for meson
2022-07-07 12:14 [RFC v1] libtraceevent: Add initial support for meson Daniel Wagner
@ 2022-07-07 13:44 ` Steven Rostedt
2022-07-07 14:01 ` Daniel Wagner
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2022-07-07 13:44 UTC (permalink / raw)
To: Daniel Wagner; +Cc: linux-trace-users
On Thu, 7 Jul 2022 14:14:40 +0200
Daniel Wagner <dwagner@suse.de> wrote:
> The rest should work as expected. The only thing I was not really
> clear what the purpose is the libtraceevent-dynamic-list which seems
> not be used or installed. The meson build will also generate the file
> but using the host nm and not the cross tool chain if any is used. I
> didn't want to invest too much time figuring out this detail if it is
> actually not used.
Hi Daniel,
Thanks for doing this. Hopefully I'll get some time to try it out.
Anyway, as for the libtraceevent-dynamic-list, it was brought over from the
kernel tools/lib directory. I guess it is needed for the plugins to work
properly, although I have not had issues with it.
But if you want to know more, see commit e3d09ec8126fe ("tools lib
traceevent: Export dynamic symbols used by traceevent plugins") in the
Linux kernel source.
-- Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC v1] libtraceevent: Add initial support for meson
2022-07-07 13:44 ` Steven Rostedt
@ 2022-07-07 14:01 ` Daniel Wagner
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Wagner @ 2022-07-07 14:01 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-trace-users
On Thu, Jul 07, 2022 at 09:44:22AM -0400, Steven Rostedt wrote:
> Thanks for doing this. Hopefully I'll get some time to try it out.
Cool, let me know if you need any help. There are some (low) hurdles to
jump over but nothing serious IMO.
> Anyway, as for the libtraceevent-dynamic-list, it was brought over from the
> kernel tools/lib directory. I guess it is needed for the plugins to work
> properly, although I have not had issues with it.
The current Makefile doesn't install it nor use it in anyway. Chances
are no one is using it. Also looking at the content shows a handful of
symbols which shouldn't be there:
{
free;
memcpy;
memset;
realloc;
sprintf;
strcmp;
strdup;
strncmp;
tep_find_any_field;
tep_find_field;
tep_find_function;
...
};
> But if you want to know more, see commit e3d09ec8126fe ("tools lib
> traceevent: Export dynamic symbols used by traceevent plugins") in the
> Linux kernel source.
Well, if this is a use case which needs to be supported we might need to
figure out how to get a correct export map. In a different project we
currently maintain the map file manual with the usual problems of
syncing up the *.c files and the map file. I was thinking about
introducing a macro like the ones in the kernel *_EXPORT from which the
map file is generated. Just as idea.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-07 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 12:14 [RFC v1] libtraceevent: Add initial support for meson Daniel Wagner
2022-07-07 13:44 ` Steven Rostedt
2022-07-07 14:01 ` 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).