Skip to content

Commit 6cccfa5

Browse files
committed
util: added '-v' and '--version' and tracks git versions as well as release numbers
1 parent a96e1f3 commit 6cccfa5

8 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎src/background/meson.build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
executable('wf-background', ['background.cpp'],
1+
executable('wf-background', ['background.cpp', version_h],
22
dependencies: [gtkmm, gtklayershell, wayland_client, libutil, wf_protos, wfconfig, epoxy],
33
install: true)

‎src/dock/meson.build‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
executable('wf-dock', ['dock.cpp', 'dock-app.cpp', 'toplevel.cpp', 'toplevel-icon.cpp'],
1+
executable('wf-dock', ['dock.cpp', 'dock-app.cpp', 'toplevel.cpp', 'toplevel-icon.cpp', version_h,],
22
dependencies: [gtkmm, gtklayershell, wayland_client, libutil, wf_protos, wfconfig],
3-
install: true)
3+
install: true)

‎src/locker-pin/meson.build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ deps = [
55

66
executable(
77
'wf-locker-pin',
8-
['locker-pin.cpp'],
8+
['locker-pin.cpp', version_h],
99
dependencies: deps,
1010
install: true,
1111
)

‎src/locker/meson.build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ endif
3636

3737
executable(
3838
'wf-locker',
39-
['locker.cpp', 'lockscreen.cpp', 'timedrevealer.cpp'] + widget_sources,
39+
['locker.cpp', 'lockscreen.cpp', 'timedrevealer.cpp', version_h] + widget_sources,
4040
dependencies: deps,
4141
install: true,
4242
)

‎src/panel/meson.build‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ endif
8989

9090
executable(
9191
'wf-panel',
92-
['panel.cpp'] + widget_sources,
92+
['panel.cpp', version_h] + widget_sources,
9393
dependencies: deps,
9494
install: true,
9595
)

‎src/util/meson.build‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ util = static_library(
1919
'network/settings.cpp',
2020
'network/connection.cpp',
2121
'background-gl.cpp',
22-
'icon-select.cpp'
22+
'icon-select.cpp',
2323
],
2424
dependencies: [
2525
wf_protos,
@@ -32,5 +32,18 @@ util = static_library(
3232
],
3333
)
3434

35+
git_command = [
36+
'sh',
37+
'-c', 'printf "%s-%s@%s" "'
38+
+ meson.project_version()
39+
+ '" "$(git rev-parse --abbrev-ref HEAD)" "$(git rev-parse --short HEAD)"',
40+
]
41+
version_h = vcs_tag(
42+
input: 'version.h.in',
43+
output: 'version.h',
44+
command: git_command,
45+
fallback: meson.project_version(),
46+
)
47+
3548
util_includes = include_directories('.')
3649
libutil = declare_dependency(link_with: util, include_directories: util_includes)

‎src/util/version.h.in‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
#define WF_SHELL_VERSION_STRING "@VCS_TAG@"

‎src/util/wf-shell-app.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <wayfire/config/file.hpp>
1010
#include <wf-option-wrap.hpp>
1111
#include <gtk-utils.hpp>
12+
#include "version.h"
1213

1314
#include <unistd.h>
1415

@@ -402,6 +403,16 @@ WayfireShellApp& WayfireShellApp::get()
402403

403404
void WayfireShellApp::run(int argc, char **argv)
404405
{
406+
for (int i = 1; i < argc; ++i)
407+
{
408+
std::string arg = argv[i];
409+
if ((arg == "-v") || (arg == "--version"))
410+
{
411+
std::cout << "WayfireShell version: " << WF_SHELL_VERSION_STRING << std::endl;
412+
return; // Terminate early
413+
}
414+
}
415+
405416
app->run(argc, argv);
406417
}
407418

0 commit comments

Comments
 (0)