2020-04-01 22:58:44 +00:00
|
|
|
VERSION = $(shell git describe --dirty --tags --always)
|
|
|
|
DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
|
|
|
PKGS = $(shell go list ./...)
|
|
|
|
TEST_PKGS = $(shell find . -type f -name "*_test.go" -printf '%h\n' | sort -u)
|
|
|
|
GOARGS = GOOS=linux GOARCH=amd64
|
|
|
|
GO_BUILD_ARGS = -buildmode=plugin -ldflags="-w -s"
|
|
|
|
GO_CONTAINER_BUILD_ARGS = -buildmode=plugin -ldflags="-w -s" -a -installsuffix cgo
|
|
|
|
GO_DEBUG_BUILD_ARGS = -buildmode=plugin -gcflags "all=-N -l"
|
|
|
|
PLUGIN_NAME = $(shell basename $(DIR)).so
|
2020-04-11 13:31:08 +00:00
|
|
|
OUT_DIR = $(DIR)../../
|
2020-04-01 22:58:44 +00:00
|
|
|
DEBUG_PORT = 2345
|
|
|
|
|
2020-04-12 01:51:41 +00:00
|
|
|
.PHONY: deps update-deps format compile test cli-cover-report html-cover-report
|
2020-04-01 22:58:44 +00:00
|
|
|
|
|
|
|
all: format compile test
|
|
|
|
|
|
|
|
deps:
|
2020-04-12 01:51:41 +00:00
|
|
|
@go build -buildmode=plugin -v $(DIR)...
|
|
|
|
|
|
|
|
update-deps:
|
2020-04-01 22:58:44 +00:00
|
|
|
@go mod tidy
|
2020-04-11 13:31:08 +00:00
|
|
|
@go get -u
|
2020-04-01 22:58:44 +00:00
|
|
|
|
|
|
|
format:
|
|
|
|
@go fmt $(PKGS)
|
|
|
|
|
|
|
|
compile: deps
|
|
|
|
@mkdir -p $(OUT_DIR)
|
|
|
|
ifdef DEBUG
|
|
|
|
@echo 'Compiling for debugging...'
|
|
|
|
@$(GOARGS) go build $(GO_DEBUG_BUILD_ARGS) -o $(OUT_DIR)/$(PLUGIN_NAME) $(DIR)
|
|
|
|
else ifdef CONTAINER
|
|
|
|
@$(GOARGS) go build $(GO_CONTAINER_BUILD_ARGS) -o $(OUT_DIR)/$(PLUGIN_NAME) $(DIR)
|
|
|
|
else
|
2020-04-12 01:51:41 +00:00
|
|
|
@$(GOARGS) go build $(GO_BUILD_ARGS) -o $(OUT_DIR)/$(PLUGIN_NAME) $(DIR)
|
2020-04-01 22:58:44 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
test:
|
|
|
|
@go test -coverprofile=./cov-raw.out -v $(TEST_PKGS)
|
|
|
|
@cat ./cov-raw.out | grep -v "generated" > ./cov.out
|
|
|
|
@rm -f $(DIR)$(PLUGIN_NAME)
|
|
|
|
|
|
|
|
cli-cover-report:
|
|
|
|
@go tool cover -func=cov.out
|
|
|
|
|
|
|
|
html-cover-report:
|
|
|
|
@go tool cover -html=cov.out -o .coverage.html
|