Skip to content

Commit

Permalink
Use meson's vcs_tag() for the git hash
Browse files Browse the repository at this point in the history
  • Loading branch information
phako committed Sep 23, 2018
1 parent 904c972 commit e04e37f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 18 deletions.
4 changes: 0 additions & 4 deletions git-hash

This file was deleted.

10 changes: 3 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/AppWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions src/Resources.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define _GIT_VERSION "@VCS_TAG@"

0 comments on commit e04e37f

Please sign in to comment.