diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..df2eb4d --- /dev/null +++ b/Makefile @@ -0,0 +1,84 @@ +# LibreForts build helpers — thin wrappers around the Podman workflow. +# +# Everything COMPILES inside the container (Fedora + every dependency prebuilt +# in /usr/local, see Containerfile). The binary RUNS on the host, which supplies +# SDL3 and a display. `make run` does both halves in the right place. +# +# Recipe lines are indented with TABs; make requires it. + +IMAGE := forts-clone-dev +BUILDDIR := builddir +BIN := $(BUILDDIR)/forts-clone + +# Run a command in the dev image with the repo bind-mounted at /src. +PODMAN_RUN := podman run --rm -v "$(CURDIR)":/src:Z --userns=keep-id \ + localhost/$(IMAGE):latest bash -c + +.DEFAULT_GOAL := build +.PHONY: help image build reconfigure run check check-lua shell clean clean-image + +help: + @echo "LibreForts:" + @echo " make image build the Podman dev image (once, and after" + @echo " editing Containerfile)" + @echo " make build compile in the container (default target)" + @echo " make run compile, then run the game on the host" + @echo " make check compile + validate the Lua data (do this before" + @echo " claiming a change works)" + @echo " make check-lua validate the Lua data only" + @echo " make reconfigure re-run meson setup, after editing meson.build" + @echo " make shell interactive shell in the dev container" + @echo " make clean remove $(BUILDDIR)" + @echo " make clean-image remove the Podman dev image" + +image: + podman build -t $(IMAGE) . + +# Configures builddir on first use, then compiles. Re-running is cheap. +build: + $(PODMAN_RUN) 'cd /src && { [ -f $(BUILDDIR)/build.ninja ] || \ + meson setup $(BUILDDIR); } && meson compile -C $(BUILDDIR)' + +# meson refuses a plain re-setup on a configured dir; this is the escape hatch. +reconfigure: + $(PODMAN_RUN) 'cd /src && meson setup $(BUILDDIR) --reconfigure && \ + meson compile -C $(BUILDDIR)' + +# Runs on the HOST, from the repo root: data/ is resolved relative to CWD. +run: build + ./$(BIN) + +check: build check-lua + +# The GUI cannot run headless here, so parsing the Lua is the other half of +# "it works". Mods are validated LAYERED (base file first), because they +# table.insert into globals the base defines — running one alone always fails. +check-lua: + @command -v lua >/dev/null 2>&1 || \ + { echo "check-lua: no 'lua' on the host, skipping"; exit 0; } + @set -e; \ + for f in data/*.lua; do \ + lua -e "dofile('$$f')"; \ + echo " OK $$f"; \ + done; \ + for f in data/mods/*/*.lua; do \ + [ -e "$$f" ] || continue; \ + base="data/$$(basename "$$f")"; \ + if [ -f "$$base" ]; then \ + lua -e "dofile('$$base'); dofile('$$f')"; \ + echo " OK $$f (layered on $$base)"; \ + else \ + lua -e "dofile('$$f')"; \ + echo " OK $$f"; \ + fi; \ + done + +shell: + podman run --rm -it -v "$(CURDIR)":/src:Z --userns=keep-id \ + localhost/$(IMAGE):latest bash + +clean: + rm -rf $(BUILDDIR) + +clean-image: + -podman rmi localhost/$(IMAGE):latest |
