From 8405d0b7cccacf5b776a1b1314976a254094c371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Mart=C3=ADnez?= Date: Mon, 28 Aug 2017 20:23:19 +0200 Subject: build: Port to meson build system meson is a build system focused on speed an ease of use, which speeds up software development by the developer. https://bugzilla.gnome.org/show_bug.cgi?id=786969 --- Makefile.am | 4 + data/Makefile.am | 1 + data/icons/Makefile.am | 1 + data/icons/meson.build | 45 ++++++ data/meson.build | 8 ++ meson.build | 318 +++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 9 ++ meson_post_install.py | 23 +++ po/meson.build | 1 + tools/Makefile.am | 4 +- tools/meson.build | 13 ++ tp-account-widgets/Makefile.am | 1 + tp-account-widgets/meson.build | 122 ++++++++++++++++ 13 files changed, 549 insertions(+), 1 deletion(-) create mode 100644 data/icons/meson.build create mode 100644 data/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 meson_post_install.py create mode 100644 po/meson.build create mode 100644 tools/meson.build create mode 100644 tp-account-widgets/meson.build diff --git a/Makefile.am b/Makefile.am index b295e419..58409334 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,4 +9,8 @@ EXTRA_DIST = \ CONTRIBUTORS \ README \ autogen.sh \ + meson.build \ + meson_options.txt \ + meson_post_install.py \ + po\meson.build \ $(NULL) diff --git a/data/Makefile.am b/data/Makefile.am index 037672c5..210dad51 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -22,6 +22,7 @@ endif EXTRA_DIST = \ $(schemas_DATA) \ $(gsettings_SCHEMAS_real) \ + meson.build \ $(NULL) DISTCLEANFILES = \ diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am index 2ee5ea9d..55bce2a8 100644 --- a/data/icons/Makefile.am +++ b/data/icons/Makefile.am @@ -136,6 +136,7 @@ private_icons = \ EXTRA_DIST = \ $(private_icons) \ local-xmpp.svg \ + meson.build \ $(NULL) include $(srcdir)/utils.mk diff --git a/data/icons/meson.build b/data/icons/meson.build new file mode 100644 index 00000000..2dab4894 --- /dev/null +++ b/data/icons/meson.build @@ -0,0 +1,45 @@ +common_app_names = [ + 'im-aim', + 'im-ekiga', + 'im-gizmo', + 'im-google-talk', + 'im-icq', + 'im-irc', + 'im-jabber', + 'im-msn', + 'im-silc', + 'im-sip', + 'im-local-xmpp', + 'im-gadugadu', + 'im-groupwise', + 'im-qq', + 'im-meanwhile', + 'im-mxit', + 'im-myspace', + 'im-sametime', + 'im-yahoo', + 'im-zephyr' +] + +complete_app_names = common_app_names + [ + 'im-facebook', + 'im-skype' +] + +icons = [ + ['16x16', complete_app_names, 'png'], + ['22x22', complete_app_names, 'png'], + ['24x24', common_app_names, 'png'], + ['32x32', common_app_names, 'png'], + ['48x48', complete_app_names, 'png'], + ['scalable', common_app_names, 'svg'] +] + +foreach icon: icons + foreach name: icon[1] + install_data( + '_'.join(['hicolor', 'apps', icon[0], name + '.' + icon[2]]), + install_dir: join_paths(tpaw_icondir, 'hicolor', icon[0], 'apps') + ) + endforeach +endforeach diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 00000000..19c5f719 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,8 @@ +subdir('icons') + +if enable_settings + install_data( + 'org.gnome.telepathy-account-widgets.gschema.xml', + install_dir: tpaw_schemadir + ) +endif diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..c7d515db --- /dev/null +++ b/meson.build @@ -0,0 +1,318 @@ +project( + 'telepathy-account-widgets', 'c', + version: '0.1', + license: 'LGPL2.1', + default_options: [ + 'buildtype=debugoptimized', + 'warning_level=1' + ], + meson_version: '>= 0.41.0' +) + +tpaw_name = 'tpaw' +tpaw_version = meson.project_version() + +tpaw_prefix = get_option('prefix') +tpaw_datadir = join_paths(tpaw_prefix, get_option('datadir')) + +tpaw_schemadir = join_paths(tpaw_datadir, 'glib-2.0', 'schemas') + +enable_unreleased_checks = get_option('enable-unreleased-checks') +enable_settings = get_option('enable-settings') +enable_coding_style_checks = get_option('enable-coding-style-checks') + +# Allow to overwrite where to install data files +tpaw_pkgdatadir = get_option('with-pkgdatadir').strip() +if tpaw_pkgdatadir == '' + tpaw_pkgdatadir = join_paths(tpaw_datadir, meson.project_name()) +endif + +tpaw_icondir = get_option('with-icondir').strip() +if tpaw_icondir == '' + tpaw_icondir = join_paths(tpaw_pkgdatadir, 'icons') +endif + +tpaw_debug = get_option('buildtype').contains('debug') + +tpaw_gettext_package = get_option('with-gettext-package').strip() +if tpaw_gettext_package == '' + tpaw_gettext_package = tpaw_name +endif + +cc = meson.get_compiler('c') + +config_h = configuration_data() + +# defines +set_defines = [ + # package + ['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/browse.cgi?product=empathy'], + ['PACKAGE_NAME', meson.project_name()], + ['PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), tpaw_version)], + ['PACKAGE_TARNAME', meson.project_name()], + ['PACKAGE_URL', ''], + ['PACKAGE_VERSION', tpaw_version], + # i18n + ['GETTEXT_PACKAGE', tpaw_gettext_package] +] + +foreach define: set_defines + config_h.set_quoted(define[0], define[1]) +endforeach + +# debug options +config_h.set('ENABLE_DEBUG', tpaw_debug) + +uoa_provider = 'im.telepathy.Account.Storage.UOA' + +# library options +set_values = [ + # glib + ['GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_34', 'Prevent post 2.34 APIs'], + ['GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_30', 'Ignore post 2.30 deprecations'], + # gtk + ['GDK_VERSION_MAX_ALLOWED', 'GDK_VERSION_3_4', 'Prevent post 3.4 APIs'], + ['GDK_VERSION_MIN_REQUIRED', 'GDK_VERSION_3_4', 'Ignore post 3.4 deprecations'], + # telepathy + ['TP_VERSION_MIN_REQUIRED', 'TP_VERSION_0_22', 'Ignore post 0.22 deprecations'], + ['TP_VERSION_MAX_ALLOWED', 'TP_VERSION_0_22', 'Prevent post 0.22 APIs'], + ['TP_SEAL_ENABLE', 1, 'Prevent to use sealed variables'], + ['TP_DISABLE_SINGLE_INCLUDE', 1, 'Disable single include header'], + # UOA configuration bits + ['TPAW_UOA_PROVIDER', uoa_provider, 'Name of provider for accounts imported from libaccounts'] +] + +foreach values: set_values + config_h.set(values[0], values[1], description: values[2]) +endforeach + +# headers +check_headers = [ + ['HAVE_DLFCN_H', 'dlfcn.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_SYS_TYPES_H', 'sys/types.h'], + ['HAVE_UNISTD_H', 'unistd.h'], +] + +foreach header: check_headers + config_h.set(header[0], cc.has_header(header[1])) +endforeach + +# compiler flags +common_flags = [ + '-DHAVE_CONFIG_H', + '-DDATADIR="@0@"'.format(tpaw_datadir), + '-DPKGDATADIR="@0@"'.format(tpaw_pkgdatadir), + '-DICONDIR="@0@"'.format(tpaw_icondir), + '-DG_LOG_DOMAIN="tp-account-widgets"', + '-DGCR_API_SUBJECT_TO_CHANGE' +] +compiler_flags = [] + +if tpaw_debug + test_flags = [ + '-Wdeclaration-after-statement', + '-Wmissing-declarations', + '-Wmissing-prototypes', + '-Wshadow', + '-Wstrict-prototypes' + ] + + if enable_unreleased_checks + test_flags = [ + '-Wno-missing-field-initializers', + '-Wno-unused-parameter' + ] + endif + + foreach flag: test_flags + if cc.has_argument(flag) + compiler_flags += [flag] + endif + endforeach +endif + +add_project_arguments(common_flags + compiler_flags, language: 'c') + +glib_req_version = '>= 2.33.3' +gtk_req_version = '>= 3.5.1' +libsecret_req_version = '>= 0.5' +telepathy_glib_req_version = '>= 0.22.0' + +required = [ + 'pkg-config >= 0.21', + 'dbus-glib-1', + 'gio-2.0 ' + glib_req_version, + 'glib-2.0 ' + glib_req_version, + 'gobject-2.0 ' + glib_req_version, + 'gtk+-3.0 ' + gtk_req_version, + 'libsecret-1 ' + libsecret_req_version, + 'telepathy-glib ' + telepathy_glib_req_version, + 'libxml-2.0' +] + +tpaw_deps = [ + dependency('dbus-glib-1'), + dependency('gio-2.0', version: glib_req_version), + dependency('glib-2.0', version: glib_req_version), + dependency('gobject-2.0', version: glib_req_version), + dependency('gtk+-3.0', version: gtk_req_version), + dependency('libsecret-1', version: libsecret_req_version), + dependency('libxml-2.0'), + dependency('telepathy-glib', version: telepathy_glib_req_version) +] + +# *** Check for gudev *** +enable_gudev = get_option('enable-gudev') +have_gudev = false + +if enable_gudev != 'no' + gudev_dep = dependency('gudev-1.0', required: (enable_gudev == 'yes')) + have_gudev = gudev_dep.found() + tpaw_deps += gudev_dep + + if have_gudev + required += 'gudev-1.0' + endif +endif + +config_h.set('HAVE_UDEV', have_gudev) + +# Cheese (optional dependency for avatar selection) +enable_cheese = get_option('with-cheese') +have_cheese = false + +if enable_cheese != 'no' + cheese_dep = dependency('cheese-gtk', required: (enable_cheese == 'yes')) + have_cheese = cheese_dep.found() + tpaw_deps += cheese_dep + + if have_cheese + required += 'cheese-gtk' + endif +endif + +config_h.set('HAVE_CHESE', have_cheese) + +# ubuntu-online-accounts support +enable_uoa = get_option('enable-ubuntu-online-accounts') +have_uoa = false + +if enable_uoa != 'no' + missing_deps = [] + + account_plugin_dep = dependency('account-plugin', required: false) + if not account_plugin_dep.found() + missing_deps += 'account-plugin' + endif + + mission_control_plugins_dep = dependency('mission-control-plugins', version: '>= 5.13.1', required: false) + if not mission_control_plugins_dep.found() + missing_deps += 'mission-control-plugins' + endif + + libaccounts_glib_dep = dependency('libaccounts-glib', version: '>= 1.4', required: false) + if not libaccounts_glib_dep.found() + missing_deps += 'libaccounts-glib' + endif + + libsignon_glib_dep = dependency('libsignon-glib', version: '>= 1.8', required: false) + if not libsignon_glib_dep.found() + missing_deps += 'libsignon-glib' + endif + + have_uoa = (missing_deps.length() == 0) + + if have_uoa + accounts_provider_plugindir = account_plugin_dep.get_pkgconfig_variable('provider_plugindir') + message(accounts_provider_plugindir) + + accounts_app_plugindir = account_plugin_dep.get_pkgconfig_variable('application_plugindir') + message(accounts_app_plugindir) + + accounts_provider_filesdir = libaccounts_glib_dep.get_pkgconfig_variable('providerfilesdir') + message(accounts_provider_filesdir) + + accounts_service_filesdir = libaccounts_glib_dep.get_pkgconfig_variable('servicefilesdir') + message(accounts_service_filesdir) + + accounts_app_filesdir = libaccounts_glib_dep.get_pkgconfig_variable('applicationfilesdir') + message(accounts_app_filesdir) + + mcp_abi_version = mission_control_plugins_dep.get_pkgconfig_variable('MCP_ABI_VERSION') + mission_control_pluginsdir = join_paths(tpaw_libdir, 'mission-control-plugins.', mcp_abi_version) + message(mission_control_pluginsdir) + + tpaw_deps += [ + account_plugin_dep, + mission_control_plugins_dep, + libaccounts_glib_dep, + libsignon_glib_dep + ] + else + str = 'Could not find Ubuntu Online Accounts dependencies: ' + ' '.join(missing_deps) + if enable_uoa == 'yes' + error(str) + endif + message(str) + endif +endif + +configure_file( + output: 'config.h', + configuration: config_h +) + +gnome = import('gnome') +i18n = import('i18n') +pkg = import('pkgconfig') + +top_inc = include_directories('.') + +subdir('tools') +subdir('po') +subdir('data') +subdir('tp-account-widgets') + +if enable_settings + meson.add_install_script('meson_post_install.py', tpaw_icondir, tpaw_schemadir) +else + meson.add_install_script('meson_post_install.py', tpaw_icondir) +endif + +# FIXME: These are not fully working due to unspecified working dir +# Coding style checks +''' +if enable_coding_style_checks + res = run_command(check_misc, sources) + res = run_command(check_c_style, sources + headers) + if res.returncode() != 0 + message(res.stdout()) + message(res.stderr()) + endif +endif +''' + +output = '\nConfigure summary:\n\n' +output += ' Compiler....................: ' + cc.get_id() + '\n' +output += ' Compiler Flags..............: ' + ' '.join(compiler_flags) + '\n' +# FIXME: set linker flags +#output += ' Linker Flags................: \n' +output += ' Prefix......................: ' + tpaw_prefix + '\n' +output += ' Data directory .............: ' + tpaw_pkgdatadir + '\n' +output += ' Icon directory .............: ' + tpaw_icondir + '\n' +output += ' GSettings schema support....: ' + enable_settings.to_string() + '\n' +output += ' Coding style checks.........: ' + enable_coding_style_checks.to_string() + '\n' +output += ' Unreleased version checks...: ' + enable_unreleased_checks.to_string() + '\n' +output += ' GETTEXT_PACKAGE.............: ' + tpaw_gettext_package + '\n\n' +output += ' Features:\n' +output += ' Cheese webcam support ......: ' + have_cheese.to_string() + '\n' +output += ' Camera monitoring...........: ' + have_gudev.to_string() + '\n' +output += ' Ubuntu Online plugins.......: ' + have_uoa.to_string() + '\n' +message(output) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..177a4889 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,9 @@ +option('enable-settings', type: 'boolean', value: true, description: 'compile without installing GSettings schema') +option('enable-unreleased-checks', type: 'boolean', value: false, description: 'enable extra checks for unreleased versions') +option('enable-gudev', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'build with gudev support') +option('with-cheese', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'enable cheese webcam support') +option('enable-ubuntu-online-accounts', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'build Ubuntu Online Accounts plugins') +option('enable-coding-style-checks', type: 'boolean', value: true, description: 'do not check coding style using grep') +option('with-pkgdatadir', type: 'string', value: '', description: 'set a different directory where to install data files') +option('with-icondir', type: 'string', value: '', description: 'set a different directory where to install icons') +option('with-gettext-package', type: 'string', value: '', description: 'set a different GETTEXT_PACKAGE to avoid conflicts') diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100644 index 00000000..f876ca23 --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import glob +import os +import re +import subprocess +import sys + +icondir = os.path.join(sys.argv[1], 'hicolor') + +name_pattern = re.compile('hicolor_(?:apps)_(?:\d+x\d+|scalable)_(.*)') +search_pattern = '/**/hicolor_*' + +[os.rename(file, os.path.join(os.path.dirname(file), name_pattern.search(file).group(1))) + for file in glob.glob(icondir + search_pattern, recursive=True)] + +if not os.environ.get('DESTDIR'): + print('Update icon cache...') + subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir]) + + if len(sys.argv) > 2: + print('Compiling gsettings schemas...') + subprocess.call(['glib-compile-schemas', sys.argv[2]]) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 00000000..df8bb9a4 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(tpaw_name, preset: 'glib') diff --git a/tools/Makefile.am b/tools/Makefile.am index 6908d259..547763ce 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -35,7 +35,9 @@ EXTRA_DIST = \ telepathy-glib-env.in \ test-wrapper.sh \ with-session-bus.sh \ - xincludator.py + xincludator.py \ + meson.build + CLEANFILES = libtpcodegen.pyc libtpcodegen.pyo libglibcodegen.pyc libglibcodegen.pyo $(noinst_SCRIPTS) diff --git a/tools/meson.build b/tools/meson.build new file mode 100644 index 00000000..dcfb6d45 --- /dev/null +++ b/tools/meson.build @@ -0,0 +1,13 @@ +env_conf = configuration_data() +env_conf.set('abs_top_builddir', meson.build_root()) + +env = 'telepathy-glib-env' + +configure_file( + input: env + '.in', + output: env, + configuration: env_conf +) + +check_misc = find_program('check-misc.sh') +check_c_style = find_program('check-c-style.sh') diff --git a/tp-account-widgets/Makefile.am b/tp-account-widgets/Makefile.am index ff60c4ac..2b4444a1 100644 --- a/tp-account-widgets/Makefile.am +++ b/tp-account-widgets/Makefile.am @@ -146,6 +146,7 @@ tpaw-account-widgets-resources.h: tpaw-account-widgets.gresource.xml $(account_w EXTRA_DIST += \ tpaw-account-widgets.gresource.xml \ + meson.build \ $(account_widgets_dtd_files) \ $(account_widgets_ui_files) \ $(ircnetworks_DATA) \ diff --git a/tp-account-widgets/meson.build b/tp-account-widgets/meson.build new file mode 100644 index 00000000..602184c3 --- /dev/null +++ b/tp-account-widgets/meson.build @@ -0,0 +1,122 @@ +install_data( + 'irc-networks.xml', + install_dir: tpaw_pkgdatadir +) + +headers = files( + 'tpaw-account-settings.h', + 'tpaw-account-widget.h', + 'tpaw-account-widget-irc.h', + 'tpaw-account-widget-sip.h', + 'tpaw-avatar-chooser.h', + 'tpaw-builder.h', + 'tpaw-calendar-button.h', + 'tpaw-camera-monitor.h', + 'tpaw-connection-managers.h', + 'tpaw-contactinfo-utils.h', + 'tpaw-debug.h', + 'tpaw-gsettings.h', + 'tpaw-images.h', + 'tpaw-keyring.h', + 'tpaw-irc-network-chooser-dialog.h', + 'tpaw-irc-network-chooser.h', + 'tpaw-irc-network-dialog.h', + 'tpaw-irc-network-manager.h', + 'tpaw-irc-network.h', + 'tpaw-irc-server.h', + 'tpaw-live-search.h', + 'tpaw-pixbuf-utils.h', + 'tpaw-protocol.h', + 'tpaw-string-parser.h', + 'tpaw-time.h', + 'tpaw-user-info.h', + 'tpaw-utils.h' +) + +sources = files( + 'tpaw-account-settings.c', + 'tpaw-account-widget.c', + 'tpaw-account-widget-irc.c', + 'tpaw-account-widget-private.h', + 'tpaw-account-widget-sip.c', + 'tpaw-avatar-chooser.c', + 'tpaw-builder.c', + 'tpaw-calendar-button.c', + 'tpaw-camera-monitor.c', + 'tpaw-connection-managers.c', + 'tpaw-contactinfo-utils.c', + 'tpaw-debug.c', + 'tpaw-keyring.c', + 'tpaw-irc-network-chooser.c', + 'tpaw-irc-network-chooser-dialog.c', + 'tpaw-irc-network-dialog.c', + 'tpaw-irc-network-manager.c', + 'tpaw-irc-network.c', + 'tpaw-irc-server.c', + 'tpaw-live-search.c', + 'tpaw-pixbuf-utils.c', + 'tpaw-protocol.c', + 'tpaw-string-parser.c', + 'tpaw-time.c', + 'tpaw-user-info.c', + 'tpaw-utils.c' +) + +# nocheck sources +sources += files( + 'cheese-camera-device-monitor.c', + 'totem-subtitle-encoding.c' +) + +# these are sources that depend on Ubuntu Online Accounts +if have_uoa + sources = files('tpaw-uoa-utils.c') +endif + +resource_data = files( + 'tpaw-account-widget-aim.ui', + 'tpaw-account-widget-generic.ui', + 'tpaw-account-widget-groupwise.ui', + 'tpaw-account-widget-icq.ui', + 'tpaw-account-widget-irc.ui', + 'tpaw-account-widget-jabber.ui', + 'tpaw-account-widget-local-xmpp.ui', + 'tpaw-account-widget-msn.ui', + 'tpaw-account-widget-sip.ui', + 'tpaw-account-widget-yahoo.ui', + 'tpaw-irc-networks.dtd' +) + +built_sources = gnome.compile_resources( + 'tpaw-account-widgets-resources', + 'tpaw-account-widgets.gresource.xml', + source_dir: '.', + dependencies: resource_data +) + +libtp_account_widgets = static_library( + 'tp-account-widgets', + sources: sources + built_sources, + include_directories: top_inc, + dependencies: tpaw_deps +) + +libtp_account_widgets_dep = declare_dependency( + link_with: libtp_account_widgets, + include_directories: include_directories('.') +) + +pkg.generate( + libraries: libtp_account_widgets, + version: tpaw_version, + name: 'telepathy-account-widgets (uninstalled copy)', + description: 'Widgets and utility functions for configuring Telepathy accounts', + filebase: 'telepathy-account-widgets-uninstalled', + requires: ', '.join(required), + variables: [ + 'abs_top_srcdir=' + meson.source_root(), + 'abs_top_builddir=' + meson.build_root(), + 'uoa_provider=' + uoa_provider + ], + install_dir: meson.build_root() +) -- cgit v1.2.1