Skip to content

Commit 441ca45

Browse files
committed
util: added '-v' and '--version' and tracks git versions as well as release numbers
1 parent 31286a3 commit 441ca45

11 files changed

Lines changed: 64 additions & 9 deletions

File tree

‎src/background/meson.build‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
executable(
22
'wf-background',
3-
'background.cpp',
3+
['background.cpp', version_h],
44
dependencies: [
55
gtkmm,
66
gtklayershell,
@@ -10,5 +10,5 @@ executable(
1010
wfconfig,
1111
epoxy
1212
],
13-
install: true
13+
install: true,
1414
)

‎src/dock/meson.build‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ executable(
44
'dock.cpp',
55
'dock-app.cpp',
66
'toplevel.cpp',
7-
'toplevel-icon.cpp'
7+
'toplevel-icon.cpp',
8+
version_h
89
],
910
dependencies: [
1011
gtkmm,
@@ -14,5 +15,5 @@ executable(
1415
wf_protos,
1516
wfconfig
1617
],
17-
install: true
18+
install: true,
1819
)

‎src/locker-pin/locker-pin.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <iomanip>
88

99
#include "locker-pin.hpp"
10+
#include "version.h"
1011

1112
WayfirePinChangeApp::WayfirePinChangeApp() : Gtk::Application("org.wayfire.locker-pin",
1213
Gio::Application::Flags::NONE)
@@ -207,6 +208,15 @@ std::string WayfirePinChangeApp::sha512(const std::string input)
207208
/* Starting point */
208209
int main(int argc, char **argv)
209210
{
211+
for (int count = 0; count < argc; count++)
212+
{
213+
if ((strcmp(argv[count], "--version") == 0) || (strcmp(argv[count], "-v") == 0))
214+
{
215+
std::cout << WF_SHELL_VERSION_STRING << std::endl;
216+
return 0;
217+
}
218+
}
219+
210220
auto app = new WayfirePinChangeApp();
211221
app->run();
212222
exit(0);

‎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/locker.cpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "wf-option-wrap.hpp"
3939
#include "wf-shell-app.hpp"
4040
#include "locker.hpp"
41+
#include "version.h"
4142

4243
#define INOT_BUF_SIZE (1024 * sizeof(inotify_event))
4344

@@ -446,7 +447,7 @@ void WayfireLockerApp::set_is_locked(bool locked)
446447
int main(int argc, char **argv)
447448
{
448449
bool nofork = false, now = false;
449-
for (int count = 0; count < argc; count++)
450+
for (int count = 1; count < argc; count++)
450451
{
451452
if (strcmp(argv[count], "--nofork") == 0)
452453
{
@@ -457,6 +458,12 @@ int main(int argc, char **argv)
457458
{
458459
now = true;
459460
}
461+
462+
if ((strcmp(argv[count], "--version") == 0) || (strcmp(argv[count], "-v") == 0))
463+
{
464+
std::cout << WF_SHELL_VERSION_STRING << std::endl;
465+
return 0;
466+
}
460467
}
461468

462469
std::cout << "nofork: " << nofork << " now: " << now << std::endl;

‎src/locker/meson.build‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ executable(
3838
widget_sources + [
3939
'locker.cpp',
4040
'lockscreen.cpp',
41-
'timedrevealer.cpp'
41+
'timedrevealer.cpp',
42+
version_h
4243
],
4344
dependencies: deps,
4445
install: true,

‎src/panel/meson.build‎

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

8686
executable(
8787
'wf-panel',
88-
widget_sources + 'panel.cpp',
88+
['panel.cpp', version_h] + widget_sources,
8989
dependencies: deps,
9090
install: true,
9191
)

‎src/stream-chooser/stream-chooser.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "mainlayout.hpp"
1515
#include "outputwidget.hpp"
1616
#include "toplevelwidget.hpp"
17+
#include "version.h"
1718

1819
/* Static callbacks for toplevel list object */
1920
static void handle_toplevel(void *data,
@@ -469,6 +470,15 @@ void WayfireStreamChooserApp::resize(int width, int height)
469470
/* Starting point */
470471
int main(int argc, char **argv)
471472
{
473+
for (int count = 1; count < argc; count++)
474+
{
475+
if ((strcmp(argv[count], "--version") == 0) || (strcmp(argv[count], "-v") == 0))
476+
{
477+
std::cout << WF_SHELL_VERSION_STRING << std::endl;
478+
return 0;
479+
}
480+
}
481+
472482
WayfireStreamChooserApp::getInstance().run();
473483
exit(0);
474484
}

‎src/util/meson.build‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,19 @@ util = static_library(
3232
],
3333
)
3434

35+
git_command = [
36+
'sh',
37+
'-c', 'printf "@0@ version @1@-%s (%s) branch %s gtk @2@" "$(git rev-parse --short HEAD)" "$(git log -1 --format=%as)" "$(git rev-parse --abbrev-ref HEAD)"'.format(meson.project_name(), meson.project_version(), gtkmm.version()),
38+
]
39+
40+
fallback_string = '@0@ version @1@-unknown-commit (unknown-date) branch unknown-branch gtk @2@'.format(meson.project_name(), meson.project_version(), gtkmm.version())
41+
42+
version_h = vcs_tag(
43+
input: 'version.h.in',
44+
output: 'version.h',
45+
command: git_command,
46+
fallback: fallback_string,
47+
)
48+
3549
util_includes = include_directories('.')
3650
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@"

0 commit comments

Comments
 (0)