[gnome-packagekit] Port to the meson build system



commit f2f986288d0fba190875217405d27fee4f1ba673
Author: Richard Hughes <richard hughsie com>
Date:   Tue Dec 6 19:50:50 2016 +0000

    Port to the meson build system
    
    Automake and autoconf are impossible to fully understand and Meson now provides
    everything we need for a much smaller, faster, and more understandable build.
    
    See http://mesonbuild.com/ for more information.

 data/appdata/meson.build               |   14 +++
 data/icons/create-application-icons.sh |   25 +++++
 data/icons/meson.build                 |   23 +++++
 data/meson.build                       |   29 ++++++
 man/meson.build                        |   31 ++++++
 meson.build                            |  155 +++++++++++++++++++++++++++++++
 meson_options.txt                      |    3 +
 meson_post_install.sh                  |   14 +++
 po/meson.build                         |    6 +
 src/meson.build                        |  159 ++++++++++++++++++++++++++++++++
 10 files changed, 459 insertions(+), 0 deletions(-)
---
diff --git a/data/appdata/meson.build b/data/appdata/meson.build
new file mode 100644
index 0000000..41d5a11
--- /dev/null
+++ b/data/appdata/meson.build
@@ -0,0 +1,14 @@
+appdata_files = [
+  'org.gnome.Packages.appdata.xml',
+  'org.gnome.PackageUpdater.appdata.xml'
+]
+foreach appdata_file: appdata_files
+  i18n.merge_file(
+    input: appdata_file + '.in',
+    output: appdata_file,
+    type: 'xml',
+    po_dir: join_paths(meson.source_root(), 'po'),
+    install: true,
+    install_dir: join_paths(get_option('datadir'), 'appdata')
+  )
+endforeach
diff --git a/data/icons/create-application-icons.sh b/data/icons/create-application-icons.sh
new file mode 100644
index 0000000..db26920
--- /dev/null
+++ b/data/icons/create-application-icons.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+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..84bed3d
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,23 @@
+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/meson.build b/data/meson.build
new file mode 100644
index 0000000..3a3cf85
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,29 @@
+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'
+)
+
+desktop_files = [
+  'gpk-install-local-file.desktop',
+  'gpk-log.desktop',
+  'gpk-prefs.desktop',
+  'org.gnome.Packages.desktop',
+  'org.gnome.PackageUpdater.desktop'
+]
+foreach desktop_file: desktop_files
+  i18n.merge_file(
+    input: desktop_file + '.in',
+    output: desktop_file,
+    type: 'desktop',
+    po_dir: join_paths(meson.source_root(), 'po'),
+    install: true,
+    install_dir: join_paths(get_option('datadir'), 'applications')
+  )
+endforeach
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 0000000..37f4c60
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,31 @@
+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..79d131f
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,155 @@
+# 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('PKGDATADIR',
+                join_paths(get_option('prefix'),
+                           get_option('datadir'),
+                           'gnome-software'))
+configure_file(
+  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 100644
index 0000000..c523b15
--- /dev/null
+++ b/meson_post_install.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+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..964935b
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,6 @@
+i18n.gettext(meson.project_name(),
+  preset : 'glib',
+  args: [
+    '--default-domain=' + meson.project_name()
+  ]
+)
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..0b2c6b7
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,159 @@
+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]