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.
This commit is contained in:
Niels De Graef 2025-12-07 01:21:41 +01:00
parent dc14aa091c
commit 6ce2373a75
39 changed files with 126 additions and 131 deletions

26
bindings/vapi/config.vapi Normal file
View file

@ -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;
}

View file

@ -79,7 +79,7 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane {
public EditorListPane(Editor editor) { public EditorListPane(Editor editor) {
this.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 // keep our own copy of this so we can disconnect from its signals
// without worrying about the editor's lifecycle // without worrying about the editor's lifecycle

View file

@ -61,7 +61,7 @@ public class Accounts.Editor : Gtk.Dialog {
public Editor(Application.Client application, Gtk.Window parent) { public Editor(Application.Client application, Gtk.Window parent) {
this.application = application; this.application = application;
this.transient_for = parent; this.transient_for = parent;
this.icon_name = Application.Client.APP_ID; this.icon_name = Config.APP_ID;
this.accounts = application.controller.account_manager; this.accounts = application.controller.account_manager;
this.certificates = application.controller.certificate_manager; this.certificates = application.controller.certificate_manager;

View file

@ -6,28 +6,13 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (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. * The client application's main point of entry and desktop integration.
*/ */
public class Application.Client : Gtk.Application { public class Application.Client : Gtk.Application {
public const string NAME = "Geary" + _NAME_SUFFIX; public const string NAME = "Geary" + Config.NAME_SUFFIX;
public const string APP_ID = _APP_ID;
public const string RESOURCE_BASE_PATH = "/org/gnome/Geary"; public const string RESOURCE_BASE_PATH = "/org/gnome/Geary";
public const string SCHEMA_ID = "org.gnome.Geary"; public const string SCHEMA_ID = "org.gnome.Geary";
public const string DESCRIPTION = _("Send and receive email"); 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 WEBSITE_LABEL = _("Visit the Geary web site");
public const string BUGREPORT = "https://wiki.gnome.org/Apps/Geary/ReportingABug"; 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 // keep these in sync with meson_options.txt
public const string PROFILE_RELEASE = "release"; public const string PROFILE_RELEASE = "release";
public const string PROFILE_BETA = "beta"; public const string PROFILE_BETA = "beta";
@ -240,7 +219,7 @@ public class Application.Client : Gtk.Application {
/** Returns the compile-time configured installation directory. */ /** Returns the compile-time configured installation directory. */
internal GLib.File install_prefix { 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<RuntimeDetail?>(); new Gee.LinkedList<RuntimeDetail?>();
/// Application runtime information label /// Application runtime information label
info.add({ _("Geary version"), VERSION }); info.add({ _("Geary version"), Config.VERSION });
/// Application runtime information label /// Application runtime information label
info.add({ _("Geary revision"), _REVNO }); info.add({ _("Geary revision"), Config.REVNO });
/// Application runtime information label /// Application runtime information label
info.add({ _("GTK version"), info.add({ _("GTK version"),
"%u.%u.%u".printf( "%u.%u.%u".printf(
@ -307,7 +286,7 @@ public class Application.Client : Gtk.Application {
}); });
/// Application runtime information label /// Application runtime information label
info.add({ _("Installation prefix"), INSTALL_PREFIX }); info.add({ _("Installation prefix"), Config.INSTALL_PREFIX });
return info; return info;
} }
@ -315,7 +294,7 @@ public class Application.Client : Gtk.Application {
public Client() { public Client() {
Object( Object(
application_id: APP_ID, application_id: Config.APP_ID,
resource_base_path: RESOURCE_BASE_PATH, resource_base_path: RESOURCE_BASE_PATH,
flags: ( flags: (
GLib.ApplicationFlags.HANDLES_OPEN | GLib.ApplicationFlags.HANDLES_OPEN |
@ -350,7 +329,7 @@ public class Application.Client : Gtk.Application {
} }
if (options.contains(OPTION_VERSION)) { if (options.contains(OPTION_VERSION)) {
GLib.stdout.printf( GLib.stdout.printf(
"%s: %s\n", this.binary, Client.VERSION "%s: %s\n", this.binary, Config.VERSION
); );
ret = 0; ret = 0;
} }
@ -359,11 +338,11 @@ public class Application.Client : Gtk.Application {
public override void startup() { public override void startup() {
Environment.set_application_name(NAME); Environment.set_application_name(NAME);
Environment.set_prgname(APP_ID); Environment.set_prgname(Config.APP_ID);
Util.I18n.init(GETTEXT_PACKAGE, this.binary); Util.I18n.init(Config.GETTEXT_PACKAGE, this.binary);
Util.Date.init(); 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 // Add application's actions before chaining up so they are
// present when the application is first registered on the // present when the application is first registered on the
@ -381,7 +360,7 @@ public class Application.Client : Gtk.Application {
this.autostart = new StartupManager(this); this.autostart = new StartupManager(this);
// Ensure all geary windows have an icon // 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 // Application accels
add_app_accelerators(Action.Application.COMPOSE, { "<Ctrl>N" }); add_app_accelerators(Action.Application.COMPOSE, { "<Ctrl>N" });
@ -562,8 +541,8 @@ public class Application.Client : Gtk.Application {
"authors", AUTHORS, "authors", AUTHORS,
"copyright", string.join("\n", COPYRIGHT_1, COPYRIGHT_2), "copyright", string.join("\n", COPYRIGHT_1, COPYRIGHT_2),
"license-type", Gtk.License.LGPL_2_1, "license-type", Gtk.License.LGPL_2_1,
"logo-icon-name", APP_ID, "logo-icon-name", Config.APP_ID,
"version", _REVNO == "" ? VERSION : "%s (%s)".printf(VERSION, _REVNO), "version", Config.REVNO == "" ? Config.VERSION : "%s (%s)".printf(Config.VERSION, Config.REVNO),
"website", WEBSITE, "website", WEBSITE,
"website-label", WEBSITE_LABEL, "website-label", WEBSITE_LABEL,
"title", _("About %s").printf(NAME), "title", _("About %s").printf(NAME),
@ -794,14 +773,14 @@ public class Application.Client : Gtk.Application {
public GLib.File get_resource_directory() { public GLib.File get_resource_directory() {
return (is_installed) return (is_installed)
? this.install_prefix.get_child("share").get_child("geary") ? 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. */ /** Returns the location of the application's desktop files. */
public GLib.File get_desktop_directory() { public GLib.File get_desktop_directory() {
return (is_installed) return (is_installed)
? this.install_prefix.get_child("share").get_child("applications") ? 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() { public GLib.File get_web_extensions_dir() {
return (is_installed) return (is_installed)
? GLib.File.new_for_path(_WEB_EXTENSIONS_DIR) ? GLib.File.new_for_path(Config.WEB_EXTENSIONS_DIR)
: GLib.File.new_for_path(BUILD_ROOT_DIR).get_child("src"); : 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() { public GLib.File get_app_plugins_dir() {
return (is_installed) return (is_installed)
? GLib.File.new_for_path(_PLUGINS_DIR) ? GLib.File.new_for_path(Config.PLUGINS_DIR)
: GLib.File.new_for_path(BUILD_ROOT_DIR) : GLib.File.new_for_path(Config.BUILD_ROOT_DIR)
.get_child("src").get_child("client").get_child("plugin"); .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); GLib.Notification error = new GLib.Notification(summary);
error.set_body(body); error.set_body(body);
error.set_icon( 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); send_notification(ERROR_NOTIFICATION_ID, error);
this.error_notification = error; this.error_notification = error;
@ -966,9 +945,9 @@ public class Application.Client : Gtk.Application {
message( message(
"%s %s%s prefix=%s exec_dir=%s is_installed=%s", "%s %s%s prefix=%s exec_dir=%s is_installed=%s",
NAME, NAME,
VERSION, Config.VERSION,
_REVNO != "" ? " (%s)".printf(_REVNO) : "", Config.REVNO != "" ? " (%s)".printf(Config.REVNO) : "",
INSTALL_PREFIX, Config.INSTALL_PREFIX,
exec_dir.get_path(), exec_dir.get_path(),
this.is_installed.to_string() this.is_installed.to_string()
); );
@ -1159,9 +1138,9 @@ public class Application.Client : Gtk.Application {
// separate directories since they have different app ids, and // separate directories since they have different app ids, and
// hence don't need the suffix. // hence don't need the suffix.
return ( return (
_PROFILE == PROFILE_RELEASE || this.is_flatpak_sandboxed Config.PROFILE == PROFILE_RELEASE || this.is_flatpak_sandboxed
? "geary" ? "geary"
: "geary-" + _PROFILE : "geary-" + Config.PROFILE
); );
} }
@ -1227,7 +1206,7 @@ public class Application.Client : Gtk.Application {
File exec_dir = this.exec_dir; File exec_dir = this.exec_dir;
string[] argv = new string[3]; string[] argv = new string[3];
argv[0] = "yelp"; argv[0] = "yelp";
argv[1] = Client.SOURCE_ROOT_DIR + "/help/C/"; argv[1] = Config.SOURCE_ROOT_DIR + "/help/C/";
argv[2] = null; argv[2] = null;
if (!Process.spawn_async( if (!Process.spawn_async(
exec_dir.get_path(), exec_dir.get_path(),

View file

@ -576,7 +576,7 @@ public class Application.MainWindow :
load_config(application.config); load_config(application.config);
restore_saved_window_state(); restore_saved_window_state();
if (_PROFILE != Client.PROFILE_RELEASE) { if (Config.PROFILE != Client.PROFILE_RELEASE) {
this.get_style_context().add_class("devel"); this.get_style_context().add_class("devel");
} }

View file

@ -79,7 +79,7 @@ public class Application.StartupManager : GLib.Object {
options.insert("autostart", new GLib.Variant( options.insert("autostart", new GLib.Variant(
"b", autostart)); "b", autostart));
options.insert("commandline", new GLib.Variant.strv(cmdline)); 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<portal.Request>(BUS_NAME, handle); yield bus.get_proxy<portal.Request>(BUS_NAME, handle);
} catch (GLib.Error error) { } catch (GLib.Error error) {
warning("Failed to request to run in background: %s", error.message); warning("Failed to request to run in background: %s", error.message);

View file

@ -1318,7 +1318,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
} }
// User-Agent // User-Agent
email.mailer = Environment.get_prgname() + "/" + Application.Client.VERSION; email.mailer = Environment.get_prgname() + "/" + Config.VERSION;
return email; return email;
} }

View file

@ -152,6 +152,7 @@ client_vala_sources = files(
) )
client_dependencies = [ client_dependencies = [
config_dep,
enchant, enchant,
folks, folks,
gck, gck,
@ -199,7 +200,6 @@ client_lib = shared_library(
client_package, client_package,
client_vala_sources + geary_resources, client_vala_sources + geary_resources,
dependencies: client_dependencies, dependencies: client_dependencies,
include_directories: config_h_dir,
vala_args: client_vala_args, vala_args: client_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
install: true, install: true,

View file

@ -149,7 +149,7 @@ public class Plugin.DesktopNotifications :
} }
private void notify_general(Folder folder, int total, int added) { 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 title = to_notitication_title(folder.account, total);
string body = ngettext( string body = ngettext(
/// Notification body when multiple messages have been /// Notification body when multiple messages have been

View file

@ -9,7 +9,6 @@ shared_module(
plugin_name, plugin_name,
sources: plugin_src, sources: plugin_src,
dependencies: plugin_dependencies, dependencies: plugin_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,
@ -24,4 +23,4 @@ custom_target(
command: msgfmt_plugin_cmd, command: msgfmt_plugin_cmd,
install: true, install: true,
install_dir: plugin_dest install_dir: plugin_dest
) )

View file

@ -9,7 +9,6 @@ shared_module(
plugin_name, plugin_name,
sources: plugin_src, sources: plugin_src,
dependencies: plugin_dependencies, dependencies: plugin_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,
@ -24,4 +23,4 @@ custom_target(
command: msgfmt_plugin_cmd, command: msgfmt_plugin_cmd,
install: true, install: true,
install_dir: plugin_dest install_dir: plugin_dest
) )

View file

@ -9,7 +9,6 @@ shared_module(
plugin_name, plugin_name,
sources: plugin_src, sources: plugin_src,
dependencies: plugin_dependencies, dependencies: plugin_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,
@ -24,4 +23,4 @@ custom_target(
command: msgfmt_plugin_cmd, command: msgfmt_plugin_cmd,
install: true, install: true,
install_dir: plugin_dest install_dir: plugin_dest
) )

View file

@ -23,7 +23,6 @@ lib = static_library(
'util', 'util',
sources: lib_src, sources: lib_src,
dependencies: plugin_dependencies, dependencies: plugin_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: false install: false
@ -34,7 +33,6 @@ plugin = shared_module(
sources: plugin_src, sources: plugin_src,
dependencies: plugin_dependencies, dependencies: plugin_dependencies,
link_with: lib, link_with: lib,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,
@ -56,7 +54,6 @@ plugin_test = executable(
test_src, test_src,
dependencies: plugin_dependencies + [ vala_unit_dep ], dependencies: plugin_dependencies + [ vala_unit_dep ],
link_with: lib, link_with: lib,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: false install: false

View file

@ -4,6 +4,7 @@
# #
plugin_dependencies = [ plugin_dependencies = [
config_dep,
folks, folks,
gdk, gdk,
client_dep, client_dep,

View file

@ -28,7 +28,6 @@ if libmessagingmenu_dep.found()
'unity-' + plugin_name, 'unity-' + plugin_name,
sources: plugin_src, sources: plugin_src,
dependencies: messaging_menu_dependencies, dependencies: messaging_menu_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,

View file

@ -12,7 +12,6 @@ shared_module(
plugin_name, plugin_name,
sources: plugin_src, sources: plugin_src,
dependencies: plugin_dependencies, dependencies: plugin_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,
@ -27,4 +26,4 @@ custom_target(
command: msgfmt_plugin_cmd, command: msgfmt_plugin_cmd,
install: true, install: true,
install_dir: plugin_dest install_dir: plugin_dest
) )

View file

@ -54,7 +54,7 @@ public class Plugin.NotificationBadge :
this.entry = new UnityLauncherEntry( this.entry = new UnityLauncherEntry(
connection, connection,
path + "/plugin/notificationbadge", path + "/plugin/notificationbadge",
global::Application.Client.APP_ID + ".desktop" Config.APP_ID + ".desktop"
); );
FolderStore folder_store = yield this.folders.get_folder_store(); FolderStore folder_store = yield this.folders.get_folder_store();

View file

@ -12,7 +12,6 @@ shared_module(
plugin_name, plugin_name,
sources: plugin_src, sources: plugin_src,
dependencies: send_sound_dependencies, dependencies: send_sound_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,
@ -27,4 +26,4 @@ custom_target(
command: msgfmt_plugin_cmd, command: msgfmt_plugin_cmd,
install: true, install: true,
install_dir: plugin_dest install_dir: plugin_dest
) )

View file

@ -9,7 +9,6 @@ shared_module(
plugin_name, plugin_name,
sources: plugin_src, sources: plugin_src,
dependencies: plugin_dependencies, dependencies: plugin_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: plugin_c_args, c_args: plugin_c_args,
install: true, install: true,
@ -24,4 +23,4 @@ custom_target(
command: msgfmt_plugin_cmd, command: msgfmt_plugin_cmd,
install: true, install: true,
install_dir: plugin_dest install_dir: plugin_dest
) )

View file

@ -6,10 +6,6 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (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. * Internationalisation support functions.
*/ */
@ -29,7 +25,7 @@ namespace Util.I18n {
// TODO: Geary should be able to use langpacks from the build directory // TODO: Geary should be able to use langpacks from the build directory
private string get_langpack_dir_path(string program_path) { 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) { if (language_names == null) {
language_names = new HashTable<string, string>(GLib.str_hash, GLib.str_equal); language_names = new HashTable<string, string>(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) { if (doc == null) {
return null; return null;
} }
@ -201,7 +197,7 @@ namespace Util.I18n {
if (country_names == null) { if (country_names == null) {
country_names = new HashTable<string, string>(GLib.str_hash, GLib.str_equal); country_names = new HashTable<string, string>(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) { if (doc == null) {
return null; return null;

View file

@ -248,9 +248,9 @@ namespace Util.Migrate {
public static void old_app_config(Settings newSettings, string old_app_id = OLD_APP_ID) { public static void old_app_config(Settings newSettings, string old_app_id = OLD_APP_ID) {
SettingsSchemaSource schemaSource = SettingsSchemaSource.get_default(); SettingsSchemaSource schemaSource = SettingsSchemaSource.get_default();
if (Application.Client.GSETTINGS_DIR != null) { if (Config.GSETTINGS_DIR != null) {
try { 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) { } catch (Error e) {
// If it didn't work, do nothing (i.e. use the default GSettings dir) // If it didn't work, do nothing (i.e. use the default GSettings dir)
} }

View file

@ -5,8 +5,6 @@ n * Copyright 2016 Software Freedom Conservancy Inc.
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
extern const string _VERSION;
errordomain CommandException { errordomain CommandException {
USAGE, USAGE,
STATE STATE
@ -415,7 +413,7 @@ class ImapConsole : Gtk.Window {
Gee.HashMap<string, string> fields = new Gee.HashMap<string, string>(); Gee.HashMap<string, string> fields = new Gee.HashMap<string, string>();
fields.set("name", "geary-console"); fields.set("name", "geary-console");
fields.set("version", _VERSION); fields.set("version", Config.VERSION);
this.cx.send_command( this.cx.send_command(
new Geary.Imap.IdCommand(fields, null) new Geary.Imap.IdCommand(fields, null)

View file

@ -3,6 +3,7 @@ console_sources = files(
) )
console_dependencies = [ console_dependencies = [
config_dep,
gtk, gtk,
gee, gee,
gmime, gmime,
@ -13,7 +14,6 @@ console_dependencies = [
console = executable('geary-console', console = executable('geary-console',
console_sources, console_sources,
dependencies: console_dependencies, dependencies: console_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
) )

View file

@ -318,6 +318,7 @@ engine_sources = [
] ]
engine_dependencies = [ engine_dependencies = [
config_dep,
gee, gee,
gio, gio,
glib, glib,
@ -374,7 +375,6 @@ endif
engine_lib = static_library('geary-engine', engine_lib = static_library('geary-engine',
engine_sources, engine_sources,
dependencies: engine_dependencies, dependencies: engine_dependencies,
include_directories: config_h_dir,
vala_args: engine_vala_args, vala_args: engine_vala_args,
c_args: engine_c_args, c_args: engine_c_args,
) )

View file

@ -3,6 +3,7 @@ mailer_sources = files(
) )
mailer_dependencies = [ mailer_dependencies = [
config_dep,
gee, gee,
gmime, gmime,
webkit2gtk, webkit2gtk,
@ -12,7 +13,6 @@ mailer_dependencies = [
mailer = executable('geary-mailer', mailer = executable('geary-mailer',
mailer_sources, mailer_sources,
dependencies: mailer_dependencies, dependencies: mailer_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
) )

View file

@ -1,24 +1,31 @@
# Build source configuration # Build source configuration
config_h_dir = include_directories('.')
conf = configuration_data() conf = configuration_data()
# keep this in sync with config.vapi
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf.set_quoted('G_LOG_DOMAIN', meson.project_name()) conf.set_quoted('G_LOG_DOMAIN', meson.project_name())
conf.set_quoted('_APP_ID', geary_id) conf.set_quoted('APP_ID', geary_id)
conf.set_quoted('_BUILD_ROOT_DIR', meson.project_build_root()) conf.set_quoted('BUILD_ROOT_DIR', meson.project_build_root())
conf.set_quoted('_GSETTINGS_DIR', meson.project_build_root() / 'desktop') conf.set_quoted('GSETTINGS_DIR', meson.project_build_root() / 'desktop')
conf.set_quoted('_INSTALL_PREFIX', geary_prefix) conf.set_quoted('INSTALL_PREFIX', geary_prefix)
conf.set_quoted('_ISO_CODE_3166_XML', iso_3166_xml) conf.set_quoted('ISO_CODE_3166_XML', iso_3166_xml)
conf.set_quoted('_ISO_CODE_639_XML', iso_639_xml) conf.set_quoted('ISO_CODE_639_XML', iso_639_xml)
conf.set_quoted('_LANGUAGE_SUPPORT_DIRECTORY', locale_dir) conf.set_quoted('LANGUAGE_SUPPORT_DIRECTORY', locale_dir)
conf.set_quoted('_NAME_SUFFIX', name_suffix) conf.set_quoted('NAME_SUFFIX', name_suffix)
conf.set_quoted('_PLUGINS_DIR', plugins_dir) conf.set_quoted('PLUGINS_DIR', plugins_dir)
conf.set_quoted('_PROFILE', profile) conf.set_quoted('PROFILE', profile)
conf.set_quoted('_REVNO', revno) conf.set_quoted('REVNO', revno)
conf.set_quoted('_SOURCE_ROOT_DIR', meson.project_source_root()) conf.set_quoted('SOURCE_ROOT_DIR', meson.project_source_root())
conf.set_quoted('_VERSION', geary_version) conf.set_quoted('VERSION', geary_version)
conf.set_quoted('_WEB_EXTENSIONS_DIR', web_extensions_dir) conf.set_quoted('WEB_EXTENSIONS_DIR', web_extensions_dir)
configure_file(output: 'config.h', configuration: conf) 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 # Common valac options
geary_vala_args = [ geary_vala_args = [
@ -68,12 +75,12 @@ web_process_sources = files(
web_process = library('geary-web-process', web_process = library('geary-web-process',
web_process_sources, web_process_sources,
dependencies: [ dependencies: [
config_dep,
engine_dep, engine_dep,
gee, gee,
gmime, gmime,
webkit2gtk_web_extension, webkit2gtk_web_extension,
], ],
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
install: true, install: true,
@ -158,6 +165,7 @@ foreach dep : valadoc_dependencies
valadoc_dep_args += 'libhandy-1' valadoc_dep_args += 'libhandy-1'
endif endif
endforeach endforeach
valadoc_dep_args += [ '--pkg', 'config' ]
valadoc_dep_args += [ '--pkg', 'icu-uc' ] valadoc_dep_args += [ '--pkg', 'icu-uc' ]
valadoc_dep_args += [ '--pkg', 'libstemmer' ] valadoc_dep_args += [ '--pkg', 'libstemmer' ]
valadoc_dep_args += [ '--pkg', 'posix' ] valadoc_dep_args += [ '--pkg', 'posix' ]

View file

@ -27,7 +27,7 @@ class Application.ClientTest : TestCase {
public void paths_when_installed() throws GLib.Error { public void paths_when_installed() throws GLib.Error {
string[] args = new string[] { string[] args = new string[] {
_INSTALL_PREFIX + "/bin/geary", Config.INSTALL_PREFIX + "/bin/geary",
// Specify this so the app doesn't actually attempt // Specify this so the app doesn't actually attempt
// to start up // to start up
"-v" "-v"
@ -38,11 +38,11 @@ class Application.ClientTest : TestCase {
assert_equal( assert_equal(
this.test_article.get_resource_directory().get_path(), this.test_article.get_resource_directory().get_path(),
_INSTALL_PREFIX + "/share/geary" Config.INSTALL_PREFIX + "/share/geary"
); );
assert_equal( assert_equal(
this.test_article.get_desktop_directory().get_path(), this.test_article.get_desktop_directory().get_path(),
_INSTALL_PREFIX + "/share/applications" Config.INSTALL_PREFIX + "/share/applications"
); );
} }

View file

@ -21,7 +21,7 @@ public abstract class Components.WebViewTestCase<V> : TestCase {
WebView.init_web_context( WebView.init_web_context(
this.config, 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 File.new_for_path("/tmp"), // XXX use something better here
false // https://bugs.webkit.org/show_bug.cgi?id=213174 false // https://bugs.webkit.org/show_bug.cgi?id=213174
); );

View file

@ -20,7 +20,7 @@ public class Components.WebViewTest : TestCase {
config.enable_debug = true; config.enable_debug = true;
WebView.init_web_context( WebView.init_web_context(
config, 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 File.new_for_path("/tmp"), // XXX use something better here
false // https://bugs.webkit.org/show_bug.cgi?id=213174 false // https://bugs.webkit.org/show_bug.cgi?id=213174
); );

View file

@ -5,9 +5,6 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (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 { class Geary.AttachmentTest : TestCase {
private const string CONTENT_TYPE = "image/svg+xml"; private const string CONTENT_TYPE = "image/svg+xml";
@ -64,7 +61,7 @@ class Geary.AttachmentTest : TestCase {
this.default_type = Mime.ContentType.ATTACHMENT_DEFAULT; this.default_type = Mime.ContentType.ATTACHMENT_DEFAULT;
this.content_disposition = new Mime.ContentDisposition("attachment", null); 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); this.file = source.get_child(FILE_PATH);
} }

View file

@ -35,7 +35,7 @@ class Geary.ContactStoreImplTest : TestCase {
this.db = new ImapDB.Database( this.db = new ImapDB.Database(
db_file, 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, attachments_dir,
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE),
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM)

View file

@ -38,7 +38,7 @@ public class Geary.FtsSearchQueryTest : TestCase {
this.account = new ImapDB.Account( this.account = new ImapDB.Account(
config, config,
this.tmp_dir, 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( this.account.open_async.begin(
null, null,

View file

@ -44,7 +44,7 @@ class Geary.ImapDB.AccountTest : TestCase {
this.account = new Account( this.account = new Account(
config, config,
this.tmp_dir, 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( this.account.open_async.begin(
null, null,

View file

@ -34,7 +34,7 @@ class Geary.ImapDB.DatabaseTest : TestCase {
public void open_new() throws Error { public void open_new() throws Error {
Database db = new Database( Database db = new Database(
this.tmp_dir.get_child("test.db"), 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"), this.tmp_dir.get_child("attachments"),
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE),
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM)
@ -94,7 +94,7 @@ class Geary.ImapDB.DatabaseTest : TestCase {
Database db = new Database( Database db = new Database(
db_file, 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, attachments_dir,
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE),
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) 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 { public void utf8_case_insensitive_collation() throws GLib.Error {
Database db = new Database( Database db = new Database(
this.tmp_dir.get_child("test.db"), 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"), this.tmp_dir.get_child("attachments"),
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE), new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_UPGRADE),
new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM) new Geary.SimpleProgressMonitor(Geary.ProgressType.DB_VACUUM)

View file

@ -44,7 +44,7 @@ class Geary.ImapDB.FolderTest : TestCase {
this.account = new Account( this.account = new Account(
config, config,
this.tmp_dir, 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( this.account.open_async.begin(
null, null,
@ -375,8 +375,8 @@ class Geary.ImapDB.FolderTest : TestCase {
beyond_threshold.to_unix().to_string()) beyond_threshold.to_unix().to_string())
); );
this.account.db.exec( this.account.db.exec(
"INSERT INTO MessageLocationTable " + "INSERT INTO MessageLocationTable " +
" (id, message_id, folder_id, ordering, remove_marker) " + " (id, message_id, folder_id, ordering, remove_marker) " +
"VALUES (%d, %d, 1, %d, 1);".printf(i, i, i) "VALUES (%d, %d, 1, %d, 1);".printf(i, i, i)
); );
} }

View file

@ -55,7 +55,7 @@ public class Geary.ImapEngine.GenericAccountTest : TestCase {
this.local_account = new ImapDB.Account( this.local_account = new ImapDB.Account(
config, config,
this.tmp_dir, 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.begin(null, this.async_completion);
this.local_account.open_async.end(async_result()); this.local_account.open_async.end(async_result());

View file

@ -125,6 +125,7 @@ test_integration_sources = [
# Engine tests # Engine tests
test_engine_dependencies = [ test_engine_dependencies = [
config_dep,
engine_internal_dep, engine_internal_dep,
vala_unit_dep, vala_unit_dep,
] ]
@ -142,7 +143,6 @@ endif
test_engine_bin = executable('test-engine', test_engine_bin = executable('test-engine',
test_engine_sources + libmock_sources, test_engine_sources + libmock_sources,
dependencies: test_engine_dependencies, dependencies: test_engine_dependencies,
include_directories: config_h_dir,
vala_args: test_engine_vala_args, vala_args: test_engine_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
) )
@ -150,6 +150,7 @@ test_engine_bin = executable('test-engine',
# Client tests # Client tests
test_client_dependencies = [ test_client_dependencies = [
config_dep,
client_internal_dep, client_internal_dep,
vala_unit_dep, vala_unit_dep,
] ]
@ -158,13 +159,13 @@ test_client_dependencies += client_dependencies
test_client_bin = executable('test-client', test_client_bin = executable('test-client',
test_client_sources + libmock_sources, test_client_sources + libmock_sources,
dependencies: test_client_dependencies, dependencies: test_client_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
build_rpath: client_build_dir, build_rpath: client_build_dir,
) )
test_js_dependencies = [ test_js_dependencies = [
config_dep,
client_internal_dep, client_internal_dep,
vala_unit_dep, vala_unit_dep,
] ]
@ -173,7 +174,6 @@ test_js_dependencies += client_dependencies
test_js_bin = executable('test-js', test_js_bin = executable('test-js',
test_js_sources + libmock_sources, test_js_sources + libmock_sources,
dependencies: test_js_dependencies, dependencies: test_js_dependencies,
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
build_rpath: client_build_dir, build_rpath: client_build_dir,
@ -184,6 +184,7 @@ test_js_bin = executable('test-js',
test_integration_bin = executable('test-integration', test_integration_bin = executable('test-integration',
test_integration_sources, test_integration_sources,
dependencies: [ dependencies: [
config_dep,
engine_dep, engine_dep,
gee, gee,
gio, gio,
@ -191,7 +192,6 @@ test_integration_bin = executable('test-integration',
vala_unit_dep, vala_unit_dep,
webkit2gtk, webkit2gtk,
], ],
include_directories: config_h_dir,
vala_args: geary_vala_args, vala_args: geary_vala_args,
c_args: geary_c_args, c_args: geary_c_args,
) )

View file

@ -16,7 +16,7 @@ int main(string[] args) {
Environment.set_variable("GSETTINGS_BACKEND", "memory", true); Environment.set_variable("GSETTINGS_BACKEND", "memory", true);
// Let GSettings know where to find the dev schema // 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. * Initialise all the things.
@ -27,7 +27,7 @@ int main(string[] args) {
Gtk.init(ref args); Gtk.init(ref args);
Test.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.RFC822.init();
Geary.HTML.init(); Geary.HTML.init();
Geary.Logging.init(); Geary.Logging.init();

View file

@ -16,7 +16,7 @@ int main(string[] args) {
Environment.set_variable("GSETTINGS_BACKEND", "memory", true); Environment.set_variable("GSETTINGS_BACKEND", "memory", true);
// Let GSettings know where to find the dev schema // 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. * Initialise all the things.
@ -27,7 +27,7 @@ int main(string[] args) {
Gtk.init(ref args); Gtk.init(ref args);
Test.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.RFC822.init();
Geary.HTML.init(); Geary.HTML.init();
Geary.Logging.init(); Geary.Logging.init();