Makefile 940 字节
Newer Older
W
wangzelin.wzl 已提交
1 2
include Makefile.common

C
chris-sun-star 已提交
3
.PHONY: all test clean build monagent
W
wangzelin.wzl 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

default: clean fmt build

build: build-debug

build-debug: set-debug-flags monagent

build-release: set-release-flags monagent

set-debug-flags:
	@echo Build with debug flags
	$(eval LDFLAGS += $(LDFLAGS_DEBUG))

set-release-flags:
	@echo Build with release flags
	$(eval LDFLAGS += $(LDFLAGS_RELEASE))

monagent:
	$(GOBUILD) $(GO_RACE_FLAG) -ldflags '$(MONAGENT_LDFLAGS)' -o bin/monagent cmd/monagent/main.go

test:
	$(GOTEST) $(GOTEST_PACKAGES)

fmt:
	@gofmt -s -w $(filter-out , $(GOFILES))

fmt-check:
	@if [ -z "$(UNFMT_FILES)" ]; then \
		echo "gofmt check passed"; \
		exit 0; \
    else \
    	echo "gofmt check failed, not formatted files:"; \
    	echo "$(UNFMT_FILES)" | tr -s " " "\n"; \
    	exit 1; \
    fi

tidy:
	$(GO) mod tidy

vet:
	go vet $$(go list ./...)

clean:
	rm -rf $(GOCOVERAGE_FILE)
	rm -rf tests/mock/*
	rm -rf bin/monagent
	$(GO) clean -i ./...