-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
80 lines (56 loc) · 1.77 KB
/
Makefile
1
2
3
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
include Makefile.common
.PHONY: pre-build build bindata obshell rpm buildsucc
default: clean fmt pre-build build
pre-build: bindata swagger
bindata: get
go-bindata -o agent/bindata/bindata.go -pkg bindata agent/assets/...
swagger: get
swag init -g agent/api/agent_route.go -o agent/api/docs
build: build-debug
build-debug: set-debug-flags obshell buildsucc
build-release: set-release-flags obshell buildsucc
build-with-swagger: enable-swagger build-release
rpm:
cd ./rpm && VERSION=$(VERSION) RELEASE=$(RELEASE) NAME=$(NAME) OBSHELL_RELEASE=$(OBSHELL_RELEASE) rpmbuild -bb obshell.spec
set-debug-flags:
@echo Build with debug flags
$(eval LDFLAGS += $(LDFLAGS_DEBUG))
$(eval BUILD_FLAG += $(GO_RACE_FLAG))
set-release-flags:
@echo Build with release flags
$(eval LDFLAGS += $(LDFLAGS_RELEASE))
enable-swagger:
@echo Build with swagger flags
$(eval BUILD_FLAG +=-tags swagger)
enable-sm4:
@echo Build with sm4 flags
$(eval BUILD_FLAG +=-tags sm4)
obshell:
$(GO) build $(BUILD_FLAG) -ldflags '$(OBSHELL_LDFLAGS)' -o bin/obshell cmd/main.go
buildsucc:
@echo Build obshell successfully!
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
get:
$(GO) install github.com/go-bindata/go-bindata/[email protected]+incompatible
$(GO) install github.com/golang/mock/[email protected]
$(GO) install github.com/swaggo/swag/cmd/swag@latest
vet:
go vet $$(go list ./...)
clean:
rm -rf $(GOCOVERAGE_FILE)
rm -rf tests/mock/*
rm -rf bin/ob_mgragent bin/ob_monagent bin/ob_agentctl bin/ob_agentd
$(GO) clean -i ./...
init: pre-build pre-test tidy