[gnome-power-manager] Port to the Meson buildsystem



commit c987c5761c56ae75a0c8c434b7dcab401e8d43b7
Author: Richard Hughes <richard hughsie com>
Date:   Tue Dec 6 16:56:22 2016 +0000

    Port to the Meson buildsystem
    
    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       |   12 ++++
 data/icons/hicolor/meson.build |   18 +++++
 data/icons/meson.build         |    5 ++
 data/meson.build               |   26 ++++++++
 man/meson.build                |   14 ++++
 meson.build                    |  139 ++++++++++++++++++++++++++++++++++++++++
 meson_options.txt              |    1 +
 meson_post_install.sh          |   18 +++++
 po/meson.build                 |   10 +++
 src/meson.build                |   62 ++++++++++++++++++
 10 files changed, 305 insertions(+), 0 deletions(-)
---
diff --git a/data/appdata/meson.build b/data/appdata/meson.build
new file mode 100644
index 0000000..4135bf6
--- /dev/null
+++ b/data/appdata/meson.build
@@ -0,0 +1,12 @@
+# 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.PowerStats.appdata.xml.in',
+  output: 'org.gnome.PowerStats.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/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..ef686a2
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,26 @@
+# 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
+)
+i18n.merge_file(
+  input: versionedfile,
+  output: 'org.gnome.PowerStats.desktop',
+  type: 'desktop',
+  po_dir: join_paths(meson.source_root(), 'po'),
+  install: true,
+  install_dir: join_paths(get_option('datadir'), 'applications')
+)
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..ddccf4e
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,139 @@
+# 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.23.3',
+  default_options : ['warning_level=1'],
+  meson_version : '>=0.37.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
+
+# 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'
+)
+
+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_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')))
+configure_file(
+  output : 'config.h',
+  configuration : conf
+)
+top_build_incdir = include_directories(meson.current_build_dir())
+
+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
+
+# 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..04c3a3a
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('enable-tests', type : 'boolean', value : true, description : 'enable tests')
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/meson.build b/src/meson.build
new file mode 100644
index 0000000..49fa9e3
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,62 @@
+# 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('..'),
+  ],
+  dependencies : [
+    cairo,
+    gdk,
+    gtk,
+    libm,
+    upower
+  ],
+  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('..'),
+    ],
+    dependencies : [
+      cairo,
+      gdk,
+      gtk,
+      libm,
+      upower
+    ],
+    c_args : cargs
+  )
+  test('gnome-power-self-test', e)
+endif


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