[gnome-power-manager/wip/hughsie/meson: 2/2] Port to meson



commit 249b0571b3e5fcc24e2a3f26a014b386c587f453
Author: Richard Hughes <richard hughsie com>
Date:   Wed Nov 30 14:44:16 2016 +0000

    Port to meson

 Makefile.am                                      |   67 -------
 RELEASE                                          |    2 +-
 autogen.sh                                       |   20 ---
 config.h.in                                      |    4 +
 configure.ac                                     |  155 -----------------
 contrib/gnome-power-manager.spec.in              |    8 +-
 data/Makefile.am                                 |   18 +--
 data/appdata/meson.build                         |   15 ++
 data/appdata/org.gnome.PowerStats.appdata.xml.in |   12 +-
 data/icons/Makefile.am                           |   16 --
 data/icons/hicolor/Makefile.am                   |   19 --
 data/icons/hicolor/meson.build                   |   18 ++
 data/icons/meson.build                           |    5 +
 data/meson.build                                 |   27 +++
 data/org.gnome.PowerStats.desktop.in.in          |    8 +-
 git.mk                                           |  200 ----------------------
 m4/.gitignore                                    |    1 -
 man/Makefile.am                                  |   16 --
 man/meson.build                                  |   14 ++
 meson.build                                      |  112 ++++++++++++
 meson_options.txt                                |    1 +
 po/.gitignore                                    |    8 -
 po/LINGUAS                                       |    2 +-
 po/POTFILES                                      |    6 +
 po/POTFILES.in                                   |    9 -
 po/meson.build                                   |  115 +++++++++++++
 src/Makefile.am                                  |   98 -----------
 src/gpm-statistics.c                             |    6 +-
 src/meson.build                                  |   49 ++++++
 29 files changed, 387 insertions(+), 644 deletions(-)
---
diff --git a/RELEASE b/RELEASE
index ca990fc..bcea6ac 100644
--- a/RELEASE
+++ b/RELEASE
@@ -3,7 +3,7 @@ Follow http://developer.gnome.org/dotplan/for_maintainers.html
 git log --format="%s" GNOME_POWER_MANAGER_3_22_2.. | grep -i -v trivial | grep -v Merge | uniq
 Add any user visible changes into data/appdata/org.gnome.PowerStats.appdata.xml.in
 
-Run "make distcheck", correct any problems encountered
+Run "ninja dist"
 
 git commit -a -m "GNOME Power Manager 3.22.3"
 git tag -s GNOME_POWER_MANAGER_3_22_3 -m "==== Version 3.22.3 ===="
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..b7ddd97
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,4 @@
+/* config.h.in. */
+
+/* Package name for gettext */
+#mesondefine GETTEXT_PACKAGE
diff --git a/contrib/gnome-power-manager.spec.in b/contrib/gnome-power-manager.spec.in
index 8ec317e..58f3f34 100644
--- a/contrib/gnome-power-manager.spec.in
+++ b/contrib/gnome-power-manager.spec.in
@@ -14,10 +14,10 @@ BuildRequires: gettext
 BuildRequires: libtool
 BuildRequires: cairo-devel
 BuildRequires: upower-devel >= 0.9.0
-BuildRequires: intltool
 BuildRequires: glib2-devel >= 2.25.9
 BuildRequires: gtk3-devel >= 2.91.3
 BuildRequires: docbook-utils
+BuildRequires: meson
 
 # obsolete sub-package
 Obsoletes: gnome-power-manager-extra <= 2.30.1
@@ -31,11 +31,11 @@ displaying icons and handling user callbacks in an interactive GNOME session.
 %setup -q
 
 %build
-%configure
-make
+%meson
+%meson_build
 
 %install
-%make_install
+%meson_install
 
 %find_lang %name --with-gnome
 
diff --git a/data/Makefile.am b/data/Makefile.am
index 9928dc7..ebcebdb 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,22 +1,6 @@
-SUBDIRS = appdata icons
+SUBDIRS = icons
 
 @INTLTOOL_DESKTOP_RULE@
 desktopdir = $(datadir)/applications
 desktop_in_files = org.gnome.PowerStats.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-
-@GSETTINGS_RULES@
-gsettings_SCHEMAS = org.gnome.power-manager.gschema.xml
-
-EXTRA_DIST =                                           \
-       $(gsettings_SCHEMAS)                            \
-       $(desktop_in_files)
-
-clean-local :
-       rm -f *~
-
-DISTCLEANFILES =                                       \
-       org.gnome.PowerStats.desktop                    \
-       org.gnome.power-manager.gschema.xml
-
--include $(top_srcdir)/git.mk
diff --git a/data/appdata/meson.build b/data/appdata/meson.build
new file mode 100644
index 0000000..3b943dd
--- /dev/null
+++ b/data/appdata/meson.build
@@ -0,0 +1,15 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+# FIXME: Use i18n.merge_file when available
+msgfmt = find_program('msgfmt')
+podir = join_paths(meson.source_root(), 'po')
+custom_target('appdata-file',
+              input: 'org.gnome.PowerStats.appdata.xml.in',
+              output: 'org.gnome.PowerStats.appdata.xml',
+              install: true,
+              install_dir: join_paths(get_option('datadir'), 'appdata'),
+              command: [
+                msgfmt, '--xml', '--template', '@INPUT@', '-d', podir, '-o', '@OUTPUT@'
+              ])
diff --git a/data/appdata/org.gnome.PowerStats.appdata.xml.in 
b/data/appdata/org.gnome.PowerStats.appdata.xml.in
index 3b44be7..185fbc4 100644
--- a/data/appdata/org.gnome.PowerStats.appdata.xml.in
+++ b/data/appdata/org.gnome.PowerStats.appdata.xml.in
@@ -4,18 +4,18 @@
   <id>org.gnome.PowerStats.desktop</id>
   <metadata_license>CC0-1.0</metadata_license>
   <project_license>GPL-2.0+ and GFDL-1.3</project_license>
-  <_name>GNOME Power Statistics</_name>
-  <_summary>Observe power management</_summary>
+  <name>GNOME Power Statistics</name>
+  <summary>Observe power management</summary>
   <description>
-    <_p>
+    <p>
       Power Statistics can show historical and current battery information and
       programs waking up that use power.
-    </_p>
-    <_p>
+    </p>
+    <p>
       You probably only need to install this application if you are having
       problems with your laptop battery, or are trying to work out what programs
       are using significant amounts of power.
-    </_p>
+    </p>
   </description>
   <screenshots>
     <screenshot type="default">
diff --git a/data/icons/hicolor/meson.build b/data/icons/hicolor/meson.build
new file mode 100644
index 0000000..73269f4
--- /dev/null
+++ b/data/icons/hicolor/meson.build
@@ -0,0 +1,18 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+install_data('16x16/org.gnome.PowerStats.png',
+             install_dir : 'share/icons/hicolor/16x16/apps')
+install_data('22x22/org.gnome.PowerStats.png',
+             install_dir : 'share/icons/hicolor/22x22/apps')
+install_data('24x24/org.gnome.PowerStats.png',
+             install_dir : 'share/icons/hicolor/24x24/apps')
+install_data('32x32/org.gnome.PowerStats.png',
+             install_dir : 'share/icons/hicolor/32x32/apps')
+install_data('48x48/org.gnome.PowerStats.png',
+             install_dir : 'share/icons/hicolor/48x48/apps')
+install_data('scalable/org.gnome.PowerStats.svg',
+             install_dir : 'share/icons/hicolor/scalable/apps')
+install_data('symbolic/org.gnome.PowerStats-symbolic.svg',
+             install_dir : 'share/icons/hicolor/symbolic/apps')
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..3721dff
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,5 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+subdir('hicolor')
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..7de22b9
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,27 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+subdir('appdata')
+subdir('icons')
+
+compiled = gnome.compile_schemas()
+install_data('org.gnome.power-manager.gschema.xml',
+             install_dir : 'share/glib-2.0/schemas')
+
+# replace @VERSION@
+versionedfile = configure_file(input : 'org.gnome.PowerStats.desktop.in.in',
+                               output : 'org.gnome.PowerStats.desktop.in',
+                               configuration : conf)
+
+# FIXME: Use i18n.merge_file when available
+msgfmt = find_program('msgfmt')
+podir = join_paths(meson.source_root(), 'po')
+custom_target('desktop-file',
+              input: versionedfile,
+              output: 'org.gnome.PowerStats.desktop',
+              install: true,
+              install_dir: join_paths(get_option('datadir'), 'applications'),
+              command: [
+                msgfmt, '--desktop', '--template', '@INPUT@', '-d', podir, '-o', '@OUTPUT@'
+              ])
diff --git a/data/org.gnome.PowerStats.desktop.in.in b/data/org.gnome.PowerStats.desktop.in.in
index d0eacf4..e6653e4 100644
--- a/data/org.gnome.PowerStats.desktop.in.in
+++ b/data/org.gnome.PowerStats.desktop.in.in
@@ -1,7 +1,7 @@
 [Desktop Entry]
-_Name=Power Statistics
-_Comment=Observe power management
-_Keywords=battery;consumption;charge;
+Name=Power Statistics
+Comment=Observe power management
+Keywords=battery;consumption;charge;
 Icon=org.gnome.PowerStats
 Exec=gnome-power-statistics
 Terminal=false
@@ -12,5 +12,5 @@ StartupNotify=true
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-power-manager
 X-GNOME-Bugzilla-Component=gnome-power-statistics
-X-GNOME-Bugzilla-Version=@VERSION@
+X-GNOME-Bugzilla-Version=@PACKAGE_VERSION@
 X-Desktop-File-Install-Version=0.10
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 0000000..24c33e6
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,14 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+docbook2man = find_program('docbook2man', required : false)
+if docbook2man.found()
+  custom_target('gnome-power-statistics-man',
+    output : 'gnome-power-statistics.1',
+    input : 'gnome-power-statistics.sgml',
+    command : [docbook2man, '@INPUT@', '--output', 'man'],
+    install : true,
+    install_dir : 'share/man/man1'
+  )
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..d6c41ce
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,112 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+project('gnome-power-manager', 'c',
+        version : '3.22.3',
+        default_options : ['warning_level=1'],
+        meson_version : '>=0.36.0')
+
+conf = configuration_data()
+conf.set('PACKAGE_VERSION', meson.project_version())
+
+# get suported warning flags
+test_args = [
+  '-Waggregate-return',
+  '-Warray-bounds',
+  '-Wcast-align',
+  '-Wclobbered',
+  '-Wdeclaration-after-statement',
+  '-Wempty-body',
+  '-Wextra',
+  '-Wformat=2',
+  '-Wformat-nonliteral',
+  '-Wformat-security',
+  '-Wformat-signedness',
+  '-Wignored-qualifiers',
+  '-Wimplicit-function-declaration',
+  '-Winit-self',
+  '-Winline',
+  '-Wmissing-declarations',
+  '-Wmissing-format-attribute',
+  '-Wmissing-include-dirs',
+  '-Wmissing-noreturn',
+  '-Wmissing-parameter-type',
+  '-Wmissing-prototypes',
+  '-Wnested-externs',
+  '-Wno-discarded-qualifiers',
+  '-Wno-missing-field-initializers',
+  '-Wno-strict-aliasing',
+  '-Wno-suggest-attribute=format',
+  '-Wno-unused-parameter',
+  '-Wold-style-definition',
+  '-Woverride-init',
+  '-Wpacked',
+  '-Wpointer-arith',
+  '-Wredundant-decls',
+  '-Wreturn-type',
+  '-Wshadow',
+  '-Wsign-compare',
+  '-Wstrict-aliasing',
+  '-Wstrict-prototypes',
+  '-Wswitch-default',
+  '-Wtype-limits',
+  '-Wundef',
+  '-Wuninitialized',
+  '-Wunused-but-set-variable',
+  '-Wwrite-strings'
+]
+cc = meson.get_compiler('c')
+foreach arg: test_args
+  if cc.has_argument(arg)
+    add_project_arguments(arg, language : 'c')
+  endif
+endforeach
+
+gtk = dependency('gtk+-3.0', version : '>= 3.3.8')
+gdk = dependency('gdk-3.0', version : '>= 2.91.7')
+cairo = dependency('cairo', version : '>= 1.0.0')
+upower = dependency('upower-glib', version : '>= 0.9.1')
+libm = cc.find_library('libm', required: false)
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+conf.set('GETTEXT_PACKAGE', '"gnome-power-manager"')
+configure_file(input : 'config.h.in',
+               output : 'config.h',
+               configuration : conf)
+top_build_incdir = include_directories(meson.current_build_dir())
+
+add_project_arguments('-DLOCALEDIR="@0@"'.format(join_paths(get_option('prefix'), get_option('localedir'))), 
language : 'c')
+add_project_arguments('-DDATA_DIR="@0@"'.format(join_paths(get_option('prefix'), get_option('datadir'))), 
language : 'c')
+
+subdir('src')
+subdir('man')
+subdir('po')
+subdir('data')
+
+archiver = find_program('git', required : false)
+if archiver.found()
+  run_target('dist',
+             # git config tar.tar.xz.command "xz -c"
+             command: ['git', 'archive',
+                       '--prefix=' + meson.project_name() + '-' + meson.project_version() + '/',
+                       'HEAD',
+                       '--format=tar.xz',
+                       '--output',
+                       meson.project_name() + '-' + meson.project_version() + '.tar.xz']
+  )
+else
+  message('git not found, you will not be able to run `ninja dist`')
+endif
+
+appstream_util = find_program('appstream-util', required : false)
+if appstream_util.found()
+  custom_target('NEWS',
+    output : 'NEWS',
+    input : 'data/appdata/org.gnome.PowerStats.appdata.xml.in',
+    command : [appstream_util, 'appdata-to-news', '@INPUT@'],
+    capture : true
+  )
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..04c3a3a
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('enable-tests', type : 'boolean', value : true, description : 'enable tests')
diff --git a/po/LINGUAS b/po/LINGUAS
index 14b4f2c..eb14eaf 100644
--- a/po/LINGUAS
+++ b/po/LINGUAS
@@ -73,7 +73,7 @@ te
 tg
 th
 tr
-ug 
+ug
 uk
 vi
 zh_CN
diff --git a/po/POTFILES b/po/POTFILES
new file mode 100644
index 0000000..62440f1
--- /dev/null
+++ b/po/POTFILES
@@ -0,0 +1,6 @@
+data/appdata/org.gnome.PowerStats.appdata.xml.in
+data/org.gnome.power-manager.gschema.xml
+data/org.gnome.PowerStats.desktop.in
+src/egg-graph-widget.c
+src/gpm-statistics.c
+src/gpm-statistics.ui
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..a0fb4a8
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,115 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+# FIXME : get from LINGUAS
+langs = [
+  'af',
+  'ar',
+  'as',
+  'ast',
+  'be',
+  'be@latin',
+  'bg',
+  'bn',
+  'bn_IN',
+  'bs',
+  'ca',
+  'ca@valencia',
+  'cs',
+  'cy',
+  'da',
+  'de',
+  'dz',
+  'el',
+  'en_CA',
+  'en_GB',
+  'en@shaw',
+  'eo',
+  'es',
+  'et',
+  'eu',
+  'fa',
+  'fi',
+  'fr',
+  'ga',
+  'gd',
+  'gl',
+  'gu',
+  'he',
+  'hi',
+  'hr',
+  'hu',
+  'id',
+  'is',
+  'it',
+  'ja',
+  'ka',
+  'km',
+  'kn',
+  'ko',
+  'ku',
+  'lt',
+  'lv',
+  'mai',
+  'mg',
+  'mk',
+  'ml',
+  'mr',
+  'my',
+  'nb',
+  'nl',
+  'nn',
+  'oc',
+  'or',
+  'pa',
+  'pl',
+  'pt',
+  'pt_BR',
+  'ro',
+  'ru',
+  'si',
+  'sk',
+  'sl',
+  'sr',
+  'sr@latin',
+  'sv',
+  'ta',
+  'te',
+  'tg',
+  'th',
+  'tr',
+  'ug',
+  'uk',
+  'vi',
+  'zh_CN',
+  'zh_HK',
+  'zh_TW'
+  ]
+
+# FIXME: remove a lot of copy-paste: https://github.com/mesonbuild/meson/issues/1123
+i18n.gettext(meson.project_name(),
+             languages : langs,
+             args: [
+               '--default-domain=' + meson.project_name(),
+               '--from-code=UTF-8',
+               '--add-comments',
+
+               '--keyword=_',
+               '--keyword=N_',
+               '--keyword=C_:1c,2',
+               '--keyword=NC_:1c,2',
+               '--keyword=g_dcgettext:2',
+               '--keyword=g_dngettext:2,3',
+               '--keyword=g_dpgettext2:2c,3',
+
+               '--flag=N_:1:pass-c-format',
+               '--flag=C_:2:pass-c-format',
+               '--flag=NC_:2:pass-c-format',
+               '--flag=g_dngettext:2:pass-c-format',
+               '--flag=g_strdup_printf:1:c-format',
+               '--flag=g_string_printf:2:c-format',
+               '--flag=g_string_append_printf:2:c-format',
+               '--flag=g_error_new:3:c-format',
+               '--flag=g_set_error:4:c-format',
+             ])
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index cf18d21..29b566f 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -1913,7 +1913,7 @@ main (int argc, char *argv[])
 
        setlocale (LC_ALL, "");
 
-       bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+       bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
 
@@ -1932,7 +1932,9 @@ main (int argc, char *argv[])
 
        /* add application specific icons to search path */
        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
-                                           GPM_DATA G_DIR_SEPARATOR_S "icons");
+                                           DATA_DIR G_DIR_SEPARATOR_S
+                                           "gnome-power-manager" G_DIR_SEPARATOR_S
+                                           "icons");
 
        /* run */
        status = g_application_run (G_APPLICATION (application), argc, argv);
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..b4bf1cd
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,49 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+cargs = ['-DG_LOG_DOMAIN="Gpm"']
+
+gnome_power_statistics_resources = gnome.compile_resources(
+  'gnome-power-statistics-resources',
+  'gnome-power-manager.gresource.xml',
+  source_dir : '.',
+  c_name : 'gpm')
+
+executable(
+  'gnome-power-statistics',
+  gnome_power_statistics_resources,
+  sources : [
+    'gpm-array-float.c',
+    'gpm-array-float.h',
+    'gpm-statistics.c',
+    'egg-graph-point.c',
+    'egg-graph-point.h',
+    'egg-graph-widget.c',
+    'egg-graph-widget.h',
+  ],
+  include_directories : [
+    include_directories('@0@/..'.format(meson.current_build_dir())),
+  ],
+  dependencies : [gtk, gdk, cairo, upower, libm],
+  c_args : cargs,
+  install : true,
+  install_dir : 'bin'
+)
+
+if get_option('enable-tests')
+  e = executable(
+    'gnome-power-self-test',
+    sources : [
+      'gpm-array-float.c',
+      'gpm-array-float.h',
+      'gpm-self-test.c'
+    ],
+    include_directories : [
+      include_directories('@0@/..'.format(meson.current_build_dir())),
+    ],
+    dependencies : [gtk, gdk, cairo, upower, libm],
+    c_args : cargs
+  )
+  test('gnome-power-self-test', e)
+endif


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