[seahorse-nautilus] Build: port to Meson build system.



commit 0d7367ce837453189a8cb2704367736a536f27ce
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sun Dec 3 18:38:41 2017 +0100

    Build: port to Meson build system.

 data/meson.build                     |    7 +++
 meson.build                          |   92 ++++++++++++++++++++++++++++++++++
 meson/gpg_check_version.py           |   42 +++++++++++++++
 meson/post_install.py                |   15 ++++++
 meson_options.txt                    |    3 +
 nautilus-ext/meson.build             |   17 ++++++
 po/meson.build                       |    3 +
 tool/meson.build                     |   81 ++++++++++++++++++++++++++++++
 tool/seahorse-nautilus.gresource.xml |    8 +++
 9 files changed, 268 insertions(+), 0 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..c630d23
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,7 @@
+gsettings_files = [
+  'org.gnome.seahorse.nautilus.gschema.xml',
+  'org.gnome.seahorse.nautilus.window.gschema.xml',
+]
+install_data(gsettings_files,
+  install_dir: join_paths(datadir, 'glib-2.0', 'schemas'),
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..2d6027b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,92 @@
+project('seahorse-nautilus', 'c',
+  version: '3.11.92',
+  meson_version: '>= 0.42',
+  license: 'GPL2+',
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+# Options
+check_compatible_gpg = get_option('check-compatible-gpg')
+libnotify_enabled = get_option('libnotify')
+nautilus_ext_dir = get_option('nautilus-ext-dir')
+
+# Some useful variables
+cc = meson.get_compiler('c')
+seahorse_nautilus_prefix = get_option('prefix')
+po_dir = join_paths(meson.source_root(), 'po')
+datadir = join_paths(seahorse_nautilus_prefix, get_option('datadir'))
+bindir = join_paths(seahorse_nautilus_prefix, get_option('bindir'))
+localedir = join_paths(seahorse_nautilus_prefix, get_option('localedir'))
+uidir = join_paths(datadir, 'seahorse-nautilus', 'ui')
+config_h_dir = include_directories('.')
+
+# Dependencies
+min_glib_version = '2.10.0'
+accepted_gpg_versions= ['1.2.0', '1.4.0', '2.0.0', '2.1.0', '2.2.0' ]
+min_gpgme_version = '1.0.0'
+
+libnautilus_extension = dependency('libnautilus-extension', version: '>= 2.12.0')
+if nautilus_ext_dir == ''
+  nautilus_ext_dir = libnautilus_extension.get_pkgconfig_variable('extensiondir')
+endif
+message('Nautilus extension dir: "@0@"'.format(nautilus_ext_dir))
+
+glib = dependency('gio-2.0', version: '>= ' + min_glib_version)
+gio = dependency('gio-2.0', version: '>= ' + min_glib_version)
+gtk = dependency('gtk+-3.0', version: '>= 3.0')
+dbus_glib = dependency('dbus-glib-1', version: '>= 0.35')
+cryptui = dependency('cryptui-0.0', version: '>= 3.9.90')
+gcr = dependency('gcr-3', version: '>= 3.4.0')
+if libnotify_enabled
+  libnotify = dependency('libnotify', version: '>= 0.3')
+endif
+
+gpg_check_version = find_program(join_paths('meson', 'gpg_check_version.py'))
+gpg_bin = find_program('gpg2', 'gpg')
+gpgme = cc.find_library('gpgme')
+gpgme_config = find_program('gpgme-config')
+if check_compatible_gpg
+  gpg_version_check = run_command([gpg_check_version, gpg_bin.path(), 'false', accepted_gpg_versions ])
+  gpg_version = gpg_version_check.stdout()
+  message('GnuPG Version: @0@'.format(gpg_version))
+  if gpg_version_check.returncode() != 0
+    error('Incompatible version of GnuPG. Accepted versions are: @0@'.format(accepted_gpg_versions))
+  endif
+
+  gpgme_version_check = run_command([gpg_check_version, gpgme_config.path(), 'true', min_gpgme_version ])
+  gpgme_version = gpgme_version_check.stdout()
+  message('GPGME version: @0@'.format(gpgme_version))
+  if gpgme_version_check.returncode() != 0
+    error('Incompatible version of GPGME. Minimal version required is @0@'.format(min_gpgme_version))
+  endif
+endif
+
+# Configuration
+conf = configuration_data()
+conf.set_quoted('VERSION', meson.project_version())
+conf.set_quoted('PACKAGE', meson.project_name())
+conf.set_quoted('PACKAGE_NAME', meson.project_name())
+conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+conf.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), meson.project_version()))
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('G_LOG_DOMAIN', meson.project_name())
+conf.set_quoted('DATA_DIR', datadir)
+conf.set_quoted('LOCALEDIR', localedir)
+conf.set_quoted('GNOMELOCALEDIR', localedir)
+conf.set_quoted('SEAHORSE_UIDIR', uidir)
+conf.set('HAVE_LIBNOTIFY', libnotify_enabled)
+config_file = configure_file(
+  output: 'config.h',
+  configuration: conf,
+)
+
+# Post-install scripts
+meson.add_install_script(join_paths('meson', 'post_install.py'))
+
+# subdirs
+subdir('data')
+subdir('tool')
+subdir('nautilus-ext')
+subdir('po')
diff --git a/meson/gpg_check_version.py b/meson/gpg_check_version.py
new file mode 100755
index 0000000..b3481b3
--- /dev/null
+++ b/meson/gpg_check_version.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+import sys
+import subprocess
+
+# Parses the GPG version from the output of the --version flag.
+# Should work on the output for `gpg`, `gpg2` and `gpgme-config`.
+def parse_version(gpg_output):
+    version_line = gpg_output.splitlines()[0]
+    return version_line.strip().split(' ')[-1]
+
+# Checks whether the GPG version is compatible with the given version.
+# For GPG, this means that the major and minor version should be equal;
+# for GPGME, this means only the major version should be equal.
+def check_version(gpg_version, accepted_version, is_gpgme = False):
+    gpg_major, gpg_minor, gpg_micro = gpg_version.split('.', 2)
+    acc_major, acc_minor, acc_micro = accepted_version.split('.', 2)
+    if is_gpgme:
+        return gpg_major == acc_major and gpg_minor >= acc_minor and gpg_micro >= acc_micro
+    else:
+        return gpg_major == acc_major and gpg_minor == acc_minor and gpg_micro >= acc_micro
+
+if len(sys.argv) <= 3:
+    sys.exit(1)
+
+gpg_path = sys.argv[1]
+is_gpgme =  True if sys.argv[2].lower() == 'true' else False
+accepted_versions = sys.argv[3:]
+
+# Parse and print the version
+proc = subprocess.Popen([gpg_path, '--version'],
+                        stdout=subprocess.PIPE,
+                        universal_newlines=True)
+gpg_version = parse_version(proc.stdout.read())
+print(gpg_version, end='')
+
+# Then return whether we're compatible with that version
+for accepted_version in accepted_versions:
+    if check_version(gpg_version, accepted_version, is_gpgme):
+        sys.exit(0)
+
+sys.exit(1)
diff --git a/meson/post_install.py b/meson/post_install.py
new file mode 100644
index 0000000..bf320a9
--- /dev/null
+++ b/meson/post_install.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+install_prefix = os.environ['MESON_INSTALL_PREFIX']
+icondir = os.path.join(install_prefix, 'share', 'icons', 'hicolor')
+schemadir = os.path.join(install_prefix, 'share', 'glib-2.0', 'schemas')
+
+if not os.environ.get('DESTDIR'):
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+
+  print('Compiling gsettings schemas...')
+  subprocess.call(['glib-compile-schemas', schemadir])
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..5d29cea
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('check-compatible-gpg', type: 'boolean', value: true, description: 'Perform a rudimentary check if 
the GPG and GPG versions are compatible')
+option('nautilus-ext-dir', type: 'string', value: '', description: 'Path to the nautilus extensions 
directory')
+option('libnotify', type: 'boolean', value: true, description: 'Allow libnotify notifications')
diff --git a/nautilus-ext/meson.build b/nautilus-ext/meson.build
new file mode 100644
index 0000000..42ddc54
--- /dev/null
+++ b/nautilus-ext/meson.build
@@ -0,0 +1,17 @@
+libnautilus_seahorse_sources = [
+  'seahorse-nautilus.c',
+  'seahorse-nautilus-module.c',
+]
+
+libnautilus_seahorse_dependencies = [
+  glib,
+  libnautilus_extension,
+]
+
+libnautilus_seahorse = library('nautilus-seahorse',
+  libnautilus_seahorse_sources,
+  dependencies: libnautilus_seahorse_dependencies,
+  include_directories: config_h_dir,
+  install: true,
+  install_dir: nautilus_ext_dir,
+)
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..f904cde
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+i18n.gettext(meson.project_name(),
+  preset: 'glib'
+)
diff --git a/tool/meson.build b/tool/meson.build
new file mode 100644
index 0000000..b2e4194
--- /dev/null
+++ b/tool/meson.build
@@ -0,0 +1,81 @@
+marshaller = gnome.genmarshal('seahorse-marshal',
+  sources: 'seahorse-marshal.list',
+  prefix: 'seahorse_marshal',
+)
+
+# Resources
+resources = gnome.compile_resources('seahorse-resources',
+  'seahorse-nautilus.gresource.xml',
+  c_name: 'seahorse',
+)
+
+seahorse_tool_sources = [
+  'seahorse-notification.c',
+  'seahorse-operation.c',
+  'seahorse-passphrase.c',
+  'seahorse-pgp-operation.c',
+  'seahorse-progress.c',
+  'seahorse-tool.c',
+  'seahorse-tool-files.c',
+  'seahorse-tool-progress.c',
+  'seahorse-util.c',
+  'seahorse-vfs-data.c',
+  'seahorse-widget.c',
+  marshaller,
+]
+
+seahorse_tool_dependencies = [
+  glib,
+  gio,
+  gtk,
+  gcr,
+  cryptui,
+  gpgme,
+]
+
+if libnotify_enabled
+  seahorse_tool_dependencies += libnotify
+endif
+
+seahorse_tool_cflags = [
+       '-DLIBCRYPTUI_API_SUBJECT_TO_CHANGE',
+       '-DGCR_API_SUBJECT_TO_CHANGE',
+]
+
+seahorse_tool = executable('seahorse-tool',
+  seahorse_tool_sources,
+  dependencies: seahorse_tool_dependencies,
+  c_args: seahorse_tool_cflags,
+  include_directories: config_h_dir,
+  install: true,
+)
+
+# Manpage
+install_man('seahorse-tool.1')
+
+# The desktop file
+desktop_files = [
+  'seahorse-pgp-encrypted.desktop',
+  'seahorse-pgp-signature.desktop',
+  'seahorse-pgp-keys.desktop',
+]
+
+foreach desktop_file : desktop_files
+  desktop_conf = configuration_data()
+  desktop_conf.set('bindir', bindir)
+  desktop_conf.set('VERSION', meson.project_version())
+
+  configured_desktop_file = configure_file(
+    input: desktop_file + '.in.in',
+    output: desktop_file + '.in',
+    configuration: desktop_conf,
+  )
+  i18n.merge_file(
+    input: configured_desktop_file,
+    output: desktop_file,
+    type: 'desktop',
+    po_dir: po_dir,
+    install: true,
+    install_dir: join_paths(datadir, 'applications')
+  )
+endforeach
diff --git a/tool/seahorse-nautilus.gresource.xml b/tool/seahorse-nautilus.gresource.xml
new file mode 100644
index 0000000..6047ed2
--- /dev/null
+++ b/tool/seahorse-nautilus.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gresources>
+  <gresource prefix="/org/gnome/Seahorse">
+    <file preprocess="xml-stripblanks">seahorse-multi-encrypt.ui</file>
+    <file preprocess="xml-stripblanks">seahorse-notify.ui</file>
+    <file preprocess="xml-stripblanks">seahorse-progress.ui</file>
+  </gresource>
+</gresources>


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