forked from ThinkInAIXYZ/go-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (90 loc) · 2.18 KB
/
Copy pathMakefile
File metadata and controls
110 lines (90 loc) · 2.18 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
user := $(shell whoami)
rev := $(shell git rev-parse --short HEAD)
os := $(shell sh -c 'echo $$(uname -s) | cut -c1-5')
# GOBIN > GOPATH > INSTALLDIR
# Mac OS X
ifeq ($(shell uname),Darwin)
GOBIN := $(shell echo ${GOBIN} | cut -d':' -f1)
GOPATH := $(shell echo $(GOPATH) | cut -d':' -f1)
endif
# Linux
ifeq ($(os),Linux)
GOBIN := $(shell echo ${GOBIN} | cut -d':' -f1)
GOPATH := $(shell echo $(GOPATH) | cut -d':' -f1)
endif
# Windows
ifeq ($(os),MINGW)
GOBIN := $(subst \,/,$(GOBIN))
GOPATH := $(subst \,/,$(GOPATH))
GOBIN :=/$(shell echo "$(GOBIN)" | cut -d';' -f1 | sed 's/://g')
GOPATH :=/$(shell echo "$(GOPATH)" | cut -d';' -f1 | sed 's/://g')
endif
BIN := ""
# check GOBIN
ifneq ($(GOBIN),)
BIN=$(GOBIN)
else
# check GOPATH
ifneq ($(GOPATH),)
BIN=$(GOPATH)/bin
endif
endif
TOOLS_SHELL="./hack/tools.sh"
# golangci-lint
LINTER := bin/golangci-lint
$(LINTER):
curl -SL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v2.1.1
.PHONY: init-dev
init-dev:
go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest
go install mvdan.cc/gofumpt@latest
go install golang.org/x/tools/cmd/goimports@latest
.PHONY: inspector
inspector:
npx -y @modelcontextprotocol/inspector
.PHONY: fmt
fmt:
gofumpt -w -l .
goimports -w -l .
.PHONY: clean
clean:
@${TOOLS_SHELL} tidy
@echo "clean finished"
.PHONY: fix
fix: $(LINTER)
@${TOOLS_SHELL} fix
@echo "lint fix finished"
.PHONY: test
test:
@${TOOLS_SHELL} test
@echo "go test finished"
.PHONY: test-coverage
test-coverage:
@${TOOLS_SHELL} test_coverage
@echo "go test with coverage finished"
.PHONY: lint
lint: $(LINTER)
echo $(os)
@${TOOLS_SHELL} lint
@echo "lint check finished"
.PHONY: changelog
# 生成 changelog
changelog:
git-chglog -o ./CHANGELOG.md
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help