[swell-foop/wip/inigomartinez/meson: 1/5] meson: Use best practices



commit 1edfc7bb423ed77d08ef1db1bec6093823e94645
Author: Robert Roth <robert roth off gmail com>
Date:   Fri Feb 9 21:01:42 2018 +0200

    meson: Use best practices

 data/meson.build      |   21 ++++++++++++---------
 help/meson.build      |    8 ++++----
 meson.build           |   26 ++++++++++++--------------
 meson_post_install.py |   11 +++++------
 src/meson.build       |   34 +++++++++++++++-------------------
 5 files changed, 48 insertions(+), 52 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 7df55a6..9482a71 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,6 +1,6 @@
 # Icons
 install_subdir('icons',
-  install_dir: join_paths(get_option('datadir')),
+  install_dir: datadir,
   exclude_files: [ 'Makefile', 'Makefile.in', 'Makefile.am', 'icon-source.svg','.gitignore' ],
 )
 
@@ -22,28 +22,31 @@ install_data('swell-foop.css',
   install_dir: pkgdatadir,
 )
 
+desktop = 'swell-foop.desktop'
+
 # Desktop file
 i18n.merge_file(
-  input: 'swell-foop.desktop.in',
-  output: 'swell-foop.desktop',
+  input: desktop + '.in',
+  output: desktop,
   type: 'desktop',
   po_dir: podir,
   install: true,
-  install_dir: join_paths(get_option('datadir'), 'applications'),
+  install_dir: join_paths(datadir, 'applications'),
 )
 
+appdata = 'swell-foop.appdata.xml'
+
 # Appdata
 i18n.merge_file(
-  input: 'swell-foop.appdata.xml.in',
-  output: 'swell-foop.appdata.xml',
-  type: 'xml',
+  input: appdata + '.in',
+  output: appdata,
   po_dir: podir,
   install: true,
-  install_dir: join_paths(get_option('datadir'), 'metainfo')
+  install_dir: join_paths(datadir, 'metainfo')
 )
 
 # Gschema
 install_data('org.gnome.swell-foop.gschema.xml',
-  install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas'),
+  install_dir: join_paths(datadir, 'glib-2.0', 'schemas'),
 )
 
diff --git a/help/meson.build b/help/meson.build
index 6b86f8a..1bfd161 100644
--- a/help/meson.build
+++ b/help/meson.build
@@ -1,9 +1,9 @@
-swell_foop_help_pages = [
+help_pages = [
   'legal.xml',
   'index.docbook',
 ]
 
-swell_foop_help_media = [
+help_media = [
   'figures/play1.png',
   'figures/play2.png',
   'figures/play3.png',
@@ -12,6 +12,6 @@ swell_foop_help_media = [
 ]
 
 gnome.yelp(meson.project_name(),
-  sources: swell_foop_help_pages,
-  media: swell_foop_help_media
+  sources: help_pages,
+  media: help_media
 )
diff --git a/meson.build b/meson.build
index 73dfd07..6264249 100644
--- a/meson.build
+++ b/meson.build
@@ -16,20 +16,20 @@ pkgdatadir = join_paths (datadir, 'swell-foop')
 
 glib_min_version = '2.36'
 
-glib = dependency('glib-2.0', version: '>= ' + glib_min_version)
-gmodule = dependency('gmodule-2.0')
-gobject = dependency('gobject-2.0', version: '>= ' + glib_min_version)
-gtk = dependency('gtk+-3.0', version: '>= 3.12')
-clutter = dependency('clutter-1.0', version: '>= 1.14.0')
-clutter_gtk = dependency('clutter-gtk-1.0', version: '>= 1.5.0')
+glib_dep = dependency('glib-2.0', version: '>= ' + glib_min_version)
+gmodule_dep = dependency('gmodule-2.0')
+gobject_dep = dependency('gobject-2.0', version: '>= ' + glib_min_version)
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.12')
+clutter_dep = dependency('clutter-1.0', version: '>= 1.14.0')
+clutter_gtk_dep = dependency('clutter-gtk-1.0', version: '>= 1.5.0')
 
 # Check for compilers
 valac = meson.get_compiler('vala')
 cc = meson.get_compiler('c')
 
 # Libraries
-libmath = cc.find_library('m')
-posix = valac.find_library('posix')
+libmath_dep = cc.find_library('m')
+posix_dep = valac.find_library('posix')
 
 # Configuration
 conf = configuration_data()
@@ -39,11 +39,7 @@ conf.set_quoted('LOCALEDIR', localedir)
 conf.set_quoted('DATADIR', pkgdatadir)
 conf.set_quoted('VERSION', meson.project_version())
 
-configure_file(output: 'config.h', configuration: conf)
-config_h_dir = include_directories('.')
-
-# Extra scripts
-meson.add_install_script('meson_post_install.py')
+config_h_inc = include_directories('.')
 
 # Subdirs
 subdir('data')
@@ -51,4 +47,6 @@ subdir('src')
 subdir('help')
 subdir('po')
 
-
+config_file = configure_file(output: 'config.h', configuration: conf)
+# Extra scripts
+meson.add_install_script('meson_post_install.py', datadir)
diff --git a/meson_post_install.py b/meson_post_install.py
index 125789a..10a87fb 100644
--- a/meson_post_install.py
+++ b/meson_post_install.py
@@ -2,15 +2,14 @@
 
 import os
 import subprocess
-
-install_prefix = os.environ['MESON_INSTALL_PREFIX']
-icondir = os.path.join(install_prefix, 'share', 'icons', 'hicolor')
-schemadir = os.path.join(install_prefix, 'share', 'glib-2.0', 'schemas')
+import sys
 
 if not os.environ.get('DESTDIR'):
+  icon_dir = os.path.join(sys.argv[1], 'icons', 'hicolor')
+  schema_dir = os.path.join(sys.argv[1], 'glib-2.0', 'schemas')
   print('Update icon cache...')
-  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icon_dir])
 
   print('Compiling gsettings schemas...')
-  subprocess.call(['glib-compile-schemas', schemadir])
+  subprocess.call(['glib-compile-schemas', schema_dir])
 
diff --git a/src/meson.build b/src/meson.build
index b9262f3..d1ab2b9 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,4 +1,4 @@
-swell_foop_sources = [
+sources = [
   'config.vapi',
   'history.vala',
   'game.vala',
@@ -7,31 +7,27 @@ swell_foop_sources = [
   'swell-foop.vala',
 ]
 
-swell_foop_deps = [
-  posix,
-  libmath,
-  gmodule,
-  glib,
-  gobject,
-  gtk,
-  clutter,
-  clutter_gtk,
+deps = [
+  posix_dep,
+  libmath_dep,
+  gmodule_dep,
+  glib_dep,
+  gobject_dep,
+  gtk_dep,
+  clutter_dep,
+  clutter_gtk_dep,
 ]
 
-swell_foop_c_flags = [ 
+c_flags = [ 
   '-DVERSION="@0@"'.format (meson.project_version ()),
   '-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()),
   '-DLOCALEDIR="@0@"'.format (localedir),
   '-DDATADIR="@0@"'.format (pkgdatadir),
 ]
 
-swell_foop_vala_flags = [
-  '--target-glib', glib_min_version,
-]
-
-executable('swell-foop', swell_foop_sources,
-  dependencies: swell_foop_deps,
-  vala_args: swell_foop_vala_flags,
-  c_args: swell_foop_c_flags,
+executable('swell-foop', sources,
+  dependencies: deps,
+  include_directories: config_h_inc,
+  c_args: c_flags,
   install: true,
 )


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