[shotwell] Use meson's vcs_tag() for the git hash
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Use meson's vcs_tag() for the git hash
- Date: Sun, 23 Sep 2018 10:15:13 +0000 (UTC)
commit e04e37f6fefdaf6e2156e968249e95e1faeb8b1a
Author: Jens Georg <mail jensge org>
Date: Sun Sep 23 12:13:34 2018 +0200
Use meson's vcs_tag() for the git hash
git-hash | 4 ----
meson.build | 10 +++-------
src/AppWindow.vala | 2 +-
src/Resources.vala | 4 ----
src/main.vala | 4 ++--
version.h.in | 3 +++
6 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/meson.build b/meson.build
index dbe13f53..44d001e4 100644
--- a/meson.build
+++ b/meson.build
@@ -20,7 +20,8 @@ vapi_incdir = include_directories('vapi')
shotwell_plugin_dir = join_paths(get_option('libdir'), 'shotwell', 'plugins', 'builtin')
add_global_arguments(['-DHAVE_CONFIG_H=1'],
- ['-include'], ['config.h'], language : 'c')
+ ['-include'], ['config.h'],
+ ['-include'], ['version.h'], language : 'c')
add_global_arguments(['--target-glib=2.40',
'--vapidir=@0@'.format(join_paths(meson.current_source_dir(),
'vapi')),
@@ -29,12 +30,7 @@ add_global_arguments(['--target-glib=2.40',
'--enable-experimental',
'--enable-deprecated'], language : 'vala')
-gitver = run_command(find_program('git-hash'))
-if gitver.returncode() == 0
- add_global_arguments(['-D_GIT_VERSION="@0@"'.format(gitver.stdout().strip())],
- language : 'c')
- add_global_arguments(['--define=_GITVERSION'], language : 'vala')
-endif
+vcs_tag(command: ['git', 'rev-parse', 'HEAD'], input: 'version.h.in', output: 'version.h', fallback: '')
gtk = dependency('gtk+-3.0', version : '>= 3.22')
gio = dependency('gio-2.0', version: '>= 2.40')
diff --git a/src/AppWindow.vala b/src/AppWindow.vala
index e50a254f..a9b3ceba 100644
--- a/src/AppWindow.vala
+++ b/src/AppWindow.vala
@@ -594,7 +594,7 @@ public abstract class AppWindow : PageWindow {
protected void on_about() {
const string[] artists = { "Braunschweiger Löwe created by Magnus Manske., CC BY-SA 3.0,
https://commons.wikimedia.org/w/index.php?curid=109735", null };
Gtk.show_about_dialog(this,
- "version", Resources.APP_VERSION,
+ "version", Resources.APP_VERSION + (Resources.GIT_VERSION != "" ? " — " + Resources.GIT_VERSION
: ""),
"comments", get_app_role(),
"copyright", Resources.COPYRIGHT,
"website", Resources.HOME_URL,
diff --git a/src/Resources.vala b/src/Resources.vala
index 909964e7..821819ff 100644
--- a/src/Resources.vala
+++ b/src/Resources.vala
@@ -18,11 +18,7 @@ namespace Resources {
public const string APP_DIRECT_ROLE = _("Photo Viewer");
public const string APP_VERSION = _VERSION;
-#if _GITVERSION
public const string? GIT_VERSION = _GIT_VERSION;
-#else
- public const string? GIT_VERSION = null;
-#endif
public const string COPYRIGHT = _("Copyright 2016 Software Freedom Conservancy Inc.");
public const string APP_GETTEXT_PACKAGE = GETTEXT_PACKAGE;
diff --git a/src/main.vala b/src/main.vala
index 8ae41fc0..68822435 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -383,7 +383,7 @@ void main(string[] args) {
}
if (CommandlineOptions.show_version) {
- if (Resources.GIT_VERSION != null)
+ if (Resources.GIT_VERSION != "")
print("%s %s (%s)\n", Resources.APP_TITLE, Resources.APP_VERSION, Resources.GIT_VERSION);
else
print("%s %s\n", Resources.APP_TITLE, Resources.APP_VERSION);
@@ -415,7 +415,7 @@ void main(string[] args) {
Debug.init(is_string_empty(filename) ? Debug.LIBRARY_PREFIX : Debug.VIEWER_PREFIX);
- if (Resources.GIT_VERSION != null)
+ if (Resources.GIT_VERSION != "")
message("Shotwell %s %s (%s)",
is_string_empty(filename) ? Resources.APP_LIBRARY_ROLE : Resources.APP_DIRECT_ROLE,
Resources.APP_VERSION, Resources.GIT_VERSION);
diff --git a/version.h.in b/version.h.in
new file mode 100644
index 00000000..fe25b696
--- /dev/null
+++ b/version.h.in
@@ -0,0 +1,3 @@
+#pragma once
+
+#define _GIT_VERSION "@VCS_TAG@"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]