.DEFAULT_GOAL := all .DELETE_ON_ERROR: .SUFFIXES: include .env export PROJECT := $(shell cat go.mod | grep '^module\s' | cut -b 8-) export VERSION ?= $(shell date -u '+%F')-snapshot export DEBUG ?= 0 BUILD_TIME := $(shell date -u '+%F_%T') COMMIT_HASH := $(shell git rev-parse --short HEAD) LDFLAGS := '-linkmode external -w -s -extldflags "-static" -X $(PROJECT).Version=$(VERSION)' GCFLAGS := ifeq ($(DEBUG),1) GCFLAGS = "all=-N -l" endif .PHONY: all all: gen deps fmt test .PHONY: gen gen: -@echo "-> $@" -@echo "=== Generate strategies" $(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);) .PHONY: deps deps: -@echo "-> $@" go mod tidy .PHONY: fmt fmt: -@echo "-> $@" -go fmt $(shell go list ./...) .PHONY: test test: -@echo "-> $@" CGO_ENABLED=1 go test $(shell go list ./...) -go vet $(shell go list ./...)