From 757d36ae8e0c74c809cfa1e679179f7733fbe40e Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 25 May 2022 14:07:02 -0500 Subject: [PATCH] Cleanup the build a bit Makes the Meson build a little bit better and cleans up some of the formatting. --- build-aux/meson/post_install.sh | 24 ----- data/meson.build | 3 +- examples/meson.build | 4 - help/meson.build | 10 +- meson.build | 21 ++-- meson_options.txt | 10 +- po/meson.build | 2 +- src/libsysprof-ui/meson.build | 4 - src/libsysprof/meson.build | 4 - src/meson.build | 34 +++--- src/sysprof/meson.build | 4 - src/sysprofd/meson.build | 4 - src/tests/meson.build | 183 +++++++++++++++----------------- src/tools/meson.build | 6 +- 14 files changed, 136 insertions(+), 177 deletions(-) delete mode 100755 build-aux/meson/post_install.sh diff --git a/build-aux/meson/post_install.sh b/build-aux/meson/post_install.sh deleted file mode 100755 index 6fe3c177..00000000 --- a/build-aux/meson/post_install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -if [ -z $MESON_INSTALL_PREFIX ]; then - echo 'This is meant to be ran from Meson only!' - exit 1 -fi - -if [ -z $DESTDIR ]; then - - echo 'Compiling GSchema' - glib-compile-schemas "$MESON_INSTALL_PREFIX/share/glib-2.0/schemas" - echo 'Updating mime database' - update-mime-database "$MESON_INSTALL_PREFIX/share/mime" - - if [ -e "$MESON_INSTALL_PREFIX/bin/sysprof" ]; then - - echo 'Updating icon cache' - gtk-update-icon-cache -qtf "$MESON_INSTALL_PREFIX/share/icons/hicolor" - echo 'Updating desktop database' - update-desktop-database -q "$MESON_INSTALL_PREFIX/share/applications" - - fi - -fi diff --git a/data/meson.build b/data/meson.build index d70ea582..86a65a5f 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,5 +1,4 @@ -if get_option('enable_gtk') and get_option('libsysprof') - +if get_option('gtk') and get_option('libsysprof') install_data('sysprof-mime.xml', install_dir: join_paths(datadir, 'mime/packages') ) diff --git a/examples/meson.build b/examples/meson.build index 4cef7d15..71a036a4 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,7 +1,3 @@ -if get_option('enable_examples') - app = executable('example-app', 'app.c', dependencies: [dependency('glib-2.0'), libsysprof_capture_dep], ) - -endif diff --git a/help/meson.build b/help/meson.build index b2aec10d..d7a24017 100644 --- a/help/meson.build +++ b/help/meson.build @@ -1,7 +1,5 @@ -if get_option('help') - find_program('itstool', required: true) +find_program('itstool') - gnome.yelp('sysprof', - sources: ['index.page', 'introduction.page', 'profiling.page', 'faq.page', 'legal.xml'], - ) -endif +gnome.yelp('sysprof', + sources: ['index.page', 'introduction.page', 'profiling.page', 'faq.page', 'legal.xml'], +) diff --git a/meson.build b/meson.build index 029b5742..59703943 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ project('sysprof', 'c', symbolic_version = '43.alpha0' -gnome = import('gnome') +gnome = import('gnome', required: get_option('gtk')) pkgconfig = import('pkgconfig') i18n = import('i18n') @@ -46,7 +46,6 @@ config_h.set('PACKAGE_TARNAME', 'PACKAGE_STRING') config_h.set('PACKAGE', 'PACKAGE_NAME') config_h.set('VERSION', 'PACKAGE_VERSION') - # Detect and set symbol visibility if get_option('default_library') != 'static' if host_machine.system() == 'windows' @@ -200,16 +199,26 @@ endif subdir('src') subdir('data') -subdir('examples') -subdir('help') subdir('po') +if get_option('help') + subdir('help') +endif + +if get_option('examples') + subdir('examples') +endif + configure_file( input: 'config.h.meson', output: 'config.h', configuration: config_h ) -if get_option('enable_gtk') - meson.add_install_script('build-aux/meson/post_install.sh') +if get_option('gtk') and gnome.found() + gnome.post_install( + glib_compile_schemas: true, + gtk_update_icon_cache: true, + update_desktop_database: true + ) endif diff --git a/meson_options.txt b/meson_options.txt index 10f90fb1..3562830b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,7 +1,7 @@ # Optionally disable the GTK application in case you're building the # sysprof-cli only for your platform. Might be useful in IoT or various # server scenarios. -option('enable_gtk', type: 'boolean') +option('gtk', type: 'boolean') # Disable libsysprof/ui (in situations you only want sysprof-capture) option('libsysprof', type: 'boolean') @@ -10,7 +10,7 @@ option('libsysprof', type: 'boolean') # You only really want to ignore this if you are running from a container # and are talking to a host daemon. Also, if you're compiling for something # other than Linux to allow viewing syscap files. -option('with_sysprofd', type: 'combo', +option('sysprofd', type: 'combo', choices: ['host', 'bundled', 'none'], value: 'bundled', ) @@ -35,12 +35,12 @@ option('libunwind', type: 'boolean') # Optionally disable the tools (this is mostly only useful for building only # libsysprof-capture as a subproject) -option('enable_tools', type: 'boolean') +option('tools', type: 'boolean') # Optionally disable the tests (this is mostly only useful for building only # libsysprof-capture as a subproject) -option('enable_tests', type: 'boolean') +option('tests', type: 'boolean') # Optionally disable the examples (this is mostly only useful for building only # libsysprof-capture as a subproject) -option('enable_examples', type: 'boolean') +option('examples', type: 'boolean') diff --git a/po/meson.build b/po/meson.build index 0cf2c180..21029343 100644 --- a/po/meson.build +++ b/po/meson.build @@ -2,5 +2,5 @@ i18n.gettext('sysprof-workaround', preset: 'glib', install: false) if get_option('libsysprof') -i18n.gettext('sysprof', preset: 'glib') + i18n.gettext('sysprof', preset: 'glib') endif diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build index 956a7b5f..d87a093d 100644 --- a/src/libsysprof-ui/meson.build +++ b/src/libsysprof-ui/meson.build @@ -1,5 +1,3 @@ -if get_option('enable_gtk') and get_option('libsysprof') - libsysprof_ui_public_sources = [ 'sysprof-check.c', 'sysprof-display.c', @@ -135,5 +133,3 @@ pkgconfig.generate( ) install_headers(libsysprof_ui_public_headers, subdir: sysprof_ui_header_subdir) - -endif diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build index 3d9c0b2f..bd6e8a70 100644 --- a/src/libsysprof/meson.build +++ b/src/libsysprof/meson.build @@ -1,5 +1,3 @@ -if get_option('libsysprof') - libsysprof_c_args = [ '-DSYSPROF_COMPILATION' ] libsysprof_public_sources = [ @@ -195,5 +193,3 @@ pkgconfig.generate( install_headers(libsysprof_public_headers, subdir: sysprof_header_subdir) subdir('preload') - -endif diff --git a/src/meson.build b/src/meson.build index a595f554..903559ec 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,7 +8,7 @@ sysprof_version_conf.set('MINOR_VERSION', sysprof_version[1]) sysprof_version_conf.set('MICRO_VERSION', sysprof_version[2]) sysprof_version_conf.set('VERSION', meson.project_version()) -if get_option('with_sysprofd') == 'bundled' or get_option('libsysprof') +if get_option('sysprofd') == 'bundled' or get_option('libsysprof') ipc_profiler_src = gnome.gdbus_codegen('ipc-profiler', sources: 'org.gnome.Sysprof3.Profiler.xml', interface_prefix: 'org.gnome.Sysprof3.', @@ -43,18 +43,26 @@ endif ipc_include_dirs = include_directories('.') -stackstash_sources = files([ - 'stackstash.c', -]) +stackstash_sources = files('stackstash.c') -helpers_sources = files([ - 'helpers.c', -]) +helpers_sources = files('helpers.c') subdir('libsysprof-capture') -subdir('sysprofd') -subdir('libsysprof') -subdir('libsysprof-ui') -subdir('sysprof') -subdir('tools') -subdir('tests') +if get_option('sysprofd') == 'bundled' + subdir('sysprofd') +endif +if get_option('libsysprof') + subdir('libsysprof') +endif +if get_option('gtk') and get_option('libsysprof') + subdir('libsysprof-ui') +endif +if get_option('gtk') and get_option('libsysprof') + subdir('sysprof') +endif +if get_option('tools') + subdir('tools') +endif +if get_option('tests') + subdir('tests') +endif diff --git a/src/sysprof/meson.build b/src/sysprof/meson.build index ca40c456..c5c4593a 100644 --- a/src/sysprof/meson.build +++ b/src/sysprof/meson.build @@ -1,5 +1,3 @@ -if get_option('enable_gtk') and get_option('libsysprof') - sysprof_sources = [ 'egg-binding-group.c', 'sysprof.c', @@ -26,5 +24,3 @@ sysprof = executable('sysprof', sysprof_resources + sysprof_sources, install_dir: get_option('bindir'), install: true, ) - -endif diff --git a/src/sysprofd/meson.build b/src/sysprofd/meson.build index 40e0138b..b6a8dd97 100644 --- a/src/sysprofd/meson.build +++ b/src/sysprofd/meson.build @@ -1,5 +1,3 @@ -if get_option('with_sysprofd') == 'bundled' - sysprofd_sources = [ '../libsysprof/sysprof-kallsyms.c', 'sysprofd.c', @@ -96,5 +94,3 @@ configure_file( configuration: sysprofdconf, install_dir: systemdunitdir, ) - -endif diff --git a/src/tests/meson.build b/src/tests/meson.build index d1593cba..611ff260 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -1,5 +1,3 @@ -if get_option('enable_tests') - test_env = [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), @@ -39,117 +37,112 @@ find_temp_allocs = executable('find-temp-allocs', 'find-temp-allocs.c', dependencies: test_capture_deps, ) - test('test-capture', test_capture, env: test_env) test('test-capture-cursor', test_capture_cursor, env: test_env) test('test-mapped-ring-buffer', test_mapped_ring_buffer, env: test_env) if get_option('libsysprof') - -test_deps = [ - libsysprof_static_dep, -] - -test_addr_map = executable('test-addr-map', 'test-addr-map.c', - c_args: test_cflags, - dependencies: test_deps, -) - -test_addr_decode = executable('test-addr-decode', 'test-addr-decode.c', - c_args: test_cflags, - dependencies: test_deps, -) - -test_mountinfo = executable('test-mountinfo', 'test-mountinfo.c', - c_args: test_cflags, - dependencies: test_deps, -) - -test_flatpak = executable('test-flatpak', 'test-flatpak.c', - c_args: test_cflags, - dependencies: test_deps, -) - -test_resolvers = executable('test-resolvers', 'test-resolvers.c', - c_args: test_cflags, - dependencies: test_deps, -) - -allocs_by_size = executable('allocs-by-size', 'allocs-by-size.c', - c_args: test_cflags, - dependencies: test_deps, -) - -allocs_within_mark = executable('allocs-within-mark', 'allocs-within-mark.c', - c_args: test_cflags, - dependencies: test_deps, -) - -cross_thread_frees = executable('cross-thread-frees', 'cross-thread-frees.c', - c_args: test_cflags, - dependencies: test_deps, -) - -memory_stack_stash = executable('memory-stack-stash', 'memory-stack-stash.c', - c_args: test_cflags, - dependencies: test_deps, -) - -read_build_id = executable('read-build-id', 'read-build-id.c', - c_args: test_cflags, - dependencies: test_deps, -) - -show_page_usage = executable('show-page-usage', 'show-page-usage.c', - c_args: test_cflags, - dependencies: test_deps + [dependency('cairo')], -) - -list_pid_maps = executable('list-all-maps', 'list-all-maps.c', - c_args: test_cflags, - dependencies: [libsysprof_static_dep], - include_directories: include_directories('..'), -) - -list_maps = executable('list-maps', 'list-maps.c', - c_args: test_cflags, - dependencies: [libsysprof_static_dep], - include_directories: include_directories('..'), -) - -if get_option('enable_gtk') - - test_ui_deps = [ - libsysprof_dep, - libsysprof_ui_dep, - dependency('gtk4', version: gtk_req_version), - dependency('pangoft2', required: false), + test_deps = [ + libsysprof_static_dep, ] - test_model_filter = executable('test-model-filter', 'test-model-filter.c', + test_addr_map = executable('test-addr-map', 'test-addr-map.c', c_args: test_cflags, - dependencies: test_ui_deps, + dependencies: test_deps, ) - test_process_model = executable('test-process-model', 'test-process-model.c', + test_addr_decode = executable('test-addr-decode', 'test-addr-decode.c', c_args: test_cflags, - dependencies: test_ui_deps, + dependencies: test_deps, ) - test_zoom = executable('test-zoom', - ['test-zoom.c', '../libsysprof-ui/sysprof-zoom-manager.c'], + test_mountinfo = executable('test-mountinfo', 'test-mountinfo.c', c_args: test_cflags, - dependencies: test_ui_deps, + dependencies: test_deps, ) - test_capture_view = executable('test-capture-view', 'test-capture-view.c', + test_flatpak = executable('test-flatpak', 'test-flatpak.c', c_args: test_cflags, - dependencies: test_ui_deps, + dependencies: test_deps, ) - test('test-model-filter', test_model_filter, env: test_env) - test('test-zoom', test_zoom, env: test_env) + test_resolvers = executable('test-resolvers', 'test-resolvers.c', + c_args: test_cflags, + dependencies: test_deps, + ) -endif -endif + allocs_by_size = executable('allocs-by-size', 'allocs-by-size.c', + c_args: test_cflags, + dependencies: test_deps, + ) + + allocs_within_mark = executable('allocs-within-mark', 'allocs-within-mark.c', + c_args: test_cflags, + dependencies: test_deps, + ) + + cross_thread_frees = executable('cross-thread-frees', 'cross-thread-frees.c', + c_args: test_cflags, + dependencies: test_deps, + ) + + memory_stack_stash = executable('memory-stack-stash', 'memory-stack-stash.c', + c_args: test_cflags, + dependencies: test_deps, + ) + + read_build_id = executable('read-build-id', 'read-build-id.c', + c_args: test_cflags, + dependencies: test_deps, + ) + + show_page_usage = executable('show-page-usage', 'show-page-usage.c', + c_args: test_cflags, + dependencies: test_deps + [dependency('cairo')], + ) + + list_pid_maps = executable('list-all-maps', 'list-all-maps.c', + c_args: test_cflags, + dependencies: [libsysprof_static_dep], + include_directories: include_directories('..'), + ) + + list_maps = executable('list-maps', 'list-maps.c', + c_args: test_cflags, + dependencies: [libsysprof_static_dep], + include_directories: include_directories('..'), + ) + + if get_option('gtk') + test_ui_deps = [ + libsysprof_dep, + libsysprof_ui_dep, + dependency('gtk4', version: gtk_req_version), + dependency('pangoft2', required: false), + ] + + test_model_filter = executable('test-model-filter', 'test-model-filter.c', + c_args: test_cflags, + dependencies: test_ui_deps, + ) + + test_process_model = executable('test-process-model', 'test-process-model.c', + c_args: test_cflags, + dependencies: test_ui_deps, + ) + + test_zoom = executable('test-zoom', + ['test-zoom.c', '../libsysprof-ui/sysprof-zoom-manager.c'], + c_args: test_cflags, + dependencies: test_ui_deps, + ) + + test_capture_view = executable('test-capture-view', 'test-capture-view.c', + c_args: test_cflags, + dependencies: test_ui_deps, + ) + + test('test-model-filter', test_model_filter, env: test_env) + test('test-zoom', test_zoom, env: test_env) + endif endif diff --git a/src/tools/meson.build b/src/tools/meson.build index 3246ecb7..9e9ae5f3 100644 --- a/src/tools/meson.build +++ b/src/tools/meson.build @@ -1,5 +1,3 @@ -if get_option('enable_tools') - tools_deps = [ dependency('glib-2.0'), libsysprof_capture_dep, @@ -28,7 +26,7 @@ sysprof_dump = executable('sysprof-dump', 'sysprof-dump.c', install: false, ) -if get_option('with_sysprofd') == 'bundled' or get_option('libsysprof') +if get_option('sysprofd') == 'bundled' or get_option('libsysprof') sysprof_profiler_ctl = executable('sysprof-profiler-ctl', [ 'sysprof-profiler-ctl.c', ipc_profiler_src ], dependencies: [ tools_deps, dependency('gio-unix-2.0', version: glib_req_version) ], @@ -42,5 +40,3 @@ list_threads = executable('list-threads', ['list-threads.c'], c_args: tools_cflags, install: false, ) - -endif