[gnome-packagekit/wip/hughsie/meson] Port to Meson



commit bab4445fb6b69e245e4ab0a771ef202779ed486e
Author: Richard Hughes <richard hughsie com>
Date:   Mon Dec 5 13:47:58 2016 +0000

    Port to Meson

 Makefile.am                                        |   82 -------
 autogen.sh                                         |   40 ----
 build/meson-private/meson_benchmark_setup.dat      |  Bin 0 -> 6 bytes
 config.h.in                                        |    7 +
 configure.ac                                       |  237 --------------------
 contrib/gnome-packagekit.spec.in                   |   13 +-
 data/Makefile.am                                   |   44 ----
 data/appdata/Makefile.am                           |   10 -
 data/appdata/meson.build                           |   21 ++
 .../org.gnome.PackageUpdater.appdata.xml.in        |   12 +-
 data/appdata/org.gnome.Packages.appdata.xml.in     |   12 +-
 data/gpk-install-local-file.desktop.in             |    4 +-
 data/gpk-log.desktop.in                            |    4 +-
 data/gpk-prefs.desktop.in                          |    4 +-
 data/icons/16x16/Makefile.am                       |    3 -
 .../{categories => actions}/pk-desktop-gnome.png   |  Bin 895 -> 895 bytes
 .../{categories => actions}/pk-desktop-kde.png     |  Bin 1083 -> 1083 bytes
 .../{categories => actions}/pk-desktop-xfce.png    |  Bin 1019 -> 1019 bytes
 data/icons/16x16/categories/Makefile.am            |   17 --
 data/icons/16x16/status/Makefile.am                |   44 ----
 data/icons/22x22/Makefile.am                       |    3 -
 .../{categories => actions}/pk-desktop-gnome.png   |  Bin 1340 -> 1340 bytes
 .../{categories => actions}/pk-desktop-kde.png     |  Bin 1737 -> 1737 bytes
 .../{categories => actions}/pk-desktop-xfce.png    |  Bin 1572 -> 1572 bytes
 data/icons/22x22/categories/Makefile.am            |   17 --
 data/icons/22x22/status/Makefile.am                |   46 ----
 data/icons/24x24/Makefile.am                       |    3 -
 .../{categories => actions}/pk-desktop-gnome.png   |  Bin 2344 -> 2344 bytes
 .../{categories => actions}/pk-desktop-kde.png     |  Bin 2409 -> 2409 bytes
 .../{categories => actions}/pk-desktop-xfce.png    |  Bin 1593 -> 1593 bytes
 data/icons/24x24/categories/Makefile.am            |   18 --
 data/icons/24x24/status/Makefile.am                |   44 ----
 data/icons/48x48/Makefile.am                       |    3 -
 .../{categories => actions}/pk-desktop-gnome.png   |  Bin 3888 -> 3888 bytes
 .../{categories => actions}/pk-desktop-kde.png     |  Bin 5340 -> 5340 bytes
 .../{categories => actions}/pk-desktop-xfce.png    |  Bin 4510 -> 4510 bytes
 data/icons/48x48/categories/Makefile.am            |   18 --
 data/icons/48x48/status/Makefile.am                |   44 ----
 data/icons/Makefile.am                             |   16 --
 data/icons/create-application-icons.sh             |   29 +++
 data/icons/meson.build                             |   27 +++
 data/icons/scalable/Makefile.am                    |    3 -
 .../{categories => actions}/pk-desktop-gnome.svg   |    0
 .../{categories => actions}/pk-desktop-kde.svgz    |  Bin 6544 -> 6544 bytes
 .../{categories => actions}/pk-desktop-xfce.svg    |    0
 data/icons/scalable/categories/Makefile.am         |   18 --
 data/icons/scalable/status/Makefile.am             |   44 ----
 data/meson.build                                   |   61 +++++
 data/org.gnome.PackageUpdater.desktop.in           |    6 +-
 data/org.gnome.Packages.desktop.in                 |    6 +-
 docs/Makefile.am                                   |    1 -
 git.mk                                             |  200 -----------------
 m4/.gitignore                                      |    1 -
 man/Makefile.am                                    |   37 ---
 man/meson.build                                    |   35 +++
 meson.build                                        |  160 +++++++++++++
 meson_options.txt                                  |    3 +
 meson_post_install.sh                              |   18 ++
 po/meson.build                                     |   10 +
 src/Makefile.am                                    |  219 ------------------
 src/gpk-prefs.c                                    |    4 +-
 src/gpk-self-test.c                                |  178 ---------------
 src/meson.build                                    |  163 ++++++++++++++
 63 files changed, 564 insertions(+), 1425 deletions(-)
---
diff --git a/build/meson-private/meson_benchmark_setup.dat b/build/meson-private/meson_benchmark_setup.dat
new file mode 100644
index 0000000..482c0e3
Binary files /dev/null and b/build/meson-private/meson_benchmark_setup.dat differ
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..fa40508
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,7 @@
+#mesondefine GETTEXT_PACKAGE
+#mesondefine DATADIR
+#mesondefine LOCALEDIR
+#mesondefine BINDIR
+#mesondefine VERSION
+#mesondefine GPK_DATA
+#mesondefine PACKAGE_VERSION
diff --git a/contrib/gnome-packagekit.spec.in b/contrib/gnome-packagekit.spec.in
index 8965e69..b711f38 100644
--- a/contrib/gnome-packagekit.spec.in
+++ b/contrib/gnome-packagekit.spec.in
@@ -30,6 +30,7 @@ BuildRequires: systemd-devel
 BuildRequires: polkit-devel
 BuildRequires: itstool
 BuildRequires: libappstream-glib
+BuildRequires: meson
 
 # the top level package depends on all the apps to make upgrades work
 Requires: %{name}-installer
@@ -76,14 +77,11 @@ without rebooting.
 %setup -q
 
 %build
-%configure --enable-systemd
-make %{?_smp_mflags}
+%meson
+%meson_build
 
 %install
-%make_install
-
-# nuke the ChangeLog file, it's huge
-rm -f $RPM_BUILD_ROOT%{_datadir}/doc/gnome-packagekit-*/ChangeLog
+%meson_install
 
 %find_lang %name --with-gnome
 
@@ -108,7 +106,7 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
 
 %files common -f %{name}.lang
 %license COPYING
-%doc AUTHORS NEWS README
+%doc AUTHORS
 %{_bindir}/gpk-log
 %{_bindir}/gpk-prefs
 %dir %{_datadir}/gnome-packagekit
@@ -118,7 +116,6 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
 %dir %{_datadir}/gnome-packagekit/icons/hicolor/*/*
 %{_datadir}/gnome-packagekit/icons/hicolor/*/*/*.png
 %{_datadir}/gnome-packagekit/icons/hicolor/scalable/*/*.svg*
-%{_datadir}/icons/hicolor/*/*/*.png
 %{_datadir}/icons/hicolor/scalable/*/*.svg*
 %{_datadir}/man/man1/gpk-log.1*
 %{_datadir}/man/man1/gpk-prefs.1*
diff --git a/data/appdata/meson.build b/data/appdata/meson.build
new file mode 100644
index 0000000..473076f
--- /dev/null
+++ b/data/appdata/meson.build
@@ -0,0 +1,21 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+i18n.merge_file(
+  input: 'org.gnome.Packages.appdata.xml.in',
+  output: 'org.gnome.Packages.appdata.xml',
+  type: 'xml',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'appdata')
+)
+
+i18n.merge_file(
+  input: 'org.gnome.PackageUpdater.appdata.xml.in',
+  output: 'org.gnome.PackageUpdater.appdata.xml',
+  type: 'xml',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'appdata')
+)
diff --git a/data/appdata/org.gnome.PackageUpdater.appdata.xml.in 
b/data/appdata/org.gnome.PackageUpdater.appdata.xml.in
index b7abc30..8d08b6c 100644
--- a/data/appdata/org.gnome.PackageUpdater.appdata.xml.in
+++ b/data/appdata/org.gnome.PackageUpdater.appdata.xml.in
@@ -4,18 +4,18 @@
   <id>org.gnome.PackageUpdater.desktop</id>
   <metadata_license>CC0-1.0</metadata_license>
   <project_license>GPL-2.0+</project_license>
-  <_name>GNOME Package Updater</_name>
-  <_summary>Update software installed on the system</_summary>
+  <name>GNOME Package Updater</name>
+  <summary>Update software installed on the system</summary>
   <description>
-    <_p>
+    <p>
       Package Updater allows you to update packages on your system without
       rebooting.
       You can view details about each update and choose which updates to apply.
-    </_p>
-    <_p>
+    </p>
+    <p>
       Package Updater uses PackageKit and can work on any distribution using
       the native package management framework.
-    </_p>
+    </p>
   </description>
   <screenshots>
     <screenshot 
type="default">https://git.gnome.org/browse/gnome-packagekit/plain/data/appdata/ss-updater.png</screenshot>
diff --git a/data/appdata/org.gnome.Packages.appdata.xml.in b/data/appdata/org.gnome.Packages.appdata.xml.in
index d3f37dd..ee64df5 100644
--- a/data/appdata/org.gnome.Packages.appdata.xml.in
+++ b/data/appdata/org.gnome.Packages.appdata.xml.in
@@ -4,20 +4,20 @@
   <id>org.gnome.Packages.desktop</id>
   <metadata_license>CC0-1.0</metadata_license>
   <project_license>GPL-2.0+</project_license>
-  <_name>GNOME Packages</_name>
-  <_summary>Add or remove software installed on the system</_summary>
+  <name>GNOME Packages</name>
+  <summary>Add or remove software installed on the system</summary>
   <description>
-    <_p>
+    <p>
       Packages allows you to install and remove packages on your system.
       You can view and search packages by name, details or even file name
       and also see dependencies of one package on other packages.
       Searching by groups is possible and is an easy way to find software in
       your favorite desktop environment.
-    </_p>
-    <_p>
+    </p>
+    <p>
       Packages uses PackageKit and can work on any distribution using
       the native package management framework.
-    </_p>
+    </p>
   </description>
   <screenshots>
     <screenshot 
type="default">https://git.gnome.org/browse/gnome-packagekit/plain/data/appdata/ss-application.png</screenshot>
diff --git a/data/gpk-install-local-file.desktop.in b/data/gpk-install-local-file.desktop.in
index c8bf445..a8e10c4 100644
--- a/data/gpk-install-local-file.desktop.in
+++ b/data/gpk-install-local-file.desktop.in
@@ -1,6 +1,6 @@
 [Desktop Entry]
-_Name=Package Install
-_Comment=Install selected packages on the system
+Name=Package Install
+Comment=Install selected packages on the system
 Categories=System;
 Exec=gpk-install-local-file %F
 Terminal=false
diff --git a/data/gpk-log.desktop.in b/data/gpk-log.desktop.in
index 4c15e65..43c31be 100644
--- a/data/gpk-log.desktop.in
+++ b/data/gpk-log.desktop.in
@@ -1,6 +1,6 @@
 [Desktop Entry]
-_Name=Package Log
-_Comment=View past package management tasks
+Name=Package Log
+Comment=View past package management tasks
 Icon=gpk-log
 Exec=gpk-log
 Terminal=false
diff --git a/data/gpk-prefs.desktop.in b/data/gpk-prefs.desktop.in
index 8573197..5c55887 100644
--- a/data/gpk-prefs.desktop.in
+++ b/data/gpk-prefs.desktop.in
@@ -1,6 +1,6 @@
 [Desktop Entry]
-_Name=Package Sources
-_Comment=Enable or disable package repositories
+Name=Package Sources
+Comment=Enable or disable package repositories
 Icon=gpk-prefs
 Exec=gpk-prefs
 Terminal=false
diff --git a/data/icons/create-application-icons.sh b/data/icons/create-application-icons.sh
new file mode 100755
index 0000000..33b0a0f
--- /dev/null
+++ b/data/icons/create-application-icons.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+echo "Starting custom installation step"
+
+if [ -z $MESON_INSTALL_PREFIX ]; then
+    echo 'This is meant to be ran from Meson only!'
+    exit 1
+fi
+
+PKGICONSDIR="${DESTDIR:-}${MESON_INSTALL_PREFIX}/share/gnome-packagekit/icons/hicolor";
+ICONSDIR="${DESTDIR:-}${MESON_INSTALL_PREFIX}/share/icons/hicolor";
+echo ${ICONSDIR}
+mkdir -p ${ICONSDIR}/scalable/apps
+mkdir -p ${ICONSDIR}/scalable/mimetypes
+ln -fs ${PKGICONSDIR}/scalable/status/pk-package-sources.svg \
+    ${ICONSDIR}/scalable/apps/gpk-repo.svg
+ln -fs ${PKGICONSDIR}/scalable/status/pk-package-info.svg \
+    ${ICONSDIR}/scalable/apps/gpk-log.svg
+ln -fs ${PKGICONSDIR}/scalable/status/pk-update-high.svg \
+    ${ICONSDIR}/scalable/apps/gpk-prefs.svg
+ln -fs ${PKGICONSDIR}/scalable/status/pk-package-info.svg \
+    ${ICONSDIR}/scalable/mimetypes/application-x-package-list.svg
+ln -fs ${PKGICONSDIR}/scalable/status/pk-collection-installed.svg \
+    ${ICONSDIR}/scalable/mimetypes/application-x-catalog.svg
+
+echo "Finished custom install step"
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 0000000..8aa1a4c
--- /dev/null
+++ b/data/icons/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
+
+icon_sizes = ['16x16', '22x22', '24x24', '48x48', 'scalable']
+foreach size: icon_sizes
+  install_subdir(size + '/actions',
+    install_dir: join_paths(
+      get_option('datadir'),
+      'gnome-packagekit',
+      'icons',
+      'hicolor',
+      size
+    )
+  )
+  install_subdir(size + '/status',
+    install_dir: join_paths(
+      get_option('datadir'),
+      'gnome-packagekit',
+      'icons',
+      'hicolor',
+      size
+    )
+  )
+endforeach
+
+meson.add_install_script('create-application-icons.sh')
diff --git a/data/icons/scalable/categories/pk-desktop-gnome.svg 
b/data/icons/scalable/actions/pk-desktop-gnome.svg
similarity index 100%
rename from data/icons/scalable/categories/pk-desktop-gnome.svg
rename to data/icons/scalable/actions/pk-desktop-gnome.svg
diff --git a/data/icons/scalable/categories/pk-desktop-xfce.svg 
b/data/icons/scalable/actions/pk-desktop-xfce.svg
similarity index 100%
rename from data/icons/scalable/categories/pk-desktop-xfce.svg
rename to data/icons/scalable/actions/pk-desktop-xfce.svg
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..647fe84
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,61 @@
+# 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.packagekit.gschema.xml',
+  install_dir : 'share/glib-2.0/schemas'
+)
+
+install_data('org.gnome.packagekit.gschema.migrate',
+  install_dir : 'share/GConf/gsettings'
+)
+
+i18n.merge_file(
+  input: 'gpk-install-local-file.desktop.in',
+  output: 'gpk-install-local-file.desktop',
+  type: 'desktop',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
+i18n.merge_file(
+  input: 'gpk-log.desktop.in',
+  output: 'gpk-log.desktop',
+  type: 'desktop',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
+i18n.merge_file(
+  input: 'gpk-prefs.desktop.in',
+  output: 'gpk-prefs.desktop',
+  type: 'desktop',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
+i18n.merge_file(
+  input: 'org.gnome.Packages.desktop.in',
+  output: 'org.gnome.Packages.desktop',
+  type: 'desktop',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
+i18n.merge_file(
+  input: 'org.gnome.PackageUpdater.desktop.in',
+  output: 'org.gnome.PackageUpdater.desktop',
+  type: 'desktop',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'applications')
+)
+
diff --git a/data/org.gnome.PackageUpdater.desktop.in b/data/org.gnome.PackageUpdater.desktop.in
index c83e438..46bf54b 100644
--- a/data/org.gnome.PackageUpdater.desktop.in
+++ b/data/org.gnome.PackageUpdater.desktop.in
@@ -1,12 +1,12 @@
 [Desktop Entry]
-_Name=Package Updater
-_Comment=Update software installed on the system
+Name=Package Updater
+Comment=Update software installed on the system
 Icon=system-software-update
 Exec=gpk-update-viewer
 Terminal=false
 Type=Application
 Categories=GNOME;GTK;System;
-_Keywords=Updates;Upgrade;
+Keywords=Updates;Upgrade;
 NotShowIn=KDE;
 StartupNotify=true
 X-GNOME-UsesNotifications=true
diff --git a/data/org.gnome.Packages.desktop.in b/data/org.gnome.Packages.desktop.in
index 72b299d..f09d97b 100644
--- a/data/org.gnome.Packages.desktop.in
+++ b/data/org.gnome.Packages.desktop.in
@@ -1,12 +1,12 @@
 [Desktop Entry]
-_Name=Packages
-_Comment=Add or remove software installed on the system
+Name=Packages
+Comment=Add or remove software installed on the system
 Icon=system-software-install
 Exec=gpk-application
 Terminal=false
 Type=Application
 Categories=GNOME;GTK;System;PackageManager;
-_Keywords=Sources;Repositories;Preferences;Install;Store;
+Keywords=Sources;Repositories;Preferences;Install;Store;
 NotShowIn=KDE;
 StartupNotify=true
 X-GNOME-UsesNotifications=true
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 0000000..9b14745
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,35 @@
+# 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('gpk-application-man',
+    output : 'gpk-application.1',
+    input : 'gpk-application.sgml',
+    command : [docbook2man, '@INPUT@', '--output', 'man'],
+    install : true,
+    install_dir : 'share/man/man1'
+  )
+  custom_target('gpk-log-man',
+    output : 'gpk-log.1',
+    input : 'gpk-log.sgml',
+    command : [docbook2man, '@INPUT@', '--output', 'man'],
+    install : true,
+    install_dir : 'share/man/man1'
+  )
+  custom_target('gpk-prefs-man',
+    output : 'gpk-prefs.1',
+    input : 'gpk-prefs.sgml',
+    command : [docbook2man, '@INPUT@', '--output', 'man'],
+    install : true,
+    install_dir : 'share/man/man1'
+  )
+  custom_target('gpk-update-viewer-man',
+    output : 'gpk-update-viewer.1',
+    input : 'gpk-update-viewer.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..d14f757
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,160 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+project('gnome-packagekit', 'c',
+  version : '3.22.2',
+  default_options : ['warning_level=1'],
+  meson_version : '>=0.37.0'
+)
+
+conf = configuration_data()
+conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+conf.set_quoted('VERSION', meson.project_version())
+
+if get_option('enable-small-form-factor')
+  conf.set('PK_BUILD_SMALL_FORM_FACTOR', '1')
+endif
+
+# 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',
+  '-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',
+  '-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
+
+# enable full RELRO where possible
+# FIXME: until https://github.com/mesonbuild/meson/issues/1140 is fixed
+global_link_args = []
+test_link_args = [
+  '-Wl,-z,relro',
+  '-Wl,-z,now',
+]
+foreach arg: test_link_args
+  if cc.has_argument(arg)
+    global_link_args += arg
+  endif
+endforeach
+add_global_link_arguments(
+  global_link_args,
+  language: 'c'
+)
+
+gio = dependency('gio-2.0', version : '>= 2.25.9')
+gtk = dependency('gtk+-3.0', version : '>= 3.15.3')
+packagekit = dependency('packagekit-glib2', version : '>= 0.9.1')
+upower = dependency('upower-glib', version : '>= 0.9.1')
+libm = cc.find_library('libm', required: false)
+
+if get_option('enable-systemd')
+  systemd = dependency('libsystemd')
+  polkit = dependency('polkit-gobject-1')
+endif
+
+add_project_arguments('-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE',
+                      language : 'c')
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('LOCALEDIR',
+                join_paths(get_option('prefix'),
+                           get_option('localedir')))
+conf.set_quoted('DATADIR',
+                join_paths(get_option('prefix'),
+                           get_option('datadir')))
+conf.set_quoted('BINDIR',
+                join_paths(get_option('prefix'),
+                           get_option('bindir')))
+conf.set_quoted('GPK_DATA',
+                join_paths(get_option('prefix'),
+                           get_option('datadir'),
+                           'gnome-software'))
+configure_file(
+  input : 'config.h.in',
+  output : 'config.h',
+  configuration : conf
+)
+
+subdir('man')
+subdir('src')
+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
+
+# FIXME: remove when https://github.com/mesonbuild/meson/issues/837 fixed
+meson.add_install_script('meson_post_install.sh')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..4306083
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('enable-tests', type : 'boolean', value : true, description : 'enable tests')
+option('enable-small-form-factor', type : 'boolean', value : true, description : 'enable small form factor 
mode')
+option('enable-systemd', type : 'boolean', value : true, description : 'if systemd is used for session 
tracking')
diff --git a/meson_post_install.sh b/meson_post_install.sh
new file mode 100755
index 0000000..465156b
--- /dev/null
+++ b/meson_post_install.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+if [ -z $MESON_INSTALL_PREFIX ]; then
+    echo 'This is meant to be ran from Meson only!'
+    exit 1
+fi
+
+if [ -z $DESTDIR ]; then
+    echo 'Compiling GSchema'
+    glib-compile-schemas "$MESON_INSTALL_PREFIX/share/glib-2.0/schemas"
+    echo 'Updating icon cache'
+    gtk-update-icon-cache -qtf "$MESON_INSTALL_PREFIX/share/icons/hicolor"
+    echo 'Updating desktop database'
+    update-desktop-database -q "$MESON_INSTALL_PREFIX/share/applications"
+fi
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..4ae4c19
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,10 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+i18n.gettext(meson.project_name(),
+  preset : 'glib',
+  args: [
+    '--default-domain=' + meson.project_name()
+  ]
+)
diff --git a/src/gpk-prefs.c b/src/gpk-prefs.c
index 12ecfa2..5c4f2ed 100644
--- a/src/gpk-prefs.c
+++ b/src/gpk-prefs.c
@@ -19,9 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "config.h"
 
 #include <glib/gi18n.h>
 #include <locale.h>
diff --git a/src/gpk-self-test.c b/src/gpk-self-test.c
index f513ab9..60a1923 100644
--- a/src/gpk-self-test.c
+++ b/src/gpk-self-test.c
@@ -27,44 +27,6 @@
 #include "gpk-error.h"
 #include "gpk-task.h"
 
-
-/** ver:1.0 ***********************************************************/
-static GMainLoop *_test_loop = NULL;
-static guint _test_loop_timeout_id = 0;
-
-static gboolean
-_g_test_hang_wait_cb (gpointer user_data)
-{
-       g_main_loop_quit (_test_loop);
-       _test_loop_timeout_id = 0;
-       return FALSE;
-}
-
-static void
-_g_test_loop_wait (guint timeout_ms)
-{
-       g_assert (_test_loop_timeout_id == 0);
-       _test_loop = g_main_loop_new (NULL, FALSE);
-       _test_loop_timeout_id = g_timeout_add (timeout_ms, _g_test_hang_wait_cb, &timeout_ms);
-       g_main_loop_run (_test_loop);
-}
-
-static void
-_g_test_loop_quit (void)
-{
-       if (_test_loop_timeout_id > 0) {
-               g_source_remove (_test_loop_timeout_id);
-               _test_loop_timeout_id = 0;
-       }
-       if (_test_loop != NULL) {
-               g_main_loop_quit (_test_loop);
-               g_main_loop_unref (_test_loop);
-               _test_loop = NULL;
-       }
-}
-
-/**********************************************************************/
-
 static void
 gpk_test_enum_func (void)
 {
@@ -182,78 +144,10 @@ gpk_test_enum_func (void)
 }
 
 static void
-gpk_test_error_func (void)
-{
-       gboolean ret;
-
-       /* do dialog */
-       ret = gpk_error_dialog ("No space is left on the disk",
-                               "There is insufficient space on the device.\n"
-                               "Free some space on the system disk to perform this operation.",
-                               "[Errno 28] No space left on device");
-       g_assert (ret);
-}
-
-static void
 gpk_test_common_func (void)
 {
        gchar *text;
 
-       /* time zero */
-       text = gpk_time_to_localised_string (0);
-       g_assert_cmpstr (text, ==, "Now");
-       g_free (text);
-
-       /* time 1s */
-       text = gpk_time_to_localised_string (1);
-       g_assert_cmpstr (text, ==, "1 second");
-       g_free (text);
-
-       /* time 1m */
-       text = gpk_time_to_localised_string (1*60);
-       g_assert_cmpstr (text, ==, "1 minute");
-       g_free (text);
-
-       /* time 1h */
-       text = gpk_time_to_localised_string (1*60*60);
-       g_assert_cmpstr (text, ==, "1 hour");
-       g_free (text);
-
-       /* time 30s */
-       text = gpk_time_to_localised_string (30);
-       g_assert_cmpstr (text, ==, "30 seconds");
-       g_free (text);
-
-       /* time 30m */
-       text = gpk_time_to_localised_string (30*60);
-       g_assert_cmpstr (text, ==, "30 minutes");
-       g_free (text);
-
-       /* time 30m1s */
-       text = gpk_time_to_localised_string (30*60+1);
-       g_assert_cmpstr (text, ==, "30 minutes 1 second");
-       g_free (text);
-
-       /* time 30m10s */
-       text = gpk_time_to_localised_string (30*60+10);
-       g_assert_cmpstr (text, ==, "30 minutes 10 seconds");
-       g_free (text);
-
-       /* imprecise time 1s */
-       text = gpk_time_to_imprecise_string (1);
-       g_assert_cmpstr (text, ==, "1 second");
-       g_free (text);
-
-       /* imprecise time 30m */
-       text = gpk_time_to_imprecise_string (30*60);
-       g_assert_cmpstr (text, ==, "30 minutes");
-       g_free (text);
-
-       /* imprecise time 30m10s */
-       text = gpk_time_to_imprecise_string (30*60+10);
-       g_assert_cmpstr (text, ==, "30 minutes");
-       g_free (text);
-
        /* package id pretty valid package id, no summary */
        text = gpk_package_id_format_twoline (NULL, "simon;0.0.1;i386;data", NULL);
        g_assert_cmpstr (text, ==, "simon-0.0.1 (32-bit)");
@@ -275,73 +169,6 @@ gpk_test_common_func (void)
        g_free (text);
 }
 
-static void
-gpk_task_test_install_packages_cb (GObject *object, GAsyncResult *res, gpointer user_data)
-{
-       GpkTask *task = GPK_TASK (object);
-       g_autoptr(GError) error = NULL;
-       g_autoptr(PkResults) results = NULL;
-       g_autoptr(GPtrArray) packages = NULL;
-       g_autoptr(PkError) error_code = NULL;
-
-       /* get the results */
-       results = pk_task_generic_finish (PK_TASK(task), res, &error);
-       if (results == NULL) {
-               g_warning ("failed to resolve: %s", error->message);
-               goto out;
-       }
-
-       /* check error code */
-       error_code = pk_results_get_error_code (results);
-       if (error_code != NULL)
-               g_warning ("failed to resolve success: %s", pk_error_get_details (error_code));
-
-       packages = pk_results_get_package_array (results);
-       if (packages == NULL)
-               g_warning ("no packages!");
-
-       if (packages->len != 4)
-               g_warning ("invalid number of packages: %i", packages->len);
-out:
-       _g_test_loop_quit ();
-}
-
-static void
-gpk_task_test_progress_cb (PkProgress *progress, PkProgressType type, gpointer user_data)
-{
-       PkStatusEnum status;
-       if (type == PK_PROGRESS_TYPE_STATUS) {
-               g_object_get (progress,
-                             "status", &status,
-                             NULL);
-               g_debug ("now %s", pk_status_enum_to_string (status));
-       }
-}
-
-static void
-gpk_test_task_func (void)
-{
-       g_autoptr(GpkTask) task = NULL;
-       g_auto(GStrv) package_ids = NULL;
-
-       /* get task */
-       task = gpk_task_new ();
-       g_assert (task);
-
-       /* For testing, you will need to manually do:
-       pkcon repo-set-data dummy use-gpg 1
-       pkcon repo-set-data dummy use-eula 1
-       pkcon repo-set-data dummy use-media 1
-       */
-
-       /* install package */
-       package_ids = pk_package_ids_from_id ("vips-doc;7.12.4-2.fc8;noarch;linva");
-       pk_task_install_packages_async (PK_TASK(task), package_ids, NULL,
-                                       (PkProgressCallback) gpk_task_test_progress_cb, NULL,
-                                       (GAsyncReadyCallback) gpk_task_test_install_packages_cb, NULL);
-       _g_test_loop_wait (150000);
-}
-
 int
 main (int argc, char **argv)
 {
@@ -350,11 +177,6 @@ main (int argc, char **argv)
 
        g_test_add_func ("/gnome-packagekit/enum", gpk_test_enum_func);
        g_test_add_func ("/gnome-packagekit/common", gpk_test_common_func);
-       g_test_add_func ("/gnome-packagekit/markdown", gpk_test_markdown_func);
-       if (g_test_thorough ()) {
-               g_test_add_func ("/gnome-packagekit/error", gpk_test_error_func);
-               g_test_add_func ("/gnome-packagekit/task", gpk_test_task_func);
-       }
 
        return g_test_run ();
 }
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..9d651e6
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,163 @@
+# Copyright (C) 2016 Richard Hughes <richard hughsie com>
+#
+# Licensed under the GNU General Public License Version 2 or later
+
+cargs = ['-DG_LOG_DOMAIN="GnomePackageKit"']
+
+gpk_application_resources = gnome.compile_resources(
+  'gpk-application-resources',
+  'gpk-application.gresource.xml',
+  source_dir : '.',
+  c_name : 'gpk'
+)
+
+gpk_log_resources = gnome.compile_resources(
+  'gpk-log-resources',
+  'gpk-log.gresource.xml',
+  source_dir : '.',
+  c_name : 'gpk'
+)
+
+gpk_prefs_resources = gnome.compile_resources(
+  'gpk-prefs-resources',
+  'gpk-prefs.gresource.xml',
+  source_dir : '.',
+  c_name : 'gpk'
+)
+
+gpk_update_viewer_resources = gnome.compile_resources(
+  'gpk-update-viewer-resources',
+  'gpk-update-viewer.gresource.xml',
+  source_dir : '.',
+  c_name : 'gpk'
+)
+
+shared_srcs = [
+  'gpk-debug.c',
+  'gpk-debug.h',
+  'gpk-enum.c',
+  'gpk-enum.h',
+  'gpk-dialog.c',
+  'gpk-dialog.h',
+  'gpk-common.c',
+  'gpk-common.h',
+  'gpk-task.c',
+  'gpk-task.h',
+  'gpk-error.c',
+  'gpk-error.h'
+]
+
+executable(
+  'gpk-application',
+  gpk_application_resources,
+  sources : [
+    'gpk-application.c',
+    shared_srcs
+  ],
+  include_directories : [
+    include_directories('..'),
+  ],
+  dependencies : [
+    packagekit,
+    gio,
+    gtk
+  ],
+  c_args : cargs,
+  install : true,
+  install_dir : 'bin'
+)
+
+executable(
+  'gpk-prefs',
+  gpk_prefs_resources,
+  sources : [
+    'gpk-prefs.c',
+    shared_srcs
+  ],
+  include_directories : [
+    include_directories('..'),
+  ],
+  dependencies : [
+    packagekit,
+    gio,
+    gtk
+  ],
+  c_args : cargs,
+  install : true,
+  install_dir : 'bin'
+)
+
+executable(
+  'gpk-log',
+  gpk_log_resources,
+  sources : [
+    'gpk-log.c',
+    shared_srcs
+  ],
+  include_directories : [
+    include_directories('..'),
+  ],
+  dependencies : [
+    packagekit,
+    gio,
+    gtk
+  ],
+  c_args : cargs,
+  install : true,
+  install_dir : 'bin'
+)
+
+gpk_update_viewer_srcs = [
+  'gpk-update-viewer.c',
+  'gpk-cell-renderer-size.c',
+  'gpk-cell-renderer-size.h',
+  'gpk-cell-renderer-info.c',
+  'gpk-cell-renderer-info.h',
+  'gpk-cell-renderer-restart.c',
+  'gpk-cell-renderer-restart.h',
+  shared_srcs
+]
+
+if get_option('enable-systemd')
+  gpk_update_viewer_srcs += 'systemd-proxy.c'
+  gpk_update_viewer_srcs += 'systemd-proxy.h'
+endif
+
+executable(
+  'gpk-update-viewer',
+  gpk_update_viewer_resources,
+  sources : gpk_update_viewer_srcs,
+  include_directories : [
+    include_directories('..'),
+  ],
+  dependencies : [
+    polkit,
+    packagekit,
+    gio,
+    systemd,
+    gtk
+  ],
+  c_args : cargs,
+  install : true,
+  install_dir : 'bin'
+)
+
+if get_option('enable-tests')
+  e = executable(
+    'gpk-self-test',
+    sources : [
+      'gpk-self-test.c',
+      shared_srcs
+    ],
+    include_directories : [
+      include_directories('..'),
+    ],
+    dependencies : [
+      packagekit,
+      gio,
+      gtk
+    ],
+    c_args : cargs
+  )
+  test('gnome-power-self-test', e)
+endif


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