makefile (1178B)
1 .SILENT: 2 3 EXPLAIN_MODEL ?= openai/gpt-5.4-mini-fast 4 EXPLAIN_CMD ?= opencode run --model "$(EXPLAIN_MODEL)" 5 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: 6 EXPLAIN_TITLE ?= AI explanation for Ada error: 7 EXPLAIN_MARKER ?= : error: 8 EXPLAIN_TMP ?= $${TMPDIR:-/tmp}/nightshade-explain.XXXXXX 9 10 BUILD_COMMAND ?= mkdir -p ./bin/ && gnatmake -gnat2022 -o bin/nightshade src/nightshade.adb && rm -rf *.o *.ali && ./bin/nightshade test.mty 11 12 define run_with_explain 13 @tmp="$$(mktemp "$(EXPLAIN_TMP)")"; \ 14 { $(1); } >"$$tmp" 2>&1; \ 15 status=$$?; \ 16 cat "$$tmp"; \ 17 if [ $$status -ne 0 ]; then \ 18 line=$$(grep -m 1 -F "$(EXPLAIN_MARKER)" "$$tmp" 2>/dev/null || true); \ 19 if [ -n "$$line" ]; then \ 20 printf '\n%s\n' "$(EXPLAIN_TITLE)"; \ 21 $(EXPLAIN_CMD) "$(EXPLAIN_PROMPT) $$line" || true; \ 22 fi; \ 23 fi; \ 24 rm -f "$$tmp"; \ 25 exit $$status 26 endef 27 28 default: 29 $(BUILD_COMMAND) 30 31 pedantic: 32 gnatmake -gnat2022 -gnatwa -o bin/nightshade src/nightshade.adb 33 34 fmt: 35 gnatformat src/*.adb src/*.ads 36 37 err: 38 make 2>&1 | grep -w --color=always 'error' 39 40 huh: 41 $(call run_with_explain,$(BUILD_COMMAND))