[hitori/meson: 2/4] build: Add Meson support
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hitori/meson: 2/4] build: Add Meson support
- Date: Tue, 19 Feb 2019 15:49:02 +0000 (UTC)
commit 31021c3e45e868dd2f61b5663330849f89d2b217
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Sat Jan 12 23:21:18 2019 +0100
build: Add Meson support
Including fixups and additions by Philip Withnall.
https://gitlab.gnome.org/GNOME/hitori/issues/10
build-aux/meson_post_install.py | 19 ++++++++
data/icons/meson.build | 13 ++++++
data/meson.build | 57 ++++++++++++++++++++++++
help/meson.build | 17 +++++++
meson.build | 98 +++++++++++++++++++++++++++++++++++++++++
po/meson.build | 1 +
src/meson.build | 40 +++++++++++++++++
7 files changed, 245 insertions(+)
---
diff --git a/build-aux/meson_post_install.py b/build-aux/meson_post_install.py
new file mode 100644
index 0000000..87df37e
--- /dev/null
+++ b/build-aux/meson_post_install.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+install_prefix = os.environ['MESON_INSTALL_PREFIX']
+schemadir = os.path.join(install_prefix, 'share/glib-2.0/schemas')
+
+if not os.environ.get('DESTDIR'):
+ print('Compiling gsettings schemas…')
+ subprocess.call(['glib-compile-schemas', schemadir])
+
+ print('Updating icon cache…')
+ icon_cache_dir = os.path.join(install_prefix, 'share/icons/hicolor')
+ subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
+
+ print('Updating desktop database…')
+ desktop_database_dir = os.path.join(install_prefix, 'share/applications')
+ subprocess.call(['update-desktop-database', '-q', desktop_database_dir])
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..8db7be4
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,13 @@
+sizes = ['16x16', '22x22', '32x32', '48x48']
+
+foreach size: sizes
+ install_data(
+ join_paths(size, application_id + '.png'),
+ install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', size, 'apps')
+ )
+endforeach
+
+install_data(
+ join_paths('symbolic', application_id + '-symbolic.svg'),
+ install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps')
+)
\ No newline at end of file
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..97b8e68
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,57 @@
+subdir('icons')
+
+desktop_file = i18n.merge_file('desktop-file',
+ type: 'desktop',
+ input: '@0 desktop in'.format(application_id),
+ output: '@0@.desktop'.format(application_id),
+ po_dir: join_paths(meson.source_root(), 'po'),
+ install: true,
+ install_dir: join_paths(get_option('datadir'), 'applications'),
+)
+
+desktop_file_validate = find_program('desktop-file-validate', required: false)
+if desktop_file_validate.found()
+ test(
+ 'validate-desktop',
+ desktop_file_validate,
+ args: [
+ desktop_file.full_path(),
+ ],
+ )
+endif
+
+appdata_file = i18n.merge_file('appdata-file',
+ input: '@0 appdata xml in'.format(application_id),
+ output: '@0 appdata xml'.format(application_id),
+ po_dir: join_paths(meson.source_root(), 'po'),
+ install: true,
+ install_dir: join_paths(get_option('datadir'), 'metainfo'),
+)
+
+appstream_util = find_program('appstream-util', required: false)
+if appstream_util.found()
+ test(
+ 'validate-appdata', appstream_util,
+ args: [
+ 'validate-relax', '--nonet', appdata_file.full_path(),
+ ],
+ )
+endif
+
+install_data(
+ 'org.gnome.hitori.gschema.xml',
+ install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas'),
+)
+
+xmllint = find_program('xmllint', required: false)
+if xmllint.found()
+ gtk_prefix = gtk_dependency.get_pkgconfig_variable('prefix')
+ test(
+ 'validate-ui', xmllint,
+ args: [
+ '--nonet', '--noblanks', '--noout',
+ '--relaxng', join_paths(gtk_prefix, 'share', 'gtk-3.0', 'gtkbuilder.rng'),
+ files('hitori.ui'),
+ ],
+ )
+endif
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..883d739
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,17 @@
+help_media = [
+ 'figures/hitori_main_window.png',
+]
+help_files = [
+ 'customization.page',
+ 'game.page',
+ 'index.page',
+ 'legal.xml',
+ 'playing.page',
+ 'strategy.page',
+]
+
+gnome.yelp(meson.project_name(),
+ sources: help_files,
+ media: help_media,
+ symlink_media: true,
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..a717423
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,98 @@
+project('hitori', 'c',
+ version: '3.22.4',
+ meson_version : '>= 0.48.0',
+ license: 'GPLv3+',
+ default_options : [
+ 'buildtype=debugoptimized',
+ 'warning_level=2',
+ 'c_std=gnu11',
+ ],
+)
+
+i18n = import('i18n')
+gnome = import('gnome')
+application_id = 'org.gnome.Hitori'
+
+# Dependencies
+glib_dependency = dependency('glib-2.0')
+gio_dependency = dependency('gio-2.0', version: '>= 2.32')
+gtk_dependency = dependency('gtk+-3.0', version: '>= 3.15.0')
+gmodule_dependency = dependency('gmodule-2.0')
+cairo_dependency = dependency('cairo', version: '>= 1.4')
+
+config_h = configuration_data()
+config_h.set_quoted('PACKAGE', meson.project_name())
+config_h.set_quoted('PACKAGE_URL', 'https://wiki.gnome.org/Apps/Hitori')
+config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+config_h.set_quoted('PACKAGE_LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir')))
+config_h.set_quoted('VERSION', meson.project_version())
+
+# Enable warning flags
+test_c_args = [
+ '-fno-strict-aliasing',
+ '-fstack-protector-strong',
+ '-Waggregate-return',
+ '-Wall',
+ '-Wunused',
+ '-Warray-bounds',
+ '-Wcast-align',
+ '-Wclobbered',
+ '-Wno-declaration-after-statement',
+ '-Wduplicated-branches',
+ '-Wduplicated-cond',
+ '-Wempty-body',
+ '-Wformat=2',
+ '-Wformat-nonliteral',
+ '-Wformat-security',
+ '-Wformat-signedness',
+ '-Wignored-qualifiers',
+ '-Wimplicit-function-declaration',
+ '-Wincompatible-pointer-types',
+ '-Wincompatible-pointer-types-discards-qualifiers',
+ '-Winit-self',
+ '-Wint-conversion',
+ '-Wlogical-op',
+ '-Wmisleading-indentation',
+ '-Wmissing-declarations',
+ '-Wmissing-format-attribute',
+ '-Wmissing-include-dirs',
+ '-Wmissing-noreturn',
+ '-Wmissing-parameter-type',
+ '-Wmissing-prototypes',
+ '-Wnested-externs',
+ '-Wno-error=cpp',
+ '-Wno-discarded-qualifiers',
+ '-Wno-missing-field-initializers',
+ '-Wno-suggest-attribute=format',
+ '-Wno-unused-parameter',
+ '-Wnull-dereference',
+ '-Wold-style-definition',
+ '-Woverflow',
+ '-Woverride-init',
+ '-Wparentheses',
+ '-Wpointer-arith',
+ '-Wredundant-decls',
+ '-Wreturn-type',
+ '-Wshadow',
+ '-Wsign-compare',
+ '-Wstrict-aliasing=2',
+ '-Wstrict-prototypes',
+ '-Wswitch-default',
+ '-Wswitch-enum',
+ '-Wtype-limits',
+ '-Wundef',
+ '-Wuninitialized',
+ '-Wunused-but-set-variable',
+ '-Wunused-result',
+ '-Wunused-variable',
+ '-Wwrite-strings'
+]
+cc = meson.get_compiler('c')
+add_project_arguments(cc.get_supported_arguments(test_c_args), language: 'c')
+
+subdir('data')
+subdir('help')
+subdir('po')
+subdir('src')
+
+meson.add_install_script('build-aux/meson_post_install.py')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..e9b77d7
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(meson.project_name(), preset: 'glib')
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..9860fb5
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,40 @@
+sources = files(
+ 'generator.c',
+ 'interface.c',
+ 'main.c',
+ 'rules.c',
+)
+
+if not cc.has_function('atexit')
+ error('atexit() needed for generated GResource files')
+endif
+
+resources = gnome.compile_resources(
+ 'hitori-resources',
+ '@0 gresource xml'.format(meson.project_name()),
+ source_dir: meson.source_root(),
+)
+
+config_header = configure_file(
+ output: 'config.h',
+ configuration: config_h,
+)
+
+executable(
+ meson.project_name(),
+ sources + resources,
+ config_header,
+ dependencies: [
+ glib_dependency,
+ gio_dependency,
+ gtk_dependency,
+ gmodule_dependency,
+ cairo_dependency
+ ],
+ install: true,
+ c_args: [
+ '-DHAVE_CONFIG_H',
+ '-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name())
+ ],
+ install_dir: get_option('bindir'),
+)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]