makefile standalone

This commit is contained in:
2026-09-16 13:52:04 -03:00
parent fed5d92034
commit c3fe4422f2
3 changed files with 77 additions and 0 deletions

View File

@@ -168,6 +168,26 @@ check "guards on the variable" "1" "$(grep -c 'allow_k8s_contexts(CTX)' Tiltfil
check "asks ports.sh for facts" "1" "$(grep -c "local('bash ports.sh active'" Tiltfile)"
note "the standalone Makefile only calls real verbs"
# That file exists so nothing wrapping these scripts has to GUESS how to call
# them. A generated Makefile once did guess: `rigmini.sh on`, which is not a
# verb, and a bare `rigdeps.sh` for "check and report", which installs. So each
# target's default verb must be one the script's own dispatch accepts — read
# from the script's `case`, not from a list here that could drift from it.
verbs_of() {
sed -n '/^case "\$cmd" in/,/^esac/p' "$1" | grep -oE '^ [a-z]+\)' | tr -d ' )'
}
for pair in deps:rigdeps.sh mem:rigmini.sh; do
target=${pair%%:*}; script=${pair##*:}
verb="$(make --no-print-directory -s -n -f ../standalone/Makefile "$target" 2>/dev/null \
| awk -v s="$script" 'index($0, s) { print $NF; exit }')"
check "make $target -> $script ${verb:-?}, a verb it accepts" "yes" \
"$(verbs_of "../standalone/$script" | grep -qx "$verb" && echo yes || echo "no: '$verb'")"
done
check "no \`mini\` target, which already means minimal footprint" "0" \
"$(grep -cE '^mini:' ../standalone/Makefile)"
note "optional — needs tilt and this rig's cluster"
# Parsing the Tiltfile for real is the only way to know it still evaluates, but
# Tilt snapshots a kubectl context before parsing, so it cannot run without a

43
rig/standalone/Makefile Normal file
View File

@@ -0,0 +1,43 @@
# Optional shorthand for the two standalone scripts. They run without it:
# `bash rigdeps.sh detect` and `bash rigmini.sh status` are the whole interface,
# and this file only spells those out so nobody has to guess them.
#
# Guessing is what went wrong before. A Makefile generated around these scripts
# invented `make mini` -> `rigmini.sh on`, a verb that does not exist, and a bare
# `rigdeps.sh` for "check and report", which actually installs. So every target
# here calls only a verb the script accepts, and ctrl/selftest.sh checks that.
#
# Works wherever the three files sit together — the scripts are found beside
# this Makefile, not in the current directory, so `make -f path/Makefile` works.
#
# Usage:
# make deps report the host and toolchain; changes nothing
# make deps install [dev] download, verify and install into ~/.local/bin
# make mem advertised memory and what caps it; safe
# make mem push allocates until it stops — not on a box you need
HERE := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
# Words after the target become the script's verb and arguments.
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
ifneq ($(ARGS),)
$(eval $(ARGS):;@:)
.PHONY: $(ARGS)
endif
.DEFAULT_GOAL := help
.PHONY: help deps mem
help: ## list targets
@grep -hE '^[a-z][a-z-]*:.*?##' $(MAKEFILE_LIST) | sed 's/:.*##/\t/' | expand -t16
# Defaults to `detect`, not `install`: on a machine you are still evaluating,
# the bare command should report. Installing is a word you type.
deps: ## toolchain [detect|list|verify|install|fetch] (default detect)
bash $(HERE)rigdeps.sh $(or $(ARGS),detect)
# `mem`, matching the full rig's `make mem`, and deliberately NOT `mini`: that
# word already means "minimal footprint" in the projects that use this, and one
# name pointing at two jobs is how the invented target happened.
mem: ## memory and its caps [status|push|all] (default status)
bash $(HERE)rigmini.sh $(or $(ARGS),status)

View File

@@ -39,6 +39,20 @@ bash rigmini.sh status # advertised memory and caps; safe
bash rigmini.sh push # allocates until it stops — not on a machine you need
```
The `Makefile` beside them is **optional shorthand** for exactly those calls —
copy it along or don't; the scripts do not need it:
```bash
make deps # = rigdeps.sh detect (reports; installing is `make deps install`)
make mem # = rigmini.sh status
```
If you wrap these scripts in a Makefile of your own, copy the calls from that
file rather than guessing them. `rigmini.sh` measures memory; it has no `on` or
`off`, and toggling a heavy service off for a smaller footprint is a job for the
project's own manifests, not for this script. `make selftest` in the full rig
fails if this Makefile ever calls a verb its script does not accept.
If an earlier setup already put these tools in some other directory on PATH,
remove that directory and the line that added it — do not rely on `install` to
notice. It only reports shadowing once `~/.local/bin` is itself on PATH, which on