Skip to contentSkip to conversation

libtracefs: Use explicit libtraceevent include path

RFC In review Daniel Wagner 2 participants 5 messages Jul 7, 2022 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

RFC 1/2 libtracefs: Use explicit libtraceevent include path

The libtraceevent pkg-config generated by meson is not adding the subdirectory to the CLFAGS. This is generally a good idea in order to avoid any file name collisions. Hence use explicit include paths for libtraceevent.

---
 include/tracefs.h     | 2 +-
 src/tracefs-events.c  | 2 +-
 src/tracefs-filter.c  | 2 +-
 src/tracefs-sqlhist.c | 2 +-
 src/tracefs-utils.c   | 4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)
include/tracefs.h +1 -1
index 693860d47a56..dd339464ca0e 100644
@@ -8,7 +8,7 @@
 
 #include <fcntl.h>
 #include <sched.h>
-#include <event-parse.h>
+#include <libtraceevent/event-parse.h>
 
 char *tracefs_get_tracing_file(const char *name);
 void tracefs_put_tracing_file(char *name);
src/tracefs-events.c +1 -1
index 65d5707362c6..ebff59e4cb7a 100644
@@ -15,7 +15,7 @@
 #include <fcntl.h>
 #include <limits.h>
 
-#include <kbuffer.h>
+#include <libtraceevent/kbuffer.h>
 
 #include "tracefs.h"
 #include "tracefs-local.h"
src/tracefs-filter.c +1 -1
index 85d0be17f6b7..cac4e255d7d4 100644
@@ -6,7 +6,7 @@
  * Copyright (C) 2021, VMware, Tzvetomir Stoyanov <[email protected]>
  *
  */
-#include <trace-seq.h>
+#include <libtraceevent/trace-seq.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <errno.h>
src/tracefs-sqlhist.c +1 -1
index 27c9c82647e4..fbdf29d5bebb 100644
@@ -6,7 +6,7 @@
  * Copyright (C) 2021, VMware, Tzvetomir Stoyanov <[email protected]>
  *
  */
-#include <trace-seq.h>
+#include <libtraceevent/trace-seq.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <ctype.h>
src/tracefs-utils.c +2 -2
index 22f82afe032b..c1260d3c7c8a 100644
@@ -15,8 +15,8 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include <event-parse.h>
-#include <event-utils.h>
+#include <libtraceevent/event-parse.h>
+#include <libtraceevent/event-utils.h>
 #include "tracefs.h"
 #include "tracefs-local.h"
 
Signature · 1 line
2.36.1
#1 lore raw

RFC 2/2 libtracefs: Add initial support for meson

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.

---
 include/meson.build |  9 ++++++++
 meson.build         | 32 +++++++++++++++++++++++++++
 src/meson.build     | 53 +++++++++++++++++++++++++++++++++++++++++++++
 utest/meson.build   | 14 ++++++++++++
 4 files changed, 108 insertions(+)
 create mode 100644 include/meson.build
 create mode 100644 meson.build
 create mode 100644 src/meson.build
 create mode 100644 utest/meson.build
include/meson.build new file +9 -0
new file mode 100644
index 000000000000..1bbfe8afb280
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+headers = [
+   'tracefs.h',
+]
+
+foreach h : headers
+	install_headers(h, subdir : 'libtracefs')
+endforeach
meson.build new file +32 -0
new file mode 100644
index 000000000000..2138d2f149f1
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+project(
+    'libtracefs', ['c'],
+    meson_version: '>= 0.47.0',
+    license: 'LGPL-2.1',
+    version: '1.4.0',
+    default_options: [
+      'c_std=gnu99',
+      'buildtype=release',
+      'prefix=/usr',
+      'warning_level=1',
+    ]
+)
+
+library_version = meson.project_version()
+
+libtraceevent_dep = dependency('libtraceevent', required: true)
+cunit_dep = dependency('cunit', required : false)
+
+add_project_arguments(
+    [
+      '-D_GNU_SOURCE',
+    ],
+    language : 'c',
+)
+
+incdir = include_directories(['include'])
+
+subdir('src')
+subdir('include')
+subdir('utest')
src/meson.build new file +53 -0

53 lines not on this page · raw message

utest/meson.build new file +14 -0
new file mode 100644
index 000000000000..07058afb5f9b
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1
+
+source = [
+    'trace-utest.c',
+    'tracefs-utest.c',
+]
+
+e = executable(
+   'trace-utest',
+   source,
+   include_directories: [incdir],
+   dependencies: [libtracefs_dep, libtraceevent_dep, cunit_dep])
+
+test('trace-utest', e)
Signature · 1 line
2.36.1
#2 lore raw
In reply to Daniel Wagner
Quoted 4 lines · On Thu, 7 Jul 2022 14:15:41 +0200 Daniel Wagner <[email protected]> wrote:

The libtraceevent pkg-config generated by meson is not adding the subdirectory to the CLFAGS. This is generally a good idea in order to avoid any file name collisions. Hence use explicit include paths for libtraceevent.

Is there a way to fix this. Honestly, I hate the libtraceevent name (should at least be traceevent), and I have been thinking of changing it.

If we do not have pkg-config working and everything needs to add explicit include paths, then I'll never be able to change it, or even just get rid of the subdirectory.

-- Steve

#3 lore raw
Quoted 10 lines · Steven Rostedt
Quoted 4 lines · On Thu, 7 Jul 2022 14:15:41 +0200 Daniel Wagner <[email protected]> wrote:

The libtraceevent pkg-config generated by meson is not adding the subdirectory to the CLFAGS. This is generally a good idea in order to avoid any file name collisions. Hence use explicit include paths for libtraceevent.

Is there a way to fix this. Honestly, I hate the libtraceevent name (should at least be traceevent), and I have been thinking of changing it.

I suppose we can change pkg-config so that the complete path is included, with the downside that file name collisions are more likely to happen. E.g. the kbuffer.h is very a generic name.

In libnvme/nvme-cli we had some troubles consuming libuuid because of inconsistent use of include paths. As far I can tell we just need to state what the correct includes paths are.

Quoted 3 lines

If we do not have pkg-config working and everything needs to add explicit include paths, then I'll never be able to change it, or even just get rid of the subdirectory.

I am not really expert how to structure the include paths. As said, I think the most important bit is that we use it consistent. Let me try to add the include path to pkg-config.

#4 lore raw
Quoted 9 lines · On Thu, 7 Jul 2022 16:07:23 +0200 Daniel Wagner <[email protected]> wrote:
Quoted 8 lines · Steven Rostedt
Quoted 4 lines · On Thu, 7 Jul 2022 14:15:41 +0200 Daniel Wagner <[email protected]> wrote:

The libtraceevent pkg-config generated by meson is not adding the subdirectory to the CLFAGS. This is generally a good idea in order to avoid any file name collisions. Hence use explicit include paths for libtraceevent.

Quoted 6 lines
Quoted 2 lines

Is there a way to fix this. Honestly, I hate the libtraceevent name (should at least be traceevent), and I have been thinking of changing it.

I suppose we can change pkg-config so that the complete path is included, with the downside that file name collisions are more likely to happen. E.g. the kbuffer.h is very a generic name.

Sorta-of ;-) That's actually the file I want to "claim" first!

Quoted 5 lines

In libnvme/nvme-cli we had some troubles consuming libuuid because of inconsistent use of include paths. As far I can tell we just need to state what the correct includes paths are.

Quoted 7 lines
Quoted 3 lines

If we do not have pkg-config working and everything needs to add explicit include paths, then I'll never be able to change it, or even just get rid of the subdirectory.

I am not really expert how to structure the include paths. As said, I think the most important bit is that we use it consistent. Let me try to add the include path to pkg-config.

Thanks,

-- Steve