diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 12:42:08 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 12:42:08 -0300 |
| commit | 7fd555fcaf4304cb0dff3e8f5661565c3618299e (patch) | |
| tree | 61199793c3046d73b97e9822895ede2a33034d41 /Makefile | |
| download | lua-7fd555fcaf4304cb0dff3e8f5661565c3618299e.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d3c470d --- /dev/null +++ b/Makefile @@ -0,0 +1,63 @@ +# Development tasks. +# +# make list the targets +# make test run the suite +# make lint luacheck if installed, otherwise luac -p; touches nothing +# make build byte-compile every module into build/ +# +# LUA pins the interpreter. It defaults to `lua`; override it to run the suite +# on another one, e.g. `make test LUA=lua5.4` or `make test LUA=luajit`. +LUA ?= lua +LUAC ?= luac + +SOURCES := cepis.lua $(wildcard cepis/*.lua) +ALL_LUA := $(SOURCES) $(wildcard test/*.lua) + +.DEFAULT_GOAL := help +.PHONY: help test lint format build check clean + +help: + @echo 'Targets:' + @echo ' test run the test suite (LUA=$(LUA))' + @echo ' lint luacheck when installed, else $(LUAC) -p (read-only)' + @echo ' format apply stylua when installed (writes)' + @echo ' build byte-compile every module into build/' + @echo ' check lint + test + build, in that order' + @echo ' clean remove build artefacts' + @echo + @echo 'Override the interpreter with e.g. make test LUA=luajit' + +test: + @$(LUA) test/run.lua + +# Read-only by design, so it is safe in CI and in a pre-commit hook. luacheck +# is the real linter; luac -p is the fallback that needs nothing installed and +# still catches a syntax error before the suite does. +lint: + @if command -v luacheck >/dev/null 2>&1; then \ + luacheck $(ALL_LUA); \ + else \ + echo '==> luacheck not installed, checking syntax with $(LUAC) -p'; \ + $(LUAC) -p $(ALL_LUA) && echo 'syntax ok'; \ + fi + +format: + @if command -v stylua >/dev/null 2>&1; then \ + stylua $(ALL_LUA); \ + else \ + echo '==> stylua not installed, nothing was formatted'; \ + fi + +build: + @mkdir -p build + @for source in $(SOURCES); do \ + $(LUAC) -o "build/$$(echo $$source | tr / _)c" "$$source" || exit 1; \ + done + @echo 'byte-compiled into build/' + +# The order matters: lint is the fastest to fail, so a broken run reports the +# cheapest problem first. +check: lint test build + +clean: + rm -rf build |