BINARY  := bin/hammyd
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -X main.version=$(VERSION)

.PHONY: build run gen test race cover lint tidy clean

build:
	go build -ldflags "$(LDFLAGS)" -o $(BINARY) ./cmd/hammyd

run:
	go run -ldflags "$(LDFLAGS)" ./cmd/hammyd serve

# Regenerate internal/db from queries/*.sql. Run after touching a migration or
# a query; forgetting turns a compile error into a runtime scan error.
gen:
	sqlc generate

test:
	go test ./...

race:
	go test -race ./...

cover:
	go test -cover ./...

lint:
	go vet ./...
	gofmt -l .

tidy:
	go mod tidy

clean:
	rm -rf bin