feat: switch to git based versioning

- Makefile computes version automatically
- added version flag for splash cli
This commit is contained in:
2026-05-29 11:17:28 +05:30
parent f0578aabfa
commit 52b221cf73
2 changed files with 12 additions and 0 deletions

View File

@@ -1,10 +1,13 @@
# Makefile for gsplash (community-standard layout)
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "unknown")
PREFIX ?= /usr/local
bindir ?= $(PREFIX)/bin
CC ?= gcc
CFLAGS ?= -O2 -Wall -Wextra
CFLAGS += -DGSPLASH_VERSION=\"$(VERSION)\"
PKG_CONFIG ?= pkg-config
SDL_CFLAGS := $(shell $(PKG_CONFIG) --cflags sdl2 SDL2_image)

View File

@@ -96,6 +96,10 @@ int main(int argc, char* argv[]) {
RenderMode render_mode = RENDER_CENTER;
int arg_index = 1;
#ifndef GSPLASH_VERSION
#define GSPLASH_VERSION "unknown"
#endif
while (arg_index < argc && argv[arg_index][0] == '-') {
if (strcmp(argv[arg_index], "--") == 0) {
arg_index++;
@@ -110,11 +114,16 @@ int main(int argc, char* argv[]) {
}
render_mode = parse_render_mode(argv[arg_index + 1]);
arg_index += 2;
} else if (strcmp(argv[arg_index], "--version") == 0 ||
strcmp(argv[arg_index], "-v") == 0) {
printf("gsplash version %s\n", GSPLASH_VERSION);
return 0;
} else if (strcmp(argv[arg_index], "-h") == 0 ||
strcmp(argv[arg_index], "--help") == 0) {
printf("Usage: %s [options] <image_path> <game_executable> [args...]\n",
argv[0]);
printf("Options:\n");
printf(" -v, --version Show version information\n");
printf(
" -m, --mode=MODE Set render mode: stretch, center (default), "
"crop\n");