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

View file

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

View file

@ -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)

View file

@ -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,

View file

@ -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,

View file

@ -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)

View file

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

View file

@ -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());