Skip to content

Commit

Permalink
Refactor c_args into a separate Vala namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
v1993 committed Nov 11, 2023
1 parent 75129b3 commit 51609f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/config.vapi
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Passed via c_args
[CCode (cprefix = "", lower_case_cprefix = "")]
namespace BuildCArgs {
public const string GETTEXT_PACKAGE;
public const string G_LOG_DOMAIN;
}

// Defined in config.h generated by meson
// lower_case_cprefix is required even if unused in practice
[CCode (cprefix = "NXDC_", lower_case_cprefix = "nxdc_", cheader_filename = "config.h")]
namespace BuildConfig {
Expand Down
8 changes: 3 additions & 5 deletions src/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@

internal string argv0;

extern const string GETTEXT_PACKAGE;

int main(string[] args) {
argv0 = args[0] ?? "nxdumpclient";

Intl.setlocale();
Intl.bindtextdomain(GETTEXT_PACKAGE, BuildConfig.LOCALE_DIR);
Intl.bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain(GETTEXT_PACKAGE);
Intl.bindtextdomain(BuildCArgs.GETTEXT_PACKAGE, BuildConfig.LOCALE_DIR);
Intl.bind_textdomain_codeset(BuildCArgs.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain(BuildCArgs.GETTEXT_PACKAGE);

var app = new NXDumpClient.Application();
return app.run(args);
Expand Down
2 changes: 2 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,12 @@ else
endif

conf_data = configuration_data()

conf_data.set_quoted('NXDC_VERSION', meson.project_version())
conf_data.set_quoted('NXDC_LOCALE_DIR', get_option('prefix') / get_option('localedir'))
conf_data.set_quoted('NXDC_ICONS_PATH', get_option('prefix') / get_option('datadir') / 'icons')
conf_data.set_quoted('NXDC_EXECUTABLE', get_option('prefix') / get_option('bindir') / 'nxdumpclient')

configure_file(
output: 'config.h',
configuration: conf_data
Expand Down

0 comments on commit 51609f6

Please sign in to comment.