From 24b876f43711b148a0f8b805e491f014b10876d3 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 25 May 2023 15:43:53 -0700 Subject: [PATCH] libsysprof-profile: stub out libsysprof-profile library This does the same thing as we did for libsysprof-analyze, but to contain the profiler bits that will be used from applications/etc. --- meson.build | 5 ++ src/libsysprof-profile/meson.build | 61 ++++++++++++++++++++++++ src/libsysprof-profile/sysprof-profile.h | 28 +++++++++++ src/libsysprof-profile/tests/meson.build | 0 src/meson.build | 13 ++++- 5 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/libsysprof-profile/meson.build create mode 100644 src/libsysprof-profile/sysprof-profile.h create mode 100644 src/libsysprof-profile/tests/meson.build diff --git a/meson.build b/meson.build index 56045b75..dfe65e1b 100644 --- a/meson.build +++ b/meson.build @@ -41,6 +41,11 @@ need_glib = (need_gtk or get_option('sysprofd') != 'none' or get_option('agent')) +# Determine what libraries to build +need_libsysprof_capture = true +need_libsysprof_profile = get_option('libsysprof') or get_option('agent') +need_libsysprof_analyze = get_option('libsysprof') or get_option('agent') + glib_req = '2.76.0' gtk_req = '4.10' polkit_req = '0.105' diff --git a/src/libsysprof-profile/meson.build b/src/libsysprof-profile/meson.build new file mode 100644 index 00000000..8d414a74 --- /dev/null +++ b/src/libsysprof-profile/meson.build @@ -0,0 +1,61 @@ +libsysprof_profile_public_sources = [ +] + +libsysprof_profile_private_sources = [ +] + +libsysprof_profile_public_headers = [ + 'sysprof-profile.h', +] + +libsysprof_profile_deps = [ + dependency('gio-2.0', version: glib_req_version), + + libsysprof_capture_dep, +] + +libsysprof_profile_static = static_library( + 'sysprof-profile-@0@'.format(soname_major_version), + libsysprof_profile_public_sources + + libsysprof_profile_private_sources, + + include_directories: [include_directories('.'), + ipc_include_dirs, + libsysprof_capture_include_dirs], + dependencies: libsysprof_profile_deps, + gnu_symbol_visibility: 'hidden', +) + +libsysprof_profile_static_dep = declare_dependency( + link_with: libsysprof_profile_static, + dependencies: libsysprof_profile_deps, + include_directories: [include_directories('.'), + libsysprof_capture_include_dirs], +) + +libsysprof_profile = library('sysprof-profile-@0@'.format(soname_major_version), + dependencies: [libsysprof_profile_static_dep], + gnu_symbol_visibility: 'hidden', + version: '@0@.0.0'.format(soname_major_version), + darwin_versions: '@0@.0'.format(soname_major_version), + install: true, +) + +libsysprof_profile_dep = declare_dependency( + link_with: libsysprof_profile, + dependencies: libsysprof_profile_deps, + include_directories: [include_directories('.'), libsysprof_capture_include_dirs], +) +meson.override_dependency('sysprof-profile-@0@'.format(soname_major_version), libsysprof_profile_dep) + +pkgconfig.generate(libsysprof_profile, + subdirs: [sysprof_header_subdir], + description: 'A library for recording profiles using various instruments', + install_dir: join_paths(get_option('libdir'), 'pkgconfig'), + requires: ['gio-2.0'], + variables: ['datadir=' + datadir_for_pc_file], +) + +install_headers(libsysprof_profile_public_headers, subdir: sysprof_header_subdir) + +subdir('tests') diff --git a/src/libsysprof-profile/sysprof-profile.h b/src/libsysprof-profile/sysprof-profile.h new file mode 100644 index 00000000..8b2c7af7 --- /dev/null +++ b/src/libsysprof-profile/sysprof-profile.h @@ -0,0 +1,28 @@ +/* sysprof-profile.h + * + * Copyright 2023 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +G_BEGIN_DECLS + +#define SYSPROF_PROFILE_INSIDE +#undef SYSPROF_PROFILE_INSIDE + +G_END_DECLS diff --git a/src/libsysprof-profile/tests/meson.build b/src/libsysprof-profile/tests/meson.build new file mode 100644 index 00000000..e69de29b diff --git a/src/meson.build b/src/meson.build index a74f2754..c735b46c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -54,8 +54,17 @@ stackstash_sources = files('stackstash.c') helpers_sources = files('helpers.c') -subdir('libsysprof-capture') -subdir('libsysprof-analyze') +if need_libsysprof_capture + subdir('libsysprof-capture') +endif + +if need_libsysprof_analyze + subdir('libsysprof-analyze') +endif + +if need_libsysprof_profile + subdir('libsysprof-profile') +endif if get_option('sysprofd') == 'bundled' subdir('sysprofd')