Make binaries say what git commit they come from

The manual skipping of the initial "v" from tag names is unfortunate,
but still a bit better than further cluttering up the build system.
This commit is contained in:
Přemysl Eric Janouch 2022-08-12 21:16:37 +02:00
parent dcbc8a90b4
commit dd09af34b7
Signed by: p
GPG Key ID: A0420B94F92B9493
3 changed files with 16 additions and 9 deletions

View File

@ -397,7 +397,8 @@ main(int argc, char *argv[])
gboolean initialized = gtk_init_with_args( gboolean initialized = gtk_init_with_args(
&argc, &argv, " - Lossless JPEG cropper", options, NULL, &error); &argc, &argv, " - Lossless JPEG cropper", options, NULL, &error);
if (show_version) { if (show_version) {
printf("fiv-jpegcrop " PROJECT_VERSION "\n"); const char *version = PROJECT_VERSION;
printf("%s %s\n", "fiv-jpegcrop", &version[*version == 'v']);
return 0; return 0;
} }
if (!initialized) if (!initialized)

11
fiv.c
View File

@ -450,8 +450,12 @@ show_about_dialog(GtkWidget *parent)
// The rest is approximately copying GTK+'s own gtkaboutdialog.ui. // The rest is approximately copying GTK+'s own gtkaboutdialog.ui.
GtkWidget *name = gtk_label_new(NULL); GtkWidget *name = gtk_label_new(NULL);
gtk_label_set_selectable(GTK_LABEL(name), TRUE); gtk_label_set_selectable(GTK_LABEL(name), TRUE);
gtk_label_set_markup(
GTK_LABEL(name), "<b>" PROJECT_NAME "</b> " PROJECT_VERSION); const char *version = PROJECT_VERSION;
gchar *markup = g_strdup_printf(
"<b>%s</b> %s", PROJECT_NAME, &version[*version == 'v']);
gtk_label_set_markup(GTK_LABEL(name), markup);
g_free(markup);
GtkWidget *website = gtk_label_new(NULL); GtkWidget *website = gtk_label_new(NULL);
gtk_label_set_selectable(GTK_LABEL(website), TRUE); gtk_label_set_selectable(GTK_LABEL(website), TRUE);
@ -2005,7 +2009,8 @@ main(int argc, char *argv[])
gboolean initialized = gtk_init_with_args( gboolean initialized = gtk_init_with_args(
&argc, &argv, " - Image browser and viewer", options, NULL, &error); &argc, &argv, " - Image browser and viewer", options, NULL, &error);
if (show_version) { if (show_version) {
printf(PROJECT_NAME " " PROJECT_VERSION "\n"); const char *version = PROJECT_VERSION;
printf("%s %s\n", PROJECT_NAME, &version[*version == 'v']);
return 0; return 0;
} }
if (show_supported_media_types) { if (show_supported_media_types) {

View File

@ -74,7 +74,7 @@ application_ns = 'name.janouch.'
conf = configuration_data() conf = configuration_data()
conf.set_quoted('PROJECT_NAME', meson.project_name()) conf.set_quoted('PROJECT_NAME', meson.project_name())
conf.set_quoted('PROJECT_VERSION', meson.project_version()) conf.set_quoted('PROJECT_VERSION', '@VCS_TAG@')
conf.set_quoted('PROJECT_NS', application_ns) conf.set_quoted('PROJECT_NS', application_ns)
conf.set_quoted('PROJECT_DOCDIR', get_option('prefix') / docdir) conf.set_quoted('PROJECT_DOCDIR', get_option('prefix') / docdir)
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
@ -91,9 +91,10 @@ conf.set('HAVE_LIBHEIF', libheif.found())
conf.set('HAVE_LIBTIFF', libtiff.found()) conf.set('HAVE_LIBTIFF', libtiff.found())
conf.set('HAVE_GDKPIXBUF', gdkpixbuf.found()) conf.set('HAVE_GDKPIXBUF', gdkpixbuf.found())
configure_file( config = vcs_tag(
command : ['git', 'describe', '--always', '--dirty=+'],
input : configure_file(output : 'config.h.in', configuration : conf),
output : 'config.h', output : 'config.h',
configuration : conf,
) )
rc = [] rc = []
@ -137,7 +138,7 @@ tiff_tables = custom_target('tiff-tables.h',
desktops = ['fiv.desktop', 'fiv-browse.desktop'] desktops = ['fiv.desktop', 'fiv-browse.desktop']
exe = executable('fiv', 'fiv.c', 'fiv-view.c', 'fiv-io.c', 'fiv-context-menu.c', exe = executable('fiv', 'fiv.c', 'fiv-view.c', 'fiv-io.c', 'fiv-context-menu.c',
'fiv-browser.c', 'fiv-sidebar.c', 'fiv-thumbnail.c', 'fiv-collection.c', 'fiv-browser.c', 'fiv-sidebar.c', 'fiv-thumbnail.c', 'fiv-collection.c',
'xdg.c', gresources, rc, 'xdg.c', gresources, rc, config,
install : true, install : true,
dependencies : dependencies, dependencies : dependencies,
win_subsystem : 'windows', win_subsystem : 'windows',
@ -149,7 +150,7 @@ if gdkpixbuf.found()
endif endif
desktops += 'fiv-jpegcrop.desktop' desktops += 'fiv-jpegcrop.desktop'
jpegcrop = executable('fiv-jpegcrop', 'fiv-jpegcrop.c', rc, jpegcrop = executable('fiv-jpegcrop', 'fiv-jpegcrop.c', rc, config,
install : true, install : true,
dependencies : [ dependencies : [
dependency('gtk+-3.0'), dependency('gtk+-3.0'),