mirror of
https://codeberg.org/dwl/dwl.git
synced 2024-12-27 03:36:31 +00:00
add flag to print version and exit
This commit is contained in:
parent
07d56c6d7b
commit
5d8084daa7
4 changed files with 20 additions and 2 deletions
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 -pedantic
|
CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 -pedantic -DVERSION=\"$(VERSION)\"
|
||||||
|
|
||||||
WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
|
WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
|
||||||
WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
|
WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
_VERSION = 0.3.1
|
||||||
|
VERSION = $(shell ./generate-version.sh $(_VERSION))
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
MANDIR = $(PREFIX)/share/man
|
MANDIR = $(PREFIX)/share/man
|
||||||
|
|
4
dwl.c
4
dwl.c
|
@ -2516,9 +2516,11 @@ main(int argc, char *argv[])
|
||||||
char *startup_cmd = NULL;
|
char *startup_cmd = NULL;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "s:h")) != -1) {
|
while ((c = getopt(argc, argv, "s:hv")) != -1) {
|
||||||
if (c == 's')
|
if (c == 's')
|
||||||
startup_cmd = optarg;
|
startup_cmd = optarg;
|
||||||
|
else if (c == 'v')
|
||||||
|
die("dwl " VERSION);
|
||||||
else
|
else
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
|
|
13
generate-version.sh
Executable file
13
generate-version.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if git tag --contains HEAD | grep -q $1; then
|
||||||
|
echo $1
|
||||||
|
else
|
||||||
|
branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
commit="$(git rev-parse --short HEAD)"
|
||||||
|
if [ "${branch}" != "main" ]; then
|
||||||
|
echo $1-$branch-$commit
|
||||||
|
else
|
||||||
|
echo $1-$commit
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in a new issue