diff options
author | Iñigo Martínez <inigomartinez@gmail.com> | 2018-02-08 11:26:06 +0100 |
---|---|---|
committer | Iñigo Martínez <inigomartinez@gmail.com> | 2018-09-11 08:55:18 +0200 |
commit | d80568dd45ac50cea87480ea7a9008f23a9cce27 (patch) | |
tree | 0ebb4ed5abf06d09ef5bdd1b25cf276d7650aba6 | |
parent | 7ccf81fddadebfb489dd8a3ca39b26ff03a3ac6a (diff) |
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.
-rw-r--r-- | data/meson.build | 50 | ||||
-rw-r--r-- | doc/dbus/meson.build | 46 | ||||
-rw-r--r-- | doc/libaccountsservice/meson.build | 12 | ||||
-rw-r--r-- | meson.build | 212 | ||||
-rw-r--r-- | meson_options.txt | 14 | ||||
-rw-r--r-- | meson_post_install.py | 18 | ||||
-rw-r--r-- | po/meson.build | 1 | ||||
-rw-r--r-- | src/libaccountsservice/meson.build | 118 | ||||
-rw-r--r-- | src/libaccountsservice/symbol.map | 4 | ||||
-rw-r--r-- | src/meson.build | 75 |
10 files changed, 550 insertions, 0 deletions
diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..4987937 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,50 @@ +ifaces = files( + act_namespace + '.xml', + act_namespace + '.User.xml', +) + +install_data( + ifaces, + install_dir: dbus_ifaces_dir, +) + +install_data( + act_namespace + '.conf', + install_dir: dbus_conf_dir, +) + +service_conf = configuration_data() +service_conf.set('libexecdir', act_libexecdir) + +service = act_namespace + '.service' + +configure_file( + input: service + '.in', + output: service, + configuration: service_conf, + install: true, + install_dir: dbus_sys_dir, +) + +policy = act_namespace.to_lower() + '.policy' + +i18n.merge_file( + policy, + input: policy + '.in', + output: policy, + po_dir: po_dir, + install: true, + install_dir: policy_dir, +) + +if install_systemd_unit_dir + service = 'accounts-daemon.service' + + configure_file( + input: service + '.in', + output: service, + configuration: service_conf, + install: true, + install_dir: systemd_system_unit_dir, + ) +endif diff --git a/doc/dbus/meson.build b/doc/dbus/meson.build new file mode 100644 index 0000000..7b4f2d2 --- /dev/null +++ b/doc/dbus/meson.build @@ -0,0 +1,46 @@ +ifaces_refs = [] + +ifaces = [ + act_namespace, + act_namespace + '.User', +] + +xsltproc = find_program('xsltproc') +spec_to_docbook = files('spec-to-docbook.xsl') + +foreach iface: ifaces + iface_ref = iface + '.ref.xml' + + ifaces_refs += custom_target( + iface_ref, + input: join_paths(data_dir, iface + '.xml'), + output: iface_ref, + command: [xsltproc, '--output', '@OUTPUT@', spec_to_docbook, '@INPUT@'], + ) +endforeach + +output = 'AccountsService.xml' + +docbook_conf = configuration_data() +docbook_conf.set('srcdir', meson.current_build_dir()) +docbook_conf.set('VERSION', act_version) + +docbook = 'AccountsService.xml' + +docbook_xml = configure_file( + input: docbook + '.in', + output: docbook, + configuration: docbook_conf, +) + +html = 'AccountsService.html' + +custom_target( + html, + input: docbook_xml, + output: html, + command: [find_program('xmlto'), 'xhtml-nochunks', '-o', meson.current_build_dir(), '-m', files('config.xsl'), '@INPUT@'], + depends: ifaces_refs, + install: true, + install_dir: join_paths(act_datadir, 'doc', act_name, 'spec'), +) diff --git a/doc/libaccountsservice/meson.build b/doc/libaccountsservice/meson.build new file mode 100644 index 0000000..acafe0b --- /dev/null +++ b/doc/libaccountsservice/meson.build @@ -0,0 +1,12 @@ +doc_module = 'libaccountsservice' + +gnome.gtkdoc( + doc_module, + main_xml: doc_module + '-docs.xml', + src_dir: libaccountsservice_dir, + dependencies: libaccountsservice_dep, + namespace: act_id.to_lower(), + fixxref_args: '--html-dir=' + join_paths(act_prefix, gnome.gtkdoc_html_dir(doc_module)), + gobject_typesfile: files(doc_module + '.types'), + install: true, +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..1a6c285 --- /dev/null +++ b/meson.build @@ -0,0 +1,212 @@ +project( + 'AccountsService', 'c', + version: '0.6.50', + license: 'GPL3+', + default_options: 'buildtype=debugoptimized', + meson_version: '>= 0.46.0', +) + +act_name = meson.project_name().to_lower() +act_version = meson.project_version() + +act_api_version = '1.0' +act_api_name = '@0@-@1@'.format(act_name, act_api_version) + +act_id = 'Act' + +act_prefix = get_option('prefix') +act_datadir = join_paths(act_prefix, get_option('datadir')) +act_includedir = join_paths(act_prefix, get_option('includedir')) +act_libexecdir = join_paths(act_prefix, get_option('libexecdir')) +act_localstatedir = join_paths(act_prefix, get_option('localstatedir')) +act_sysconfdir = join_paths(act_prefix, get_option('sysconfdir')) + +act_pkgincludedir = join_paths(act_includedir, act_api_name) + +act_namespace = 'org.freedesktop.Accounts' + +act_gettext = 'accounts-service' + +soversion = 0 +current = 0 +revision = 0 +libversion = '@0@.@1@.@2@'.format(soversion, current, revision) + +act_buildtype = get_option('buildtype') + +gnome = import('gnome') +i18n = import('i18n') +pkg = import('pkgconfig') + +data_dir = join_paths(meson.current_source_dir(), 'data') +po_dir = join_paths(meson.current_source_dir(), 'po') + +top_inc = include_directories('.') + +cc = meson.get_compiler('c') + +config_h = configuration_data() + +# defines +config_h.set_quoted('VERSION', act_version) +config_h.set('_DEFAULT_SOURCE', true) +config_h.set('_GNU_SOURCE', true) + +# i18n +config_h.set_quoted('PACKAGE', act_gettext) +config_h.set_quoted('GETTEXT_PACKAGE', act_gettext) + +# headers +check_headers = [ + 'paths.h', + 'shadow.h', + 'utmpx.h', +] + +foreach header: check_headers + config_h.set('HAVE_' + header.underscorify().to_upper(), cc.has_header(header)) +endforeach + +# functions +check_functions = [ + 'getusershell', + 'setutxdb', + 'fgetpwent', +] + +foreach func: check_functions + config_h.set('HAVE_' + func.underscorify().to_upper(), cc.has_function(func)) +endforeach + +if cc.has_header_symbol('utmpx.h', 'WTMPX_FILENAME', prefix: '#define _GNU_SOURCE') + config_h.set('PATH_WTMP', 'WTMPX_FILENAME') +elif cc.has_header_symbol('paths.h', '_PATH_WTMPX') + config_h.set('PATH_WTMP', '_PATH_WTMPX') +else + assert(run_command('test', '-e', '/var/log/utx.log').returncode() == 0, 'Do not know which filename to watch for wtmp changes') + config_h.set('PATH_WTMP', '/var/log/utx.log') +endif + +# compiler flags +common_flags = [] + +# Only add this when optimizing is enabled +optimized_src = ''' + #ifdef __OPTIMIZE__ + #error No optimization + #endif +''' + +act_optimized = act_buildtype.contains('optimized') and cc.compiles(optimized_src) +message('whether optimization is enabled: ' + act_optimized.to_string()) +if act_optimized + common_flags += '-Wp,-D_FORTIFY_SOURCE=2' +endif + +if act_buildtype.contains('debug') + common_flags += cc.get_supported_arguments([ + '-Wcast-align', + '-Winit-self', + '-Wmissing-declarations', + '-Wmissing-prototypes', + '-Wnested-externs', + '-Wno-deprecated-declarations', + '-Wswitch-enum', + '-Wunsafe-loop-optimizations', + '-Wwrite-strings', + ]) +endif + +add_project_arguments(common_flags, language: 'c') + +gio_dep = dependency('gio-2.0', version: '>= 2.37.3') +gio_unix_dep = dependency('gio-unix-2.0') +glib_dep = dependency('glib-2.0', version: '>= 2.44') +polkit_gobject_dep = dependency('polkit-gobject-1') + +crypt_dep = cc.find_library('crypt') + +dbus_dep = dependency('dbus-1') +dbus_conf_dir = join_paths(dbus_dep.get_pkgconfig_variable('sysconfdir', define_variable: ['sysconfdir', act_sysconfdir]), 'dbus-1', 'system.d') +dbus_ifaces_dir = dbus_dep.get_pkgconfig_variable('interfaces_dir', define_variable: ['datadir', act_datadir]) +dbus_sys_dir = dbus_dep.get_pkgconfig_variable('system_bus_services_dir', define_variable: ['datadir', act_datadir]) + +policy_dir = polkit_gobject_dep.get_pkgconfig_variable('policydir', define_variable: ['prefix', act_prefix]) + +# FIXME: systemd.pc file does not use variables with relative paths, so `define_variable` cannot be used +systemd_system_unit_dir = get_option('systemdsystemunitdir') +install_systemd_unit_dir = (systemd_system_unit_dir != 'no') + +if install_systemd_unit_dir and systemd_system_unit_dir == '' + systemd_dep = dependency('systemd', required: false) + assert(systemd_dep.found(), 'systemd required but not found, please provide a valid systemd user unit dir or disable it') + systemd_system_unit_dir = systemd_dep.get_pkgconfig_variable('systemdsystemunitdir') +endif + +# Core configuration +admin_group = get_option('admin_group') +if admin_group == '' + if run_command('test', '-e', '/etc/debian_version').returncode() == 0 + admin_group = 'sudo' + # FIXME: this has been left for documentation purposes + elif run_command('test', '-e', '/etc/sysconfig/network-scripts').returncode() == 0 + admin_group = 'wheel' + else + admin_group = 'wheel' + endif +endif + +extra_admin_groups = ','.join(get_option('extra_admin_groups')) + +config_h.set_quoted('ADMIN_GROUP', admin_group) +config_h.set_quoted('EXTRA_ADMIN_GROUPS', extra_admin_groups) + +config_h.set('ENABLE_USER_HEURISTICS', get_option('user_heuristics')) +config_h.set_quoted('MINIMUM_UID', get_option('minimum_uid')) + +# GDM +gdm_conf_file = get_option('gdmconffile') +config_h.set_quoted('PATH_GDM_CUSTOM', gdm_conf_file) + +enable_systemd = get_option('systemd') +enable_elogind = get_option('elogind') +assert(not enable_systemd or not enable_elogind, 'systemd and elogind support requested, please choose only one.') + +if enable_systemd + logind_dep = dependency('libsystemd', version: '>= 186') +endif + +if enable_elogind + logind_dep = dependency('libelogind', version: '>= 229.4') +endif +config_h.set('WITH_SYSTEMD', enable_systemd or enable_elogind) + +subdir('data') +subdir('src') +subdir('po') + +enable_docbook = get_option('docbook') +if enable_docbook + subdir('doc/dbus') +endif + +if get_option('gtk_doc') + subdir('doc/libaccountsservice') +endif + +configure_file( + output: 'config.h', + configuration: config_h, +) + +meson.add_install_script( + 'meson_post_install.py', + act_localstatedir, +) + +output = '\n' + meson.project_name() + ' was configured with the following options:\n' +output += '** DocBook documentation build: ' + enable_docbook.to_string() + '\n' +output += '** Administrator group: ' + admin_group + '\n' +output += '** Extra administrator groups: ' + extra_admin_groups + '\n' +output += '** GDM configuration: ' + gdm_conf_file +message(output) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..878bdd7 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,14 @@ +option('systemdsystemunitdir', type: 'string', value: '', description: 'custom directory for systemd system units') +option('gdmconffile', type: 'string', value: '/etc/gdm/custom.conf', description: 'GDM configuration file') + +option('admin_group', type: 'string', value: '', description: 'Set group for administrative accounts') +option('user_heuristics', type: 'boolean', value: true, description: 'Enable heuristics for guessing system vs. human users in the range 500-minimum-uid') +option('extra_admin_groups', type: 'array', value: [], description: 'Comma-separated list of extra groups that administrator users are part of') +option('minimum_uid', type: 'string', value: '1000', description: 'Set minimum uid for human users') + +option('systemd', type: 'boolean', value: false, description: 'Use systemd') +option('elogind', type: 'boolean', value: false, description: 'Use elogind') + +option('introspection', type: 'boolean', value: true, description: 'Enable introspection for this build') +option('docbook', type: 'boolean', value: false, description: 'build documentation (requires xmlto)') +option('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..ba95055 --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import os +import sys + +destdir = os.environ.get('DESTDIR', '') +localstatedir = os.path.normpath(destdir + os.sep + sys.argv[1]) + +# FIXME: meson will not track the creation of these directories +# https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39 +dst_dirs = [ + os.path.join(localstatedir, 'lib', 'AccountsService', 'icons'), + os.path.join(localstatedir, 'lib', 'AccountsService', 'users'), +] + +for dst_dir in dst_dirs: + if not os.path.exists(dst_dir): + os.makedirs(dst_dir) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..1227d0f --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(act_gettext, preset: 'glib') diff --git a/src/libaccountsservice/meson.build b/src/libaccountsservice/meson.build new file mode 100644 index 0000000..d4cd781 --- /dev/null +++ b/src/libaccountsservice/meson.build @@ -0,0 +1,118 @@ +libaccountsservice_dir = meson.current_source_dir() + +subdir = act_id.to_lower() + +headers = files( + 'act-user.h', + 'act-user-manager.h', +) + +install_headers( + headers + ['act.h'], + install_dir: join_paths(act_pkgincludedir, subdir), +) + +sources = files( + 'act-user.c', + 'act-user-manager.c', +) + +enum_sources = [] +enum_types = 'act-user-enum-types' + +enum_sources += gnome.mkenums( + enum_types + '.c', + sources: headers, + fhead: '#include "act-user.h"\n#include "act-user-manager.h"\n#include "act-user-enum-types.h"\n#include <glib-object.h>\n\n', + fprod: '\n/* enumerations from "@filename@" */', + vhead: 'GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {', + vprod: ' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },', + vtail: ' { 0, NULL, NULL }\n };\n etype = g_@type@_register_static ("@EnumName@", values);\n }\n return etype;\n}\n', +) + +enum_sources += gnome.mkenums( + enum_types + '.h', + sources: headers, + fhead: '#ifndef __ACT_USER_ENUM_TYPES_H__\n#define __ACT_USER_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n', + fprod: '/* enumerations from "@filename@" */\n', + vhead: 'GType @enum_name@_get_type (void);\n#define ACT_USER_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n', + ftail: 'G_END_DECLS\n\n#endif /* __ACT_USER_ENUM_TYPES_H__ */', + install_header: true, + install_dir: join_paths(act_pkgincludedir, subdir), +) + +dbus_sources = [] + +ifaces = [ + 'Manager', + 'Seat', + 'Session', +] + +namespace = 'ConsoleKit' +prefix = 'org.freedesktop.' + namespace + +foreach iface: ifaces + dbus_sources += gnome.gdbus_codegen( + 'ck-@0@-generated'.format(iface.to_lower()), + '@0@.@1@.xml'.format(prefix, iface), + interface_prefix: prefix, + namespace: namespace, + ) +endforeach + +deps = [ + crypt_dep, + gio_unix_dep, + glib_dep, + libaccounts_generated_dep, +] + +symbol_map = join_paths(meson.current_source_dir(), 'symbol.map') +ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map)) + +if enable_systemd or enable_elogind + deps += logind_dep +endif + +libaccountsservice = shared_library( + act_name, + sources: sources + enum_sources + dbus_sources, + version: libversion, + include_directories: top_inc, + dependencies: deps, + c_args: '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()), + link_args: ldflags, + link_depends: symbol_map, + install: true, +) + +libaccountsservice_dep = declare_dependency( + sources: enum_sources[1], + include_directories: include_directories('.'), + dependencies: [gio_dep, glib_dep], + link_with: libaccountsservice, +) + +pkg.generate( + libaccountsservice, + name: 'Accounts Service', + description: 'Client Library for communicating with accounts service', + filebase: act_name, + subdirs: act_api_name, + variables: 'exec_prefix=${prefix}', +) + +if get_option('introspection') + gnome.generate_gir( + libaccountsservice, + sources: sources + headers + [enum_sources[1]], + includes: ['GObject-2.0', 'Gio-2.0'], + dependencies: libaccountsservice_dep, + namespace: meson.project_name(), + nsversion: act_api_version, + identifier_prefix: act_id, + header: join_paths(subdir, 'act.h'), + install: true, + ) +endif diff --git a/src/libaccountsservice/symbol.map b/src/libaccountsservice/symbol.map new file mode 100644 index 0000000..e7b7bb5 --- /dev/null +++ b/src/libaccountsservice/symbol.map @@ -0,0 +1,4 @@ +{ + local: + _*; +}; diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..3c8e7fe --- /dev/null +++ b/src/meson.build @@ -0,0 +1,75 @@ +sources = [] + +gdbus_headers = [] + +ifaces = [ + ['accounts-generated', 'org.freedesktop.', 'Accounts'], + ['accounts-user-generated', act_namespace + '.', 'User'], +] + +foreach iface: ifaces + gdbus_sources = gnome.gdbus_codegen( + iface[0], + join_paths(data_dir, iface[1] + iface[2] + '.xml'), + interface_prefix: iface[1], + namespace: 'Accounts', + ) + sources += gdbus_sources + gdbus_headers += gdbus_sources[1] +endforeach + +deps = [ + gio_dep, + gio_unix_dep, +] + +cflags = [ + '-DLOCALSTATEDIR="@0@"'.format(act_localstatedir), + '-DDATADIR="@0@"'.format(act_datadir), + '-DICONDIR="@0@"'.format(join_paths(act_localstatedir, 'lib', meson.project_name(), 'icons')), + '-DUSERDIR="@0@"'.format(join_paths(act_localstatedir, 'lib', meson.project_name(), 'users')), +] + +libaccounts_generated = static_library( + 'accounts-generated', + sources: sources, + include_directories: top_inc, + dependencies: deps, + c_args: cflags, +) + +libaccounts_generated_dep = declare_dependency( + sources: gdbus_headers, + include_directories: include_directories('.'), + dependencies: gio_dep, + link_with: libaccounts_generated, +) + +sources = files( + 'daemon.c', + 'extensions.c', + 'main.c', + 'user.c', + 'user-classify.c', + 'util.c', + 'wtmp-helper.c', +) + +deps = [ + gio_unix_dep, + glib_dep, + libaccounts_generated_dep, + polkit_gobject_dep, +] + +executable( + 'accounts-daemon', + sources, + include_directories: top_inc, + dependencies: deps, + c_args: cflags, + install: true, + install_dir: act_libexecdir, +) + +subdir('libaccountsservice') |