From 5a90e793ddec723677f2b715b967f29f046e16d2 Mon Sep 17 00:00:00 2001 From: hrxi Date: Mon, 20 Mar 2023 02:01:22 +0100 Subject: [PATCH] First steps of meson support Basic configuration of qlite, xmpp-vala, the Dino library and the Dino application are supported. There's no support for the plugins. This e.g. enables using the Vala language server. --- libdino/CMakeLists.txt | 1 + libdino/meson.build | 86 ++++++++++++++++++++++ libdino/src/application.vala | 1 - libdino/src/version.vala | 6 ++ libdino/version.py | 36 ++++++++++ main/data/gresource.xml | 74 +++++++++++++++++++ main/meson.build | 104 +++++++++++++++++++++++++++ meson.build | 23 ++++++ meson_options.txt | 1 + qlite/meson.build | 22 ++++++ xmpp-vala/meson.build | 133 +++++++++++++++++++++++++++++++++++ 11 files changed, 486 insertions(+), 1 deletion(-) create mode 100644 libdino/meson.build create mode 100644 libdino/src/version.vala create mode 100644 libdino/version.py create mode 100644 main/data/gresource.xml create mode 100644 main/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 qlite/meson.build create mode 100644 xmpp-vala/meson.build diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt index 5aa4035f..3c184cfd 100644 --- a/libdino/CMakeLists.txt +++ b/libdino/CMakeLists.txt @@ -9,6 +9,7 @@ find_packages(LIBDINO_PACKAGES REQUIRED vala_precompile(LIBDINO_VALA_C SOURCES src/application.vala + src/version.vala src/dbus/login1.vala src/dbus/notifications.vala diff --git a/libdino/meson.build b/libdino/meson.build new file mode 100644 index 00000000..0ebaff33 --- /dev/null +++ b/libdino/meson.build @@ -0,0 +1,86 @@ +# version_vala +dot_git = meson.current_source_dir() / '../.git' +version_file = meson.current_source_dir() / '../VERSION' +command = [prog_python, files('version.py'), version_file, '@OUTPUT@', '--git-repo', meson.current_source_dir()] +if prog_git.found() + command += ['--git', prog_git] +endif +depend_files = [] +if fs.exists(dot_git) + depend_files += [dot_git] +endif +if fs.exists(version_file) + depend_files += [version_file] +endif +version_vala = custom_target('libdino_version_vala', command: command, output: 'version.vala', depend_files: depend_files) + +# libdino +dependencies = [ + dep_gdk_pixbuf, + dep_gee, + dep_gio, + dep_glib, + dep_gmodule, + dep_qlite, + dep_xmpp_vala +] +sources = files( + 'src/application.vala', + 'src/dbus/login1.vala', + 'src/dbus/notifications.vala', + 'src/dbus/upower.vala', + 'src/entity/account.vala', + 'src/entity/call.vala', + 'src/entity/conversation.vala', + 'src/entity/encryption.vala', + 'src/entity/file_transfer.vala', + 'src/entity/message.vala', + 'src/entity/settings.vala', + 'src/plugin/interfaces.vala', + 'src/plugin/loader.vala', + 'src/plugin/registry.vala', + 'src/service/avatar_manager.vala', + 'src/service/blocking_manager.vala', + 'src/service/call_store.vala', + 'src/service/call_state.vala', + 'src/service/call_peer_state.vala', + 'src/service/calls.vala', + 'src/service/chat_interaction.vala', + 'src/service/connection_manager.vala', + 'src/service/content_item_store.vala', + 'src/service/conversation_manager.vala', + 'src/service/counterpart_interaction_manager.vala', + 'src/service/database.vala', + 'src/service/entity_capabilities_storage.vala', + 'src/service/entity_info.vala', + 'src/service/fallback_body.vala', + 'src/service/file_manager.vala', + 'src/service/file_transfer_storage.vala', + 'src/service/history_sync.vala', + 'src/service/jingle_file_transfers.vala', + 'src/service/message_correction.vala', + 'src/service/message_processor.vala', + 'src/service/message_storage.vala', + 'src/service/module_manager.vala', + 'src/service/muc_manager.vala', + 'src/service/notification_events.vala', + 'src/service/presence_manager.vala', + 'src/service/replies.vala', + 'src/service/reactions.vala', + 'src/service/registration.vala', + 'src/service/roster_manager.vala', + 'src/service/search_processor.vala', + 'src/service/stream_interactor.vala', + 'src/service/util.vala', + 'src/util/display_name.vala', + 'src/util/util.vala', + 'src/util/weak_map.vala', +) +sources += [version_vala] +c_args = [ + '-DDINO_SYSTEM_LIBDIR_NAME="@0@"'.format(get_option('prefix') / get_option('libdir')), + '-DDINO_SYSTEM_PLUGIN_DIR="@0@"'.format(get_option('prefix') / get_option('plugindir')), + '-DG_LOG_DOMAIN="libdino"', +] +lib_dino = library('dino', sources, c_args: c_args, include_directories: include_directories('src'), dependencies: dependencies) +dep_dino = declare_dependency(link_with: lib_dino, include_directories: include_directories('.', 'src')) diff --git a/libdino/src/application.vala b/libdino/src/application.vala index 490cd40c..5e58e364 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -2,7 +2,6 @@ using Dino.Entities; namespace Dino { -extern const string VERSION; public string get_version() { return VERSION; } public string get_short_version() { if (!VERSION.contains("~")) return VERSION; diff --git a/libdino/src/version.vala b/libdino/src/version.vala new file mode 100644 index 00000000..0fdc0145 --- /dev/null +++ b/libdino/src/version.vala @@ -0,0 +1,6 @@ +// Not used in Meson. +namespace Dino { + +extern const string VERSION; + +} diff --git a/libdino/version.py b/libdino/version.py new file mode 100644 index 00000000..d34db6a8 --- /dev/null +++ b/libdino/version.py @@ -0,0 +1,36 @@ +import argparse +import subprocess +VERSION_VALA = """\ +namespace Dino {{ + +public const string VERSION = "{}"; + +}} +""" + +def compute_version(file, git_repo, git): + try: + with open(file) as f: + return f.read().strip() + except FileNotFoundError: + pass + return subprocess.check_output([git, "describe", "--tags"], cwd=git_repo, text=True).strip() + +def generate_version_vala(version): + if "\\" in version or "\"" in version: + raise ValueError(f"invalid version {version!r}") + return VERSION_VALA.format(version) + +def main(): + p = argparse.ArgumentParser(description="Compute the Dino version") + p.add_argument("--git-repo", help="Path to checked out git repository") + p.add_argument("--git", help="Path to git executable", default="git") + p.add_argument("version_file", metavar="VERSION_FILE", help="Use this file's contents as version if the file exists") + p.add_argument("output", metavar="OUTPUT", help="Vala file to output to") + args = p.parse_args() + out = generate_version_vala(compute_version(args.version_file, args.git_repo, args.git)) + with open(args.output, "w") as f: + f.write(out) + +if __name__ == "__main__": + main() diff --git a/main/data/gresource.xml b/main/data/gresource.xml new file mode 100644 index 00000000..6d9febab --- /dev/null +++ b/main/data/gresource.xml @@ -0,0 +1,74 @@ + + + + add_conversation/add_contact_dialog.ui + add_conversation/add_groupchat_dialog.ui + add_conversation/conference_details_fragment.ui + add_conversation/list_row.ui + add_conversation/select_jid_fragment.ui + call_widget.ui + chat_input.ui + contact_details_dialog.ui + conversation_content_view/item_metadata_header.ui + conversation_content_view/view.ui + conversation_item_widget.ui + conversation_list_titlebar.ui + conversation_list_titlebar_csd.ui + conversation_row.ui + conversation_view.ui + dino-conversation-list-placeholder-arrow.svg + file_default_widget.ui + file_send_overlay.ui + global_search.ui + icons/scalable/actions/dino-account-plus-symbolic.svg + icons/scalable/actions/dino-emoticon-add-symbolic.svg + icons/scalable/actions/dino-emoticon-symbolic.svg + icons/scalable/actions/dino-qr-code-symbolic.svg + icons/scalable/apps/im.dino.Dino-symbolic.svg + icons/scalable/apps/im.dino.Dino.svg + icons/scalable/devices/dino-device-desktop-symbolic.svg + icons/scalable/devices/dino-device-phone-symbolic.svg + icons/scalable/devices/dino-phone-hangup-symbolic.svg + icons/scalable/devices/dino-phone-in-talk-symbolic.svg + icons/scalable/devices/dino-phone-missed-symbolic.svg + icons/scalable/devices/dino-phone-ring-symbolic.svg + icons/scalable/devices/dino-phone-symbolic.svg + icons/scalable/mimetypes/dino-file-document-symbolic.svg + icons/scalable/mimetypes/dino-file-download-symbolic.svg + icons/scalable/mimetypes/dino-file-image-symbolic.svg + icons/scalable/mimetypes/dino-file-music-symbolic.svg + icons/scalable/mimetypes/dino-file-symbolic.svg + icons/scalable/mimetypes/dino-file-table-symbolic.svg + icons/scalable/mimetypes/dino-file-video-symbolic.svg + icons/scalable/status/dino-double-tick-symbolic.svg + icons/scalable/status/dino-microphone-off-symbolic.svg + icons/scalable/status/dino-microphone-symbolic.svg + icons/scalable/status/dino-party-popper-symbolic.svg + icons/scalable/status/dino-security-high-symbolic.svg + icons/scalable/status/dino-status-away.svg + icons/scalable/status/dino-status-chat.svg + icons/scalable/status/dino-status-dnd.svg + icons/scalable/status/dino-status-online.svg + icons/scalable/status/dino-tick-symbolic.svg + icons/scalable/status/dino-video-off-symbolic.svg + icons/scalable/status/dino-video-symbolic.svg + manage_accounts/account_row.ui + manage_accounts/add_account_dialog.ui + manage_accounts/dialog.ui + menu_add.ui + menu_app.ui + menu_conversation.ui + menu_encryption.ui + message_item_widget_edit_mode.ui + occupant_list.ui + occupant_list_item.ui + quote.ui + search_autocomplete.ui + settings_dialog.ui + shortcuts.ui + style-dark.css + style.css + unified_main_content.ui + unified_window_placeholder.ui + + diff --git a/main/meson.build b/main/meson.build new file mode 100644 index 00000000..a38e15b8 --- /dev/null +++ b/main/meson.build @@ -0,0 +1,104 @@ +dependencies = [ + dep_dino, + dep_gee, + dep_glib, + dep_gmodule, + dep_gtk4, + dep_icu_uc, + dep_libadwaita, + dep_m, + dep_qlite, + dep_xmpp_vala, +] +sources = files( + 'src/main.vala', + 'src/ui/add_conversation/add_conference_dialog.vala', + 'src/ui/add_conversation/add_contact_dialog.vala', + 'src/ui/add_conversation/add_groupchat_dialog.vala', + 'src/ui/add_conversation/conference_details_fragment.vala', + 'src/ui/add_conversation/conference_list.vala', + 'src/ui/add_conversation/list_row.vala', + 'src/ui/add_conversation/roster_list.vala', + 'src/ui/add_conversation/select_contact_dialog.vala', + 'src/ui/add_conversation/select_jid_fragment.vala', + 'src/ui/application.vala', + 'src/ui/call_window/audio_settings_popover.vala', + 'src/ui/call_window/call_bottom_bar.vala', + 'src/ui/call_window/call_connection_details_window.vala', + 'src/ui/call_window/call_encryption_button.vala', + 'src/ui/call_window/call_window.vala', + 'src/ui/call_window/call_window_controller.vala', + 'src/ui/call_window/participant_widget.vala', + 'src/ui/call_window/video_settings_popover.vala', + 'src/ui/chat_input/chat_input_controller.vala', + 'src/ui/chat_input/chat_text_view.vala', + 'src/ui/chat_input/encryption_button.vala', + 'src/ui/chat_input/occupants_tab_completer.vala', + 'src/ui/chat_input/smiley_converter.vala', + 'src/ui/chat_input/view.vala', + 'src/ui/contact_details/blocking_provider.vala', + 'src/ui/contact_details/dialog.vala', + 'src/ui/contact_details/muc_config_form_provider.vala', + 'src/ui/contact_details/permissions_provider.vala', + 'src/ui/contact_details/settings_provider.vala', + 'src/ui/conversation_content_view/call_widget.vala', + 'src/ui/conversation_content_view/chat_state_populator.vala', + 'src/ui/conversation_content_view/content_populator.vala', + 'src/ui/conversation_content_view/conversation_item_skeleton.vala', + 'src/ui/conversation_content_view/conversation_view.vala', + 'src/ui/conversation_content_view/date_separator_populator.vala', + 'src/ui/conversation_content_view/file_default_widget.vala', + 'src/ui/conversation_content_view/file_image_widget.vala', + 'src/ui/conversation_content_view/file_widget.vala', + 'src/ui/conversation_content_view/item_actions.vala', + 'src/ui/conversation_content_view/message_widget.vala', + 'src/ui/conversation_content_view/quote_widget.vala', + 'src/ui/conversation_content_view/reactions_widget.vala', + 'src/ui/conversation_content_view/subscription_notification.vala', + 'src/ui/conversation_list_titlebar.vala', + 'src/ui/conversation_selector/conversation_selector.vala', + 'src/ui/conversation_selector/conversation_selector_row.vala', + 'src/ui/conversation_titlebar/call_entry.vala', + 'src/ui/conversation_titlebar/conversation_titlebar.vala', + 'src/ui/conversation_titlebar/menu_entry.vala', + 'src/ui/conversation_titlebar/occupants_entry.vala', + 'src/ui/conversation_titlebar/search_entry.vala', + 'src/ui/conversation_view.vala', + 'src/ui/conversation_view_controller.vala', + 'src/ui/file_send_overlay.vala', + 'src/ui/global_search.vala', + 'src/ui/main_window.vala', + 'src/ui/main_window_controller.vala', + 'src/ui/manage_accounts/account_row.vala', + 'src/ui/manage_accounts/add_account_dialog.vala', + 'src/ui/manage_accounts/dialog.vala', + 'src/ui/notifier_freedesktop.vala', + 'src/ui/notifier_gnotifications.vala', + 'src/ui/occupant_menu/list.vala', + 'src/ui/occupant_menu/list_row.vala', + 'src/ui/occupant_menu/view.vala', + 'src/ui/settings_dialog.vala', + 'src/ui/util/accounts_combo_box.vala', + 'src/ui/util/config.vala', + 'src/ui/util/data_forms.vala', + 'src/ui/util/helper.vala', + 'src/ui/util/label_hybrid.vala', + 'src/ui/util/size_request_box.vala', + 'src/ui/util/sizing_bin.vala', + 'src/ui/widgets/avatar_picture.vala', + 'src/ui/widgets/date_separator.vala', + 'src/ui/widgets/fixed_ratio_picture.vala', + 'src/ui/widgets/natural_size_increase.vala', +) +sources += import('gnome').compile_resources( + 'dino-resources', + 'data/gresource.xml', + source_dir: 'data', +) + +c_args = [ + '-DG_LOG_DOMAIN="dino"', + '-DGETTEXT_PACKAGE="dino"', + '-DLOCALE_INSTALL_DIR="@0@"'.format(get_option('prefix') / get_option('localedir')), +] +exe_dino = executable('dino', sources, c_args: c_args, vala_args: ['--vapidir', meson.current_source_dir() / 'vapi'], dependencies: dependencies) diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..aea22d57 --- /dev/null +++ b/meson.build @@ -0,0 +1,23 @@ +project('xmpp-vala', 'vala') + +fs = import('fs') +python = import('python') + +dep_gdk_pixbuf = dependency('gdk-pixbuf-2.0') +dep_gee = dependency('gee-0.8') +dep_gio = dependency('gio-2.0') +dep_glib = dependency('glib-2.0') +dep_gmodule = dependency('gmodule-2.0') +dep_gtk4 = dependency('gtk4') +dep_icu_uc = dependency('icu-uc') +dep_libadwaita = dependency('libadwaita-1') +dep_m = meson.get_compiler('c').find_library('m', required: false) +dep_sqlite3 = dependency('sqlite3', version: '>=3.24') + +prog_git = find_program('git', required: false) +prog_python = python.find_installation() + +subdir('qlite') +subdir('xmpp-vala') +subdir('libdino') +subdir('main') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..6e47b7c8 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('plugindir', type: 'string', value: 'lib/dino/plugins', description: 'Plugin directory for Dino plugins') diff --git a/qlite/meson.build b/qlite/meson.build new file mode 100644 index 00000000..714a4224 --- /dev/null +++ b/qlite/meson.build @@ -0,0 +1,22 @@ +dependencies = [ + dep_gee, + dep_glib, + dep_sqlite3, +] +sources = files( + 'src/column.vala', + 'src/database.vala', + 'src/delete_builder.vala', + 'src/insert_builder.vala', + 'src/query_builder.vala', + 'src/row.vala', + 'src/statement_builder.vala', + 'src/table.vala', + 'src/update_builder.vala', + 'src/upsert_builder.vala', +) +c_args = [ + '-DG_LOG_DOMAIN="qlite"', +] +lib_qlite = library('qlite', sources, c_args: c_args, vala_args: ['--vapidir', meson.current_source_dir() / 'vapi'], dependencies: dependencies) +dep_qlite = declare_dependency(link_with: lib_qlite, include_directories: include_directories('.')) diff --git a/xmpp-vala/meson.build b/xmpp-vala/meson.build new file mode 100644 index 00000000..3064339a --- /dev/null +++ b/xmpp-vala/meson.build @@ -0,0 +1,133 @@ +dependencies = [ + dep_gdk_pixbuf, + dep_gee, + dep_gio, + dep_glib, + dep_icu_uc, + dep_m, +] +sources = files( + 'src/core/direct_tls_xmpp_stream.vala', + 'src/core/io_xmpp_stream.vala', + 'src/core/module_flag.vala', + 'src/core/namespace_state.vala', + 'src/core/stanza_attribute.vala', + 'src/core/stanza_node.vala', + 'src/core/stanza_reader.vala', + 'src/core/stanza_writer.vala', + 'src/core/starttls_xmpp_stream.vala', + 'src/core/stream_connect.vala', + 'src/core/tls_xmpp_stream.vala', + 'src/core/xmpp_log.vala', + 'src/core/xmpp_stream.vala', + 'src/glib_fixes.vapi', + 'src/module/bind.vala', + 'src/module/bookmarks_provider.vala', + 'src/module/conference.vala', + 'src/module/iq/module.vala', + 'src/module/iq/stanza.vala', + 'src/module/jid.vala', + 'src/module/message/module.vala', + 'src/module/message/stanza.vala', + 'src/module/presence/flag.vala', + 'src/module/presence/module.vala', + 'src/module/presence/stanza.vala', + 'src/module/roster/flag.vala', + 'src/module/roster/item.vala', + 'src/module/roster/module.vala', + 'src/module/roster/versioning_module.vala', + 'src/module/sasl.vala', + 'src/module/session.vala', + 'src/module/stanza.vala', + 'src/module/stanza_error.vala', + 'src/module/stream_error.vala', + 'src/module/util.vala', + 'src/module/xep/0004_data_forms.vala', + 'src/module/xep/0030_service_discovery/flag.vala', + 'src/module/xep/0030_service_discovery/identity.vala', + 'src/module/xep/0030_service_discovery/info_result.vala', + 'src/module/xep/0030_service_discovery/item.vala', + 'src/module/xep/0030_service_discovery/items_result.vala', + 'src/module/xep/0030_service_discovery/module.vala', + 'src/module/xep/0045_muc/flag.vala', + 'src/module/xep/0045_muc/module.vala', + 'src/module/xep/0045_muc/status_code.vala', + 'src/module/xep/0047_in_band_bytestreams.vala', + 'src/module/xep/0048_bookmarks.vala', + 'src/module/xep/0048_conference.vala', + 'src/module/xep/0049_private_xml_storage.vala', + 'src/module/xep/0054_vcard/module.vala', + 'src/module/xep/0059_result_set_management.vala', + 'src/module/xep/0060_pubsub.vala', + 'src/module/xep/0065_socks5_bytestreams.vala', + 'src/module/xep/0066_out_of_band_data.vala', + 'src/module/xep/0077_in_band_registration.vala', + 'src/module/xep/0082_date_time_profiles.vala', + 'src/module/xep/0084_user_avatars.vala', + 'src/module/xep/0085_chat_state_notifications.vala', + 'src/module/xep/0115_entity_capabilities.vala', + 'src/module/xep/0166_jingle/component.vala', + 'src/module/xep/0166_jingle/content.vala', + 'src/module/xep/0166_jingle/content_description.vala', + 'src/module/xep/0166_jingle/content_node.vala', + 'src/module/xep/0166_jingle/content_security.vala', + 'src/module/xep/0166_jingle/content_transport.vala', + 'src/module/xep/0166_jingle/jingle_flag.vala', + 'src/module/xep/0166_jingle/jingle_module.vala', + 'src/module/xep/0166_jingle/jingle_structs.vala', + 'src/module/xep/0166_jingle/reason_element.vala', + 'src/module/xep/0166_jingle/session.vala', + 'src/module/xep/0166_jingle/session_info.vala', + 'src/module/xep/0167_jingle_rtp/content_parameters.vala', + 'src/module/xep/0167_jingle_rtp/content_type.vala', + 'src/module/xep/0167_jingle_rtp/jingle_rtp_module.vala', + 'src/module/xep/0167_jingle_rtp/payload_type.vala', + 'src/module/xep/0167_jingle_rtp/session_info_type.vala', + 'src/module/xep/0167_jingle_rtp/stream.vala', + 'src/module/xep/0176_jingle_ice_udp/candidate.vala', + 'src/module/xep/0176_jingle_ice_udp/jingle_ice_udp_module.vala', + 'src/module/xep/0176_jingle_ice_udp/transport_parameters.vala', + 'src/module/xep/0177_jingle_raw_udp.vala', + 'src/module/xep/0184_message_delivery_receipts.vala', + 'src/module/xep/0191_blocking_command.vala', + 'src/module/xep/0198_stream_management.vala', + 'src/module/xep/0199_ping.vala', + 'src/module/xep/0203_delayed_delivery.vala', + 'src/module/xep/0215_external_service_discovery.vala', + 'src/module/xep/0234_jingle_file_transfer.vala', + 'src/module/xep/0249_direct_muc_invitations.vala', + 'src/module/xep/0260_jingle_socks5_bytestreams.vala', + 'src/module/xep/0261_jingle_in_band_bytestreams.vala', + 'src/module/xep/0272_muji.vala', + 'src/module/xep/0280_message_carbons.vala', + 'src/module/xep/0297_stanza_forwarding.vala', + 'src/module/xep/0298_coin.vala', + 'src/module/xep/0308_last_message_correction.vala', + 'src/module/xep/0313_2_message_archive_management.vala', + 'src/module/xep/0313_message_archive_management.vala', + 'src/module/xep/0333_chat_markers.vala', + 'src/module/xep/0334_message_processing_hints.vala', + 'src/module/xep/0353_call_invite_message.vala', + 'src/module/xep/0353_jingle_message_initiation.vala', + 'src/module/xep/0359_unique_stable_stanza_ids.vala', + 'src/module/xep/0363_http_file_upload.vala', + 'src/module/xep/0380_explicit_encryption.vala', + 'src/module/xep/0384_omemo/omemo_decryptor.vala', + 'src/module/xep/0384_omemo/omemo_encryptor.vala', + 'src/module/xep/0391_jingle_encrypted_transports.vala', + 'src/module/xep/0392_consistent_color/consistent_color.vala', + 'src/module/xep/0392_consistent_color/hsluv.vala', + 'src/module/xep/0402_bookmarks2.vala', + 'src/module/xep/0410_muc_self_ping.vala', + 'src/module/xep/0421_occupant_ids.vala', + 'src/module/xep/0428_fallback_indication.vala', + 'src/module/xep/0444_reactions.vala', + 'src/module/xep/0461_replies.vala', + 'src/module/xep/pixbuf_storage.vala', + 'src/util.vala', +) +c_args = [ + '-DG_LOG_DOMAIN="xmpp-vala"', +] +lib_xmpp_vala = library('xmpp-vala', sources, c_args: c_args, vala_args: ['--vapidir', meson.current_source_dir() / 'vapi'], dependencies: dependencies) +dep_xmpp_vala = declare_dependency(link_with: lib_xmpp_vala, include_directories: include_directories('.'))