From 469d54df5b4b067bbf84efeb7a67c578585b225f Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sat, 20 Jan 2018 01:30:39 -0800 Subject: [PATCH] build: add libsysprof-capture-2 static library This allows external tooling to write capture files that Sysprof can open. Ideally, this will get used by GJS in the near future to implement profiler output for Sysprof. --- lib/capture/meson.build | 2 ++ lib/meson.build | 26 +++++++++++++++++++++++-- lib/sysprof-capture.h | 42 +++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 2 +- tools/meson.build | 2 +- tools/sysprof-dump.c | 2 +- 6 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 lib/sysprof-capture.h diff --git a/lib/capture/meson.build b/lib/capture/meson.build index fa75fedf..7af1973b 100644 --- a/lib/capture/meson.build +++ b/lib/capture/meson.build @@ -16,5 +16,7 @@ capture_sources = [ libsysprof_headers += files(capture_headers) libsysprof_sources += files(capture_sources) +libsysprof_capture_sources += files(capture_sources) + install_headers(capture_headers, subdir: join_paths(libsysprof_header_subdir, 'capture')) diff --git a/lib/meson.build b/lib/meson.build index 2cff01b9..d02d9f3a 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -24,22 +24,27 @@ configure_file( libsysprof_base_headers = [ 'sysprof.h', + 'sysprof-capture.h', 'sp-address.h', 'sp-clock.h', 'sp-error.h', ] -libsysprof_headers = libsysprof_base_headers -libsysprof_sources = [ +libsysprof_base_sources = [ 'sp-address.c', 'sp-clock.c', 'sp-error.c', ] +libsysprof_headers = libsysprof_base_headers +libsysprof_sources = libsysprof_base_sources + libsysprof_ui_base_headers = ['sysprof-ui.h'] libsysprof_ui_headers = libsysprof_ui_base_headers libsysprof_ui_sources = [] +libsysprof_capture_sources = libsysprof_base_sources + subdir('callgraph') subdir('capture') subdir('profiler') @@ -51,6 +56,10 @@ subdir('widgets') cxx = meson.get_compiler('cpp') +libsysprof_capture_deps = [ + dependency('gobject-2.0'), +] + libsysprof_deps = [ cxx.find_library('stdc++'), dependency('gio-unix-2.0'), @@ -64,6 +73,13 @@ if get_option('with_sysprofd') != 'none' libsysprof_c_args += '-DENABLE_POLKIT' endif +libsysprof_capture = static_library('sysprof-capture-' + libsysprof_api_version, + libsysprof_capture_sources, + dependencies: libsysprof_capture_deps, + c_args: libsysprof_c_args, + install: true, +) + libsysprof = shared_library('sysprof-' + libsysprof_api_version, libsysprof_sources, dependencies: libsysprof_deps, @@ -79,6 +95,12 @@ libsysprof_dep = declare_dependency( dependencies: libsysprof_deps, ) +libsysprof_capture_dep = declare_dependency( + include_directories: include_directories('.'), + link_with: libsysprof_capture, + dependencies: libsysprof_capture_deps, +) + install_headers(libsysprof_base_headers, subdir: libsysprof_header_subdir) if get_option('enable_gtk') diff --git a/lib/sysprof-capture.h b/lib/sysprof-capture.h new file mode 100644 index 00000000..859f96bd --- /dev/null +++ b/lib/sysprof-capture.h @@ -0,0 +1,42 @@ +/* sysprof-capture.h + * + * Copyright © 2018 Christian Hergert + * + * This file is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef SYSPROF_CAPTURE_H +#define SYSPROF_CAPTURE_H + +#include + +G_BEGIN_DECLS + +#define SYSPROF_INSIDE + +# include "sp-address.h" +# include "sp-clock.h" +# include "sp-error.h" +# include "sysprof-version.h" + +# include "capture/sp-capture-condition.h" +# include "capture/sp-capture-cursor.h" +# include "capture/sp-capture-reader.h" +# include "capture/sp-capture-writer.h" + +#undef SYSPROF_INSIDE + +G_END_DECLS + +#endif /* SYSPROF_CAPTURE_H */ diff --git a/tests/meson.build b/tests/meson.build index 398d8c75..3b874186 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -8,7 +8,7 @@ test_env = [ test_capture = executable('test-capture', 'test-capture.c', - dependencies: libsysprof_dep, + dependencies: libsysprof_capture_dep, ) test('test-capture', test_capture, env: test_env) diff --git a/tools/meson.build b/tools/meson.build index f7900461..b0b17b5e 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -8,7 +8,7 @@ sysprof_cli = executable('sysprof-cli', sysprof_dump = executable('sysprof-dump', 'sysprof-dump.c', - dependencies: libsysprof_dep, + dependencies: libsysprof_capture_dep, c_args: exe_c_args, link_args: exe_link_args, ) diff --git a/tools/sysprof-dump.c b/tools/sysprof-dump.c index cf110a2f..2fdb4351 100644 --- a/tools/sysprof-dump.c +++ b/tools/sysprof-dump.c @@ -18,7 +18,7 @@ #include #include -#include +#include #define NSEC_PER_SEC G_GINT64_CONSTANT(1000000000)