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:
parent
dc14aa091c
commit
6ce2373a75
39 changed files with 126 additions and 131 deletions
|
|
@ -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"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public abstract class Components.WebViewTestCase<V> : 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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue