From 6ce2373a75112d2ea4c76a7f68f41b05e4adfa57 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Sun, 7 Dec 2025 01:21:41 +0100 Subject: [PATCH] Create a config.vapi for config.h Currently, a lot of our build variables that are defined at configuration time, are spread out across the code base, often declared as `extern` which can break when moving around sections of the code across files. This commit introduces a "Config" namespace which basically maps to the definitions in `config.h`, but allows us to properly access them too from the Vala source code. By doing so, it helps us to more explicitly see where we rely on a build variable from this file (which should be obvious from the `Config' namespace). To make it ourselves a bit easier in Meson too, we can declare an internal dependency, which helps ensure that we pull in the dependency where needed. --- bindings/vapi/config.vapi | 26 +++++++ .../accounts/accounts-editor-list-pane.vala | 2 +- src/client/accounts/accounts-editor.vala | 2 +- .../application/application-client.vala | 73 +++++++------------ .../application/application-main-window.vala | 2 +- .../application-startup-manager.vala | 2 +- src/client/composer/composer-widget.vala | 2 +- src/client/meson.build | 2 +- .../desktop-notifications.vala | 2 +- .../plugin/desktop-notifications/meson.build | 3 +- src/client/plugin/email-templates/meson.build | 3 +- .../plugin/folder-highlight/meson.build | 3 +- src/client/plugin/mail-merge/meson.build | 3 - src/client/plugin/meson.build | 1 + src/client/plugin/messaging-menu/meson.build | 1 - .../plugin/notification-badge/meson.build | 3 +- .../notification-badge.vala | 2 +- src/client/plugin/sent-sound/meson.build | 3 +- src/client/plugin/special-folders/meson.build | 3 +- src/client/util/util-i18n.vala | 10 +-- src/client/util/util-migrate.vala | 4 +- src/console/main.vala | 4 +- src/console/meson.build | 2 +- src/engine/meson.build | 2 +- src/mailer/meson.build | 2 +- src/meson.build | 44 ++++++----- .../application/application-client-test.vala | 6 +- .../components-web-view-test-case.vala | 2 +- .../components/components-web-view-test.vala | 2 +- test/engine/api/geary-attachment-test.vala | 5 +- .../common-contact-store-impl-test.vala | 2 +- .../common/common-fts-search-query-test.vala | 2 +- test/engine/imap-db/imap-db-account-test.vala | 2 +- .../engine/imap-db/imap-db-database-test.vala | 6 +- test/engine/imap-db/imap-db-folder-test.vala | 6 +- .../imap-engine-generic-account-test.vala | 2 +- test/meson.build | 8 +- test/test-client.vala | 4 +- test/test-js.vala | 4 +- 39 files changed, 126 insertions(+), 131 deletions(-) create mode 100644 bindings/vapi/config.vapi diff --git a/bindings/vapi/config.vapi b/bindings/vapi/config.vapi new file mode 100644 index 00000000..487eaa79 --- /dev/null +++ b/bindings/vapi/config.vapi @@ -0,0 +1,26 @@ +/** + * This VAPI describes the contents of the config.h file, which is + * autogenerated by the build system. It contains the values for the specific + * build configuration. + */ +[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")] +namespace Config +{ + // Keep this list in sync with the config.h configuration_data() in meson + public const string GETTEXT_PACKAGE; + public const string G_LOG_DOMAIN; + public const string APP_ID; + public const string BUILD_ROOT_DIR; + public const string GSETTINGS_DIR; + public const string INSTALL_PREFIX; + public const string ISO_CODE_3166_XML; + public const string ISO_CODE_639_XML; + public const string LANGUAGE_SUPPORT_DIRECTORY; + public const string NAME_SUFFIX; + public const string PLUGINS_DIR; + public const string PROFILE; + public const string REVNO; + public const string SOURCE_ROOT_DIR; + public const string VERSION; + public const string WEB_EXTENSIONS_DIR; +} diff --git a/src/client/accounts/accounts-editor-list-pane.vala b/src/client/accounts/accounts-editor-list-pane.vala index f1ea439b..8cc55bd7 100644 --- a/src/client/accounts/accounts-editor-list-pane.vala +++ b/src/client/accounts/accounts-editor-list-pane.vala @@ -79,7 +79,7 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane { public EditorListPane(Editor editor) { this.editor = editor; - this.welcome_icon.icon_name = Application.Client.APP_ID; + this.welcome_icon.icon_name = Config.APP_ID; // keep our own copy of this so we can disconnect from its signals // without worrying about the editor's lifecycle diff --git a/src/client/accounts/accounts-editor.vala b/src/client/accounts/accounts-editor.vala index 65a6d493..e498a8b1 100644 --- a/src/client/accounts/accounts-editor.vala +++ b/src/client/accounts/accounts-editor.vala @@ -61,7 +61,7 @@ public class Accounts.Editor : Gtk.Dialog { public Editor(Application.Client application, Gtk.Window parent) { this.application = application; this.transient_for = parent; - this.icon_name = Application.Client.APP_ID; + this.icon_name = Config.APP_ID; this.accounts = application.controller.account_manager; this.certificates = application.controller.certificate_manager; diff --git a/src/client/application/application-client.vala b/src/client/application/application-client.vala index a0be4bf9..e12e868a 100644 --- a/src/client/application/application-client.vala +++ b/src/client/application/application-client.vala @@ -6,28 +6,13 @@ * (version 2.1 or later). See the COPYING file in this distribution. */ -// Defined by CMake build script. -extern const string GETTEXT_PACKAGE; -public extern const string _APP_ID; -public extern const string _BUILD_ROOT_DIR; -public extern const string _GSETTINGS_DIR; -public extern const string _INSTALL_PREFIX; -public extern const string _NAME_SUFFIX; -extern const string _PLUGINS_DIR; -extern const string _PROFILE; -extern const string _REVNO; -public extern const string _SOURCE_ROOT_DIR; -public extern const string _VERSION; -extern const string _WEB_EXTENSIONS_DIR; - /** * The client application's main point of entry and desktop integration. */ public class Application.Client : Gtk.Application { - public const string NAME = "Geary" + _NAME_SUFFIX; - public const string APP_ID = _APP_ID; + public const string NAME = "Geary" + Config.NAME_SUFFIX; public const string RESOURCE_BASE_PATH = "/org/gnome/Geary"; public const string SCHEMA_ID = "org.gnome.Geary"; public const string DESCRIPTION = _("Send and receive email"); @@ -37,12 +22,6 @@ public class Application.Client : Gtk.Application { public const string WEBSITE_LABEL = _("Visit the Geary web site"); public const string BUGREPORT = "https://wiki.gnome.org/Apps/Geary/ReportingABug"; - public const string VERSION = _VERSION; - public const string INSTALL_PREFIX = _INSTALL_PREFIX; - public const string GSETTINGS_DIR = _GSETTINGS_DIR; - public const string SOURCE_ROOT_DIR = _SOURCE_ROOT_DIR; - public const string BUILD_ROOT_DIR = _BUILD_ROOT_DIR; - // keep these in sync with meson_options.txt public const string PROFILE_RELEASE = "release"; public const string PROFILE_BETA = "beta"; @@ -240,7 +219,7 @@ public class Application.Client : Gtk.Application { /** Returns the compile-time configured installation directory. */ internal GLib.File install_prefix { - get; private set; default = GLib.File.new_for_path(INSTALL_PREFIX); + get; private set; default = GLib.File.new_for_path(Config.INSTALL_PREFIX); } @@ -264,9 +243,9 @@ public class Application.Client : Gtk.Application { new Gee.LinkedList(); /// Application runtime information label - info.add({ _("Geary version"), VERSION }); + info.add({ _("Geary version"), Config.VERSION }); /// Application runtime information label - info.add({ _("Geary revision"), _REVNO }); + info.add({ _("Geary revision"), Config.REVNO }); /// Application runtime information label info.add({ _("GTK version"), "%u.%u.%u".printf( @@ -307,7 +286,7 @@ public class Application.Client : Gtk.Application { }); /// Application runtime information label - info.add({ _("Installation prefix"), INSTALL_PREFIX }); + info.add({ _("Installation prefix"), Config.INSTALL_PREFIX }); return info; } @@ -315,7 +294,7 @@ public class Application.Client : Gtk.Application { public Client() { Object( - application_id: APP_ID, + application_id: Config.APP_ID, resource_base_path: RESOURCE_BASE_PATH, flags: ( GLib.ApplicationFlags.HANDLES_OPEN | @@ -350,7 +329,7 @@ public class Application.Client : Gtk.Application { } if (options.contains(OPTION_VERSION)) { GLib.stdout.printf( - "%s: %s\n", this.binary, Client.VERSION + "%s: %s\n", this.binary, Config.VERSION ); ret = 0; } @@ -359,11 +338,11 @@ public class Application.Client : Gtk.Application { public override void startup() { Environment.set_application_name(NAME); - Environment.set_prgname(APP_ID); - Util.I18n.init(GETTEXT_PACKAGE, this.binary); + Environment.set_prgname(Config.APP_ID); + Util.I18n.init(Config.GETTEXT_PACKAGE, this.binary); Util.Date.init(); - Configuration.init(this.is_installed, GSETTINGS_DIR); + Configuration.init(this.is_installed, Config.GSETTINGS_DIR); // Add application's actions before chaining up so they are // present when the application is first registered on the @@ -381,7 +360,7 @@ public class Application.Client : Gtk.Application { this.autostart = new StartupManager(this); // Ensure all geary windows have an icon - Gtk.Window.set_default_icon_name(APP_ID); + Gtk.Window.set_default_icon_name(Config.APP_ID); // Application accels add_app_accelerators(Action.Application.COMPOSE, { "N" }); @@ -562,8 +541,8 @@ public class Application.Client : Gtk.Application { "authors", AUTHORS, "copyright", string.join("\n", COPYRIGHT_1, COPYRIGHT_2), "license-type", Gtk.License.LGPL_2_1, - "logo-icon-name", APP_ID, - "version", _REVNO == "" ? VERSION : "%s (%s)".printf(VERSION, _REVNO), + "logo-icon-name", Config.APP_ID, + "version", Config.REVNO == "" ? Config.VERSION : "%s (%s)".printf(Config.VERSION, Config.REVNO), "website", WEBSITE, "website-label", WEBSITE_LABEL, "title", _("About %s").printf(NAME), @@ -794,14 +773,14 @@ public class Application.Client : Gtk.Application { public GLib.File get_resource_directory() { return (is_installed) ? this.install_prefix.get_child("share").get_child("geary") - : GLib.File.new_for_path(SOURCE_ROOT_DIR); + : GLib.File.new_for_path(Config.SOURCE_ROOT_DIR); } /** Returns the location of the application's desktop files. */ public GLib.File get_desktop_directory() { return (is_installed) ? this.install_prefix.get_child("share").get_child("applications") - : GLib.File.new_for_path(BUILD_ROOT_DIR).get_child("desktop"); + : GLib.File.new_for_path(Config.BUILD_ROOT_DIR).get_child("desktop"); } /** @@ -813,8 +792,8 @@ public class Application.Client : Gtk.Application { */ public GLib.File get_web_extensions_dir() { return (is_installed) - ? GLib.File.new_for_path(_WEB_EXTENSIONS_DIR) - : GLib.File.new_for_path(BUILD_ROOT_DIR).get_child("src"); + ? GLib.File.new_for_path(Config.WEB_EXTENSIONS_DIR) + : GLib.File.new_for_path(Config.BUILD_ROOT_DIR).get_child("src"); } /** @@ -826,8 +805,8 @@ public class Application.Client : Gtk.Application { */ public GLib.File get_app_plugins_dir() { return (is_installed) - ? GLib.File.new_for_path(_PLUGINS_DIR) - : GLib.File.new_for_path(BUILD_ROOT_DIR) + ? GLib.File.new_for_path(Config.PLUGINS_DIR) + : GLib.File.new_for_path(Config.BUILD_ROOT_DIR) .get_child("src").get_child("client").get_child("plugin"); } @@ -909,7 +888,7 @@ public class Application.Client : Gtk.Application { GLib.Notification error = new GLib.Notification(summary); error.set_body(body); error.set_icon( - new GLib.ThemedIcon("%s-symbolic".printf(Client.APP_ID)) + new GLib.ThemedIcon("%s-symbolic".printf(Config.APP_ID)) ); send_notification(ERROR_NOTIFICATION_ID, error); this.error_notification = error; @@ -966,9 +945,9 @@ public class Application.Client : Gtk.Application { message( "%s %s%s prefix=%s exec_dir=%s is_installed=%s", NAME, - VERSION, - _REVNO != "" ? " (%s)".printf(_REVNO) : "", - INSTALL_PREFIX, + Config.VERSION, + Config.REVNO != "" ? " (%s)".printf(Config.REVNO) : "", + Config.INSTALL_PREFIX, exec_dir.get_path(), this.is_installed.to_string() ); @@ -1159,9 +1138,9 @@ public class Application.Client : Gtk.Application { // separate directories since they have different app ids, and // hence don't need the suffix. return ( - _PROFILE == PROFILE_RELEASE || this.is_flatpak_sandboxed + Config.PROFILE == PROFILE_RELEASE || this.is_flatpak_sandboxed ? "geary" - : "geary-" + _PROFILE + : "geary-" + Config.PROFILE ); } @@ -1227,7 +1206,7 @@ public class Application.Client : Gtk.Application { File exec_dir = this.exec_dir; string[] argv = new string[3]; argv[0] = "yelp"; - argv[1] = Client.SOURCE_ROOT_DIR + "/help/C/"; + argv[1] = Config.SOURCE_ROOT_DIR + "/help/C/"; argv[2] = null; if (!Process.spawn_async( exec_dir.get_path(), diff --git a/src/client/application/application-main-window.vala b/src/client/application/application-main-window.vala index 4d8fac8c..9bdd8043 100644 --- a/src/client/application/application-main-window.vala +++ b/src/client/application/application-main-window.vala @@ -576,7 +576,7 @@ public class Application.MainWindow : load_config(application.config); restore_saved_window_state(); - if (_PROFILE != Client.PROFILE_RELEASE) { + if (Config.PROFILE != Client.PROFILE_RELEASE) { this.get_style_context().add_class("devel"); } diff --git a/src/client/application/application-startup-manager.vala b/src/client/application/application-startup-manager.vala index 1c89fee3..46110b65 100644 --- a/src/client/application/application-startup-manager.vala +++ b/src/client/application/application-startup-manager.vala @@ -79,7 +79,7 @@ public class Application.StartupManager : GLib.Object { options.insert("autostart", new GLib.Variant( "b", autostart)); options.insert("commandline", new GLib.Variant.strv(cmdline)); - var handle = background.request_background(_APP_ID, options); + var handle = background.request_background(Config.APP_ID, options); yield bus.get_proxy(BUS_NAME, handle); } catch (GLib.Error error) { warning("Failed to request to run in background: %s", error.message); diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala index eb6e4ce7..66a8c3e8 100644 --- a/src/client/composer/composer-widget.vala +++ b/src/client/composer/composer-widget.vala @@ -1318,7 +1318,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface { } // User-Agent - email.mailer = Environment.get_prgname() + "/" + Application.Client.VERSION; + email.mailer = Environment.get_prgname() + "/" + Config.VERSION; return email; } diff --git a/src/client/meson.build b/src/client/meson.build index e12d2e29..187e0e4e 100644 --- a/src/client/meson.build +++ b/src/client/meson.build @@ -152,6 +152,7 @@ client_vala_sources = files( ) client_dependencies = [ + config_dep, enchant, folks, gck, @@ -199,7 +200,6 @@ client_lib = shared_library( client_package, client_vala_sources + geary_resources, dependencies: client_dependencies, - include_directories: config_h_dir, vala_args: client_vala_args, c_args: geary_c_args, install: true, diff --git a/src/client/plugin/desktop-notifications/desktop-notifications.vala b/src/client/plugin/desktop-notifications/desktop-notifications.vala index 255e4ec7..6e7cee49 100644 --- a/src/client/plugin/desktop-notifications/desktop-notifications.vala +++ b/src/client/plugin/desktop-notifications/desktop-notifications.vala @@ -149,7 +149,7 @@ public class Plugin.DesktopNotifications : } private void notify_general(Folder folder, int total, int added) { - GLib.Icon icon = new GLib.ThemedIcon("%s-symbolic".printf(global::Application.Client.APP_ID)); + GLib.Icon icon = new GLib.ThemedIcon("%s-symbolic".printf(Config.APP_ID)); string title = to_notitication_title(folder.account, total); string body = ngettext( /// Notification body when multiple messages have been diff --git a/src/client/plugin/desktop-notifications/meson.build b/src/client/plugin/desktop-notifications/meson.build index 315f8242..6a8b28c3 100644 --- a/src/client/plugin/desktop-notifications/meson.build +++ b/src/client/plugin/desktop-notifications/meson.build @@ -9,7 +9,6 @@ shared_module( plugin_name, sources: plugin_src, dependencies: plugin_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, @@ -24,4 +23,4 @@ custom_target( command: msgfmt_plugin_cmd, install: true, install_dir: plugin_dest -) \ No newline at end of file +) diff --git a/src/client/plugin/email-templates/meson.build b/src/client/plugin/email-templates/meson.build index ecebaf45..dcb911fa 100644 --- a/src/client/plugin/email-templates/meson.build +++ b/src/client/plugin/email-templates/meson.build @@ -9,7 +9,6 @@ shared_module( plugin_name, sources: plugin_src, dependencies: plugin_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, @@ -24,4 +23,4 @@ custom_target( command: msgfmt_plugin_cmd, install: true, install_dir: plugin_dest -) \ No newline at end of file +) diff --git a/src/client/plugin/folder-highlight/meson.build b/src/client/plugin/folder-highlight/meson.build index 28e99720..7375c387 100644 --- a/src/client/plugin/folder-highlight/meson.build +++ b/src/client/plugin/folder-highlight/meson.build @@ -9,7 +9,6 @@ shared_module( plugin_name, sources: plugin_src, dependencies: plugin_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, @@ -24,4 +23,4 @@ custom_target( command: msgfmt_plugin_cmd, install: true, install_dir: plugin_dest -) \ No newline at end of file +) diff --git a/src/client/plugin/mail-merge/meson.build b/src/client/plugin/mail-merge/meson.build index 40209bd8..7e440422 100644 --- a/src/client/plugin/mail-merge/meson.build +++ b/src/client/plugin/mail-merge/meson.build @@ -23,7 +23,6 @@ lib = static_library( 'util', sources: lib_src, dependencies: plugin_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: false @@ -34,7 +33,6 @@ plugin = shared_module( sources: plugin_src, dependencies: plugin_dependencies, link_with: lib, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, @@ -56,7 +54,6 @@ plugin_test = executable( test_src, dependencies: plugin_dependencies + [ vala_unit_dep ], link_with: lib, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: false diff --git a/src/client/plugin/meson.build b/src/client/plugin/meson.build index 579de6a6..024e6506 100644 --- a/src/client/plugin/meson.build +++ b/src/client/plugin/meson.build @@ -4,6 +4,7 @@ # plugin_dependencies = [ + config_dep, folks, gdk, client_dep, diff --git a/src/client/plugin/messaging-menu/meson.build b/src/client/plugin/messaging-menu/meson.build index a14a582e..fc269b2c 100644 --- a/src/client/plugin/messaging-menu/meson.build +++ b/src/client/plugin/messaging-menu/meson.build @@ -28,7 +28,6 @@ if libmessagingmenu_dep.found() 'unity-' + plugin_name, sources: plugin_src, dependencies: messaging_menu_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, diff --git a/src/client/plugin/notification-badge/meson.build b/src/client/plugin/notification-badge/meson.build index 0e8457c1..e382be99 100644 --- a/src/client/plugin/notification-badge/meson.build +++ b/src/client/plugin/notification-badge/meson.build @@ -12,7 +12,6 @@ shared_module( plugin_name, sources: plugin_src, dependencies: plugin_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, @@ -27,4 +26,4 @@ custom_target( command: msgfmt_plugin_cmd, install: true, install_dir: plugin_dest -) \ No newline at end of file +) diff --git a/src/client/plugin/notification-badge/notification-badge.vala b/src/client/plugin/notification-badge/notification-badge.vala index 9a3e3e08..c0a438e7 100644 --- a/src/client/plugin/notification-badge/notification-badge.vala +++ b/src/client/plugin/notification-badge/notification-badge.vala @@ -54,7 +54,7 @@ public class Plugin.NotificationBadge : this.entry = new UnityLauncherEntry( connection, path + "/plugin/notificationbadge", - global::Application.Client.APP_ID + ".desktop" + Config.APP_ID + ".desktop" ); FolderStore folder_store = yield this.folders.get_folder_store(); diff --git a/src/client/plugin/sent-sound/meson.build b/src/client/plugin/sent-sound/meson.build index 9c91a8c8..4bd0953c 100644 --- a/src/client/plugin/sent-sound/meson.build +++ b/src/client/plugin/sent-sound/meson.build @@ -12,7 +12,6 @@ shared_module( plugin_name, sources: plugin_src, dependencies: send_sound_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, @@ -27,4 +26,4 @@ custom_target( command: msgfmt_plugin_cmd, install: true, install_dir: plugin_dest -) \ No newline at end of file +) diff --git a/src/client/plugin/special-folders/meson.build b/src/client/plugin/special-folders/meson.build index 8a6dabff..eb548cfc 100644 --- a/src/client/plugin/special-folders/meson.build +++ b/src/client/plugin/special-folders/meson.build @@ -9,7 +9,6 @@ shared_module( plugin_name, sources: plugin_src, dependencies: plugin_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: plugin_c_args, install: true, @@ -24,4 +23,4 @@ custom_target( command: msgfmt_plugin_cmd, install: true, install_dir: plugin_dest -) \ No newline at end of file +) diff --git a/src/client/util/util-i18n.vala b/src/client/util/util-i18n.vala index e57c444f..605d5aa1 100644 --- a/src/client/util/util-i18n.vala +++ b/src/client/util/util-i18n.vala @@ -6,10 +6,6 @@ * (version 2.1 or later). See the COPYING file in this distribution. */ -extern const string _LANGUAGE_SUPPORT_DIRECTORY; -extern const string _ISO_CODE_639_XML; -extern const string _ISO_CODE_3166_XML; - /** * Internationalisation support functions. */ @@ -29,7 +25,7 @@ namespace Util.I18n { // TODO: Geary should be able to use langpacks from the build directory private string get_langpack_dir_path(string program_path) { - return _LANGUAGE_SUPPORT_DIRECTORY; + return Config.LANGUAGE_SUPPORT_DIRECTORY; } /** @@ -151,7 +147,7 @@ namespace Util.I18n { if (language_names == null) { language_names = new HashTable(GLib.str_hash, GLib.str_equal); - unowned Xml.Doc doc = Xml.Parser.parse_file(_ISO_CODE_639_XML); + unowned Xml.Doc doc = Xml.Parser.parse_file(Config.ISO_CODE_639_XML); if (doc == null) { return null; } @@ -201,7 +197,7 @@ namespace Util.I18n { if (country_names == null) { country_names = new HashTable(GLib.str_hash, GLib.str_equal); - unowned Xml.Doc doc = Xml.Parser.parse_file(_ISO_CODE_3166_XML); + unowned Xml.Doc doc = Xml.Parser.parse_file(Config.ISO_CODE_3166_XML); if (doc == null) { return null; diff --git a/src/client/util/util-migrate.vala b/src/client/util/util-migrate.vala index 31109c45..111570f7 100644 --- a/src/client/util/util-migrate.vala +++ b/src/client/util/util-migrate.vala @@ -248,9 +248,9 @@ namespace Util.Migrate { public static void old_app_config(Settings newSettings, string old_app_id = OLD_APP_ID) { SettingsSchemaSource schemaSource = SettingsSchemaSource.get_default(); - if (Application.Client.GSETTINGS_DIR != null) { + if (Config.GSETTINGS_DIR != null) { try { - schemaSource = new SettingsSchemaSource.from_directory(Application.Client.GSETTINGS_DIR, null, false); + schemaSource = new SettingsSchemaSource.from_directory(Config.GSETTINGS_DIR, null, false); } catch (Error e) { // If it didn't work, do nothing (i.e. use the default GSettings dir) } diff --git a/src/console/main.vala b/src/console/main.vala index 01585986..39f4b0ca 100644 --- a/src/console/main.vala +++ b/src/console/main.vala @@ -5,8 +5,6 @@ n * Copyright 2016 Software Freedom Conservancy Inc. * (version 2.1 or later). See the COPYING file in this distribution. */ -extern const string _VERSION; - errordomain CommandException { USAGE, STATE @@ -415,7 +413,7 @@ class ImapConsole : Gtk.Window { Gee.HashMap fields = new Gee.HashMap(); fields.set("name", "geary-console"); - fields.set("version", _VERSION); + fields.set("version", Config.VERSION); this.cx.send_command( new Geary.Imap.IdCommand(fields, null) diff --git a/src/console/meson.build b/src/console/meson.build index 39864e10..0fe1b6f8 100644 --- a/src/console/meson.build +++ b/src/console/meson.build @@ -3,6 +3,7 @@ console_sources = files( ) console_dependencies = [ + config_dep, gtk, gee, gmime, @@ -13,7 +14,6 @@ console_dependencies = [ console = executable('geary-console', console_sources, dependencies: console_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: geary_c_args, ) diff --git a/src/engine/meson.build b/src/engine/meson.build index 2f42d7b0..3dcad53e 100644 --- a/src/engine/meson.build +++ b/src/engine/meson.build @@ -318,6 +318,7 @@ engine_sources = [ ] engine_dependencies = [ + config_dep, gee, gio, glib, @@ -374,7 +375,6 @@ endif engine_lib = static_library('geary-engine', engine_sources, dependencies: engine_dependencies, - include_directories: config_h_dir, vala_args: engine_vala_args, c_args: engine_c_args, ) diff --git a/src/mailer/meson.build b/src/mailer/meson.build index a01032b4..39f97bb5 100644 --- a/src/mailer/meson.build +++ b/src/mailer/meson.build @@ -3,6 +3,7 @@ mailer_sources = files( ) mailer_dependencies = [ + config_dep, gee, gmime, webkit2gtk, @@ -12,7 +13,6 @@ mailer_dependencies = [ mailer = executable('geary-mailer', mailer_sources, dependencies: mailer_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: geary_c_args, ) diff --git a/src/meson.build b/src/meson.build index 50f12cdd..52d6e1f8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,24 +1,31 @@ # Build source configuration -config_h_dir = include_directories('.') - conf = configuration_data() +# keep this in sync with config.vapi conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) conf.set_quoted('G_LOG_DOMAIN', meson.project_name()) -conf.set_quoted('_APP_ID', geary_id) -conf.set_quoted('_BUILD_ROOT_DIR', meson.project_build_root()) -conf.set_quoted('_GSETTINGS_DIR', meson.project_build_root() / 'desktop') -conf.set_quoted('_INSTALL_PREFIX', geary_prefix) -conf.set_quoted('_ISO_CODE_3166_XML', iso_3166_xml) -conf.set_quoted('_ISO_CODE_639_XML', iso_639_xml) -conf.set_quoted('_LANGUAGE_SUPPORT_DIRECTORY', locale_dir) -conf.set_quoted('_NAME_SUFFIX', name_suffix) -conf.set_quoted('_PLUGINS_DIR', plugins_dir) -conf.set_quoted('_PROFILE', profile) -conf.set_quoted('_REVNO', revno) -conf.set_quoted('_SOURCE_ROOT_DIR', meson.project_source_root()) -conf.set_quoted('_VERSION', geary_version) -conf.set_quoted('_WEB_EXTENSIONS_DIR', web_extensions_dir) -configure_file(output: 'config.h', configuration: conf) +conf.set_quoted('APP_ID', geary_id) +conf.set_quoted('BUILD_ROOT_DIR', meson.project_build_root()) +conf.set_quoted('GSETTINGS_DIR', meson.project_build_root() / 'desktop') +conf.set_quoted('INSTALL_PREFIX', geary_prefix) +conf.set_quoted('ISO_CODE_3166_XML', iso_3166_xml) +conf.set_quoted('ISO_CODE_639_XML', iso_639_xml) +conf.set_quoted('LANGUAGE_SUPPORT_DIRECTORY', locale_dir) +conf.set_quoted('NAME_SUFFIX', name_suffix) +conf.set_quoted('PLUGINS_DIR', plugins_dir) +conf.set_quoted('PROFILE', profile) +conf.set_quoted('REVNO', revno) +conf.set_quoted('SOURCE_ROOT_DIR', meson.project_source_root()) +conf.set_quoted('VERSION', geary_version) +conf.set_quoted('WEB_EXTENSIONS_DIR', web_extensions_dir) +config_h = configure_file(output: 'config.h', configuration: conf) + +config_dep = declare_dependency( + sources: config_h, + dependencies: [ + valac.find_library('config', dirs: vapi_dir), + ], + include_directories: include_directories('.'), +) # Common valac options geary_vala_args = [ @@ -68,12 +75,12 @@ web_process_sources = files( web_process = library('geary-web-process', web_process_sources, dependencies: [ + config_dep, engine_dep, gee, gmime, webkit2gtk_web_extension, ], - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: geary_c_args, install: true, @@ -158,6 +165,7 @@ foreach dep : valadoc_dependencies valadoc_dep_args += 'libhandy-1' endif endforeach +valadoc_dep_args += [ '--pkg', 'config' ] valadoc_dep_args += [ '--pkg', 'icu-uc' ] valadoc_dep_args += [ '--pkg', 'libstemmer' ] valadoc_dep_args += [ '--pkg', 'posix' ] diff --git a/test/client/application/application-client-test.vala b/test/client/application/application-client-test.vala index da2ff593..fdb5e7e4 100644 --- a/test/client/application/application-client-test.vala +++ b/test/client/application/application-client-test.vala @@ -27,7 +27,7 @@ class Application.ClientTest : TestCase { public void paths_when_installed() throws GLib.Error { string[] args = new string[] { - _INSTALL_PREFIX + "/bin/geary", + Config.INSTALL_PREFIX + "/bin/geary", // Specify this so the app doesn't actually attempt // to start up "-v" @@ -38,11 +38,11 @@ class Application.ClientTest : TestCase { assert_equal( this.test_article.get_resource_directory().get_path(), - _INSTALL_PREFIX + "/share/geary" + Config.INSTALL_PREFIX + "/share/geary" ); assert_equal( this.test_article.get_desktop_directory().get_path(), - _INSTALL_PREFIX + "/share/applications" + Config.INSTALL_PREFIX + "/share/applications" ); } diff --git a/test/client/components/components-web-view-test-case.vala b/test/client/components/components-web-view-test-case.vala index 8f8f92f7..5558889f 100644 --- a/test/client/components/components-web-view-test-case.vala +++ b/test/client/components/components-web-view-test-case.vala @@ -21,7 +21,7 @@ public abstract class Components.WebViewTestCase : TestCase { WebView.init_web_context( this.config, - File.new_for_path(_BUILD_ROOT_DIR).get_child("src"), + File.new_for_path(Config.BUILD_ROOT_DIR).get_child("src"), File.new_for_path("/tmp"), // XXX use something better here false // https://bugs.webkit.org/show_bug.cgi?id=213174 ); diff --git a/test/client/components/components-web-view-test.vala b/test/client/components/components-web-view-test.vala index 61d6340b..403576b5 100644 --- a/test/client/components/components-web-view-test.vala +++ b/test/client/components/components-web-view-test.vala @@ -20,7 +20,7 @@ public class Components.WebViewTest : TestCase { config.enable_debug = true; WebView.init_web_context( config, - File.new_for_path(_BUILD_ROOT_DIR).get_child("src"), + File.new_for_path(Config.BUILD_ROOT_DIR).get_child("src"), File.new_for_path("/tmp"), // XXX use something better here false // https://bugs.webkit.org/show_bug.cgi?id=213174 ); diff --git a/test/engine/api/geary-attachment-test.vala b/test/engine/api/geary-attachment-test.vala index 7859da28..ad50d258 100644 --- a/test/engine/api/geary-attachment-test.vala +++ b/test/engine/api/geary-attachment-test.vala @@ -5,9 +5,6 @@ * (version 2.1 or later). See the COPYING file in this distribution. */ -// Defined by CMake build script. -extern const string _SOURCE_ROOT_DIR; - class Geary.AttachmentTest : TestCase { private const string CONTENT_TYPE = "image/svg+xml"; @@ -64,7 +61,7 @@ class Geary.AttachmentTest : TestCase { this.default_type = Mime.ContentType.ATTACHMENT_DEFAULT; this.content_disposition = new Mime.ContentDisposition("attachment", null); - File source = File.new_for_path(_SOURCE_ROOT_DIR); + File source = File.new_for_path(Config.SOURCE_ROOT_DIR); this.file = source.get_child(FILE_PATH); } diff --git a/test/engine/common/common-contact-store-impl-test.vala b/test/engine/common/common-contact-store-impl-test.vala index 2cc8ec52..300f6eba 100644 --- a/test/engine/common/common-contact-store-impl-test.vala +++ b/test/engine/common/common-contact-store-impl-test.vala @@ -35,7 +35,7 @@ class Geary.ContactStoreImplTest : TestCase { this.db = new ImapDB.Database( db_file, - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql"), + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql"), attachments_dir, new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) diff --git a/test/engine/common/common-fts-search-query-test.vala b/test/engine/common/common-fts-search-query-test.vala index 790f8995..c8583b41 100644 --- a/test/engine/common/common-fts-search-query-test.vala +++ b/test/engine/common/common-fts-search-query-test.vala @@ -38,7 +38,7 @@ public class Geary.FtsSearchQueryTest : TestCase { this.account = new ImapDB.Account( config, this.tmp_dir, - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql") + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql") ); this.account.open_async.begin( null, diff --git a/test/engine/imap-db/imap-db-account-test.vala b/test/engine/imap-db/imap-db-account-test.vala index 9d699fc3..a99d16cf 100644 --- a/test/engine/imap-db/imap-db-account-test.vala +++ b/test/engine/imap-db/imap-db-account-test.vala @@ -44,7 +44,7 @@ class Geary.ImapDB.AccountTest : TestCase { this.account = new Account( config, this.tmp_dir, - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql") + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql") ); this.account.open_async.begin( null, diff --git a/test/engine/imap-db/imap-db-database-test.vala b/test/engine/imap-db/imap-db-database-test.vala index f7e00f8c..2e5ff787 100644 --- a/test/engine/imap-db/imap-db-database-test.vala +++ b/test/engine/imap-db/imap-db-database-test.vala @@ -34,7 +34,7 @@ class Geary.ImapDB.DatabaseTest : TestCase { public void open_new() throws Error { Database db = new Database( this.tmp_dir.get_child("test.db"), - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql"), + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql"), this.tmp_dir.get_child("attachments"), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) @@ -94,7 +94,7 @@ class Geary.ImapDB.DatabaseTest : TestCase { Database db = new Database( db_file, - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql"), + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql"), attachments_dir, new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) @@ -128,7 +128,7 @@ class Geary.ImapDB.DatabaseTest : TestCase { public void utf8_case_insensitive_collation() throws GLib.Error { Database db = new Database( this.tmp_dir.get_child("test.db"), - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql"), + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql"), this.tmp_dir.get_child("attachments"), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) diff --git a/test/engine/imap-db/imap-db-folder-test.vala b/test/engine/imap-db/imap-db-folder-test.vala index bce1fb43..c9497906 100644 --- a/test/engine/imap-db/imap-db-folder-test.vala +++ b/test/engine/imap-db/imap-db-folder-test.vala @@ -44,7 +44,7 @@ class Geary.ImapDB.FolderTest : TestCase { this.account = new Account( config, this.tmp_dir, - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql") + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql") ); this.account.open_async.begin( null, @@ -375,8 +375,8 @@ class Geary.ImapDB.FolderTest : TestCase { beyond_threshold.to_unix().to_string()) ); this.account.db.exec( - "INSERT INTO MessageLocationTable " + - " (id, message_id, folder_id, ordering, remove_marker) " + + "INSERT INTO MessageLocationTable " + + " (id, message_id, folder_id, ordering, remove_marker) " + "VALUES (%d, %d, 1, %d, 1);".printf(i, i, i) ); } diff --git a/test/engine/imap-engine/imap-engine-generic-account-test.vala b/test/engine/imap-engine/imap-engine-generic-account-test.vala index 6bc8246a..faa59746 100644 --- a/test/engine/imap-engine/imap-engine-generic-account-test.vala +++ b/test/engine/imap-engine/imap-engine-generic-account-test.vala @@ -55,7 +55,7 @@ public class Geary.ImapEngine.GenericAccountTest : TestCase { this.local_account = new ImapDB.Account( config, this.tmp_dir, - GLib.File.new_for_path(_SOURCE_ROOT_DIR).get_child("sql") + GLib.File.new_for_path(Config.SOURCE_ROOT_DIR).get_child("sql") ); this.local_account.open_async.begin(null, this.async_completion); this.local_account.open_async.end(async_result()); diff --git a/test/meson.build b/test/meson.build index ff7479a7..17903a65 100644 --- a/test/meson.build +++ b/test/meson.build @@ -125,6 +125,7 @@ test_integration_sources = [ # Engine tests test_engine_dependencies = [ + config_dep, engine_internal_dep, vala_unit_dep, ] @@ -142,7 +143,6 @@ endif test_engine_bin = executable('test-engine', test_engine_sources + libmock_sources, dependencies: test_engine_dependencies, - include_directories: config_h_dir, vala_args: test_engine_vala_args, c_args: geary_c_args, ) @@ -150,6 +150,7 @@ test_engine_bin = executable('test-engine', # Client tests test_client_dependencies = [ + config_dep, client_internal_dep, vala_unit_dep, ] @@ -158,13 +159,13 @@ test_client_dependencies += client_dependencies test_client_bin = executable('test-client', test_client_sources + libmock_sources, dependencies: test_client_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: geary_c_args, build_rpath: client_build_dir, ) test_js_dependencies = [ + config_dep, client_internal_dep, vala_unit_dep, ] @@ -173,7 +174,6 @@ test_js_dependencies += client_dependencies test_js_bin = executable('test-js', test_js_sources + libmock_sources, dependencies: test_js_dependencies, - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: geary_c_args, build_rpath: client_build_dir, @@ -184,6 +184,7 @@ test_js_bin = executable('test-js', test_integration_bin = executable('test-integration', test_integration_sources, dependencies: [ + config_dep, engine_dep, gee, gio, @@ -191,7 +192,6 @@ test_integration_bin = executable('test-integration', vala_unit_dep, webkit2gtk, ], - include_directories: config_h_dir, vala_args: geary_vala_args, c_args: geary_c_args, ) diff --git a/test/test-client.vala b/test/test-client.vala index af80942f..66b60665 100644 --- a/test/test-client.vala +++ b/test/test-client.vala @@ -16,7 +16,7 @@ int main(string[] args) { Environment.set_variable("GSETTINGS_BACKEND", "memory", true); // Let GSettings know where to find the dev schema - Environment.set_variable("GSETTINGS_SCHEMA_DIR", _GSETTINGS_DIR, true); + Environment.set_variable("GSETTINGS_SCHEMA_DIR", Config.GSETTINGS_DIR, true); /* * Initialise all the things. @@ -27,7 +27,7 @@ int main(string[] args) { Gtk.init(ref args); Test.init(ref args); - IconFactory.init(GLib.File.new_for_path(_SOURCE_ROOT_DIR)); + IconFactory.init(GLib.File.new_for_path(Config.SOURCE_ROOT_DIR)); Geary.RFC822.init(); Geary.HTML.init(); Geary.Logging.init(); diff --git a/test/test-js.vala b/test/test-js.vala index 20388d92..7aa4fb1a 100644 --- a/test/test-js.vala +++ b/test/test-js.vala @@ -16,7 +16,7 @@ int main(string[] args) { Environment.set_variable("GSETTINGS_BACKEND", "memory", true); // Let GSettings know where to find the dev schema - Environment.set_variable("GSETTINGS_SCHEMA_DIR", _GSETTINGS_DIR, true); + Environment.set_variable("GSETTINGS_SCHEMA_DIR", Config.GSETTINGS_DIR, true); /* * Initialise all the things. @@ -27,7 +27,7 @@ int main(string[] args) { Gtk.init(ref args); Test.init(ref args); - IconFactory.init(GLib.File.new_for_path(_SOURCE_ROOT_DIR)); + IconFactory.init(GLib.File.new_for_path(Config.SOURCE_ROOT_DIR)); Geary.RFC822.init(); Geary.HTML.init(); Geary.Logging.init();