59 lines
1.3 KiB
Makefile
59 lines
1.3 KiB
Makefile
export DEBUG = routewatch
|
|
|
|
# Git revision for version embedding
|
|
GIT_REVISION := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
|
|
GIT_REVISION_SHORT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
|
|
VERSION_PKG := git.eeqj.de/sneak/routewatch/internal/version
|
|
LDFLAGS := -X $(VERSION_PKG).GitRevision=$(GIT_REVISION) -X $(VERSION_PKG).GitRevisionShort=$(GIT_REVISION_SHORT)
|
|
|
|
.PHONY: bootstrap setup check test lint fmt fmt-check docker hooks build clean run asupdate
|
|
|
|
all: test
|
|
|
|
# Install all development dependencies.
|
|
bootstrap:
|
|
@script/bootstrap
|
|
|
|
# Prepare a fresh clone: bootstrap plus pre-commit hook.
|
|
setup:
|
|
@script/setup
|
|
|
|
# Combined pre-commit/CI gate: tests, lint, format check.
|
|
check:
|
|
@script/check
|
|
|
|
test:
|
|
@script/test
|
|
|
|
fmt:
|
|
@script/fmt
|
|
|
|
# Check if code is formatted (read-only).
|
|
fmt-check:
|
|
@script/fmt-check
|
|
|
|
lint:
|
|
@script/lint
|
|
|
|
# Build Docker image.
|
|
docker:
|
|
@script/docker
|
|
|
|
# Install pre-commit hook.
|
|
hooks:
|
|
@script/install-precommit
|
|
|
|
build:
|
|
CGO_ENABLED=1 go build -ldflags "$(LDFLAGS)" -o bin/routewatch cmd/routewatch/main.go
|
|
|
|
clean:
|
|
rm -rf bin/
|
|
|
|
run: build
|
|
DEBUG=routewatch ./bin/routewatch 2>&1 | tee log.txt
|
|
|
|
asupdate:
|
|
@echo "Updating AS info data..."
|
|
@go run cmd/asinfo-gen/main.go | gzip > pkg/asinfo/asdata.json.gz.tmp && \
|
|
mv pkg/asinfo/asdata.json.gz.tmp pkg/asinfo/asdata.json.gz
|