From 60442ce103c70110b8509eef24f5d13e872b0802 Mon Sep 17 00:00:00 2001 From: sneak Date: Mon, 10 Aug 2026 13:46:25 +0000 Subject: [PATCH] build: add a make build target, drop README's raw go build (closes #19) The executable builds to build/rogue. All generated artifacts go under build/, which .gitignore covers as a whole; a target writing outside it can commit its output. build is in neither check nor test: check stays fmt-check lint test and still writes nothing into the working tree. README's "Building and running" block and the run examples use ./build/rogue, and no raw go invocation is left in the file. Verified: make build writes build/rogue and git status stays clean; GOFLAGS=-count=1 make check green in 34s with the lint layer executing (21.9s, "0 issues.", not CACHED) and the suite running for real (cmd/rogue 1.027s, game 3.450s), git status clean afterwards. --- .dockerignore | 4 ++++ .gitignore | 1 + Makefile | 22 +++++++++++++++++----- README.md | 18 +++++++++--------- TODO.md | 10 ++++++++++ 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4f59329..52f67c3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,7 @@ # excluding a self-contained Go source here drops it from the lint silently. # Never exclude Go sources, go.mod/go.sum or .golangci.yml. .git + +# Generated artifacts only; `make build` puts a multi-megabyte binary here +# and it would otherwise be shipped into the build context. +/build/ diff --git a/.gitignore b/.gitignore index 2b846e1..25aaccd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.log *.out *.test +/build/ /rogue diff --git a/Makefile b/Makefile index 3bd0b22..784d9bd 100644 --- a/Makefile +++ b/Makefile @@ -6,15 +6,27 @@ # around the Go toolchain and prettier so `make fmt` / `make check` behave # the same as in sneak's other repos. -GO_PKGS := ./... -MD_FILES := $(shell git ls-files '*.md') -PRETTIER := prettier --tab-width 4 --prose-wrap always +GO_PKGS := ./... +MD_FILES := $(shell git ls-files '*.md') +PRETTIER := prettier --tab-width 4 --prose-wrap always -.PHONY: check fmt fmt-check lint test +# Every generated artifact goes here, and the whole directory is +# git-ignored. Targets that write outside it can commit their output. +BUILD_DIR := build +BIN := $(BUILD_DIR)/rogue -# Format, lint, and test — the full local pre-commit gate. +.PHONY: build check fmt fmt-check lint test + +# Format, lint, and test — the full local pre-commit gate. Keep this list +# to targets that write nothing into the working tree. check: fmt-check lint test +# Build the executable into $(BUILD_DIR). `go build -o` does not create the +# parent directory. +build: + @mkdir -p $(BUILD_DIR) + go build -o $(BIN) ./cmd/rogue + # Format Go and Markdown in place. fmt: gofmt -w . diff --git a/README.md b/README.md index 691dc81..2c22419 100644 --- a/README.md +++ b/README.md @@ -21,19 +21,19 @@ original program structure and the design of this port. Requires Go 1.25 or later and a terminal at least 80x24. ```bash -go build ./cmd/rogue -./rogue +make build +./build/rogue ``` ```bash # Restore a saved game -./rogue ~/rogue.save +./build/rogue ~/rogue.save # View high scores -./rogue -s +./build/rogue -s # Test the death screen (demo mode) -./rogue -d +./build/rogue -d ``` ## In-game commands @@ -57,7 +57,7 @@ Press `?` in game for the full list. export ROGUEOPTS="name=YourName,terse,jump,fruit=mango" # Wizard (debug) mode, with a reproducible dungeon -ROGUE_WIZARD=1 SEED=12345 ./rogue +ROGUE_WIZARD=1 SEED=12345 ./build/rogue ``` The scoreboard is kept in `~/.rogue.scores`. Save files are Go gob snapshots @@ -80,9 +80,9 @@ For development, the `Makefile` wraps the toolchain: `make fmt` (gofmt + prettier), `make lint` (`script/lint`, which runs golangci-lint inside the pinned container built from `Dockerfile.lint` — it is never installed on the host, so docker is required), `make test` (the suite, under the race detector -with coverage and a timeout), and `make check` (all three). Use the targets -rather than invoking `go test` directly — they carry the flags the project -relies on. +with coverage and a timeout), `make check` (all three), and `make build` (the +executable, into the git-ignored `build/`). Use the targets rather than the +toolchain directly — they carry the flags the project relies on. ## License diff --git a/TODO.md b/TODO.md index 7c2e24c..d67db14 100644 --- a/TODO.md +++ b/TODO.md @@ -35,6 +35,16 @@ is finished. # Completed Steps +- 2026-08-10 `make build` added (https://git.eeqj.de/sneak/rgoue/issues/19). The + executable is built to `build/rogue`; `README.md` no longer contains a raw + `go` invocation anywhere. `build` is in neither `check` nor `test` — + `make check` stays `fmt-check lint test` and still writes nothing into the + working tree. + + Generated artifacts now all live under `build/`, which `.gitignore` covers + as a whole. Anything written outside it is committable, so a target that + puts its output elsewhere reintroduces the stray-artifact problem. + - 2026-08-10 Linting moved into a container (https://git.eeqj.de/sneak/rgoue/issues/41). `golangci-lint` is no longer invoked on the host anywhere in the repo: `Dockerfile.lint` pins