Commit f7a71bd5 authored by Iñigo Martínez's avatar Iñigo Martínez Committed by Michael Catanzaro

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=784910
parent 8ff1b86c
......@@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS = -I m4
SUBDIRS = shm gvdb common engine service gdbus gsettings client bin docs tests
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
EXTRA_DIST = trim-lcov.py m4
EXTRA_DIST = trim-lcov.py m4 meson.build meson_options.txt meson_post_install.py
clean-am: lcov-clean gcno-clean
......
......@@ -23,4 +23,4 @@ dconf_SOURCES = \
completiondir = $(datadir)/bash-completion/completions
completion_DATA = completion/dconf
EXTRA_DIST = $(completion_DATA)
EXTRA_DIST = $(completion_DATA) meson.build
sources = gvdb_builder + libdconf_vapi + files(
'dconf-dump.vala',
'dconf-update.vala',
'dconf.vala',
'gvdb.vapi'
)
deps = [
libdconf_dep,
valac.find_library('posix')
]
executable(
meson.project_name(),
sources,
include_directories: top_inc,
dependencies: deps,
c_args: '-w',
install: true,
install_dir: dconf_bindir
)
install_data(
'completion/dconf',
install_dir: join_paths(dconf_datadir, 'bash-completion', 'completions')
)
......@@ -35,7 +35,7 @@ libdconf_so_1_0_0_LDADD = \
libdconf_so_1_0_0_LDFLAGS = -shared -Wl,-soname=libdconf.so.1
libdconf_so_1_0_0_SOURCES = $(libdconf_client_a_SOURCES)
EXTRA_DIST = dconf.vapi dconf.deps
EXTRA_DIST = dconf.vapi dconf.deps meson.build
vapi_DATA = dconf.vapi dconf.deps
vapidir = $(datadir)/vala/vapi
......
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_common_shared,
libdconf_engine_shared,
libdconf_gdbus_thread_shared,
libdconf_shm_shared,
libgvdb_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=' + dconf_libexecdir,
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')
)
......@@ -19,3 +19,5 @@ libdconf_common_shared_a_SOURCES = $(libdconf_common_a_SOURCES)
libdconf_common_hidden_a_CFLAGS = $(libdconf_common_a_CFLAGS) -fPIC -DPIC -fvisibility=hidden
libdconf_common_hidden_a_SOURCES = $(libdconf_common_a_SOURCES)
EXTRA_DIST = meson.build
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 = meson.project_name() + '-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
)
test_cflag = '-fvisibility=hidden'
if cc.has_argument(test_cflag)
cflags += [test_cflag]
endif
libdconf_common_hidden = static_library(
name + '-hidden',
sources: sources,
include_directories: top_inc,
dependencies: glib_dep,
c_args: cflags,
pic: true
)
......@@ -46,6 +46,6 @@ man_MANS += \
dconf.7
endif
EXTRA_DIST += dconf-service.xml dconf-tool.xml dconf-overview.xml
EXTRA_DIST += dconf-service.xml dconf-tool.xml dconf-overview.xml meson.build
DISTCLEANFILES = $(man_MANS)
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',
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
......@@ -18,3 +18,5 @@ libdconf_engine_a_SOURCES = \
libdconf_engine_shared_a_CFLAGS = $(libdconf_engine_a_CFLAGS) -fPIC -DPIC
libdconf_engine_shared_a_SOURCES = $(libdconf_engine_a_SOURCES)
EXTRA_DIST = meson.build
name = meson.project_name() + '-engine'
sources = files(
'dconf-engine.c',
'dconf-engine-profile.c',
'dconf-engine-source.c',
'dconf-engine-source-file.c',
'dconf-engine-source-user.c',
'dconf-engine-source-service.c',
'dconf-engine-source-system.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
)
......@@ -19,3 +19,5 @@ libdconf_gdbus_filter_a_SOURCES = \
libdconf_gdbus_filter_shared_a_CFLAGS = $(libdconf_gdbus_filter_a_CFLAGS) -fPIC -DPIC
libdconf_gdbus_filter_shared_a_SOURCES = $(libdconf_gdbus_filter_a_SOURCES)
EXTRA_DIST = meson.build
name = meson.project_name() + '-gdbus-thread'
sources = files('dconf-gdbus-thread.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 = meson.project_name() + '-gdbus-filter'
sources = files('dconf-gdbus-filter.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
)
......@@ -27,4 +27,4 @@ install-data-hook:
TESTS_ENVIRONMENT = export GSETTINGS_LIB=libdconfsettings.so;
TESTS = abicheck.sh
EXTRA_DIST = abicheck.sh
EXTRA_DIST = abicheck.sh meson.build
sources = files('dconfsettingsbackend.c')
cflags = '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name())
libdconf_settings = shared_library(
meson.project_name() + 'settings',
sources: sources,
include_directories: top_inc,
dependencies: gio_unix_dep,
c_args: cflags,
link_with: [
libdconf_common_hidden,
libdconf_engine_shared,
libdconf_gdbus_thread_shared,
libdconf_shm_shared,
libgvdb_shared
],
install: true,
install_dir: join_paths(dconf_libdir, 'gio', 'modules')
)
unit_test = 'abicheck'
test(
unit_test,
find_program(unit_test + '.sh'),
env: 'GSETTINGS_LIB=' + libdconf_settings.full_path()
)
......@@ -12,3 +12,5 @@ libgvdb_a_SOURCES = \
libgvdb_shared_a_CFLAGS = $(libgvdb_a_CFLAGS) -fPIC -DPIC
libgvdb_shared_a_SOURCES = $(libgvdb_a_SOURCES)
EXTRA_DIST = meson.build
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
)
project(
'dconf', ['c', 'vala'],
version: '0.26.0',
license: 'LGPL2.1+',
default_options: [
'buildtype=debugoptimized',
'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)
cc = meson.get_compiler('c')
valac = meson.get_compiler('vala')
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']
if get_option('buildtype').contains('debug')
test_cflags = [
'-fno-common',
'-Wmissing-prototypes',
'-Wwrite-strings'
]
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)
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')
pkg = import('pkgconfig')
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')
option('enable-man', type: 'boolean', value: true, description: 'generate man pages')
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')
#!/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]])
......@@ -35,7 +35,7 @@ DISTCLEANFILES = ca.desrt.dconf.service
BUILT_SOURCES = dconf-generated.c dconf-generated.h
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = ca.desrt.dconf.xml
EXTRA_DIST = ca.desrt.dconf.xml meson.build
ca.desrt.dconf.service: Makefile
$(AM_V_GEN) (echo '[D-BUS Service]'; \
......
[D-BUS Service]
Name=ca.desrt.dconf
Exec=@libexecdir@/dconf-service
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-keyfile-writer.c',
'dconf-service.c',
'dconf-shm-writer.c',
'dconf-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,
libdconf_shm,
libgvdb
],
install: true,
install_dir: dconf_libexecdir
)
......@@ -9,3 +9,5 @@ libdconf_shm_a_SOURCES = \
libdconf_shm_shared_a_CFLAGS = $(libdconf_shm_a_CFLAGS) -fPIC -DPIC
libdconf_shm_shared_a_SOURCES = $(libdconf_shm_a_SOURCES)
EXTRA_DIST = meson.build
name = meson.project_name() + '-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
)
......@@ -94,3 +94,5 @@ client_LDADD = \
libdconf-mock.a \
$(gio_LIBS)
client_SOURCES = client.c
EXTRA_DIST += meson.build
sources = files(
'dconf-mock-dbus.c',
'dconf-mock-gvdb.c',
'dconf-mock-shm.c'
)
libdconf_mock = static_library(
meson.project_name() + '-mock',
sources: sources,
dependencies: glib_dep
)
test_dir = meson.current_source_dir()
dl_dep = cc.find_library('dl', required: false)
m_dep = cc.find_library('m')
unit_tests = [
# [name, sources, c_args, dependencies, link_with]
['paths', 'paths.c', [], glib_dep, libdconf_common],
['changeset', 'changeset.c', [], glib_dep, libdconf_common],
['shm', ['shm.c', 'tmpdir.c'], [], [glib_dep, dl_dep], libdconf_shm],
['gvdb', 'gvdb.c', '-DSRCDIR="@0@"'.format(test_dir), glib_dep, libgvdb],
['gdbus-thread', 'dbus.c', '-DDBUS_BACKEND="/gdbus/thread"', gio_unix_dep, libdconf_gdbus_thread],
['gdbus-filter', 'dbus.c', '-DDBUS_BACKEND="/gdbus/filter"', gio_unix_dep, libdconf_gdbus_filter],
['engine', 'engine.c', '-DSRCDIR="@0@"'.format(test_dir), [glib_dep, dl_dep, m_dep], [libdconf_engine, libdconf_common, libdconf_mock]],
['client', 'client.c', '-DSRCDIR="@0@"'.format(test_dir), gio_unix_dep, [libdconf_client, libdconf_engine, libdconf_common, libdconf_mock]]
]
foreach unit_test: unit_tests
exe = executable(
unit_test[0],
unit_test[1],
c_args: unit_test[2],