Makefile 776 B

123456789101112131415161718192021222324252627282930313233
  1. BINARY := cc-switch
  2. PKG := ./cmd/cc-switch
  3. DIST := dist
  4. VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
  5. COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
  6. DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
  7. LDFLAGS := -s -w \
  8. -X github.com/kotoyuuko/cc-switch-cli/internal/cli.version=$(VERSION) \
  9. -X github.com/kotoyuuko/cc-switch-cli/internal/cli.commit=$(COMMIT) \
  10. -X github.com/kotoyuuko/cc-switch-cli/internal/cli.date=$(DATE)
  11. .PHONY: build test vet fmt clean install
  12. build:
  13. @mkdir -p $(DIST)
  14. go build -trimpath -ldflags '$(LDFLAGS)' -o $(DIST)/$(BINARY) $(PKG)
  15. test:
  16. go test ./...
  17. vet:
  18. go vet ./...
  19. fmt:
  20. gofmt -w .
  21. install:
  22. go install -trimpath -ldflags '$(LDFLAGS)' $(PKG)
  23. clean:
  24. rm -rf $(DIST)