diff options
author | Jonathan Kang <jonathan121537@gmail.com> | 2017-11-17 17:51:09 +0800 |
---|---|---|
committer | Jonathan Kang <jonathan121537@gmail.com> | 2017-12-13 15:25:44 +0800 |
commit | 4707e790dd91df48c737465bde4fae2e7091c782 (patch) | |
tree | 3a7d596c4f992b960126f86501619a60a5344f0d | |
parent | 6c70467dc6d1d5fcafba9a4fda8c0da2e12283b3 (diff) | |
download | gnome-logs-4707e790dd91df48c737465bde4fae2e7091c782.tar.gz |
Port to meson build system
According to this wiki[0], port Logs to meson build system.
*[0] https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting
https://bugzilla.gnome.org/show_bug.cgi?id=790276
-rw-r--r-- | data/icons/meson.build | 17 | ||||
-rw-r--r-- | data/meson.build | 103 | ||||
-rw-r--r-- | help/meson.build | 18 | ||||
-rw-r--r-- | meson.build | 145 | ||||
-rw-r--r-- | meson_options.txt | 2 | ||||
-rw-r--r-- | meson_post_install.py | 12 | ||||
-rw-r--r-- | po/meson.build | 1 | ||||
-rw-r--r-- | src/meson.build | 49 | ||||
-rw-r--r-- | tests/meson.build | 32 |
9 files changed, 379 insertions, 0 deletions
diff --git a/data/icons/meson.build b/data/icons/meson.build new file mode 100644 index 0000000..7e4f117 --- /dev/null +++ b/data/icons/meson.build @@ -0,0 +1,17 @@ +apps_icons = [ + ['16x16', 'gnome-logs.png'], + ['22x22', 'gnome-logs.png'], + ['24x24', 'gnome-logs.png'], + ['32x32', 'gnome-logs.png'], + ['48x48', 'gnome-logs.png'], + ['256x256', 'gnome-logs.png'], + ['512x512', 'gnome-logs.png'], + ['symbolic', 'gnome-logs-symbolic.svg'] +] + +foreach icon: apps_icons + install_data( + join_paths(icon[0], icon[1]), + install_dir: join_paths(gl_datadir, 'icons', 'hicolor', icon[0], 'apps') + ) +endforeach diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..daabc55 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,103 @@ +subdir('icons') + +add_global_arguments('-DGL_BINDIR="@0@"'.format(gl_bindir), language : 'c') + +gettext_package = gl_name + +i18n.merge_file( + input : 'org.gnome.Logs.desktop.in', + output : 'org.gnome.Logs.desktop', + type : 'desktop', + po_dir : 'po', + install : true, + install_dir : join_paths(gl_datadir, 'applications') +) + +i18n.merge_file( + input : 'org.gnome.Logs.appdata.xml.in', + output : 'org.gnome.Logs.appdata.xml', + po_dir : 'po', + install : true, + install_dir : join_paths(gl_datadir, 'appdata') +) + +service_conf = configuration_data() +service_conf.set('bindir', gl_bindir) + +service = 'org.gnome.Logs.service' + +configure_file( + input: service + '.in', + output: service, + install: true, + install_dir: join_paths(gl_datadir, 'dbus-1', 'services'), + configuration: service_conf +) + +resource_data = files( + 'gl-categorylist.ui', + 'gl-eventviewlist.ui', + 'gl-eventtoolbar.ui', + 'gl-eventviewdetail.ui', + 'gl-searchpopover.ui', + 'gl-window.ui', + 'help-overlay.ui', + 'menus.ui' +) + +gresource = files('org.gnome.Logs.gresource.xml') + +web_files = files( + 'gl-style.css' +) + +install_data( + web_files, + install_dir: gl_pkgdatadir +) + +# GSettings schemas +# https://github.com/mesonbuild/meson/issues/1687 +custom_target('gsettings-enums', + input: '../src/gl-application.h', + output: 'org.gnome.Logs.enums.xml', + install: true, + install_dir: join_paths(gl_datadir, 'glib-2.0', 'schemas'), + capture: true, + command: ['glib-mkenums', + '--comments', '<!-- @comment@ -->', + '--fhead', '<schemalist>', + '--vhead', ' <@type@ id="org.gnome.Logs.@EnumName@">', + '--vprod', ' <value nick="@valuenick@" value="@valuenum@"/>', + '--vtail', ' </@type@>', + '--ftail', '</schemalist>', + '@INPUT@' + ] +) +install_data( + 'org.gnome.Logs.gschema.xml', + install_dir : join_paths(gl_datadir, 'glib-2.0', 'schemas') +) + +configure_file( + input : 'version.xml.in', + output : 'version.xml', + command : ['cp', '@INPUT@', '@OUTPUT@'] +) + +if logs_enable_man + custom_target('gl-manfile', + input : 'gnome-logs.xml', + output : 'gnoem-logs.1', + install : true, + install_dir : gl_mandir, + command : [ + xsltproc, + '--nonet', + '--path', join_paths(meson.source_root(), 'data') + ':' + 'data', + '--output', 'data/', + 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', + '@INPUT@' + ] + ) +endif diff --git a/help/meson.build b/help/meson.build new file mode 100644 index 0000000..615e4a0 --- /dev/null +++ b/help/meson.build @@ -0,0 +1,18 @@ +sources = [ + 'index.page', + 'introduction.page', + 'legal.xml', + 'permissions.page' +] + +media = [ + 'media/gnome-logs.png', + 'media/gnome-logs-3-12.png' +] + +gnome.yelp( + gl_name, + sources: sources, + media: media, + symlink_media: true +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..ff5b766 --- /dev/null +++ b/meson.build @@ -0,0 +1,145 @@ +project('gnome-logs', 'c', version : '3.27.1') + +gl_name = meson.project_name() +gl_version = meson.project_version() + +gl_prefix = get_option('prefix') +gl_bindir = join_paths(gl_prefix, get_option('bindir')) +gl_libexecdir = join_paths(gl_prefix, get_option('libexecdir')) +gl_localedir = join_paths(gl_prefix, get_option('localedir')) +gl_datadir = join_paths(gl_prefix, get_option('datadir')) +gl_mandir = join_paths(gl_prefix, get_option('mandir'), 'man1') +gl_pkgdatadir = join_paths(gl_datadir, gl_name) + +#TODO add debug arguments + +config_h = configuration_data() + +# defines +set_defines = [ + # package + ['PACKAGE', gl_name], + ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + gl_name], + ['PACKAGE_NAME', gl_name], + ['PACKAGE_STRING', '@0@ @1@'.format(gl_name, gl_version)], + ['PACKAGE_TARNAME', gl_name], + ['PACKAGE_URL', 'https://wiki.gnome.org/Apps/Logs'], + ['PACKAGE_VERSION', gl_version], + ['VERSION', gl_version], + # i18n + ['GETTEXT_PACKAGE', gl_name], +] + +foreach define: set_defines + config_h.set_quoted(define[0], define[1]) +endforeach +configure_file(output : 'config.h', + configuration : config_h) + +# Dependencies +dependency('pkg-config', version : '>= 0.24') + +message('checking for glib-mkenums script...') +glib_mkenums = run_command('pkg-config', ['--variable=glib_mkenums', 'glib-2.0']) +if not glib_mkenums.stdout().contains('glib-mkenums') + error('glib-mkenums not listed in glib-2.0 pkg-config file') +else + message(glib_mkenums.stdout().strip()) +endif + +gsettings_desktop_schemas = dependency('gsettings-desktop-schemas', required : false) +if not gsettings_desktop_schemas.found() + message('gsettings-desktop-schemas is required at runtime') +endif + +gl_deps = [ + dependency('gio-unix-2.0', version : '>=2.43.90'), + dependency('gtk+-3.0', version : '>=3.22.0'), + dependency('libsystemd') +] + +# Testing utilities +have_desktop_file_validate = false +if get_option('tests') + desktop_file_validate = find_program('desktop-file-validate', required : false) + if desktop_file_validate.found() + have_desktop_file_validate = true + else + have_desktop_file_validate = false + endif + + py_module = 'dogtail' + message('checking for python module ' + py_module + '...') + result = run_command('echo', ['"import ' + py_module + '"| python - &>/dev/null']) + if result.returncode() != 0 + message('not found') + have_dogtail = false + else + message('found') + have_dogtail = true + endif +else + have_desktop_file_validate = false + have_dogtail = false +endif + +if have_desktop_file_validate == true and have_dogtail == true + testing_utilities = true +else + testing_utilities = false + if get_option('tests') + error('tests were requested but the required utilities were not found') + endif +endif + +if testing_utilities + logs_enable_tests = true +else + logs_enable_tests = false +endif + +# Manpage +have_manutils = false +if get_option('man') + # TODO: check xsl stylesheets as well# + + xsltproc = find_program('xsltproc', required : false) + if xsltproc.found() + have_xsltproc = true + else + have_xsltproc = false + endif + + if have_xsltproc + have_manutils = true + else + if not get_option('disable-man') + error('manpage generation requested but required utilities were not found') + have_manutils = false + endif + endif +endif + +if have_manutils + logs_enable_man = true +else + logs_enable_man = false +endif + +# i18n +gnome = import('gnome') +i18n = import('i18n') + +data_dir = join_paths(meson.source_root(), 'data') +po_dir = join_paths(meson.source_root(), 'po') + +top_inc = include_directories('.') +src_inc = include_directories('src') + +subdir('data') +subdir('src') +subdir('po') +subdir('help') +subdir('tests') + +meson.add_install_script('meson_post_install.py') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..51ebbdd --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('tests', type : 'boolean', value : false, description : 'Enable support for tests run during make check') +option('man', type : 'boolean', value : false, description : 'Enable building the man page') diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100644 index 0000000..39d75c0 --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import os +import subprocess + +schemadir = os.path.join(os.environ['MESON_INSTALL_PREFIX'], 'share', 'glib-2.0', 'schemas') + +if not os.environ.get('DESTDIR'): + print('Compiling gsettings schemas...') + subprocess.call(['glib-compile-schemas', join_paths(gl_datadir, 'glib-2.0', 'schemas')]) + print('Updating icon cache...') + subprocess.call(['gtk-update-icon-cache --ignore-theme-index --force', join_paths(gl_datadir, 'icons', 'hicolor')]) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..57d1266 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(gettext_package, preset: 'glib') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..6ee956f --- /dev/null +++ b/src/meson.build @@ -0,0 +1,49 @@ +add_global_arguments('-DLOCALEDIR="@0@"'.format(gl_localedir), language : 'c') + +sources = files( + 'gl-application.c', + 'gl-categorylist.c', + 'gl-eventtoolbar.c', + 'gl-eventviewdetail.c', + 'gl-eventviewlist.c', + 'gl-searchpopover.c', + 'gl-eventviewrow.c', + 'gl-journal.c', + 'gl-journal-model.c', + 'gl-main.c', + 'gl-util.c', + 'gl-window.c' +) + +enum_headers = files( + 'gl-categorylist.h', + 'gl-eventtoolbar.h', + 'gl-eventviewrow.h', + 'gl-journal-model.h', + 'gl-searchpopover.h', + 'gl-util.h' +) + +sources += gnome.compile_resources( + 'gl-resources', + gresource, + c_name: 'gl', + source_dir: data_dir, + dependencies: resource_data, + export: true +) + +enum = 'gl-enums' +sources += gnome.mkenums_simple( + enum, + sources : enum_headers +) + +executable( + gl_name, + sources, + include_directories : [top_inc, src_inc], + dependencies : gl_deps, + install : true, + install_dir : gl_bindir +) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..07cac68 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,32 @@ +# Tests +tests_env = [ + 'LANG=C', + 'TZ=UTC', + 'MALLOC_CHECK_=2', + 'MALLOC_PERTURB_=$$(($${RANDOM:-256} % 256))', + 'G_SLICE=debug-blocks' +] +test_gl_util_sources = files( + 'test-gl-util.c', + '../src/gl-util.c' +) + +if logs_enable_tests + selftest = executable( + 'test-gl-util', + sources : test_gl_util_sources, + include_directories : [top_inc, src_inc], + dependencies : gl_deps + ) + test('test-gl-util', selftest, env : tests_env) + + #TODO: run test_SCRIPT too + + # basictest target + run_target('basictest', + command : [ + 'env', tests_env, + join_paths(meson.source_root(), 'tests/basic.py') + ] + ) +endif |