-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (69 loc) · 2.56 KB
/
Makefile
File metadata and controls
92 lines (69 loc) · 2.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
# Copyright (c) 2024-2025 Hemi Labs, Inc.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.
# PROJECTPATH is the project root directory.
# This Makefile is stored in the project root directory, so the directory is
# retrieved by getting the directory of this Makefile.
PROJECTPATH = $(abspath $(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
export GOBIN=$(PROJECTPATH)/bin
export GOCACHE=$(PROJECTPATH)/.gocache
export GOPKG=$(PROJECTPATH)/pkg
GO_LDFLAGS=
# renovate: datasource=github-releases depName=golangci/golangci-lint versioning=semver
GOLANGCI_LINT_VERSION="v2.11.4"
# renovate: datasource=github-releases depName=joshuasing/golicenser versioning=semver
GOLICENSER_VERSION="v0.3.1"
# renovate: datasource=github-releases depName=mvdan/gofumpt versioning=semver
GOFUMPT_VERSION="v0.9.2"
cmds = \
bfgd \
hemictl \
hproxyd \
keygen \
popmd \
tbcd \
transfunctionerd \
.PHONY: all clean deps go-deps $(cmds) build install lint lint-deps tidy race test vulncheck \
vulncheck-deps
all: tidy build lint test install
clean: clean-test
rm -rf $(GOBIN) $(GOCACHE) $(GOPKG)
clean-test:
rm -rf $(PROJECTPATH)/service/tbc/.testleveldb/
deps: lint-deps vulncheck-deps go-deps
go-deps:
go mod download
go mod tidy
go mod verify
$(cmds):
go build -trimpath -ldflags "$(GO_LDFLAGS)" -o $(GOBIN)/$@ ./cmd/$@
build:
go build ./...
install: $(cmds)
define LICENSE_HEADER
Copyright (c) {{.year}} {{.author}}
Use of this source code is governed by the MIT License,
which can be found in the LICENSE file.
endef
export LICENSE_HEADER
lint:
$(shell go env GOPATH)/bin/golangci-lint fmt ./...
$(shell go env GOPATH)/bin/golangci-lint run --fix ./...
$(shell go env GOPATH)/bin/golicenser -tmpl="$$LICENSE_HEADER" -author="Hemi Labs, Inc." -year-mode=git-range -fix ./...
lint-deps:
@echo "Installing with $(shell go env GOVERSION)"
GOBIN=$(shell go env GOPATH)/bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
GOBIN=$(shell go env GOPATH)/bin go install github.com/joshuasing/golicenser/cmd/golicenser@$(GOLICENSER_VERSION)
GOBIN=$(shell go env GOPATH)/bin go install mvdan.cc/gofumpt@$(GOFUMPT_VERSION)
tidy:
go mod tidy
race:
go test -v -race ./...
test:
go test -test.timeout=20m -coverprofile=$(PROJECTPATH)/coverage.out -covermode=atomic ./...
synctest-test:
cd ./synctest && go test -v -test.timeout=1m ./...
vulncheck:
$(shell go env GOPATH)/bin/govulncheck ./...
vulncheck-deps:
GOBIN=$(shell go env GOPATH)/bin go install golang.org/x/vuln/cmd/govulncheck@latest