-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (93 loc) · 4.56 KB
/
Makefile
File metadata and controls
117 lines (93 loc) · 4.56 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
111
112
113
114
115
116
117
GO = CGO_ENABLED=0 GO111MODULE=on GOPROXY=https://goproxy.cn,direct go
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
GIT_BRANCH := $(shell git symbolic-ref --short -q HEAD)
GIT_COMMIT_HASH := $(shell git rev-parse HEAD|cut -c 1-8)
GO_FLAGS := -v -ldflags="-X 'github.com/voidint/g/build.Built=$(BUILD_DATE)' -X 'github.com/voidint/g/build.GitCommit=$(GIT_COMMIT_HASH)' -X 'github.com/voidint/g/build.GitBranch=$(GIT_BRANCH)'"
all: install lint test clean
build:
mkdir -p bin
$(GO) build $(GO_FLAGS) -o ./bin/g
install: build
$(GO) install $(GO_FLAGS)
build-all: build-linux build-darwin build-windows build-freebsd
build-linux: build-linux-386 build-linux-amd64 build-linux-arm build-linux-arm64 build-linux-s390x build-linux-riscv64
build-linux-386:
GOOS=linux GOARCH=386 $(GO) build $(GO_FLAGS) -o bin/linux-386/g
build-linux-amd64:
GOOS=linux GOARCH=amd64 $(GO) build $(GO_FLAGS) -o bin/linux-amd64/g
build-linux-arm:
GOOS=linux GOARCH=arm $(GO) build $(GO_FLAGS) -o bin/linux-arm/g
build-linux-arm64:
GOOS=linux GOARCH=arm64 $(GO) build $(GO_FLAGS) -o bin/linux-arm64/g
build-linux-s390x:
GOOS=linux GOARCH=s390x $(GO) build $(GO_FLAGS) -o bin/linux-s390x/g
build-linux-riscv64:
GOOS=linux GOARCH=riscv64 $(GO) build $(GO_FLAGS) -o bin/linux-riscv64/g
build-darwin: build-darwin-amd64 build-darwin-arm64
build-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(GO) build $(GO_FLAGS) -o bin/darwin-amd64/g
build-darwin-arm64:
GOOS=darwin GOARCH=arm64 $(GO) build $(GO_FLAGS) -o bin/darwin-arm64/g
build-windows: build-windows-386 build-windows-amd64 build-windows-arm build-windows-arm64
build-windows-386:
GOOS=windows GOARCH=386 $(GO) build $(GO_FLAGS) -o bin/windows-386/g.exe
build-windows-amd64:
GOOS=windows GOARCH=amd64 $(GO) build $(GO_FLAGS) -o bin/windows-amd64/g.exe
build-windows-arm:
GOOS=windows GOARCH=arm $(GO) build $(GO_FLAGS) -o bin/windows-arm/g.exe
build-windows-arm64:
GOOS=windows GOARCH=arm64 $(GO) build $(GO_FLAGS) -o bin/windows-arm64/g.exe
build-freebsd: build-freebsd-386 build-freebsd-amd64 build-freebsd-arm build-freebsd-arm64 build-freebsd-riscv64
build-freebsd-386:
GOOS=freebsd GOARCH=386 $(GO) build $(GO_FLAGS) -o bin/freebsd-386/g
build-freebsd-amd64:
GOOS=freebsd GOARCH=amd64 $(GO) build $(GO_FLAGS) -o bin/freebsd-amd64/g
build-freebsd-arm:
GOOS=freebsd GOARCH=arm $(GO) build $(GO_FLAGS) -o bin/freebsd-arm/g
build-freebsd-arm64:
GOOS=freebsd GOARCH=arm64 $(GO) build $(GO_FLAGS) -o bin/freebsd-arm64/g
build-freebsd-riscv64:
GOOS=freebsd GOARCH=riscv64 $(GO) build $(GO_FLAGS) -o bin/freebsd-riscv64/g
package:
sh ./package.sh
install-tools:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install github.com/google/addlicense@latest
lint:
# Please make sure you are using the latest go version before executing lint
@go version
go vet ./...
golangci-lint run ./...
staticcheck ./...
gosec -exclude=G107,G204,G304,G401,G505 -quiet ./...
test:
go test -v -gcflags=all=-l ./...
test-coverage:
go test -gcflags=all=-l -race -coverprofile=coverage.txt -covermode=atomic ./...
view-coverage: test-coverage
go tool cover -html=coverage.txt
rm -f coverage.txt
addlicense:
addlicense -v -c "voidint <[email protected]>" -l mit -ignore '.github/**' -ignore 'vendor/**' -ignore '**/*.yml' -ignore '**/*.html' -ignore '**/*.sh' .
clean:
$(GO) clean -x
rm -f sha256sum.txt
rm -rf bin
rm -f coverage.txt
upgrade-deps:
go get -u -v github.com/urfave/cli/v2@latest
go get -u -v github.com/Masterminds/semver/v3@latest
go get -u -v github.com/PuerkitoBio/goquery@latest
go get -u -v github.com/mholt/archiver/v3@latest
go get -u -v github.com/schollz/progressbar/v3@latest
go get -u -v github.com/daviddengcn/go-colortext@latest
go get -u -v github.com/fatih/color@latest
go get -u -v github.com/k0kubun/go-ansi@latest
go get -u -v github.com/agiledragon/gomonkey/v2@latest
go get -u -v github.com/stretchr/testify@latest
go get -u -v golang.org/x/text@latest
mcp-inspector: build
npx @modelcontextprotocol/inspector ./bin/g mcp
.PHONY: all build install install-tools lint test test-coverage view-coverage addlicense package clean upgrade-deps mcp-inspector build-linux build-darwin build-windows build-linux-386 build-linux-amd64 build-linux-arm build-linux-arm64 build-linux-s390x build-linux-riscv64 build-darwin-amd64 build-darwin-arm64 build-windows-386 build-windows-amd64 build-windows-arm build-windows-arm64 build-freebsd build-freebsd-386 build-freebsd-amd64 build-freebsd-arm build-freebsd-arm64 build-freebsd-riscv64