[dconf/wip/inigomartinez/meson: 2/2] build: Port to meson build system



commit aabc315b0ab2ccd9487c1706998a77befd8ec5d4
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Wed Jul 12 16:30:51 2017 +0200

    build: Port to meson build system

 bin/meson.build                   |   23 ++++++
 client/meson.build                |   76 +++++++++++++++++++++
 common/meson.build                |   54 +++++++++++++++
 docs/meson.build                  |   52 ++++++++++++++
 engine/meson.build                |   30 ++++++++
 gdbus/meson.build                 |   43 ++++++++++++
 gsettings/meson.build             |   26 +++++++
 gvdb/meson.build                  |   26 +++++++
 meson.build                       |  136 +++++++++++++++++++++++++++++++++++++
 meson_options.txt                 |    6 ++
 meson_post_install.py             |    9 +++
 service/ca.desrt.dconf.service.in |    3 +
 service/meson.build               |   53 ++++++++++++++
 shm/meson.build                   |   22 ++++++
 tests/meson.build                 |  126 ++++++++++++++++++++++++++++++++++
 15 files changed, 685 insertions(+), 0 deletions(-)
---
diff --git a/bin/meson.build b/bin/meson.build
new file mode 100644
index 0000000..38f1537
--- /dev/null
+++ b/bin/meson.build
@@ -0,0 +1,23 @@
+sources = gvdb_builder + libdconf_vapi + files(
+  'gvdb.vapi',
+  'dconf-update.vala',
+  'dconf-dump.vala',
+  'dconf.vala'
+)
+
+executable(
+  meson.project_name(),
+  sources,
+  include_directories: top_inc,
+  dependencies: libdconf_dep,
+  c_args: '-w',
+  vala_args: '--pkg=posix',
+  link_with: libdconf,
+  install: true,
+  install_dir: dconf_bindir
+)
+
+install_data(
+  'completion/dconf',
+  install_dir: join_paths(dconf_datadir, 'bash-completion', 'completions')
+)
diff --git a/client/meson.build b/client/meson.build
new file mode 100644
index 0000000..4672e76
--- /dev/null
+++ b/client/meson.build
@@ -0,0 +1,76 @@
+client_inc = include_directories('.')
+
+install_headers(
+  'dconf.h',
+  subdir: meson.project_name()
+)
+
+install_headers(
+  'dconf-client.h',
+  subdir: join_paths(meson.project_name(), 'client')
+)
+
+sources = files('dconf-client.c')
+
+cflags = '-DG_lOG_DOMAIN="@0@"'.format(meson.project_name())
+
+libdconf_client = static_library(
+  meson.project_name() + '-client',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  c_args: cflags,
+  pic: true
+)
+
+libdconf = shared_library(
+  meson.project_name(),
+  sources: sources,
+  version: libversion,
+  soversion: soversion,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  c_args: cflags,
+  link_with: [
+    libdconf_engine_shared,
+    libdconf_common_shared,
+    libdconf_gdbus_thread_shared,
+    libgvdb_shared,
+    libdconf_shm_shared
+  ],
+  install: true,
+  install_dir: dconf_libdir
+)
+
+libdconf_dep = declare_dependency(
+  link_with: libdconf,
+  include_directories: client_inc,
+  dependencies: gio_unix_dep
+)
+
+pkg.generate(
+  libraries: libdconf,
+  version: dconf_version,
+  name: meson.project_name(),
+  description: meson.project_name() + ' client library',
+  filebase: meson.project_name(),
+  subdirs: meson.project_name(),
+  requires: [
+    'gio-unix-2.0 ' + gio_unix_req_version
+  ],
+  variables: [
+    'exec_prefix=${prefix}'
+  ],
+  install_dir: join_paths(dconf_libdir, 'pkgconfig')
+)
+
+libdconf_vapi = files(meson.project_name() + '.vapi')
+
+vapi_data = libdconf_vapi + files(
+  meson.project_name() + '.deps'
+)
+
+install_data(
+  vapi_data,
+  install_dir: join_paths(dconf_datadir, 'vala', 'vapi')
+)
diff --git a/common/meson.build b/common/meson.build
new file mode 100644
index 0000000..aa198a6
--- /dev/null
+++ b/common/meson.build
@@ -0,0 +1,54 @@
+common_inc = include_directories('.')
+
+headers = files(
+  'dconf-changeset.h',
+  'dconf-enums.h',
+  'dconf-paths.h'
+)
+
+install_headers(
+  headers,
+  subdir: join_paths(meson.project_name(), 'common')
+)
+
+name = 'dconf-common'
+
+sources = files(
+  'dconf-changeset.c',
+  'dconf-error.c',
+  'dconf-paths.c'
+)
+
+cflags = ['-DG_lOG_DOMAIN="@0@"'.format(meson.project_name())]
+
+libdconf_common = static_library(
+  name,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags
+)
+
+libdconf_common_shared = static_library(
+  name + '-shared',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags,
+  pic: true
+)
+
+cflag = '-fvisibility=hidden'
+
+if cc.has_argument(cflag)
+  cflags += [cflag]
+endif
+
+libdconf_common_hidden = static_library(
+  name + '-hidden',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags,
+  pic: true
+)
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..ae4c871
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1,52 @@
+gnome.gtkdoc(
+  meson.project_name(),
+  main_xml: meson.project_name() + '-docs.xml',
+  src_dir: [
+    common_inc,
+    client_inc
+  ],
+  dependencies: libdconf_dep,
+  scan_args: '--rebuild-types',
+  gobject_typesfile: meson.project_name() + '.types',
+  mkdb_args: '--output-format=xml',
+  install: true,
+  install_dir: join_paths(dconf_datadir, 'gtk-doc', 'html', meson.project_name())
+)
+
+if get_option('enable-man')
+  xsltproc = find_program('xsltproc', required: false)
+  assert(xsltproc.found(), 'xsltproc is required for enable-man')
+
+  xsltproc_cmd = [
+    xsltproc,
+    '--output', '@OUTPUT@',
+    '--nonet',
+    '--stringparam', 'man.output.quietly', '1',
+    '--stringparam', 'funcsynopsis.style', 'ansi',
+    '--stringparam', 'man.th.extra1.suppress', '1',
+    '--stringparam', 'man.authors.section.enabled', '0',
+    '--stringparam', 'man.copyright.section.enabled', '0',
+    'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl',
+    '@INPUT@'
+  ]
+
+  mans = [
+    ['dconf-service.xml', 'dconf-service', '1'],
+    ['dconf-tool.xml', 'dconf', '1'],
+    ['dconf-overview.xml', 'dconf', '7']
+  ]
+
+  foreach man: mans
+    output = '@0@.@1@'.format(man[1], man[2])
+    man_dir = 'man' + man[2]
+
+    custom_target(
+      output,
+      input: man[0],
+      output: output,
+      command: xsltproc_cmd,
+      install: true,
+      install_dir: join_paths(dconf_mandir, man_dir)
+    )
+  endforeach
+endif
diff --git a/engine/meson.build b/engine/meson.build
new file mode 100644
index 0000000..9caf96c
--- /dev/null
+++ b/engine/meson.build
@@ -0,0 +1,30 @@
+name = 'dconf-engine'
+
+sources = files(
+  'dconf-engine-profile.c',
+  'dconf-engine-source-file.c',
+  'dconf-engine-source-user.c',
+  'dconf-engine-source-service.c',
+  'dconf-engine-source-system.c',
+  'dconf-engine-source.c',
+  'dconf-engine.c'
+)
+
+cflags = '-DG_lOG_DOMAIN="@0@"'.format(meson.project_name())
+
+libdconf_engine = static_library(
+  name,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags
+)
+
+libdconf_engine_shared = static_library(
+  name + '-shared',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags,
+  pic: true
+)
diff --git a/gdbus/meson.build b/gdbus/meson.build
new file mode 100644
index 0000000..a29efe8
--- /dev/null
+++ b/gdbus/meson.build
@@ -0,0 +1,43 @@
+name = 'dconf-gdbus-thread'
+
+sources = files(name + '.c')
+
+cflags = '-DG_lOG_DOMAIN="@0@"'.format(meson.project_name())
+
+libdconf_gdbus_thread = static_library(
+  name,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  c_args: cflags
+)
+
+libdconf_gdbus_thread_shared = static_library(
+  name + '-shared',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  c_args: cflags,
+  pic: true
+)
+
+name = 'dconf-gdbus-filter'
+
+sources = files(name + '.c')
+
+libdconf_gdbus_filter = static_library(
+  name,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  c_args: cflags
+)
+
+libdconf_gdbus_filter_shared = static_library(
+  name + '-shared',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  c_args: cflags,
+  pic: true
+)
diff --git a/gsettings/meson.build b/gsettings/meson.build
new file mode 100644
index 0000000..40cdb73
--- /dev/null
+++ b/gsettings/meson.build
@@ -0,0 +1,26 @@
+sources = files('dconfsettingsbackend.c')
+
+cflags = '-DG_lOG_DOMAIN="@0@"'.format(meson.project_name())
+
+libdconf_settings = shared_library(
+  'dconfsettings',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  c_args: cflags,
+  link_with: [
+    libdconf_engine_shared,
+    libgvdb_shared,
+    libdconf_gdbus_thread_shared,
+    libdconf_common_hidden,
+    libdconf_shm_shared
+  ],
+  install: true,
+  install_dir: join_paths(dconf_libdir, 'gio', 'modules')
+)
+
+test(
+  'abicheck',
+  find_program('abicheck.sh'),
+  env: ['GSETTINGS_LIB=' + libdconf_settings.full_path()]
+)
diff --git a/gvdb/meson.build b/gvdb/meson.build
new file mode 100644
index 0000000..351f333
--- /dev/null
+++ b/gvdb/meson.build
@@ -0,0 +1,26 @@
+name = 'gvdb'
+
+gvdb_builder = files('gvdb-builder.c')
+
+sources = gvdb_builder + files(
+  'gvdb-reader.c'
+)
+
+cflags = '-DG_lOG_DOMAIN="gvdb (via @0@)"'.format(meson.project_name())
+
+libgvdb = static_library(
+  name,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags
+)
+
+libgvdb_shared = static_library(
+  name + '-shared',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags,
+  pic: true
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..066d3be
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,136 @@
+project(
+  'dconf', ['c', 'vala'],
+  version: '0.26.0',
+  license: 'LGPL2.1',
+  default_options: [
+    'buildtype=debugoptimized',
+    'c_std=gnu99',
+    'warning_level=1'
+  ],
+  meson_version: '>= 0.41.0'
+)
+
+dconf_version = meson.project_version()
+version_array = dconf_version.split('.')
+dconf_major_version = version_array[0].to_int()
+dconf_minor_version = version_array[1].to_int()
+dconf_micro_version = version_array[2].to_int()
+
+dconf_prefix = get_option('prefix')
+dconf_bindir = join_paths(dconf_prefix, get_option('bindir'))
+dconf_datadir = join_paths(dconf_prefix, get_option('datadir'))
+dconf_includedir = join_paths(dconf_prefix, get_option('includedir'))
+dconf_libdir = join_paths(dconf_prefix, get_option('libdir'))
+dconf_libexecdir = join_paths(dconf_prefix, get_option('libexecdir'))
+dconf_mandir = join_paths(dconf_prefix, get_option('mandir'))
+
+dconf_namespace = 'ca.desrt.dconf'
+
+soversion = 1
+current = 0
+revision = 0
+libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
+
+dconf_buildtype = get_option('buildtype')
+
+cc = meson.get_compiler('c')
+
+config_h = configuration_data()
+
+# package
+set_defines = [
+  ['PACKAGE', meson.project_name()],
+  ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=dconf'],
+  ['PACKAGE_NAME', meson.project_name()],
+  ['PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), dconf_version)],
+  ['PACKAGE_TARNAME', meson.project_name()],
+  ['PACKAGE_URL', 'https://wiki.gnome.org/Projects/dconf'],
+  ['PACKAGE_VERSION', dconf_version],
+  ['VERSION', dconf_version],
+  ['GETTEXT_PACKAGE', meson.project_name()]
+]
+
+foreach define: set_defines
+  config_h.set_quoted(define[0], define[1])
+endforeach
+
+# compiler flags
+common_flags = ['-DHAVE_CONFIG_H']
+
+test_cflags = []
+if dconf_buildtype == 'debug' or dconf_buildtype == 'debugoptimized'
+  test_cflags = [
+    '-fno-common',
+    '-Wmissing-prototypes',
+    '-Wwrite-strings'
+  ]
+
+  # FIXME
+  '''
+  if get_option('enable-gcov')
+    common_flags += ['-O0']
+
+    test_cflags += [
+      '-fprofile-arcs',
+      '-ftest-coverage'
+    ]
+  endif
+  '''
+
+  foreach cflag: test_cflags
+    if cc.has_argument(cflag)
+      common_flags += [cflag]
+    endif
+  endforeach
+endif
+
+add_project_arguments(common_flags, language: 'c')
+
+gio_unix_req_version = '>= 2.25.7'
+
+glib_dep = dependency('glib-2.0', version: '>= 2.44.0')
+gio_unix_dep = dependency('gio-unix-2.0', version: gio_unix_req_version)
+
+dconf_deps = [
+  glib_dep,
+  gio_unix_dep
+]
+
+gio_querymodules = find_program('gio-querymodules', required: false)
+if gio_querymodules.found()
+  gio_modules_dir = get_option('with-gio-modules-dir').strip()
+  if gio_modules_dir == ''
+    gio_modules_dir = join_paths(dconf_libdir, 'gio', 'modules')
+  endif
+
+  meson.add_install_script('meson_post_install.py', gio_querymodules.path(), gio_modules_dir)
+endif
+
+configure_file(
+  output: 'config.h',
+  configuration: config_h
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+pkg = import('pkgconfig')
+
+po_dir = join_paths(meson.source_root(), 'po')
+
+top_inc = include_directories('.')
+
+subdir('shm')
+subdir('gvdb')
+subdir('common')
+subdir('engine')
+subdir('service')
+subdir('gdbus')
+subdir('gsettings')
+subdir('client')
+subdir('bin')
+
+if get_option('enable-gtk-doc')
+  subdir('docs')
+endif
+
+subdir('tests')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..65d7059
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,6 @@
+option('enable-man', type: 'boolean', value: true, description: 'generate man pages')
+option('enable-gcov', type: 'boolean', value: false, description: 'enable generation of code coverage 
information')
+option('with-gio-modules-dir', type: 'string', value: '', description: 'choose directory for the GIO module 
[default=LIBDIR/gio/modules]')
+option('with-dbus-service-dir', type: 'string', value: '', description: 'choose directory for dbus service 
files [default=PREFIX/share/dbus-1/services]')
+option('with-dbus-system-service-dir', type: 'string', value: '', description: 'choose directory for dbus 
system service files [default=PREFIX/share/dbus-1/system-services]')
+option('enable-gtk-doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 0000000..8960540
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+if not os.environ.get('DESTDIR'):
+  print('GIO module cache creation...')
+  subprocess.call([sys.argv[1], sys.argv[2]])
diff --git a/service/ca.desrt.dconf.service.in b/service/ca.desrt.dconf.service.in
new file mode 100644
index 0000000..369948a
--- /dev/null
+++ b/service/ca.desrt.dconf.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=ca.desrt.dconf
+Exec=@libexecdir@/dconf-service
diff --git a/service/meson.build b/service/meson.build
new file mode 100644
index 0000000..f2ff590
--- /dev/null
+++ b/service/meson.build
@@ -0,0 +1,53 @@
+dbus_service_dir = get_option('with-dbus-service-dir').strip()
+if dbus_service_dir == ''
+  dbus_service_dir = join_paths(dconf_datadir, 'dbus-1', 'services')
+endif
+
+dbus_system_service_dir = get_option('with-dbus-system-service-dir').strip()
+if dbus_system_service_dir == ''
+  dbus_system_service_dir = join_paths(dconf_datadir, 'dbus-1', 'system-services')
+endif
+
+service_conf = configuration_data()
+service_conf.set('libexecdir', dconf_libexecdir)
+
+service = dconf_namespace + '.service'
+
+configure_file(
+  input: service + '.in',
+  output: service,
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: service_conf
+)
+
+sources = [
+  'dconf-blame.c',
+  'dconf-gvdb-utils.c',
+  'dconf-service.c',
+  'dconf-writer.c',
+  'dconf-keyfile-writer.c',
+  'dconf-shm-writer.c',
+  'main.c'
+]
+
+sources += gnome.gdbus_codegen(
+  'dconf-generated',
+  dconf_namespace + '.xml',
+  interface_prefix: dconf_namespace + '.',
+  namespace: 'DConfDBus'
+)
+
+executable(
+  'dconf-service',
+  sources,
+  include_directories: top_inc,
+  dependencies: gio_unix_dep,
+  link_with: [
+    libdconf_common,
+    libgvdb,
+    libdconf_shm
+  ],
+  install: true,
+  install_dir: dconf_libexecdir
+)
diff --git a/shm/meson.build b/shm/meson.build
new file mode 100644
index 0000000..9781704
--- /dev/null
+++ b/shm/meson.build
@@ -0,0 +1,22 @@
+name = 'dconf-shm'
+
+sources = files('dconf-shm.c')
+
+cflags = '-DG_lOG_DOMAIN="@0@"'.format(meson.project_name())
+
+libdconf_shm = static_library(
+  name,
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags
+)
+
+libdconf_shm_shared = static_library(
+  name + '-shared',
+  sources: sources,
+  include_directories: top_inc,
+  dependencies: glib_dep,
+  c_args: cflags,
+  pic: true
+)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..dbb36fb
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,126 @@
+sources = files(
+  'dconf-mock-dbus.c',
+  'dconf-mock-gvdb.c',
+  'dconf-mock-shm.c'
+)
+
+libdconf_mock = static_library(
+  'dconf-mock',
+  sources: sources,
+  dependencies: glib_dep
+)
+
+dl_dep = cc.find_library('dl', required: false)
+m_dep = cc.find_library('m')
+
+unit_tests = []
+
+name = 'paths'
+exe = executable(
+  name,
+  name + '.c',
+  dependencies: glib_dep,
+  link_with: libdconf_common
+)
+
+unit_tests += [[name, exe]]
+
+name = 'changeset'
+exe = executable(
+  name,
+  name + '.c',
+  dependencies: glib_dep,
+  link_with: libdconf_common
+)
+
+unit_tests += [[name, exe]]
+
+name = 'shm'
+sources = files(
+  name + '.c',
+  'tmpdir.c'
+)
+
+exe = executable(
+  name,
+  sources,
+  dependencies: [
+    glib_dep,
+    dl_dep
+  ],
+  link_with: libdconf_shm
+)
+
+unit_tests += [[name, exe]]
+
+name = 'gvdb'
+exe = executable(
+  name,
+  name + '.c',
+  c_args: '-DSRCDIR="@0@"'.format(meson.current_source_dir()),
+  dependencies: glib_dep,
+  link_with: libgvdb
+)
+
+unit_tests += [[name, exe]]
+
+name = 'gdbus-thread'
+exe = executable(
+  name,
+  'dbus.c',
+  c_args: '-DDBUS_BACKEND="/gdbus/thread"',
+  dependencies: gio_unix_dep,
+  link_with: libdconf_gdbus_thread
+)
+
+unit_tests += [[name, exe]]
+
+name = 'gdbus-filter'
+exe = executable(
+  name,
+  'dbus.c',
+  c_args: '-DDBUS_BACKEND="/gdbus/filter"',
+  dependencies: gio_unix_dep,
+  link_with: libdconf_gdbus_filter
+)
+
+unit_tests += [[name, exe]]
+
+name = 'engine'
+exe = executable(
+  name,
+  name + '.c',
+  c_args: '-DSRCDIR="@0@"'.format(meson.current_source_dir()),
+  dependencies: [
+    glib_dep,
+    dl_dep,
+    m_dep
+  ],
+  link_with: [
+    libdconf_engine,
+    libdconf_common,
+    libdconf_mock
+  ]
+)
+
+unit_tests += [[name, exe]]
+
+name = 'client'
+exe = executable(
+  name,
+  name + '.c',
+  c_args: '-DSRCDIR="@0@"'.format(meson.current_source_dir()),
+  dependencies: gio_unix_dep,
+  link_with: [
+    libdconf_client,
+    libdconf_engine,
+    libdconf_common,
+    libdconf_mock
+  ]
+)
+
+unit_tests += [[name, exe]]
+
+foreach unit_test: unit_tests
+  test(unit_test[0], unit_test[1], is_parallel: false)
+endforeach


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