.PHONY: build test vet fmt check run install fixture install-script clean version release-build MODULE := github.com/honeypeer/cli-viz VERSION ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo dev) COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -s -w \ -X $(MODULE)/internal/update.BuildCommit=$(COMMIT) \ -X $(MODULE)/internal/update.BuildTime=$(DATE) build: go build -trimpath -ldflags "$(LDFLAGS)" -o bin/hp-viz ./cmd/hp-viz/ # Release-style multi-arch archives (mirrors CI). release-build: @mkdir -p dist @for spec in "linux amd64" "linux arm64" "darwin amd64" "darwin arm64"; do \ set -- $$spec; os=$$1 arch=$$2; \ bin="hp-viz-$${os}-$${arch}"; \ GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o "dist/$${bin}" ./cmd/hp-viz/; \ tar -czf "dist/$${bin}.tar.gz" -C dist "$${bin}"; \ sha256sum "dist/$${bin}.tar.gz" | awk '{print $$1}' > "dist/$${bin}.tar.gz.sha256"; \ echo "built dist/$${bin}.tar.gz"; \ done test: go test ./... vet: go vet ./... fmt: gofmt -w $$(find . -name '*.go' -not -path './.git/*') # Fail if sources are not gofmt-clean (CI). fmt-check: @unformatted=$$(gofmt -l $$(find . -name '*.go' -not -path './.git/*')); \ if [ -n "$$unformatted" ]; then \ echo "gofmt needed on:"; echo "$$unformatted"; exit 1; \ fi check: fmt-check vet test go build -o /tmp/hp-viz-check ./cmd/hp-viz/ version: build ./bin/hp-viz --version install: build install -m 755 bin/hp-viz $(DESTDIR)/usr/local/bin/hp-viz install-script: bash scripts/install.sh fixture: build ./bin/hp-viz --fixture tests/fixtures/sse-sample.txt --no-update run: build ./bin/hp-viz --url $(or $(URL),https://viz.honeypeer.com) --no-update clean: rm -rf bin/ dist/ /tmp/hp-viz-check