libtracefs: Add initial support for meson
RFC v2 1/1 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.
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.
---
v2:
- updated commit message
- dropped the include path patch, the pkg-config
from libtraceevent is including them
v1:
- initial version
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
@@ -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
@@ -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
@@ -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
Quoted 74 lines · On Thu, 7 Jul 2022 16:27:44 +0200 Daniel Wagner <[email protected]> wrote:
Add support for building the project with meson. It's not complete yet, for example building and installing the documentation is missing.
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 installI am using an alias for 'ninja -C .build' which is called 'ni'. This makes way more convenient to use.
Signed-off-by Daniel Wagner <[email protected]>---
v2:
- updated commit message
- dropped the include path patch, the pkg-config
from libtraceevent is including themv1:
- initial versioninclude/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.buildinclude/meson.build new file +9
-0@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1 + +headers = [ + 'tracefs.h', +] + +foreach h : headers + install_headers(h, subdir : 'libtracefs') +endforeachmeson.build new file +8
-0@@ -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: [
meson.build line 18
Quoted 10 lines
meson.build new file +10
-0+ 'c_std=gnu99', + 'buildtype=release', + 'prefix=/usr', + 'warning_level=1', + ] +) + +library_version = meson.project_version() + +libtraceevent_dep = dependency('libtraceevent', required: true)
Can the dependency also include a version? It will be needed here and in trace-cmd.
-- Steve
Quoted 93 lines
meson.build new file +14
-0+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@@ -0,0 +1,53 @@ +# SPDX-License-Identifier: LGPL-2.1 + +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-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 : '@[email protected]', +arguments : ['-o', '@OUTPUT@', '@INPUT@']) + +pgen = generator(bison, +output : ['@[email protected]', '@[email protected]'], +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, +) + +pkg = import('pkgconfig') +pkg.generate(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, +)utest/meson.build new file +14
-0@@ -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)
Quoted 4 lines · Steven Rostedt
Quoted 1 line
+libtraceevent_dep =
dependency('libtraceevent', required: true)Can the dependency also include a version? It will be needed here and in trace-cmd.
Sure, that is no problem, e.g.
libtraceevent_dep = dependency('libtraceevent',
version: '1.3',
required: true)