chore: add root Makefile with namespaced targets
Namespaced go-* targets (build, run, test, test-verbose, check, cover, fmt, vet, tidy, install, lint, clean) plus umbrella targets that delegate to them. help is the default. py-* targets will slot in during the Python port. Updates .gitignore with coverage artifacts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
91
Makefile
Normal file
91
Makefile
Normal file
@@ -0,0 +1,91 @@
|
||||
GO_DIR := go
|
||||
BINARY := latprobe
|
||||
ARGS ?=
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# ── help ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
.PHONY: help
|
||||
help: ## Show this help
|
||||
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) \
|
||||
| awk 'BEGIN {FS = ":.*##"}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' \
|
||||
| sort
|
||||
|
||||
# ── umbrella targets (delegate to Go now; py-* will be added during Python port) ──
|
||||
|
||||
.PHONY: all
|
||||
all: check build ## Run checks then build
|
||||
|
||||
.PHONY: build
|
||||
build: go-build ## Build binary (delegates to go-build)
|
||||
|
||||
.PHONY: test
|
||||
test: go-test ## Run tests (delegates to go-test; py-test added later)
|
||||
|
||||
.PHONY: check
|
||||
check: go-check ## Run fmt + vet + test gate (delegates to go-check)
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: go-fmt ## Format source code (delegates to go-fmt)
|
||||
|
||||
.PHONY: vet
|
||||
vet: go-vet ## Run go vet (delegates to go-vet)
|
||||
|
||||
.PHONY: clean
|
||||
clean: go-clean ## Remove build and coverage artifacts
|
||||
|
||||
# ── Go targets ────────────────────────────────────────────────────────────────
|
||||
|
||||
.PHONY: go-build
|
||||
go-build: ## go: build binary → go/latprobe
|
||||
go -C $(GO_DIR) build -o $(BINARY) .
|
||||
|
||||
.PHONY: go-run
|
||||
go-run: ## go: build and run (pass flags via ARGS="…")
|
||||
go -C $(GO_DIR) run . $(ARGS)
|
||||
|
||||
.PHONY: go-test
|
||||
go-test: ## go: run all tests
|
||||
go -C $(GO_DIR) test ./...
|
||||
|
||||
.PHONY: go-test-verbose
|
||||
go-test-verbose: ## go: run all tests with per-case output
|
||||
go -C $(GO_DIR) test -v ./...
|
||||
|
||||
.PHONY: go-check
|
||||
go-check: go-fmt go-vet go-test ## go: fmt + vet + test (pre-commit gate)
|
||||
|
||||
.PHONY: go-cover
|
||||
go-cover: ## go: run tests with coverage → go/coverage.html
|
||||
go -C $(GO_DIR) test -coverprofile=coverage.out ./...
|
||||
go -C $(GO_DIR) tool cover -html=coverage.out -o coverage.html
|
||||
@echo "Coverage report: $(GO_DIR)/coverage.html"
|
||||
|
||||
.PHONY: go-fmt
|
||||
go-fmt: ## go: format all Go source files with gofmt
|
||||
gofmt -w $(GO_DIR)
|
||||
|
||||
.PHONY: go-vet
|
||||
go-vet: ## go: run go vet on all packages
|
||||
go -C $(GO_DIR) vet ./...
|
||||
|
||||
.PHONY: go-tidy
|
||||
go-tidy: ## go: run go mod tidy
|
||||
go -C $(GO_DIR) mod tidy
|
||||
|
||||
.PHONY: go-install
|
||||
go-install: ## go: install binary to $GOBIN / $GOPATH/bin
|
||||
go -C $(GO_DIR) install .
|
||||
|
||||
.PHONY: go-lint
|
||||
go-lint: ## go: run golangci-lint (must be installed)
|
||||
@command -v golangci-lint >/dev/null 2>&1 || { \
|
||||
echo "golangci-lint not installed — see https://golangci-lint.run/usage/install/"; \
|
||||
exit 1; \
|
||||
}
|
||||
cd $(GO_DIR) && golangci-lint run
|
||||
|
||||
.PHONY: go-clean
|
||||
go-clean: ## go: remove binary and coverage artifacts
|
||||
rm -f $(GO_DIR)/$(BINARY) $(GO_DIR)/coverage.out $(GO_DIR)/coverage.html
|
||||
Reference in New Issue
Block a user