[gnome-mahjongg] meson: add meson_options.txt for post install options as well as removing need for meson_post_instal



commit cf5d3b69ad7f5d0eaead5efd60629008a2566b35
Author: Alberto Ruiz <aruiz gnome org>
Date:   Sat Apr 25 17:30:21 2020 +0200

    meson: add meson_options.txt for post install options as well as removing need for meson_post_install.py, 
refactor some bits of meson scripts in the process

 data/meson.build           | 52 +++++++++++++++++++++++++++++++++++-----------
 data/meson_post_install.py | 13 ------------
 meson.build                | 16 +++++++-------
 meson_options.txt          |  2 ++
 src/meson.build            | 42 ++++++++++++++++++++++---------------
 5 files changed, 75 insertions(+), 50 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 27b1696..8142127 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,23 +1,36 @@
-install_data (join_paths ('icons', 'hicolor', 'scalable', 'org.gnome.Mahjongg.svg'),
-              install_dir: join_paths (datadir, 'icons', 'hicolor', 'scalable', 'apps'))
-install_data (join_paths ('icons', 'hicolor', 'symbolic', 'org.gnome.Mahjongg-symbolic.svg'),
-              install_dir: join_paths (datadir, 'icons', 'hicolor', 'symbolic', 'apps'))
+hicolordir = datadir / 'icons' / 'hicolor'
+
+install_data ('icons' / 'hicolor' / 'scalable' / 'org.gnome.Mahjongg.svg',
+              install_dir: hicolordir / 'scalable' / 'apps')
+install_data ('icons' / 'hicolor' / 'symbolic' / 'org.gnome.Mahjongg-symbolic.svg',
+              install_dir: hicolordir / 'symbolic' / 'apps')
+
+schemasdir = gio_dep.get_pkgconfig_variable(
+  'schemasdir',
+  define_variable : [
+    'datadir',
+    get_option('datadir')
+  ]
+)
 
 install_data ('org.gnome.Mahjongg.gschema.xml',
-              install_dir: join_paths (datadir, 'glib-2.0', 'schemas'))
+              install_dir: schemasdir)
 
 install_data ('mahjongg.map', install_dir: join_paths (pkgdatadir, 'maps'))
 install_data ('postmodern.svg', install_dir: join_paths (pkgdatadir, 'themes'))
 install_data ('smooth.png', install_dir: join_paths (pkgdatadir, 'themes'))
 install_data ('edu_kang_xi.png', install_dir: join_paths (pkgdatadir, 'themes'))
 
-desktop_file = i18n.merge_file ('desktop-file',
-                 input: 'org.gnome.Mahjongg.desktop.in',
-                 output: 'org.gnome.Mahjongg.desktop',
-                 install: true,
-                 install_dir: join_paths (datadir, 'applications'),
-                 po_dir: '../po',
-                 type: 'desktop')
+desktop_file = i18n.merge_file (
+  'desktop-file',
+  input:       'org.gnome.Mahjongg.desktop.in',
+  output:      'org.gnome.Mahjongg.desktop',
+  install:     true,
+  install_dir: datadir / 'applications',
+  po_dir:      '../po',
+  type:        'desktop'
+)
+
 desktop_file_validate = find_program('desktop-file-validate', required: false)
 if desktop_file_validate.found()
   test(
@@ -50,3 +63,18 @@ install_man ('gnome-mahjongg.6')
 resources = gnome.compile_resources ('resources', 'org.gnome.Mahjongg.gresource.xml',
                                      source_dir: '.',
                                      c_name: 'resources')
+
+# Compile GSettings schemas
+
+if get_option('compile-schemas').enabled()
+  compileschemas = gio_dep.get_pkgconfig_variable('glib_compile_schemas')
+  meson.add_install_script(compileschemas, get_option('prefix') / schemasdir)
+endif
+
+# Rebuild icon cache
+
+if get_option('update-icon-cache').enabled()
+  updateiconcache = find_program('gtk-update-icon-cache')
+  meson.add_install_script(updateiconcache.path(), '-t', '-f', get_option('prefix') / hicolordir / 
'scalable')
+  meson.add_install_script(updateiconcache.path(), '-t', '-f', get_option('prefix') / hicolordir / 
'symbolic')
+endif
diff --git a/meson.build b/meson.build
index 7f709de..c40e78b 100644
--- a/meson.build
+++ b/meson.build
@@ -5,24 +5,24 @@ project ('gnome-mahjongg', ['vala', 'c'],
              'warning_level=1',
              'buildtype=debugoptimized',
          ],
-         meson_version: '>= 0.37.1')
+         meson_version: '>= 0.49.0')
 
 gnome = import ('gnome')
 i18n = import ('i18n')
 
 # Paths
-mandir = join_paths (get_option ('prefix'), get_option ('mandir'))
-localedir = join_paths (get_option ('prefix'), get_option ('localedir'))
-datadir = join_paths (get_option ('prefix'), get_option ('datadir'))
-pkgdatadir = join_paths (datadir, 'gnome-mahjongg')
+mandir     = get_option ('prefix') / get_option ('mandir')
+localedir  = get_option ('prefix') / get_option ('localedir')
+datadir    = get_option ('prefix') / get_option ('datadir')
+pkgdatadir = datadir / 'gnome-mahjongg'
 
 # Dependencies
-glib_dep = dependency ('glib-2.0', version: '>= 2.40.0')
-gtk_dep = dependency ('gtk+-3.0', version: '>= 3.13.2')
+glib_dep    = dependency ('glib-2.0', version: '>= 2.40.0')
+gio_dep     = dependency ('gio-2.0', version: '>= 2.40.0')
+gtk_dep     = dependency ('gtk+-3.0', version: '>= 3.13.2')
 librsvg_dep = dependency ('librsvg-2.0', version: '>= 2.32.0')
 
 subdir ('po')
 subdir ('data')
 subdir ('help')
 subdir ('src')
-meson.add_install_script ('data/meson_post_install.py')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..2dcdf83
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('compile-schemas', type: 'feature', value : 'disabled', description : 'Compile GSettings schemas on 
install')
+option('update-icon-cache', type: 'feature', value : 'disabled', description : 'Update icon cache')
diff --git a/src/meson.build b/src/meson.build
index 9ab079d..4227c3a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,19 +1,27 @@
 
 
-gnome_mahjongg = executable ('gnome-mahjongg',
-                             [ 'config.vapi',
-                               'game.vala',
-                               'game-view.vala',                               
-                               'gnome-mahjongg.vala',
-                               'history.vala',
-                               'map.vala',                               
-                               'score-dialog.vala'] + resources,
-                             dependencies: [ glib_dep,
-                                             gtk_dep,
-                                             librsvg_dep ],
-                             vala_args: [ '--pkg=posix' ],
-                             c_args: [ '-DVERSION="@0@"'.format (meson.project_version ()),
-                                       '-DGETTEXT_PACKAGE="gnome-mahjongg"',
-                                       '-DLOCALEDIR="@0@"'.format (localedir),
-                                       '-DDATA_DIRECTORY="@0@"'.format (pkgdatadir) ],
-                             install: true )
+gnome_mahjongg = executable (
+  'gnome-mahjongg',
+  resources + [
+    'config.vapi',
+    'game.vala',
+    'game-view.vala',
+    'gnome-mahjongg.vala',
+    'history.vala',
+    'map.vala',
+    'score-dialog.vala'
+  ],
+  dependencies: [
+    glib_dep,
+    gtk_dep,
+    librsvg_dep
+  ],
+  vala_args: [ '--pkg=posix' ],
+  c_args: [
+    '-DVERSION="@0@"'.format (meson.project_version ()),
+    '-DGETTEXT_PACKAGE="gnome-mahjongg"',
+    '-DLOCALEDIR="@0@"'.format (localedir),
+    '-DDATA_DIRECTORY="@0@"'.format (pkgdatadir)
+  ],
+  install: true
+)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]