From 108e30c59bf2c7f96611129c67d060f232ddbaf4 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 18 Nov 2018 16:12:13 +0100 Subject: build: Add meson build system --- .gitignore | 1 + data/meson.build | 13 ++++++ extensions/_gen/meson.build | 58 +++++++++++++++++++++++++ extensions/meson.build | 29 +++++++++++++ meson.build | 87 ++++++++++++++++++++++++++++++++++++++ meson_options.txt | 13 ++++++ src/meson.build | 52 +++++++++++++++++++++++ tests/meson.build | 37 ++++++++++++++++ tests/twisted/config.py.in | 1 + tests/twisted/meson.build | 93 +++++++++++++++++++++++++++++++++++++++++ tests/twisted/tools/meson.build | 22 ++++++++++ 11 files changed, 406 insertions(+) create mode 100644 data/meson.build create mode 100644 extensions/_gen/meson.build create mode 100644 extensions/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 src/meson.build create mode 100644 tests/meson.build create mode 100644 tests/twisted/config.py.in create mode 100644 tests/twisted/meson.build create mode 100644 tests/twisted/tools/meson.build diff --git a/.gitignore b/.gitignore index 33cf615..a6ed882 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ Makefile.in data/org.freedesktop.Telepathy.ConnectionManager.idle.service extensions/_gen +!extensions/_gen/meson.build extensions/extensions.html src/telepathy-idle diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..2edead8 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,13 @@ +# Telepathy manager file +install_data( + 'idle.manager', + install_dir: managerdir, +) + +# Dbus service file +configure_file( + input: 'org.freedesktop.Telepathy.ConnectionManager.idle.service.in', + output: '@BASENAME@', + configuration: pathconf, + install_dir: dbus_services_dir, +) diff --git a/extensions/_gen/meson.build b/extensions/_gen/meson.build new file mode 100644 index 0000000..9f40cdd --- /dev/null +++ b/extensions/_gen/meson.build @@ -0,0 +1,58 @@ +xsltproc_with_flags = [xsltproc, '--nonet', '--novalid'] + +gen_all_xml = custom_target( + 'all.xml', + input: [ + join_paths(tools_dir, 'identity.xsl'), + join_paths('..', 'all.xml'), + ], + output: 'all.xml', + command: xsltproc_with_flags + ['--xinclude', '@INPUT@'], + capture: true, +) + +gen_svc = custom_target( + 'svc', + input: [ + join_paths(tools_dir, 'glib-ginterface-gen.py'), + gen_all_xml, + ], + output: [ + 'svc.h', + 'svc-gtk-doc.h', + 'svc.c', + ], + command: [ + python2, + '@INPUT0@', + '--filename=extensions/_gen/svc', + '--signal-marshal-prefix=_idle_ext', + '--include=', + '--not-implemented-func=tp_dbus_g_method_return_not_implemented', + '--allow-unstable', + '@INPUT1@', + 'Idle_Svc_', + ], +) + +gen_enums_h = custom_target( + 'enums.h', + input: [ + join_paths(tools_dir, 'c-constants-generator.xsl'), + gen_all_xml, + ], + output: 'enums.h', + command: xsltproc_with_flags + ['--stringparam', 'mixed-case-prefix', 'Idle', '@INPUT@'], + capture: true, +) + +gen_interfaces_h = custom_target( + 'interfaces.h', + input: [ + join_paths(tools_dir, 'c-interfaces-generator.xsl'), + gen_all_xml, + ], + output: 'interfaces.h', + command: xsltproc_with_flags + ['--stringparam', 'mixed-case-prefix', 'Idle', '@INPUT@'], + capture: true, +) diff --git a/extensions/meson.build b/extensions/meson.build new file mode 100644 index 0000000..388820d --- /dev/null +++ b/extensions/meson.build @@ -0,0 +1,29 @@ +xmls = files( + 'all.xml', + 'Connection_Interface_IRC_Command1.xml', +) + +subdir('_gen') + +libidle_extensions = library( + 'idle-extensions', + sources: [ + 'extensions.h', + gen_svc[2], + gen_enums_h, + gen_interfaces_h, + ], + dependencies: idle_deps, + include_directories: include_directories('..'), +) + +gen_extensions_html = custom_target( + 'extensions.html', + input: [ + join_paths(tools_dir, 'doc-generator.xsl'), + gen_all_xml, + ], + output: 'extensions.html', + command: xsltproc_with_flags + ['@INPUT@'], + capture: true, +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..f2839fe --- /dev/null +++ b/meson.build @@ -0,0 +1,87 @@ +# Making releases: +# set the new version number: +# odd minor -> development series +# even minor -> stable series +# increment micro for each release within a series +# set nano_version to 0 +# make the release, tag it +# set nano_version to 1 + +project( + 'telepathy-idle', + 'c', + version: '0.2.0.1', + default_options: [ + 'c_std=c99', + ], + meson_version: '>= 0.50.0', +) + +package_string = '@0@-@1@'.format(meson.project_name(), meson.project_version()) + +cc = meson.get_compiler('c') + +glib = dependency('glib-2.0', version: '>= 2.32.0') +gobject = dependency('gobject-2.0', version: '>= 2.32.0') +gio = dependency('gio-2.0', version: '>= 2.32.0') +dbus = dependency('dbus-1', version: '>= 0.51') +dbus_glib = dependency('dbus-glib-1', version: '>= 0.51') +telepathy_glib = dependency('telepathy-glib', version: '>= 0.23.0') + +idle_deps = [ + glib, + gobject, + gio, + dbus, + dbus_glib, + telepathy_glib, +] + +xsltproc = find_program('xsltproc') +python2 = import('python').find_installation('python2') + +# check for a version of python that can run the twisted tests +if get_option('twisted_tests') + if run_command(python2, '-c', '''from sys import version_info; import dbus, dbus.mainloop.glib; raise SystemExit(version_info < (2, 5, 0, 'final', 0))''').returncode() != 0 or run_command(python2, '-c', '''import twisted.words.protocols.irc, twisted.internet.reactor''').returncode() != 0 + error('Missing twisted IRC support') + endif + + test_python = python2.path() +endif + +# Directories + +datadir = join_paths(get_option('prefix'), get_option('datadir')) +libexecdir = join_paths(get_option('prefix'), get_option('libexecdir')) +pkglibexecdir = join_paths(libexecdir, meson.project_name()) +dbus_services_dir = join_paths(datadir, 'dbus-1', 'services') +managerdir = join_paths(datadir, 'telepathy', 'managers') + +# Configuration + +conf_data = configuration_data() +conf_data.set_quoted('DBUS_SERVICES_DIR', dbus_services_dir, description: 'DBus services directory') +conf_data.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_28', description: 'Ignore post 2.28 deprecations') +conf_data.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_32', description: 'Prevent post 2.32 APIs') +conf_data.set('TP_SEAL_ENABLE', '', description: 'Prevent to use sealed variables') +conf_data.set('TP_DISABLE_SINGLE_INCLUDE', '', description: 'Disable single header include') +conf_data.set('TP_VERSION_MIN_REQUIRED', 'TP_VERSION_0_24', description: 'Ignore post 0.24 deprecations') +conf_data.set('TP_VERSION_MAX_ALLOWED', 'TP_VERSION_0_24', description: 'Prevent post 0.24 APIs') +conf_data.set_quoted('VERSION', meson.project_version()) +if cc.has_function('strnlen') + conf_data.set10('HAVE_STRNLEN', true) +endif + +configure_file( + output: 'config.h', + configuration: conf_data, +) + +configuration_inc = include_directories('.') +src_inc = include_directories('src') +tools_dir = join_paths(meson.current_source_dir(), 'tools') + +subdir('extensions') +subdir('src') +subdir('data') +subdir('tests') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..01583da --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,13 @@ +option( + 'twisted_tests', + type: 'boolean', + value: true, + description: 'Enable tests using Python with Twisted and IRC protocol support', +) + +option( + 'twisted_sleep', + type: 'string', + value: '0', + description: 'Number of seconds to sleep in twisted tests', +) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..c264c02 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,52 @@ +libidle_convenience = library( + 'idle-convenience', + sources: [ + 'idle-connection.c', + 'idle-connection-manager.c', + 'idle-contact-info.c', + 'idle-ctcp.c', + 'idle-debug.c', + 'idle-handles.c', + 'idle-im-channel.c', + 'idle-im-manager.c', + 'idle-muc-channel.c', + 'idle-muc-manager.c', + 'room-config.c', + 'idle-parser.c', + 'protocol.c', + 'idle-roomlist-channel.c', + 'idle-roomlist-manager.c', + 'idle-server-connection.c', + 'idle-text.c', + 'server-tls-channel.c', + 'server-tls-manager.c', + 'tls-certificate.c', + gen_enums_h, # required by libidle_extensions + ], + dependencies: idle_deps, + include_directories: configuration_inc, + link_with: libidle_extensions, +) + +executable( + 'telepathy-idle', + sources: [ + 'idle.c' + ], + dependencies: idle_deps, + include_directories: configuration_inc, + install: true, + install_dir: libexecdir, + link_with: libidle_convenience, +) + +pathconf = configuration_data() +pathconf.set('libexecdir', libexecdir) + +telepathy_idle_8 = configure_file( + configuration: pathconf, + input: 'telepathy-idle.8.in', + output: '@BASENAME@', +) + +install_man(telepathy_idle_8) diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..626168c --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,37 @@ + +test_ctcp_tokenize = executable( + 'test-ctcp-tokenize', + sources: [ + 'test-ctcp-tokenize.c', + ], + dependencies: idle_deps, + include_directories: [configuration_inc, src_inc], + link_with: libidle_convenience, +) +test('test_ctcp_tokenize', test_ctcp_tokenize) + +test_ctcp_kill_blingbling = executable( + 'test-ctcp-kill-blingbling', + sources: [ + 'test-ctcp-kill-blingbling.c', + ], + dependencies: idle_deps, + include_directories: [configuration_inc, src_inc], + link_with: libidle_convenience, +) +test('test_ctcp_kill_blingbling', test_ctcp_kill_blingbling) + +test_text_encode_and_split = executable( + 'test-text-encode-and-split', + sources: [ + 'test-text-encode-and-split.c', + ], + dependencies: idle_deps, + include_directories: [configuration_inc, src_inc], + link_with: libidle_convenience, +) +test('test_text_encode_and_split', test_text_encode_and_split) + +if get_option('twisted_tests') + subdir('twisted') +endif diff --git a/tests/twisted/config.py.in b/tests/twisted/config.py.in new file mode 100644 index 0000000..d0228f1 --- /dev/null +++ b/tests/twisted/config.py.in @@ -0,0 +1 @@ +PACKAGE_STRING = "@PACKAGE_STRING@" diff --git a/tests/twisted/meson.build b/tests/twisted/meson.build new file mode 100644 index 0000000..7e39d4b --- /dev/null +++ b/tests/twisted/meson.build @@ -0,0 +1,93 @@ +twisted_tests = [ + 'cm/protocol.py', + 'connect/connect-close-ssl.py', + 'connect/connect-success.py', + 'connect/connect-success-ssl.py', + 'connect/connect-reject-ssl.py', + 'connect/connect-fail.py', + 'connect/connect-fail-ssl.py', + 'connect/disconnect-before-socket-connected.py', + 'connect/disconnect-during-cert-verification.py', + 'connect/ping.py', + 'connect/server-quit-ignore.py', + 'connect/server-quit-noclose.py', + 'connect/socket-closed-after-handshake.py', + 'connect/socket-closed-during-handshake.py', + 'connect/invalid-nick.py', + 'contacts.py', + 'channels/join-muc-channel.py', + 'channels/join-muc-channel-bouncer.py', + 'channels/requests-create.py', + 'channels/requests-muc.py', + 'channels/muc-channel-topic.py', + 'channels/muc-destroy.py', + 'channels/room-list-channel.py', + 'channels/room-list-multiple.py', + 'irc-command.py', + 'messages/accept-invalid-nicks.py', + 'messages/contactinfo-request.py', + 'messages/invalid-utf8.py', + 'messages/messages-iface.py', + 'messages/message-order.py', + 'messages/leading-space.py', + 'messages/long-message-split.py', + 'messages/room-contact-mixup.py', + 'messages/room-config.py', +] + +twisted_conf = configuration_data() +twisted_conf.set_quoted('PACKAGE_STRING', package_string) + +configure_file( + input: 'config.py.in', + output: '@BASENAME@', + configuration: twisted_conf, +) + +if get_option('twisted_sleep') == '0' + idle_test_sleep = '' +else + idle_test_sleep = '--sleep=@0@'.format(get_option('twisted_sleep')) +endif + +# idle-twisted-tests.list +test_list = custom_target('idle-twisted-tests.list', + output: 'idle-twisted-tests.list', + command: ['echo', '\n'.join(twisted_tests)], + capture: true, +) + +# We don't really use idletestsdir yet - we only support uninstalled testing +# so far - but I'm substituting it to keep the script more similar to Gabble's. +# ${pkglibexecdir}/tests is what GNOME's InstalledTests goal recommends. + +abs_top_srcdir = meson.source_root() +abs_top_builddir = meson.build_root() + +run_test_conf = configuration_data() +run_test_conf.set('idletestsdir', join_paths(pkglibexecdir, 'tests')) +run_test_conf.set('TEST_PYTHON', test_python) + +run_test = configure_file( + input: 'run-test.sh.in', + output: '@BASENAME@', + configuration: run_test_conf, +) + +test( + 'check', + run_test, + args: twisted_tests, + env: [ + 'IDLE_TEST_UNINSTALLED=1', + 'IDLE_ABS_TOP_SRCDIR=@0@'.format(abs_top_srcdir), + 'IDLE_ABS_TOP_BUILDDIR=@0@'.format(abs_top_builddir), + 'IDLE_TEST_SLEEP=@0@'.format(idle_test_sleep), + ], + depends: [ + test_list, + ], + suite: 'twisted', +) + +subdir('tools') diff --git a/tests/twisted/tools/meson.build b/tests/twisted/tools/meson.build new file mode 100644 index 0000000..c3d28b6 --- /dev/null +++ b/tests/twisted/tools/meson.build @@ -0,0 +1,22 @@ +ewl_conf = configuration_data() +ewl_conf.set('abs_top_builddir', abs_top_builddir) +ewl_conf.set('abs_top_srcdir', abs_top_srcdir) + +configure_file( + input: 'exec-with-log.sh.in', + output: '@BASENAME@', + configuration: ewl_conf, +) + +configure_file( + input: 'tmp-session-bus.conf.in', + output: '@BASENAME@', + configuration: ewl_conf, +) + +# D-Bus service file for testing +configure_file( + input: 'idle.service.in', + output: 'org.freedesktop.Telepathy.ConnectionManager.idle.service', + configuration: ewl_conf, +) -- cgit v1.2.1