From b34191ee2cbbd1c6d975d2e64e3b271c2d696b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Iv=C3=A1n?= <76420970+Diego-Ivan@users.noreply.github.com> Date: Tue, 21 Feb 2023 10:18:53 -0600 Subject: [PATCH] chore: build system cleanup (#39) Co-authored-by: Evangelos Paterakis --- dev.geopjr.tooth.json | 5 + meson.build | 144 +++--------------- .../Mastodon/Configuration/meson.build | 6 + src/API/Instance/Mastodon/meson.build | 5 + src/API/Instance/meson.build | 1 + src/API/meson.build | 23 +++ src/Application.vala | 25 +-- src/Build.vala.in | 41 ----- src/Dialogs/Composer/meson.build | 8 + src/Dialogs/meson.build | 8 + src/Services/Accounts/Mastodon/meson.build | 3 + src/Services/Accounts/meson.build | 9 ++ src/Services/Cache/meson.build | 5 + src/Services/Network/meson.build | 6 + src/Services/meson.build | 7 + src/Utils/meson.build | 5 + src/Views/meson.build | 23 +++ src/Widgets/Attachment/meson.build | 5 + src/Widgets/meson.build | 20 +++ src/meson.build | 8 + vapi/build.vapi | 12 ++ 21 files changed, 199 insertions(+), 170 deletions(-) create mode 100644 src/API/Instance/Mastodon/Configuration/meson.build create mode 100644 src/API/Instance/Mastodon/meson.build create mode 100644 src/API/Instance/meson.build create mode 100644 src/API/meson.build delete mode 100644 src/Build.vala.in create mode 100644 src/Dialogs/Composer/meson.build create mode 100644 src/Dialogs/meson.build create mode 100644 src/Services/Accounts/Mastodon/meson.build create mode 100644 src/Services/Accounts/meson.build create mode 100644 src/Services/Cache/meson.build create mode 100644 src/Services/Network/meson.build create mode 100644 src/Services/meson.build create mode 100644 src/Utils/meson.build create mode 100644 src/Views/meson.build create mode 100644 src/Widgets/Attachment/meson.build create mode 100644 src/Widgets/meson.build create mode 100644 src/meson.build create mode 100644 vapi/build.vapi diff --git a/dev.geopjr.tooth.json b/dev.geopjr.tooth.json index b1ea76b..091d1c0 100644 --- a/dev.geopjr.tooth.json +++ b/dev.geopjr.tooth.json @@ -3,6 +3,11 @@ "runtime": "org.gnome.Platform", "runtime-version": "43", "sdk": "org.gnome.Sdk", + "sdk-extensions" : ["org.freedesktop.Sdk.Extension.vala"], + "build-options" : { + "prepend-path" : "/usr/lib/sdk/vala/bin/", + "prepend-ld-library-path" : "/usr/lib/sdk/vala/lib" + }, "command": "dev.geopjr.tooth", "finish-args": [ "--device=dri", diff --git a/meson.build b/meson.build index 14ce10f..d587312 100644 --- a/meson.build +++ b/meson.build @@ -9,28 +9,21 @@ project( ], ) -add_global_arguments( - [ - '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), - ], - language: 'c', -) - devel = get_option('devel') + +# Setup configuration file, accessed via vapi/build.vapi config = configuration_data() -config.set('EXEC_NAME', meson.project_name()) -config.set('GETTEXT_PACKAGE', meson.project_name()) -config.set('RESOURCES', '/' + '/'.join(meson.project_name().split('.')) + '/') -config.set('VERSION', meson.project_version()) -config.set('PREFIX', get_option('prefix')) -config.set('PROFILE', devel ? 'development' : 'production') -config.set('NAME', 'Tooth') -config.set('WEBSITE', 'https://github.com/GeopJr/tooth') -config.set('SUPPORT_WEBSITE', 'https://github.com/GeopJr/tooth/issues') -config.set( - 'COPYRIGHT', - '© 2022 bleak_grey\n© 2022 Evangelos \"GeopJr\" Paterakis', -) +config.set_quoted('EXEC_NAME', meson.project_name()) +config.set_quoted('GETTEXT_PACKAGE', meson.project_name()) +config.set_quoted('DOMAIN', meson.project_name ()) +config.set_quoted('G_LOG_DOMAIN', 'Tooth') +config.set_quoted('RESOURCES', '/' + '/'.join(meson.project_name().split('.')) + '/') +config.set_quoted('VERSION', meson.project_version()) +config.set_quoted('PREFIX', get_option('prefix')) +config.set_quoted('NAME', 'Tooth') +config.set_quoted('WEBSITE', 'https://github.com/GeopJr/tooth') +config.set_quoted('SUPPORT_WEBSITE', 'https://github.com/GeopJr/tooth/issues') +config.set_quoted('PROFILE', devel ? 'development' : 'production') if devel git = find_program('git') @@ -38,10 +31,18 @@ if devel branch = run_command('git', 'branch', '--show-current', check: true).stdout().strip() revision = run_command('git', 'rev-parse', '--short', 'HEAD', check: true).stdout().strip() version = '@0@-@1@'.format(branch, revision) - config.set('VERSION', version) + config.set_quoted('VERSION', version) endif endif +configure_file(output: 'config.h', configuration: config) + +add_project_arguments ( + '--include','config.h', + '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), + language: 'c' +) + gnome = import('gnome') i18n = import('i18n') @@ -56,110 +57,13 @@ libgtk_dep = dependency('gtk4', version: '>=4.0.0', required: true) libadwaita_dep = dependency('libadwaita-1', version: '>=1.2', required: true) sources = files( - 'src/API/Account.vala', - 'src/API/AccountField.vala', - 'src/API/Attachment.vala', - 'src/API/Conversation.vala', - 'src/API/Emoji.vala', - 'src/API/EmojiReaction.vala', - 'src/API/Entity.vala', - 'src/API/Instance.vala', - 'src/API/Instance/Mastodon/Configuration.vala', - 'src/API/Instance/Mastodon/Configuration/MediaAttachments.vala', - 'src/API/Instance/Mastodon/Configuration/Polls.vala', - 'src/API/Instance/Mastodon/Configuration/Reactions.vala', - 'src/API/Instance/Mastodon/Configuration/Statuses.vala', - 'src/API/List.vala', - 'src/API/Mention.vala', - 'src/API/Notification.vala', - 'src/API/Pleroma.vala', - 'src/API/Relationship.vala', - 'src/API/SearchResults.vala', - 'src/API/Status.vala', - 'src/API/Tag.vala', - 'src/API/TagHistory.vala', - 'src/API/Poll.vala', - 'src/API/PollOption.vala', - 'src/Application.vala', - 'src/Dialogs/Composer/AttachmentsPage.vala', - 'src/Dialogs/Composer/AttachmentsPageAttachment.vala', - 'src/Dialogs/Composer/Dialog.vala', - 'src/Dialogs/Composer/EditorPage.vala', - 'src/Dialogs/Composer/Page.vala', - 'src/Dialogs/Composer/PollPage.vala', - 'src/Dialogs/MainWindow.vala', - 'src/Dialogs/NewAccount.vala', - 'src/Dialogs/Preferences.vala', - 'src/Dialogs/Saveable.vala', - 'src/Services/Accounts/AccountHolder.vala', - 'src/Services/Accounts/AccountStore.vala', - 'src/Services/Accounts/InstanceAccount.vala', - 'src/Services/Accounts/Mastodon/Account.vala', - 'src/Services/Accounts/Places.vala', - 'src/Services/Accounts/SecretAccountStore.vala', - 'src/Services/Cache/AbstractCache.vala', - 'src/Services/Cache/EntityCache.vala', - 'src/Services/Cache/ImageCache.vala', - 'src/Services/Network/Network.vala', - 'src/Services/Network/Request.vala', - 'src/Services/Network/Streamable.vala', - 'src/Services/Network/Streams.vala', - 'src/Services/Settings.vala', - 'src/Utils/DateTime.vala', - 'src/Utils/Host.vala', - 'src/Utils/Html.vala', - 'src/Views/Base.vala', - 'src/Views/Bookmarks.vala', - 'src/Views/ContentBase.vala', - 'src/Views/Conversations.vala', - 'src/Views/EditHistory.vala', - 'src/Views/Favorites.vala', - 'src/Views/Federated.vala', - 'src/Views/Hashtag.vala', - 'src/Views/Home.vala', - 'src/Views/List.vala', - 'src/Views/Lists.vala', - 'src/Views/Local.vala', - 'src/Views/FollowRequests.vala', - 'src/Views/Main.vala', - 'src/Views/Notifications.vala', - 'src/Views/Profile.vala', - 'src/Views/Search.vala', - 'src/Views/Sidebar.vala', - 'src/Views/TabbedBase.vala', - 'src/Views/Thread.vala', - 'src/Views/Timeline.vala', - 'src/Widgets/Attachment/Box.vala', - 'src/Widgets/Attachment/Image.vala', - 'src/Widgets/Attachment/Item.vala', - 'src/Widgets/Avatar.vala', - 'src/Widgets/Background.vala', - 'src/Widgets/Conversation.vala', - 'src/Widgets/Emoji.vala', - 'src/Widgets/LockableToggleButton.vala', - 'src/Widgets/MarkupView.vala', - 'src/Widgets/Notification.vala', - 'src/Widgets/RelationshipButton.vala', - 'src/Widgets/RichLabel.vala', - 'src/Widgets/RichLabelContainer.vala', - 'src/Widgets/EmojiLabel.vala', - 'src/Widgets/Status.vala', - 'src/Widgets/StatusActionButton.vala', - 'src/Widgets/Widgetizable.vala', - 'src/Widgets/VoteBox.vala', - 'src/Widgets/VoteCheckButton.vala', -) - -build_file = configure_file( - input: 'src/Build.vala.in', - output: 'Build.vala', - configuration: config, + 'vapi/build.vapi', ) +subdir('src') executable( meson.project_name(), asresources, - build_file, sources, dependencies: [ dependency('glib-2.0', version: '>=2.70'), diff --git a/src/API/Instance/Mastodon/Configuration/meson.build b/src/API/Instance/Mastodon/Configuration/meson.build new file mode 100644 index 0000000..191ee8e --- /dev/null +++ b/src/API/Instance/Mastodon/Configuration/meson.build @@ -0,0 +1,6 @@ +sources += files( + 'MediaAttachments.vala', + 'Polls.vala', + 'Reactions.vala', + 'Statuses.vala', +) diff --git a/src/API/Instance/Mastodon/meson.build b/src/API/Instance/Mastodon/meson.build new file mode 100644 index 0000000..93e68c5 --- /dev/null +++ b/src/API/Instance/Mastodon/meson.build @@ -0,0 +1,5 @@ +sources += files( + 'Configuration.vala', +) + +subdir('Configuration') diff --git a/src/API/Instance/meson.build b/src/API/Instance/meson.build new file mode 100644 index 0000000..1d7dca2 --- /dev/null +++ b/src/API/Instance/meson.build @@ -0,0 +1 @@ +subdir('Mastodon') diff --git a/src/API/meson.build b/src/API/meson.build new file mode 100644 index 0000000..28a9862 --- /dev/null +++ b/src/API/meson.build @@ -0,0 +1,23 @@ +sources += files( + 'Account.vala', + 'AccountField.vala', + 'Attachment.vala', + 'Conversation.vala', + 'Emoji.vala', + 'EmojiReaction.vala', + 'Entity.vala', + 'Instance.vala', + 'List.vala', + 'Mention.vala', + 'Notification.vala', + 'Pleroma.vala', + 'Poll.vala', + 'PollOption.vala', + 'Relationship.vala', + 'SearchResults.vala', + 'Status.vala', + 'Tag.vala', + 'TagHistory.vala', +) + +subdir('Instance') diff --git a/src/Application.vala b/src/Application.vala index b9c642c..57c38aa 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -97,7 +97,10 @@ namespace Tooth { protected override void startup () { base.startup (); try { - Build.print_info (); + var lines = troubleshooting.split ("\n"); + foreach (unowned string line in lines) { + message (line); + } Adw.init (); settings = new Settings (); @@ -207,7 +210,9 @@ namespace Tooth { refresh (); } - string troubleshooting = "flatpak: %s\nversion: %s (%s)\ngtk: %u.%u.%u (%d.%d.%d)\nlibadwaita: %u.%u.%u (%d.%d.%d)\nlibsoup: %u.%u.%u (%d.%d.%d)\n".printf( + string troubleshooting = "os: %s %s\nprefix: %s\nflatpak: %s\nversion: %s (%s)\ngtk: %u.%u.%u (%d.%d.%d)\nlibadwaita: %u.%u.%u (%d.%d.%d)\nlibsoup: %u.%u.%u (%d.%d.%d)\n".printf( + GLib.Environment.get_os_info ("NAME"), GLib.Environment.get_os_info ("VERSION"), + Build.PREFIX, (GLib.Environment.get_variable("FLATPAK_ID") != null || GLib.File.new_for_path("/.flatpak-info").query_exists()).to_string(), Build.VERSION, Build.PROFILE, Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version(), @@ -219,15 +224,17 @@ namespace Tooth { ); void about_activated () { - const string[] artists = { + const string[] ARTISTS = { "Tobias Bernard" }; - const string[] developers = { + const string[] DEVELOPERS = { "bleak_grey", "Evangelos \"GeopJr\" Paterakis" }; + const string COPYRIGHT = "© 2022 bleak_grey\n© 2022 Evangelos \"GeopJr\" Paterakis"; + var dialog = new Adw.AboutWindow () { transient_for = main_window, modal = true, @@ -237,13 +244,13 @@ namespace Tooth { version = Build.VERSION, support_url = Build.SUPPORT_WEBSITE, license_type = License.GPL_3_0_ONLY, - copyright = Build.COPYRIGHT, - debug_info = Build.SYSTEM_INFO, - developers = developers, - artists = artists, + copyright = COPYRIGHT, + developers = DEVELOPERS, + artists = ARTISTS, debug_info = troubleshooting, debug_info_filename = @"$(Build.NAME).txt", - translator_credits = Build.TRANSLATOR != " " ? Build.TRANSLATOR : "" + // translators: Name or Name https://website.example + translator_credits = _("translator-credits") }; // For some obscure reason, const arrays produce duplicates in the credits. diff --git a/src/Build.vala.in b/src/Build.vala.in deleted file mode 100644 index b2885ce..0000000 --- a/src/Build.vala.in +++ /dev/null @@ -1,41 +0,0 @@ -public class Build { - - public const string NAME = "@NAME@"; - public const string VERSION = "@VERSION@"; - public const string DOMAIN = "@EXEC_NAME@"; - public const string RESOURCES = "@RESOURCES@"; - public const string WEBSITE = "@WEBSITE@"; - public const string SUPPORT_WEBSITE = "@SUPPORT_WEBSITE@"; - public const string COPYRIGHT = "@COPYRIGHT@"; - public const string PREFIX = "@PREFIX@"; - public const string PROFILE = "@PROFILE@"; - - public static string SYSTEM_INFO; - - // Please do not remove the credits below. You may add your own, but keep the existing ones intact. - - // TRANSLATORS: Replace this with your name. It will be displayed in the About dialog. - public const string TRANSLATOR = _(" "); - - public static string print_info () { - var os_name = get_os_info ("NAME"); - var os_ver = get_os_info ("VERSION"); - - SYSTEM_INFO = @"$NAME $VERSION"; - SYSTEM_INFO += @"\nRunning on: $os_name $os_ver"; - SYSTEM_INFO += @"\nBuild prefix: \"$PREFIX\""; - SYSTEM_INFO += @"\nBuild profile: \"$PROFILE\""; - - var lines = SYSTEM_INFO.split ("\n"); - foreach (unowned string line in lines) { - message (line); - } - - return SYSTEM_INFO; - } - - static string get_os_info (string key) { - return GLib.Environment.get_os_info (key) ?? "Unknown"; - } - -} diff --git a/src/Dialogs/Composer/meson.build b/src/Dialogs/Composer/meson.build new file mode 100644 index 0000000..9d5d524 --- /dev/null +++ b/src/Dialogs/Composer/meson.build @@ -0,0 +1,8 @@ +sources += files( + 'AttachmentsPage.vala', + 'AttachmentsPageAttachment.vala', + 'Dialog.vala', + 'EditorPage.vala', + 'Page.vala', + 'PollPage.vala', +) diff --git a/src/Dialogs/meson.build b/src/Dialogs/meson.build new file mode 100644 index 0000000..03fc7ae --- /dev/null +++ b/src/Dialogs/meson.build @@ -0,0 +1,8 @@ +sources += files( + 'MainWindow.vala', + 'NewAccount.vala', + 'Preferences.vala', + 'Saveable.vala', +) + +subdir('Composer') diff --git a/src/Services/Accounts/Mastodon/meson.build b/src/Services/Accounts/Mastodon/meson.build new file mode 100644 index 0000000..2a41693 --- /dev/null +++ b/src/Services/Accounts/Mastodon/meson.build @@ -0,0 +1,3 @@ +sources += files( + 'Account.vala', +) diff --git a/src/Services/Accounts/meson.build b/src/Services/Accounts/meson.build new file mode 100644 index 0000000..5875f09 --- /dev/null +++ b/src/Services/Accounts/meson.build @@ -0,0 +1,9 @@ +sources += files( + 'AccountHolder.vala', + 'AccountStore.vala', + 'InstanceAccount.vala', + 'Places.vala', + 'SecretAccountStore.vala', +) + +subdir('Mastodon') diff --git a/src/Services/Cache/meson.build b/src/Services/Cache/meson.build new file mode 100644 index 0000000..231d5ea --- /dev/null +++ b/src/Services/Cache/meson.build @@ -0,0 +1,5 @@ +sources += files( + 'AbstractCache.vala', + 'EntityCache.vala', + 'ImageCache.vala', +) diff --git a/src/Services/Network/meson.build b/src/Services/Network/meson.build new file mode 100644 index 0000000..55161e6 --- /dev/null +++ b/src/Services/Network/meson.build @@ -0,0 +1,6 @@ +sources += files( + 'Network.vala', + 'Request.vala', + 'Streamable.vala', + 'Streams.vala', +) diff --git a/src/Services/meson.build b/src/Services/meson.build new file mode 100644 index 0000000..4a8cce6 --- /dev/null +++ b/src/Services/meson.build @@ -0,0 +1,7 @@ +sources += files( + 'Settings.vala', +) + +subdir('Accounts') +subdir('Cache') +subdir('Network') diff --git a/src/Utils/meson.build b/src/Utils/meson.build new file mode 100644 index 0000000..bba2e74 --- /dev/null +++ b/src/Utils/meson.build @@ -0,0 +1,5 @@ +sources += files( + 'DateTime.vala', + 'Host.vala', + 'Html.vala', +) diff --git a/src/Views/meson.build b/src/Views/meson.build new file mode 100644 index 0000000..4175c97 --- /dev/null +++ b/src/Views/meson.build @@ -0,0 +1,23 @@ +sources += files( + 'Base.vala', + 'Bookmarks.vala', + 'ContentBase.vala', + 'Conversations.vala', + 'EditHistory.vala', + 'Favorites.vala', + 'Federated.vala', + 'FollowRequests.vala', + 'Hashtag.vala', + 'Home.vala', + 'List.vala', + 'Lists.vala', + 'Local.vala', + 'Main.vala', + 'Notifications.vala', + 'Profile.vala', + 'Search.vala', + 'Sidebar.vala', + 'TabbedBase.vala', + 'Thread.vala', + 'Timeline.vala', +) diff --git a/src/Widgets/Attachment/meson.build b/src/Widgets/Attachment/meson.build new file mode 100644 index 0000000..41b84a8 --- /dev/null +++ b/src/Widgets/Attachment/meson.build @@ -0,0 +1,5 @@ +sources += files( + 'Box.vala', + 'Image.vala', + 'Item.vala', +) diff --git a/src/Widgets/meson.build b/src/Widgets/meson.build new file mode 100644 index 0000000..8ea7c40 --- /dev/null +++ b/src/Widgets/meson.build @@ -0,0 +1,20 @@ +sources += files( + 'Avatar.vala', + 'Background.vala', + 'Conversation.vala', + 'Emoji.vala', + 'EmojiLabel.vala', + 'LockableToggleButton.vala', + 'MarkupView.vala', + 'Notification.vala', + 'RelationshipButton.vala', + 'RichLabel.vala', + 'RichLabelContainer.vala', + 'Status.vala', + 'StatusActionButton.vala', + 'VoteBox.vala', + 'VoteCheckButton.vala', + 'Widgetizable.vala', +) + +subdir('Attachment') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..4931ea0 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,8 @@ +sources += files('Application.vala') + +subdir('API') +subdir('Dialogs') +subdir('Services') +subdir('Utils') +subdir('Views') +subdir('Widgets') diff --git a/vapi/build.vapi b/vapi/build.vapi new file mode 100644 index 0000000..23b8313 --- /dev/null +++ b/vapi/build.vapi @@ -0,0 +1,12 @@ +[CCode (cprefix="", lower_case_cprefix = "", cheader_filename = "config.h")] +namespace Build { + public const string NAME; + public const string VERSION; + public const string DOMAIN; + public const string RESOURCES; + public const string PROFILE; + + public const string WEBSITE; + public const string SUPPORT_WEBSITE; + public const string PREFIX; +} \ No newline at end of file