[iagno] ditch autotools and migrate to meson



commit fe76afa7dca25228e0af05b9aee38063d22eb076
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Thu Dec 13 15:18:28 2018 +0100

    ditch autotools and migrate to meson
    
    Squash of the 6 main commits from Bilal
    Elmoussaoui branch (no app-id changes).
    
    Edited a bit by Arnaud Bonatti, to keep
    the COPYING file, avoid adding trailing
    spaces, use a variable named pkgdatadir
    instead of datadir (as suggested by Jan
    Tojnar), use new-lines at end of files,
    consistently use 4 spaces and not tabs.
    
    Closes !4 (see also following patches).

 Makefile.am                                        |  10 ---
 autogen.sh                                         |  47 -----------
 build-aux/meson_post_install.py                    |  14 ++++
 configure.ac                                       |  76 -----------------
 data/Makefile.am                                   |  56 -------------
 data/iagno.gresource.xml                           |   9 +++
 data/icons/Makefile.am                             |   3 -
 .../16x16/{iagno.png => org.gnome.iagno.png}       | Bin
 .../22x22/{iagno.png => org.gnome.iagno.png}       | Bin
 .../24x24/{iagno.png => org.gnome.iagno.png}       | Bin
 .../256x256/{iagno.png => org.gnome.iagno.png}     | Bin
 .../32x32/{iagno.png => org.gnome.iagno.png}       | Bin
 .../48x48/{iagno.png => org.gnome.iagno.png}       | Bin
 data/icons/hicolor/Makefile.am                     |  19 -----
 .../org.gnome.iagno-symbolic.svg}                  |   0
 data/meson.build                                   |  90 +++++++++++++++++++++
 ...pdata.xml.in => org.gnome.iagno.appdata.xml.in} |   2 +-
 ...iagno.desktop.in => org.gnome.iagno.desktop.in} |   2 +-
 data/{ => sounds}/flip-piece.ogg                   | Bin
 data/{ => sounds}/gameover.ogg                     | Bin
 data/themes/Makefile.am                            |  16 ----
 data/themes/meson.build                            |  16 ++++
 data/{ => ui}/iagno-screens.ui                     |   0
 data/{ => ui}/iagno-themes.ui                      |   0
 data/{ => ui}/iagno.ui                             |   0
 help/LINGUAS                                       |  19 +++++
 help/Makefile.am                                   |  31 -------
 help/meson.build                                   |  32 ++++++++
 meson.build                                        |  45 +++++++++++
 org.gnome.iagno.json                               |   1 +
 po/Makevars                                        |  78 ------------------
 po/POTFILES.in                                     |  10 +--
 po/meson.build                                     |   1 +
 src/Makefile.am                                    |  66 ---------------
 src/iagno.gresource.xml                            |   9 ---
 src/iagno.vala                                     |   4 +-
 src/meson.build                                    |  43 ++++++++++
 src/{ => vapi}/config.vapi                         |   0
 src/vapi/libcanberra-gtk3.vapi                     |  33 ++++++++
 39 files changed, 312 insertions(+), 420 deletions(-)
---
diff --git a/build-aux/meson_post_install.py b/build-aux/meson_post_install.py
new file mode 100644
index 0000000..6d18340
--- /dev/null
+++ b/build-aux/meson_post_install.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+from os import environ, path
+from subprocess import call
+
+if not environ.get('DESTDIR', ''):
+    PREFIX = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+    DATA_DIR = path.join(PREFIX, 'share')
+    print('Updating icon cache...')
+    call(['gtk-update-icon-cache', '-qtf', path.join(DATA_DIR, 'icons/hicolor')])
+    print("Compiling new schemas")
+    call(["glib-compile-schemas", path.join(DATA_DIR, 'glib-2.0/schemas')])
+    print("Updating desktop database")
+    call(["update-desktop-database", path.join(DATA_DIR, 'applications')])
diff --git a/data/iagno.gresource.xml b/data/iagno.gresource.xml
new file mode 100644
index 0000000..c708194
--- /dev/null
+++ b/data/iagno.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/iagno/ui">
+    <file preprocess="xml-stripblanks" compressed="true" alias="game-window.ui">ui/iagno.ui</file>
+    <file preprocess="xml-stripblanks" compressed="true" alias="themes.ui">ui/iagno-themes.ui</file>
+    <file preprocess="xml-stripblanks" compressed="true" alias="iagno-screens.ui">ui/iagno-screens.ui</file>
+    <file compressed="true">iagno.css</file>
+  </gresource>
+</gresources>
diff --git a/data/icons/hicolor/16x16/iagno.png b/data/icons/hicolor/16x16/org.gnome.iagno.png
similarity index 100%
rename from data/icons/hicolor/16x16/iagno.png
rename to data/icons/hicolor/16x16/org.gnome.iagno.png
diff --git a/data/icons/hicolor/22x22/iagno.png b/data/icons/hicolor/22x22/org.gnome.iagno.png
similarity index 100%
rename from data/icons/hicolor/22x22/iagno.png
rename to data/icons/hicolor/22x22/org.gnome.iagno.png
diff --git a/data/icons/hicolor/24x24/iagno.png b/data/icons/hicolor/24x24/org.gnome.iagno.png
similarity index 100%
rename from data/icons/hicolor/24x24/iagno.png
rename to data/icons/hicolor/24x24/org.gnome.iagno.png
diff --git a/data/icons/hicolor/256x256/iagno.png b/data/icons/hicolor/256x256/org.gnome.iagno.png
similarity index 100%
rename from data/icons/hicolor/256x256/iagno.png
rename to data/icons/hicolor/256x256/org.gnome.iagno.png
diff --git a/data/icons/hicolor/32x32/iagno.png b/data/icons/hicolor/32x32/org.gnome.iagno.png
similarity index 100%
rename from data/icons/hicolor/32x32/iagno.png
rename to data/icons/hicolor/32x32/org.gnome.iagno.png
diff --git a/data/icons/hicolor/48x48/iagno.png b/data/icons/hicolor/48x48/org.gnome.iagno.png
similarity index 100%
rename from data/icons/hicolor/48x48/iagno.png
rename to data/icons/hicolor/48x48/org.gnome.iagno.png
diff --git a/data/icons/hicolor/scalable/iagno-symbolic.svg 
b/data/icons/hicolor/symbolic/org.gnome.iagno-symbolic.svg
similarity index 100%
rename from data/icons/hicolor/scalable/iagno-symbolic.svg
rename to data/icons/hicolor/symbolic/org.gnome.iagno-symbolic.svg
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..7998780
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,90 @@
+# Install icons
+icon_sizes = ['16', '22', '24', '32', '48', '256']
+foreach size : icon_sizes
+    install_data(
+        join_paths('icons', 'hicolor', '@0@x@0@'.format(size), '@0@.png'.format(project_id)),
+        install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', '@0@x@0@'.format(size), 'apps')
+    )
+endforeach
+# Install symbolic icon
+install_data(
+        join_paths('icons', 'hicolor', 'symbolic', '@0 -symbolic svg'.format(project_id)),
+    install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps')
+)
+
+# Install gschema
+install_data(
+  '@0  gschema xml'.format(project_id),
+  install_dir : join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
+)
+
+# Compiling gresoruce
+resources = gnome.compile_resources(
+    'resources', '@0  gresource xml'.format(meson.project_name()),
+    source_dir: '.'
+)
+
+# Desktop file
+desktop_file = i18n.merge_file(
+    input: '@0  desktop in'.format(project_id),
+    output: '@0@.desktop'.format(project_id),
+    po_dir: join_paths(meson.source_root(), 'po'),
+    type: 'desktop',
+    install: true,
+    install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
+# Validate desktop file
+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
+appdata_file = i18n.merge_file(
+    input: '@0  appdata xml in'.format(project_id),
+    output: '@0  appdata xml'.format(project_id),
+    po_dir: join_paths(meson.source_root(), 'po'),
+    install: true,
+    install_dir: join_paths(get_option('datadir'), 'metainfo')
+)
+
+# Validate AppData file
+appstream_util = find_program('appstream-util', required: false)
+if appstream_util.found()
+  test(
+    'validate-appdata', appstream_util,
+    args: [
+      'validate-relax', appdata_file.full_path()
+    ]
+  )
+endif
+
+# Install man page
+install_man('@0@.6'.format(meson.project_name()))
+
+# Install sounds
+install_data(
+    [
+        'sounds/flip-piece.ogg',
+        'sounds/gameover.ogg'
+    ],
+    install_dir: join_paths(get_option('datadir'), meson.project_name(), 'sounds')
+)
+
+# Install themes
+install_data(
+    [
+        'black_and_white.svg',
+        'high_contrast.svg',
+        'sun_and_star.svg'
+    ],
+    install_dir: join_paths(get_option('datadir'), meson.project_name(), 'themes', 'svg')
+)
+subdir('themes')
diff --git a/data/iagno.appdata.xml.in b/data/org.gnome.iagno.appdata.xml.in
similarity index 99%
rename from data/iagno.appdata.xml.in
rename to data/org.gnome.iagno.appdata.xml.in
index ce8db55..8d409e2 100644
--- a/data/iagno.appdata.xml.in
+++ b/data/org.gnome.iagno.appdata.xml.in
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- Copyright 2013 Michael Catanzaro and contributors -->
 <component type="desktop">
-  <id>iagno.desktop</id>
+  <id>org.gnome.iagno</id>
   <metadata_license>CC0-1.0</metadata_license>
   <project_license>GPL-3.0+</project_license>
   <name>Iagno</name>
diff --git a/data/iagno.desktop.in b/data/org.gnome.iagno.desktop.in
similarity index 97%
rename from data/iagno.desktop.in
rename to data/org.gnome.iagno.desktop.in
index ffbbfdf..ba2f327 100644
--- a/data/iagno.desktop.in
+++ b/data/org.gnome.iagno.desktop.in
@@ -1,6 +1,6 @@
 [Desktop Entry]
 # Translators: Do NOT translate or transliterate this text (this is an icon file name)!
-Icon=iagno
+Icon=org.gnome.iagno
 Name=Iagno
 GenericName=Reversi
 Comment=Dominate the board in a classic version of Reversi
diff --git a/data/flip-piece.ogg b/data/sounds/flip-piece.ogg
similarity index 100%
rename from data/flip-piece.ogg
rename to data/sounds/flip-piece.ogg
diff --git a/data/gameover.ogg b/data/sounds/gameover.ogg
similarity index 100%
rename from data/gameover.ogg
rename to data/sounds/gameover.ogg
diff --git a/data/themes/meson.build b/data/themes/meson.build
new file mode 100644
index 0000000..b612c1e
--- /dev/null
+++ b/data/themes/meson.build
@@ -0,0 +1,16 @@
+themes = [
+    'adwaita',
+    'classic',
+    'high_contrast',
+    'sun_and_star'
+]
+foreach theme: themes
+    i18n.merge_file(
+        input: '@0  theme desktop in'.format(theme),
+        output: '@0@.theme'.format(theme),
+        po_dir: join_paths(meson.source_root(), 'po'),
+        type: 'desktop',
+        install: true,
+        install_dir: join_paths(get_option('datadir'), 'iagno', 'themes','key')
+    )
+endforeach
diff --git a/data/iagno-screens.ui b/data/ui/iagno-screens.ui
similarity index 100%
rename from data/iagno-screens.ui
rename to data/ui/iagno-screens.ui
diff --git a/data/iagno-themes.ui b/data/ui/iagno-themes.ui
similarity index 100%
rename from data/iagno-themes.ui
rename to data/ui/iagno-themes.ui
diff --git a/data/iagno.ui b/data/ui/iagno.ui
similarity index 100%
rename from data/iagno.ui
rename to data/ui/iagno.ui
diff --git a/help/LINGUAS b/help/LINGUAS
new file mode 100644
index 0000000..6f6c69e
--- /dev/null
+++ b/help/LINGUAS
@@ -0,0 +1,19 @@
+ca
+cs
+de
+el
+en_GB
+es
+eu
+fr
+gl
+hu
+it
+oc
+pl
+pt_BR
+sl
+sr
+sr@latin
+sv
+zh_CN
diff --git a/help/meson.build b/help/meson.build
new file mode 100644
index 0000000..4d95a41
--- /dev/null
+++ b/help/meson.build
@@ -0,0 +1,32 @@
+help_media = [
+    'figures/block.png',
+    'figures/first.png',
+    'figures/iagno-video.ogv',
+    'figures/logo32.png',
+    'figures/logo.png',
+    'figures/start.png'
+]
+help_files = [
+    '2player.page',
+    'ai-game.page',
+    'bug-filing.page',
+    'change-color.page',
+    'develop.page',
+    'documentation.page',
+    'index.page',
+    'legal.xml',
+    'license.page',
+    'play.page',
+    'rules.page',
+    'shortcuts.page',
+    'sound.page',
+    'strategy.page',
+    'translate.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..470a90d
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,45 @@
+project('iagno', ['vala', 'c'],
+    version: '3.30.0')
+
+
+project_id = 'org.gnome.iagno'
+i18n = import('i18n')
+# used to install help
+gnome = import('gnome')
+# used to run post install script
+python3 = import('python3')
+
+
+canberra_dependency = dependency('libcanberra')
+canberra_gtk3_dependency = dependency('libcanberra-gtk3', version: '>= 0.26')
+gio_dependency = dependency('gio-2.0', version: '>= 2.40.0')
+glib_dependency = dependency('glib-2.0', version: '>= 2.40.0')
+gtk_dependency = dependency('gtk+-3.0', version: '>= 3.15.0')
+posix_dependency = meson.get_compiler('vala').find_library('posix')
+rsvg_dependency = dependency('librsvg-2.0', version: '>= 2.32.0')
+
+# Set gettext package name
+add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language: 'c')
+
+localedir = join_paths(get_option('prefix'), get_option('localedir'))
+pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
+soundsdir = join_paths(pkgdatadir, 'sounds')
+
+conf = configuration_data ()
+conf.set_quoted ('VERSION', meson.project_version())
+conf.set_quoted ('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted ('DATA_DIRECTORY', pkgdatadir)
+conf.set_quoted ('SOUND_DIRECTORY', soundsdir)
+conf.set_quoted ('LOCALEDIR', localedir)
+
+configure_file(output: 'config.h', configuration: conf)
+config_h_dir = include_directories('.')
+
+subdir('data')
+subdir('po')
+subdir('help')
+subdir('src')
+
+meson.add_install_script(python3.find_python().path(), join_paths(meson.source_root(),
+                                                                  'build-aux',
+                                                                  'meson_post_install.py'))
diff --git a/org.gnome.iagno.json b/org.gnome.iagno.json
index 96974f2..d892bbb 100644
--- a/org.gnome.iagno.json
+++ b/org.gnome.iagno.json
@@ -43,6 +43,7 @@
     "modules" : [
         {
             "name" : "iagno",
+            "buildsystem": "meson",
             "sources" : [
                 {
                     "type" : "git",
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f2ec6ff..22334c0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,10 +1,10 @@
 # List of source files containing translatable strings.
 # Please keep this file in alphabetical order.
-data/iagno.appdata.xml.in
-data/iagno.desktop.in
-data/iagno-screens.ui
-data/iagno-themes.ui
-data/iagno.ui
+data/org.gnome.iagno.appdata.xml.in
+data/org.gnome.iagno.desktop.in
+data/ui/iagno-screens.ui
+data/ui/iagno-themes.ui
+data/ui/iagno.ui
 data/themes/adwaita.theme.desktop.in
 data/themes/classic.theme.desktop.in
 data/themes/high_contrast.theme.desktop.in
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/iagno.vala b/src/iagno.vala
index 601675e..77884b8 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -84,7 +84,7 @@ public class Iagno : Gtk.Application
         Intl.textdomain (GETTEXT_PACKAGE);
 
         Environment.set_application_name (_("Iagno"));
-        Window.set_default_icon_name ("iagno");
+        Window.set_default_icon_name ("org.gnome.iagno");
 
         return new Iagno ().run (args);
     }
@@ -280,7 +280,7 @@ public class Iagno : Gtk.Application
                            "authors", authors,
                            "documenters", documenters,
                            "translator-credits", _("translator-credits"),
-                           "logo-icon-name", "iagno",
+                           "logo-icon-name", "org.gnome.iagno",
                            "website", "https://wiki.gnome.org/Apps/Iagno";,
                            null);
     }
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..8504a51
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,43 @@
+# Tests
+iagno_tests = executable('iagno_tests',
+    [
+        'test-iagno.vala',
+        'computer-player.vala',
+        'game.vala',
+        'player.vala'
+    ],
+    dependencies : [
+        gio_dependency
+    ]
+)
+test('iagno-tests', iagno_tests)
+
+executable(meson.project_name(),
+    [
+        'vapi/config.vapi',
+        'computer-player.vala',
+        'game-view.vala',
+        'game-window.vala',
+        'game.vala',
+        'iagno.vala',
+        'player.vala',
+        'themes-dialog.vala'
+    ] + resources,
+    install: true,
+    c_args: [
+        '-include', 'config.h'
+    ],
+    vala_args: [
+        '--target-glib', '2.44',
+        '--vapidir', join_paths(meson.current_source_dir(), 'vapi')
+    ],
+    dependencies: [
+        canberra_dependency,
+        canberra_gtk3_dependency,
+        gio_dependency,
+        glib_dependency,
+        gtk_dependency,
+        posix_dependency,
+        rsvg_dependency
+    ]
+)
diff --git a/src/config.vapi b/src/vapi/config.vapi
similarity index 100%
rename from src/config.vapi
rename to src/vapi/config.vapi
diff --git a/src/vapi/libcanberra-gtk3.vapi b/src/vapi/libcanberra-gtk3.vapi
new file mode 100644
index 0000000..4e5295c
--- /dev/null
+++ b/src/vapi/libcanberra-gtk3.vapi
@@ -0,0 +1,33 @@
+/***
+  This file is part of libcanberra.
+  Copyright 2009 Lennart Poettering
+  libcanberra is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation, either version 2.1 of the
+  License, or (at your option) any later version.
+  libcanberra is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+  You should have received a copy of the GNU Lesser General Public
+  License along with libcanberra. If not, see
+  <http://www.gnu.org/licenses/>.
+***/
+
+using Canberra;
+using Gdk;
+using Gtk;
+
+[CCode (cprefix = "CA_GTK_", lower_case_cprefix = "ca_gtk_", cheader_filename = "canberra-gtk.h")]
+namespace CanberraGtk {
+
+        public unowned Context? context_get();
+        public unowned Context? context_get_for_screen(Gdk.Screen? screen);
+
+        public int proplist_set_for_widget(Proplist p, Gtk.Widget w);
+        public int play_for_widget(Gtk.Widget w, uint32 id, ...);
+        public int proplist_set_for_event(Proplist p, Gdk.Event e);
+        public int play_for_event(Gdk.Event e, uint32 id, ...);
+
+        public void widget_disable_sounds(Gtk.Widget w, bool enable = false);
+}


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