commit 9f012042269d72e38f9fd0c6e5962c54af2933a0 parent aca807e544ad6b93232c309810a63272a11d4f7f Author: citbl <citbl@citbl.org> Date: Thu, 4 Jun 2026 22:54:24 +1000 make huh Diffstat:
| M | makefile | | | 33 | +++++++++++++++++++++++++++++---- |
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/makefile b/makefile @@ -1,13 +1,38 @@ .SILENT: +EXPLAIN_MODEL ?= openai/gpt-5.4-mini-fast +EXPLAIN_CMD ?= opencode run --model "$(EXPLAIN_MODEL)" +EXPLAIN_PROMPT ?= Explain (do not edit code) this Ada compiler error in concise English. Files are in src/. Include the likely cause and a concise fix. Error: +EXPLAIN_TITLE ?= AI explanation for Ada error: +EXPLAIN_MARKER ?= : error: +EXPLAIN_TMP ?= $${TMPDIR:-/tmp}/nightshade-explain.XXXXXX + +BUILD_COMMAND ?= mkdir -p ./bin/ && gnatmake -gnat2022 -o bin/nightshade src/nightshade.adb && rm -rf *.o *.ali && ./bin/nightshade test.mty + +define run_with_explain +@tmp="$$(mktemp "$(EXPLAIN_TMP)")"; \ +{ $(1); } >"$$tmp" 2>&1; \ +status=$$?; \ +cat "$$tmp"; \ +if [ $$status -ne 0 ]; then \ + line=$$(grep -m 1 -F "$(EXPLAIN_MARKER)" "$$tmp" 2>/dev/null || true); \ + if [ -n "$$line" ]; then \ + printf '\n%s\n' "$(EXPLAIN_TITLE)"; \ + $(EXPLAIN_CMD) "$(EXPLAIN_PROMPT) $$line" || true; \ + fi; \ +fi; \ +rm -f "$$tmp"; \ +exit $$status +endef + default: - mkdir -p ./bin/ - gnatmake -gnat2022 -o bin/nightshade src/nightshade.adb - rm -rf *.o *.ali - ./bin/nightshade test.mty + $(BUILD_COMMAND) pedantic: gnatmake -gnat2022 -gnatwa -o bin/nightshade src/nightshade.adb fmt: gnatformat src/*.adb src/*.ads + +huh: + $(call run_with_explain,$(BUILD_COMMAND))