diff options
Diffstat (limited to 'libdino')
-rw-r--r-- | libdino/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libdino/meson.build | 86 | ||||
-rw-r--r-- | libdino/src/application.vala | 1 | ||||
-rw-r--r-- | libdino/src/version.vala | 6 | ||||
-rw-r--r-- | libdino/version.py | 36 |
5 files changed, 129 insertions, 1 deletions
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() |