2
0

Makefile 978 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. .DEFAULT_GOAL := all
  2. .DELETE_ON_ERROR:
  3. .SUFFIXES:
  4. include .env
  5. export
  6. PROJECT := $(shell cat go.mod | grep '^module\s' | cut -b 8-)
  7. export VERSION ?= $(shell date -u '+%F')-snapshot
  8. export DEBUG ?= 0
  9. BUILD_TIME := $(shell date -u '+%F_%T')
  10. COMMIT_HASH := $(shell git rev-parse --short HEAD)
  11. LDFLAGS := '-linkmode external -w -s -extldflags "-static" -X $(PROJECT).Version=$(VERSION)'
  12. GCFLAGS :=
  13. ifeq ($(DEBUG),1)
  14. GCFLAGS = "all=-N -l"
  15. endif
  16. .PHONY: all
  17. all: gen deps fmt test
  18. .PHONY: gen
  19. gen:
  20. -@echo "-> $@"
  21. -@echo "=== Generate strategies"
  22. $(foreach file, $(filter-out $(wildcard ./strategy/*_test.go), $(wildcard ./strategy/*.go)), CGO_ENABLED=1 go build -ldflags=$(LDFLAGS) -buildmode=plugin -gcflags=$(GCFLAGS) -o $(file).so $(file);)
  23. .PHONY: deps
  24. deps:
  25. -@echo "-> $@"
  26. go mod tidy
  27. .PHONY: fmt
  28. fmt:
  29. -@echo "-> $@"
  30. -go fmt $(shell go list ./...)
  31. .PHONY: test
  32. test:
  33. -@echo "-> $@"
  34. CGO_ENABLED=1 go test $(shell go list ./...)
  35. -go vet $(shell go list ./...)