[lightsoff] Drop autotools and port to meson (bgo#793309)



commit 7eb528a7149ad0d5dea8f2dbb0366b8aec0bf53a
Author: Robert Roth <robert roth off gmail com>
Date:   Tue May 1 07:56:18 2018 +0300

    Drop autotools and port to meson (bgo#793309)

 Makefile.am                                        |   10 -
 autogen.sh                                         |   46 ---
 configure.ac                                       |   74 ----
 data/Makefile.am                                   |   41 --
 data/icons/Makefile.am                             |    3 -
 data/icons/hicolor/Makefile.am                     |    9 -
 .../hicolor/scalable/{ => apps}/lightsoff.svg      |    0
 .../lightsoff-symbolic}                            |    0
 data/meson.build                                   |   38 ++
 git.mk                                             |  400 --------------------
 help/LINGUAS                                       |   18 +
 help/Makefile.am                                   |   24 --
 help/meson.build                                   |   23 ++
 meson.build                                        |   56 +++
 meson_post_install.py                              |   16 +
 po/meson.build                                     |    3 +
 src/Makefile.am                                    |   43 ---
 src/game-view.vala                                 |    8 +-
 src/lightsoff.vala                                 |    8 +-
 src/meson.build                                    |   47 +++
 {src => vapi}/config.vapi                          |   12 +-
 21 files changed, 218 insertions(+), 661 deletions(-)
---
diff --git a/data/icons/hicolor/scalable/lightsoff.svg b/data/icons/hicolor/scalable/apps/lightsoff.svg
similarity index 100%
rename from data/icons/hicolor/scalable/lightsoff.svg
rename to data/icons/hicolor/scalable/apps/lightsoff.svg
diff --git a/data/icons/hicolor/symbolic/lightsoff-symbolic.svg 
b/data/icons/hicolor/symbolic/apps/lightsoff-symbolic
similarity index 100%
rename from data/icons/hicolor/symbolic/lightsoff-symbolic.svg
rename to data/icons/hicolor/symbolic/apps/lightsoff-symbolic
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..0b3415c
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,38 @@
+# Icons
+install_subdir('icons',
+  install_dir: datadir,
+)
+
+# UI files
+install_data(['off.svg', 'on.svg', 'highlight.svg'],
+  install_dir: pkgdatadir,
+)
+
+desktop = 'lightsoff.desktop'
+
+# Desktop file
+i18n.merge_file(
+  input: desktop + '.in',
+  output: desktop,
+  type: 'desktop',
+  po_dir: podir,
+  install: true,
+  install_dir: join_paths(datadir, 'applications'),
+)
+
+appdata = 'lightsoff.appdata.xml'
+
+# Appdata
+i18n.merge_file(
+  input: appdata + '.in',
+  output: appdata,
+  po_dir: podir,
+  install: true,
+  install_dir: join_paths(datadir, 'metainfo')
+)
+
+# Gschema
+install_data('org.gnome.lightsoff.gschema.xml',
+  install_dir: join_paths(datadir, 'glib-2.0', 'schemas'),
+)
+
diff --git a/help/LINGUAS b/help/LINGUAS
new file mode 100644
index 0000000..01489e6
--- /dev/null
+++ b/help/LINGUAS
@@ -0,0 +1,18 @@
+ca
+cs
+de
+el
+es
+fi
+fr
+gl
+hu
+ko
+pl
+pt_BR
+ro
+ru
+sl
+sv
+zh_CN
+
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..c472a21
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,23 @@
+lightsoff_help_pages = [
+    'basic.page',
+    'bug-filing.page',
+    'develop.page',
+    'documentation.page',
+    'index.page',
+    'legal.xml',
+    'license.page',
+    'rules.page',
+    'strategy.page',
+    'translate.page',
+]
+
+lightsoff_help_media = [
+    'figures/lightsoff.jpg',
+    'figures/lightsoff_logo.jpg',
+    'figures/lo1.jpg',
+    'figures/lightsoff.ogv',
+]
+
+gnome.yelp(meson.project_name(),
+           sources: lightsoff_help_pages,
+           media: lightsoff_help_media)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..e47dda0
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,56 @@
+project('lightsoff', ['c','vala'],
+       version: '3.28.0',
+       meson_version: '>= 0.43.0',
+       license: 'GPLv2+'
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+localedir = join_paths(get_option('prefix'), get_option('localedir'))
+datadir = join_paths (get_option ('prefix'), get_option ('datadir'))
+pkgdatadir = join_paths (datadir, 'lightsoff')
+
+podir = join_paths(meson.source_root(), 'po')
+vapidir = join_paths(meson.source_root(), 'vapi')
+
+# Dependencies
+glib_min_version = '2.38'
+
+glib_dep = dependency('glib-2.0', version: '>= ' + glib_min_version)
+gmodule_dep = dependency('gmodule-2.0')
+gio_dep = dependency('gio-2.0', version: '>= ' + glib_min_version)
+gtk_dep = dependency('gtk+-3.0', version: '>= 3.13.4')
+clutter_dep = dependency('clutter-1.0', version: '>= 1.14.0')
+clutter_gtk_dep = dependency('clutter-gtk-1.0', version: '>= 1.5.0')
+librsvg_dep = dependency('librsvg-2.0', version: '>= 2.32.0')
+
+# Check for compilers
+valac = meson.get_compiler('vala')
+cc = meson.get_compiler('c')
+
+# Libraries
+libmath_dep = cc.find_library('m')
+config_dep = valac.find_library('config', dirs: vapidir)
+posix_dep = valac.find_library('posix')
+
+# Configuration
+conf = configuration_data()
+
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('LOCALEDIR', localedir)
+conf.set_quoted('DATADIR', pkgdatadir)
+conf.set_quoted('VERSION', meson.project_version())
+
+config_h_inc = include_directories('.')
+
+# Subdirs
+subdir('data')
+subdir('help')
+subdir('po')
+subdir('src')
+
+config_file = configure_file(output: 'config.h', configuration: conf)
+
+# Extra scripts
+meson.add_install_script('meson_post_install.py')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..e15992f
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+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')
+
+if not os.environ.get('DESTDIR'):
+    print('Update icon cache...')
+    subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+
+    print('Compiling gsettings schemas...')
+    subprocess.call(['glib-compile-schemas', schemadir])
+
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..fe7c2ec
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+i18n.gettext(meson.project_name(),
+             preset: 'glib'
+)
diff --git a/src/game-view.vala b/src/game-view.vala
index b108b37..2dbafad 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -8,6 +8,8 @@
  * license.
  */
 
+using Config;
+
 public void setup_animation (Clutter.Actor actor, Clutter.AnimationMode mode, uint duration) {
     actor.set_easing_duration (duration);
     actor.set_easing_mode (mode);
@@ -44,9 +46,9 @@ public class GameView : Clutter.Group
     {
         try
         {
-            highlight_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, 
"highlight.svg"));
-            off_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, "off.svg"));
-            on_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, "on.svg"));
+            highlight_texture = new Clutter.Texture.from_file (Path.build_filename (Config.DATADIR, 
"highlight.svg"));
+            off_texture = new Clutter.Texture.from_file (Path.build_filename (Config.DATADIR, "off.svg"));
+            on_texture = new Clutter.Texture.from_file (Path.build_filename (Config.DATADIR, "on.svg"));
         }
         catch (Clutter.TextureError e)
         {
diff --git a/src/lightsoff.vala b/src/lightsoff.vala
index c1cc025..3fc40e9 100644
--- a/src/lightsoff.vala
+++ b/src/lightsoff.vala
@@ -10,6 +10,8 @@
  * license.
  */
 
+using Config;
+
 public class LightsOff : Gtk.Application
 {
     private LightsoffWindow window;
@@ -102,9 +104,9 @@ public class LightsOff : Gtk.Application
     public static int main (string[] args)
     {
         Intl.setlocale (LocaleCategory.ALL, "");
-        Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-        Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-        Intl.textdomain (GETTEXT_PACKAGE);
+        Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
+        Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
+        Intl.textdomain (Config.GETTEXT_PACKAGE);
 
         Environment.set_application_name (_("Lights Off"));
 
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..4efe6e2
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,47 @@
+lightsoff_vala_sources = [
+  'board-view.vala',
+  'lightsoff.vala',
+  'lightsoff-window.vala',
+  'puzzle-generator.vala',
+  'game-view.vala',
+]
+
+lightsoff_resources_file = files('lightsoff.gresource.xml')
+lightsoff_resources = gnome.compile_resources('lightsoff.gresource.xml', lightsoff_resources_file)
+
+sources = [
+  lightsoff_vala_sources,
+  lightsoff_resources
+]
+
+deps = [
+  glib_dep,
+  gio_dep,
+  gtk_dep,
+  clutter_dep,
+  clutter_gtk_dep,
+  librsvg_dep,
+  libmath_dep,
+  config_dep,
+  posix_dep,
+  libmath_dep,
+  gmodule_dep,
+]
+
+vala_flags = [
+  '--gresources', lightsoff_resources_file
+]
+
+c_flags = [
+  '-DDATADIR="@0@"'.format(pkgdatadir),
+  '-DLOCALEDIR="@0@"'.format(localedir),
+  '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name())
+]
+
+executable('lightsoff', sources,
+  dependencies: deps,
+  include_directories: config_h_inc,
+  c_args: c_flags,
+  vala_args: vala_flags,
+  install: true,
+)
diff --git a/src/config.vapi b/vapi/config.vapi
similarity index 60%
rename from src/config.vapi
rename to vapi/config.vapi
index 978a7f7..11a3d90 100644
--- a/src/config.vapi
+++ b/vapi/config.vapi
@@ -7,8 +7,10 @@
  * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
  * license.
  */
-
-public const string DATADIR;
-public const string GETTEXT_PACKAGE;
-public const string VERSION;
-public const string LOCALEDIR;
+[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
+namespace Config {
+    public const string DATADIR;
+    public const string GETTEXT_PACKAGE;
+    public const string VERSION;
+    public const string LOCALEDIR;
+}


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