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