[dconf-editor] build: Port to meson build system



commit bfcf7ffcab73d3f497953865d37bf768f71a0709
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Thu Jul 13 19:40:49 2017 +0200

    build: Port to meson build system
    
    meson is a build system focused on speed an ease of use, which
    helps speeding up the software development. This patch adds meson
    support along autotools.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784922

 editor/ca.desrt.dconf-editor.service.in |    3 +
 editor/meson.build                      |  115 ++++++++++++++++++++++++++++
 meson.build                             |  127 +++++++++++++++++++++++++++++++
 meson_post_install.py                   |   14 ++++
 po/meson.build                          |    1 +
 5 files changed, 260 insertions(+), 0 deletions(-)
---
diff --git a/editor/ca.desrt.dconf-editor.service.in b/editor/ca.desrt.dconf-editor.service.in
new file mode 100644
index 0000000..ac22e3d
--- /dev/null
+++ b/editor/ca.desrt.dconf-editor.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=ca.desrt.dconf-editor
+Exec=@bindir@/dconf-editor --gapplication-service
diff --git a/editor/meson.build b/editor/meson.build
new file mode 100644
index 0000000..a067949
--- /dev/null
+++ b/editor/meson.build
@@ -0,0 +1,115 @@
+desktop = dconf_editor_namespace + '.desktop'
+
+i18n.merge_file (
+  desktop,
+  type: 'desktop',
+  input: desktop + '.in',
+  output: desktop,
+  po_dir: po_dir,
+  install: true,
+  install_dir: join_paths(dconf_editor_datadir, 'applications')
+)
+
+service_conf = configuration_data()
+service_conf.set('bindir', dconf_editor_bindir)
+
+service = dconf_editor_namespace + '.service'
+
+configure_file(
+  input: service + '.in',
+  output: service,
+  install: true,
+  install_dir: join_paths(dconf_editor_datadir, 'dbus-1', 'services'),
+  configuration: service_conf
+)
+
+appdata = dconf_editor_namespace + '.appdata.xml'
+
+i18n.merge_file(
+  appdata,
+  input: appdata + '.in',
+  output: appdata,
+  po_dir: po_dir,
+  install: true,
+  install_dir: join_paths(dconf_editor_datadir, 'metainfo')
+)
+
+install_data(
+  dconf_editor_namespace + '.gschema.xml',
+  install_dir: join_paths(dconf_editor_datadir, 'glib-2.0', 'schemas')
+)
+
+install_subdir(
+  'icons',
+  install_dir: dconf_editor_datadir
+)
+
+install_data(
+  dconf_editor_name + '.1',
+  install_dir: join_paths(dconf_editor_mandir, 'man1')
+)
+
+sources = files(
+  'bookmarks.vala',
+  'dconf-editor.vala',
+  'dconf-model.vala',
+  'dconf-view.vala',
+  'dconf-window.vala',
+  'key-list-box-row.vala',
+  'modifications-revealer.vala',
+  'pathbar.vala',
+  'registry-info.vala',
+  'registry-view.vala'
+)
+
+resource_data = files(
+  'bookmarks.ui',
+  'bookmark.ui',
+  'dconf-editor.css',
+  'dconf-editor-menu.ui',
+  'dconf-editor.ui',
+  'folder-list-box-row.ui',
+  'help-overlay.ui',
+  'key-list-box-row.ui',
+  'modifications-revealer.ui',
+  'pathbar-item.ui',
+  'pathbar.ui',
+  'property-row.ui',
+  'registry-info.ui',
+  'registry-view.ui'
+)
+
+sources += gnome.compile_resources(
+  'resources',
+  dconf_editor_name + '.gresource.xml',
+  dependencies: resource_data,
+  export: true
+)
+
+deps = [
+  dependency('dconf', version: '>= 0.25.1'),
+  dependency('glib-2.0', version: '>= 2.46.0'),
+  dependency('gmodule-2.0'),
+  dependency('gtk+-3.0', version: '>= 3.22.0'),
+  valac.find_library('config', dirs: meson.current_source_dir()),
+  valac.find_library('posix')
+]
+
+cflags = [
+  '-DPKGDATADIR="@0@"'.format(dconf_editor_pkgdatadir),
+  '-DVERSION="@0@"'.format(dconf_editor_version),
+  '-DLOCALEDIR="@0@"'.format(dconf_editor_localedir),
+  '-DGETTEXT_PACKAGE="@0@"'.format(dconf_editor_gettext),
+  '-w'
+]
+
+executable(
+  dconf_editor_name,
+  sources,
+  include_directories: top_inc,
+  dependencies: deps,
+  c_args: cflags,
+  vala_args: '--enable-experimental-non-null',
+  install: true,
+  install_dir: dconf_editor_bindir
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..007a01b
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,127 @@
+project(
+  'dconf-editor', ['c', 'vala'],
+  version: '3.26.1',
+  license: 'GPL3+',
+  default_options: [
+    'buildtype=debugoptimized',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.41.0'
+)
+
+dconf_editor_name = meson.project_name()
+dconf_editor_version = meson.project_version()
+
+dconf_editor_prefix = get_option('prefix')
+dconf_editor_bindir = join_paths(dconf_editor_prefix, get_option('bindir'))
+dconf_editor_datadir = join_paths(dconf_editor_prefix, get_option('datadir'))
+dconf_editor_localedir = join_paths(dconf_editor_prefix, get_option('localedir'))
+dconf_editor_mandir = join_paths(dconf_editor_prefix, get_option('mandir'))
+
+dconf_editor_pkgdatadir = join_paths(dconf_editor_datadir, dconf_editor_name)
+
+dconf_editor_gettext = 'dconf'
+dconf_editor_namespace = 'ca.desrt.dconf-editor'
+
+cc = meson.get_compiler('c')
+valac = meson.get_compiler('vala')
+
+vala_req_version = '>= 0.33.1'
+
+assert(valac.version().version_compare(vala_req_version),
+       'vala ' + vala_req_version + ' is required')
+
+config_h = configuration_data()
+
+# package
+set_defines = [
+  ['PACKAGE', dconf_editor_name],
+  ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + dconf_editor_name],
+  ['PACKAGE_NAME', dconf_editor_name],
+  ['PACKAGE_STRING', '@0@ @1@'.format(dconf_editor_name, dconf_editor_version)],
+  ['PACKAGE_TARNAME', dconf_editor_name],
+  ['PACKAGE_URL', ''],
+  ['PACKAGE_VERSION', dconf_editor_version],
+  ['VERSION', dconf_editor_version],
+  # i18n
+  ['GETTEXT_PACKAGE', dconf_editor_gettext]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
+
+# headers
+check_headers = [
+  ['HAVE_DLFCN_H', 'dlfcn.h'],
+  ['HAVE_FLOAT_H', 'float.h'],
+  ['HAVE_INTTYPES_H', 'inttypes.h'],
+  ['HAVE_MEMORY_H', 'memory.h'],
+  ['HAVE_STDINT_H', 'stdint.h'],
+  ['HAVE_STDLIB_H', 'stdlib.h'],
+  ['HAVE_STRINGS_H', 'strings.h'],
+  ['HAVE_STRING_H', 'string.h'],
+  ['HAVE_SYS_STAT_H', 'sys/stat.h'],
+  ['HAVE_UNISTD_H', 'unistd.h'],
+  # i18n
+  ['HAVE_LOCALE_H', 'locale.h']
+]
+
+foreach header: check_headers
+  if cc.has_header(header[1])
+    config_h.set(header[0], true)
+  endif
+endforeach
+
+sys_types_h = cc.has_header('sys/types.h')
+config_h.set('HAVE_SYS_TYPES_H', sys_types_h)
+if not sys_types_h
+  config_h.set('size_t', 'unsigned int')
+endif
+
+# functions
+check_functions = [
+  ['HAVE_MEMSET', 'memset'],
+  ['HAVE_STRSTR', 'strstr'],
+  # i18n
+  ['HAVE_DCGETTEXT', 'dcgettext'],
+  ['HAVE_GETTEXT', 'gettext'],
+  ['HAVE_ICONV', 'iconv'],
+  ['HAVE_SETLOCALE', 'setlocale']
+]
+
+if host_machine.system().contains('darwin')
+  check_functions += [
+    ['HAVE_CFLOCALECOPYCURRENT', 'CFLocaleCopyCurrent'],
+    ['HAVE_CFPREFERENCESCOPYAPPVALUE', 'CFPreferencesCopyAppValue']
+  ]
+endif
+
+foreach func: check_functions
+  if cc.has_function(func[1])
+    config_h.set(func[0], true)
+  endif
+endforeach
+
+# compiler flags
+add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+po_dir = join_paths(meson.source_root(), 'po')
+
+top_inc = include_directories('.')
+
+subdir('editor')
+subdir('po')
+
+configure_file(
+  output: 'config.h',
+  configuration: config_h
+)
+
+meson.add_install_script(
+  'meson_post_install.py',
+  dconf_editor_datadir
+)
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..0df4692
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+if not os.environ.get('DESTDIR'):
+  icondir = os.path.join(sys.argv[1], 'icons', 'hicolor')
+  print('Update icon cache...')
+  subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
+
+  schemadir = os.path.join(sys.argv[1], 'glib-2.0', 'schemas')
+  print('Compiling gsettings schemas...')
+  subprocess.call(['glib-compile-schemas', schemadir])
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..e739022
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext(dconf_editor_gettext, preset: 'glib')


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