aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-15 13:21:35 +0200
committeruser <user@clank>2026-08-15 13:21:35 +0200
commitd24a07a6048e6d6416e97a26483739bdd879e01b (patch)
tree764a08f255aeaa71fa8fbdc6bad7fa1b9835171f /Makefile
parentsl0ppty: write the session back out as a layout, and a loop that uses it (diff)
downloadslosh-d24a07a6048e6d6416e97a26483739bdd879e01b.tar.gz
slosh-d24a07a6048e6d6416e97a26483739bdd879e01b.tar.xz
slosh-d24a07a6048e6d6416e97a26483739bdd879e01b.zip
sl0ppty: say which build you are talking to
The middle of the status line is empty unless the pointer is on something, which is most of the time. It says which sl0ppty this is now. That reads as decoration and is not. A session keeps the binary it started with, so after a rebuild there are two versions in play: the one on disk and the one you are attached to. This session has been dogfooding sl0ppty for a while, and "which build is this?" has already been the answer to two bugs that looked like something else -- once when a config reload appeared to do nothing, and once when kitty graphics were fixed and still broken on screen. The banner answers it without asking, and `sl0ppty --version` answers for the binary, from the same string. The version is baked in by the Makefile from `git describe --always --dirty`, into a generated header that is only rewritten when the value changes -- so a commit rebuilds and a second `make` does nothing. It takes the hint's slot and yields to it: a hint is about what you are doing right now, the banner is about always, and it comes back the moment the pointer moves off. Both give way to the ends of the line, which was already the rule for hints and is why a narrow terminal loses the middle rather than its session name. `version_banner false` for anyone who finds it noisy; it is a separate knob from `hints`, and the tests hold both directions of that.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile19
1 files changed, 17 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 1b95a57..b1556b0 100644
--- a/Makefile
+++ b/Makefile
@@ -14,8 +14,14 @@ VT_INC := $(VT_OUT)/include
# header rebuilds what actually uses it. Without this a header edit rebuilt
# nothing and the only safe move was `make clean`, which is how a 0.1s build
# turns into a habit of throwing the whole thing away.
+# The version is baked in, because the first question when a session is
+# behaving oddly is "which build is this?" -- and a session keeps the binary it
+# started with, so the answer is not "whatever is in build/ now".
+VERSION := 0.1.0
+GITDESC := $(shell git describe --always --dirty 2>/dev/null || echo unknown)
+
CFLAGS := -std=c23 -O1 -g -Wall -Wextra -Wno-unused-parameter -MMD -MP \
- -I$(VT_INC) -Isrc
+ -I$(VT_INC) -Isrc -Ibuild
LDFLAGS :=
SRC := $(wildcard src/*.c)
@@ -44,9 +50,18 @@ all: $(BIN) ## build sl0ppty
$(BIN): $(OBJ) $(VT_LIB)
$(CC) $(OBJ) $(VT_LIB) -o $@ $(LDFLAGS)
-build/%.o: src/%.c $(VT_LIB) | build
+build/%.o: src/%.c build/version.h $(VT_LIB) | build
$(CC) $(CFLAGS) -c $< -o $@
+# Rewritten only when the value actually changes, so `make` after a commit
+# rebuilds, and `make` twice in a row does not.
+.PHONY: FORCE
+build/version.h: FORCE | build
+ @printf '/* generated by the Makefile */\n#define SL0PPTY_VERSION "%s+%s"\n' \
+ '$(VERSION)' '$(GITDESC)' > $@.tmp
+ @cmp -s $@.tmp $@ || mv $@.tmp $@
+ @rm -f $@.tmp
+
build:
@mkdir -p build