mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
cage: add -v argument to print version
This commit is contained in:
parent
5e27683961
commit
15eeb7784e
3 changed files with 27 additions and 5 deletions
10
cage.c
10
cage.c
|
|
@ -115,6 +115,7 @@ usage(FILE *file, const char *cage)
|
||||||
" -D\t Turn on damage tracking debugging\n"
|
" -D\t Turn on damage tracking debugging\n"
|
||||||
#endif
|
#endif
|
||||||
" -h\t Display this help message\n"
|
" -h\t Display this help message\n"
|
||||||
|
" -v\t Show the version number and exit\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Use -- when you want to pass arguments to APPLICATION\n",
|
" Use -- when you want to pass arguments to APPLICATION\n",
|
||||||
cage);
|
cage);
|
||||||
|
|
@ -125,9 +126,9 @@ parse_args(struct cg_server *server, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
while ((c = getopt(argc, argv, "drDh")) != -1) {
|
while ((c = getopt(argc, argv, "drDhv")) != -1) {
|
||||||
#else
|
#else
|
||||||
while ((c = getopt(argc, argv, "drh")) != -1) {
|
while ((c = getopt(argc, argv, "drhv")) != -1) {
|
||||||
#endif
|
#endif
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
|
|
@ -147,6 +148,9 @@ parse_args(struct cg_server *server, int argc, char *argv[])
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(stdout, argv[0]);
|
usage(stdout, argv[0]);
|
||||||
return false;
|
return false;
|
||||||
|
case 'v':
|
||||||
|
fprintf(stdout, "Cage version " CAGE_VERSION "\n");
|
||||||
|
exit(0);
|
||||||
default:
|
default:
|
||||||
usage(stderr, argv[0]);
|
usage(stderr, argv[0]);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -390,7 +394,7 @@ main(int argc, char *argv[])
|
||||||
wlr_log_errno(WLR_ERROR, "Unable to set WAYLAND_DISPLAY.",
|
wlr_log_errno(WLR_ERROR, "Unable to set WAYLAND_DISPLAY.",
|
||||||
"Clients may not be able to connect");
|
"Clients may not be able to connect");
|
||||||
} else {
|
} else {
|
||||||
wlr_log(WLR_DEBUG, "Cage is running on Wayland display %s", socket);
|
wlr_log(WLR_DEBUG, "Cage " CAGE_VERSION " is running on Wayland display %s", socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CAGE_HAS_XWAYLAND
|
#if CAGE_HAS_XWAYLAND
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,6 @@
|
||||||
|
|
||||||
#mesondefine CAGE_HAS_XWAYLAND
|
#mesondefine CAGE_HAS_XWAYLAND
|
||||||
|
|
||||||
|
#mesondefine CAGE_VERSION
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
20
meson.build
20
meson.build
|
|
@ -76,8 +76,24 @@ else
|
||||||
have_xwayland = false
|
have_xwayland = false
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
git = find_program('git', native: true, required: false)
|
||||||
|
if git.found()
|
||||||
|
git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'])
|
||||||
|
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'])
|
||||||
|
if git_commit.returncode() == 0 and git_branch.returncode() == 0
|
||||||
|
version = '@0@-@1@ (branch \'@2@\')'.format(
|
||||||
|
meson.project_version(),
|
||||||
|
git_commit.stdout().strip(),
|
||||||
|
git_branch.stdout().strip(),
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
version = '@0@'.format(meson.project_version())
|
||||||
|
endif
|
||||||
|
|
||||||
conf_data = configuration_data()
|
conf_data = configuration_data()
|
||||||
conf_data.set10('CAGE_HAS_XWAYLAND', have_xwayland)
|
conf_data.set10('CAGE_HAS_XWAYLAND', have_xwayland)
|
||||||
|
conf_data.set_quoted('CAGE_VERSION', version)
|
||||||
|
|
||||||
cage_sources = [
|
cage_sources = [
|
||||||
'cage.c',
|
'cage.c',
|
||||||
|
|
@ -125,9 +141,9 @@ executable(
|
||||||
|
|
||||||
summary = [
|
summary = [
|
||||||
'',
|
'',
|
||||||
'Cage @0@'.format(meson.project_version()),
|
'Cage @0@'.format(version),
|
||||||
'',
|
'',
|
||||||
' xwayland: @0@'.format(conf_data.get('CAGE_HAS_XWAYLAND', false)),
|
' xwayland: @0@'.format(have_xwayland),
|
||||||
''
|
''
|
||||||
]
|
]
|
||||||
message('\n'.join(summary))
|
message('\n'.join(summary))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue