From 1e2be1386b65c813d0271548eb533657b952ddc1 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 19 Sep 2020 15:13:31 +0100 Subject: Clean up the build Use modern, idiomatic Meson. --- data/icons/meson.build | 16 +++------ data/meson.build | 92 +++++++++++++++++++++++++++----------------------- help/meson.build | 53 +++++++++++++++-------------- libgdict/meson.build | 49 +++++++++++++-------------- meson.build | 48 +++++++++++++------------- src/meson.build | 45 ++++++++++-------------- 6 files changed, 147 insertions(+), 156 deletions(-) diff --git a/data/icons/meson.build b/data/icons/meson.build index 9013b1e..7b04bb9 100644 --- a/data/icons/meson.build +++ b/data/icons/meson.build @@ -1,18 +1,10 @@ install_data( - 'scalable/org.gnome.Dictionary.svg', - install_dir : join_paths( - get_option('prefix'), - get_option('datadir'), - 'icons/hicolor/scalable/apps' - ) + 'scalable/org.gnome.Dictionary.svg', + install_dir: gdict_datadir / 'icons/hicolor/scalable/apps', ) install_data( - 'symbolic/org.gnome.Dictionary-symbolic.svg', - install_dir : join_paths( - get_option('prefix'), - get_option('datadir'), - 'icons/hicolor/symbolic/apps' - ) + 'symbolic/org.gnome.Dictionary-symbolic.svg', + install_dir: gdict_datadir / 'icons/hicolor/symbolic/apps', ) diff --git a/data/meson.build b/data/meson.build index 33730a5..813ff7a 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,43 +1,47 @@ -i18n.merge_file ('desktop', - input: 'org.gnome.Dictionary.desktop.in', - output: 'org.gnome.Dictionary.desktop', - install: true, - install_dir: join_paths(gdict_datadir, 'applications'), - po_dir: po_dir, - type: 'desktop') +i18n.merge_file('desktop', + input: 'org.gnome.Dictionary.desktop.in', + output: 'org.gnome.Dictionary.desktop', + install: true, + install_dir: gdict_datadir / 'applications', + po_dir: po_dir, + type: 'desktop', +) desktop_file_validate = find_program('desktop-file-validate', required: false) if desktop_file_validate.found() test('validate-desktop', - desktop_file_validate, - args: 'org.gnome.Dictionary.desktop', - workdir: meson.current_build_dir()) + desktop_file_validate, + args: 'org.gnome.Dictionary.desktop', + workdir: meson.current_build_dir(), + ) endif -i18n.merge_file ('appdata', - input: 'org.gnome.Dictionary.appdata.xml.in', - output: 'org.gnome.Dictionary.appdata.xml', - install: true, - install_dir: join_paths(gdict_datadir, 'metainfo'), - po_dir: po_dir) +i18n.merge_file('appdata', + input: 'org.gnome.Dictionary.appdata.xml.in', + output: 'org.gnome.Dictionary.appdata.xml', + install: true, + install_dir: gdict_datadir / 'metainfo', + po_dir: po_dir, +) appstream_util = find_program('appstream-util', required: false) if appstream_util.found() test('validate-appdata', - appstream_util, - args: [ 'validate', '--nonet', 'org.gnome.Dictionary.appdata.xml' ], - workdir: meson.current_build_dir()) + appstream_util, + args: [ 'validate', '--nonet', 'org.gnome.Dictionary.appdata.xml' ], + workdir: meson.current_build_dir(), + ) endif service_conf = configuration_data () -service_conf.set ('bindir', gdict_bindir) -configure_file (input: 'org.gnome.Dictionary.service.in', - output: 'org.gnome.Dictionary.service', - configuration: service_conf, - install_dir: gdict_servicedir) +service_conf.set('bindir', gdict_bindir) +configure_file(input: 'org.gnome.Dictionary.service.in', + output: 'org.gnome.Dictionary.service', + configuration: service_conf, + install_dir: gdict_servicedir, +) -install_data ('org.gnome.dictionary.gschema.xml', - install_dir: gdict_schemadir) +install_data('org.gnome.dictionary.gschema.xml', install_dir: gdict_schemadir) subdir('icons') @@ -50,12 +54,13 @@ sources = [ foreach s: sources i18n.merge_file('sources', - input: '@0@.in'.format(s), - output: s, - install: true, - install_dir: join_paths(gdict_datadir, 'gdict-1.0', 'sources'), - po_dir: po_dir, - type: 'desktop') + input: '@0@.in'.format(s), + output: s, + install: true, + install_dir: gdict_datadir / 'gdict-1.0' / 'sources', + po_dir: po_dir, + type: 'desktop', + ) endforeach xsltproc = find_program('xsltproc', required: false) @@ -71,15 +76,16 @@ if get_option('build_man') and xsltproc.found() ] custom_target('man pages', - input: 'gnome-dictionary.xml', - output: 'gnome-dictionary.1', - command: [ - xsltproc, - xlstproc_flags, - '-o', '@OUTPUT@', - 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', - '@INPUT@', - ], - install: true, - install_dir: join_paths(gdict_mandir, 'man1')) + input: 'gnome-dictionary.xml', + output: 'gnome-dictionary.1', + command: [ + xsltproc, + xlstproc_flags, + '-o', '@OUTPUT@', + 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl', + '@INPUT@', + ], + install: true, + install_dir: gdict_mandir / 'man1', + ) endif diff --git a/help/meson.build b/help/meson.build index c742dad..d6a1fdb 100644 --- a/help/meson.build +++ b/help/meson.build @@ -1,27 +1,28 @@ gnome.yelp('gnome-dictionary', - sources: [ - 'definition.page', - 'dictionary-select.page', - 'find.page', - 'index.page', - 'introduction.page', - 'keyboard-shortcuts.page', - 'legal.xml', - 'pref.page', - 'print-font.page', - 'print.page', - 'prob-retrieving-definition.page', - 'save-definition.page', - 'similar-words.page', - 'source-add-local.page', - 'sources-default.page', - 'sources-delete.page', - 'sources-edit.page', - 'sources.page', - 'sources-select.page', - 'text-copy.page', - ], - media: [ - 'figures/gnome-dictionary-icon.png', - 'figures/gnome-dictionary-3-26.png', - ]) + sources: [ + 'definition.page', + 'dictionary-select.page', + 'find.page', + 'index.page', + 'introduction.page', + 'keyboard-shortcuts.page', + 'legal.xml', + 'pref.page', + 'print-font.page', + 'print.page', + 'prob-retrieving-definition.page', + 'save-definition.page', + 'similar-words.page', + 'source-add-local.page', + 'sources-default.page', + 'sources-delete.page', + 'sources-edit.page', + 'sources.page', + 'sources-select.page', + 'text-copy.page', + ], + media: [ + 'figures/gnome-dictionary-icon.png', + 'figures/gnome-dictionary-3-26.png', + ], +) diff --git a/libgdict/meson.build b/libgdict/meson.build index 5df874c..ce07079 100644 --- a/libgdict/meson.build +++ b/libgdict/meson.build @@ -33,12 +33,15 @@ sources_c = [ ] libgdict_enums = gnome.mkenums('gdict-enum-types', sources: sources_h, - h_template: 'gdict-enum-types.h.in', - c_template: 'gdict-enum-types.c.in', - install_header: false) + h_template: 'gdict-enum-types.h.in', + c_template: 'gdict-enum-types.c.in', + install_header: false, +) + libgdict_marshal = gnome.genmarshal('gdict-marshal', - sources: 'gdict-marshal.list', - prefix: 'gdict_marshal') + sources: 'gdict-marshal.list', + prefix: 'gdict_marshal', +) libgdict_version = meson.project_version().split('.') libgdict_major = libgdict_version[0].to_int() @@ -46,7 +49,6 @@ libgdict_minor = libgdict_version[1].to_int() libgdict_micro = libgdict_version[2].to_int() libgdict_cflags = [ - '-DHAVE_CONFIG_H', '-D_GNU_SOURCE', '-DG_LOG_DOMAIN="Gdict"', '-DDATADIR="@0@"'.format(gdict_datadir), @@ -67,26 +69,23 @@ libgdict_cflags = [ '-DGTK_DISABLE_SINGLE_INCLUDES', ] -libgdict_ldflags = [] -if cc.get_id() == 'gcc' - libgdict_ldflags += [ - '-Wl,-Bsymbolic-functions', - '-Wl,-z,relro', - '-Wl,-z,now', - ] -endif - -libgdict_inc = include_directories('.') +libgdict_ldflags = cc.get_supported_link_arguments([ + '-Wl,-Bsymbolic-functions', + '-Wl,-z,relro', + '-Wl,-z,now', +]) libgdict_lib = static_library('libgdict-1.0', - sources: sources_h_priv + sources_c + libgdict_enums + libgdict_marshal, - dependencies: [ gio_dep, gtk_dep, ipv6_deps ], - include_directories: [ root_dir, libgdict_inc ], - c_args: common_cflags + debug_cflags + libgdict_cflags, - link_args: libgdict_ldflags, - install: false) + sources: sources_c + libgdict_enums + libgdict_marshal, + dependencies: [ gio_dep, gtk_dep, ipv6_deps ], + include_directories: root_inc, + c_args: common_cflags + debug_cflags + libgdict_cflags, + link_args: libgdict_ldflags, + install: false, +) libgdict_dep = declare_dependency(sources: libgdict_enums + libgdict_marshal, - link_with: libgdict_lib, - include_directories: [ libgdict_inc ], - dependencies: [ gio_dep, gtk_dep, ipv6_deps ]) + link_with: libgdict_lib, + include_directories: [ libgdict_inc ], + dependencies: [ gio_dep, gtk_dep, ipv6_deps ], +) diff --git a/meson.build b/meson.build index 819371e..5142e3a 100644 --- a/meson.build +++ b/meson.build @@ -5,19 +5,19 @@ project('gnome-dictionary', 'c', version: '3.26.2', 'warning_level=1', ], license: 'GPLv2+', - meson_version: '>= 0.42.0') + meson_version: '>= 0.54.0') # Paths for the pkg-config file gdict_prefix = get_option('prefix') -gdict_bindir = join_paths(gdict_prefix, get_option('bindir')) -gdict_libdir = join_paths(gdict_prefix, get_option('libdir')) -gdict_datadir = join_paths(gdict_prefix, get_option('datadir')) -gdict_includedir = join_paths(gdict_prefix, get_option('includedir')) -gdict_libexecdir = join_paths(gdict_prefix, get_option('libexecdir')) -gdict_mandir = join_paths(gdict_prefix, get_option('mandir')) -gdict_sysconfdir = join_paths(gdict_prefix, get_option('sysconfdir')) -gdict_schemadir = join_paths (gdict_datadir, 'glib-2.0', 'schemas') -gdict_servicedir = join_paths (gdict_datadir, 'dbus-1', 'services') +gdict_bindir = gdict_prefix / get_option('bindir') +gdict_libdir = gdict_prefix / get_option('libdir') +gdict_datadir = gdict_prefix / get_option('datadir') +gdict_includedir = gdict_prefix / get_option('includedir') +gdict_libexecdir = gdict_prefix / get_option('libexecdir') +gdict_mandir = gdict_prefix / get_option('mandir') +gdict_sysconfdir = gdict_prefix / get_option('sysconfdir') +gdict_schemadir = gdict_datadir / 'glib-2.0' / 'schemas' +gdict_servicedir = gdict_datadir / 'dbus-1' / 'services' cc = meson.get_compiler('c') host_system = host_machine.system() @@ -68,20 +68,20 @@ else test_cflags = [] endif -common_cflags = [] -foreach cflag: test_cflags - if cc.has_argument(cflag) - common_cflags += [ cflag ] - endif -endforeach +common_cflags = cc.get_supported_arguments(test_cflags) -debug_cflags = [] +debug = get_option('debug') +optimization = get_option('optimization') buildtype = get_option('buildtype') -if buildtype == 'debug' - debug_cflags += [ '-DGDICT_ENABLE_DEBUG', ] -elif buildtype == 'debugoptimized' - debug_cflags += [ '-DGDICT_ENABLE_DEBUG', '-DG_DISABLE_CAST_CHECKS', ] -elif buildtype == 'release' +debug_cflags = [] + +if debug + debug_cflags += '-DGDICT_ENABLE_DEBUG' +elif optimization in ['2', '3', 's'] + debug_cflags += '-DG_DISABLE_CAST_CHECKS' +endif + +if buildtype == 'release' debug_cflags += [ '-DG_DISABLE_ASSERT', '-DG_DISABLE_CHECKS', '-DG_DISABLE_CAST_CHECKS', ] endif @@ -121,7 +121,9 @@ endif conf.set10('ENABLE_IPV6', use_ipv6) -root_dir = include_directories('.') +root_inc = include_directories('.') +libgdict_inc = include_directories('libgdict') +src_inc = include_directories('src') po_dir = join_paths(meson.current_source_dir(), 'po') configure_file(output: 'config.h', configuration: conf) diff --git a/src/meson.build b/src/meson.build index 4caa1aa..8823968 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,44 +1,35 @@ app_sources = [ 'gdict-about.c', - 'gdict-about.h', 'gdict-app.c', 'gdict-app.h', 'gdict-common.c', - 'gdict-common.h', 'gdict-pref-dialog.c', - 'gdict-pref-dialog.h', 'gdict-print.c', - 'gdict-print.h', 'gdict-sidebar.c', - 'gdict-sidebar.h', 'gdict-source-dialog.c', - 'gdict-source-dialog.h', 'gdict-window.c', - 'gdict-window.h', 'main.c', ] resources = gnome.compile_resources ('gdict-resources', - 'gdict.gresource.xml', - source_dir: '.', - c_name: 'gdict') + 'gdict.gresource.xml', + source_dir: '.', + c_name: 'gdict', +) mathlib = cc.find_library('m', required: false) -executable('gnome-dictionary', app_sources + resources, - c_args: [ - '-DHAVE_CONFIG_H', - '-DPREFIX="@0@"'.format(gdict_prefix), - '-DSYSCONFDIR="@0@"'.format(gdict_sysconfdir), - '-DLIBDIR="@0@"'.format(gdict_libdir), - '-DDATADIR="@0@"'.format(gdict_datadir), - '-DPKGDATADIR="@0@"'.format(join_paths(gdict_datadir, 'gnome-dictionary')), - '-DGNOMELOCALEDIR="@0@"'.format(join_paths(gdict_datadir, 'locale')), - ], - dependencies: [ libgdict_dep, mathlib ], - include_directories: [ - root_dir, - libgdict_inc, - include_directories('.'), - ], - install: true) +executable('gnome-dictionary', + sources: app_sources + resources, + c_args: [ + '-DPREFIX="@0@"'.format(gdict_prefix), + '-DSYSCONFDIR="@0@"'.format(gdict_sysconfdir), + '-DLIBDIR="@0@"'.format(gdict_libdir), + '-DDATADIR="@0@"'.format(gdict_datadir), + '-DPKGDATADIR="@0@"'.format(join_paths(gdict_datadir, 'gnome-dictionary')), + '-DGNOMELOCALEDIR="@0@"'.format(join_paths(gdict_datadir, 'locale')), + ], + dependencies: [ libgdict_dep, mathlib ], + include_directories: root_inc, + install: true, +) -- cgit v1.2.1