-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
86 lines (62 loc) · 2.24 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
81
82
83
84
85
86
#!/usr/bin/make -f
DOCKER := $(shell which docker)
COMMIT := $(shell git log -1 --format='%H')
VERSION := nightly
ldflags := $(LDFLAGS)
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=hyperlane \
-X github.com/cosmos/cosmos-sdk/version.AppName=hypd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-s -w
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -ldflags '$(ldflags)' -trimpath -tags 'ledger' -buildvcs=false
all: proto-all format lint test build-simapp
#################
### Build ###
#################
build-simapp:
@echo "--> Building simapp..."
@go build $(BUILD_FLAGS) -o "$(PWD)/build/" ./tests/hypd
@echo "--> Completed build!"
release-simapp:
@echo "--> Release simapp..."
@for b in darwin:amd64 darwin:arm64 linux:amd64 linux:arm64; do \
os=$$(echo $$b | cut -d':' -f1); \
arch=$$(echo $$b | cut -d':' -f2); \
echo "--> Building "$$os" "$$arch""; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build $(BUILD_FLAGS) -o release/hypd_"$$os"_"$$arch" ./tests/hypd; \
done
test:
@echo "--> Running tests"
@go test -cover -mod=readonly ./x/... ./util/...
.PHONY: build-simapp release-simapp test
##################
### Protobuf ###
##################
protoVer=0.15.3
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -u 0 -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
proto-all: proto-format proto-lint proto-gen
proto-gen:
@echo "--> Generating protobuf files..."
@$(protoImage) sh ./proto/protocgen.sh
@go mod tidy
proto-format:
@echo "--> Running protobuf formatter..."
@$(protoImage) find ./proto -name "*.proto" -exec clang-format -i {} \;
proto-lint:
@echo "--> Running protobuf linter..."
@$(protoImage) buf lint proto/ --error-format=json
.PHONY: proto-all proto-gen proto-format proto-lint
#################
### Linting ###
#################
gofumpt_cmd=mvdan.cc/gofumpt
golangci_lint_cmd=github.com/golangci/golangci-lint/cmd/[email protected]
format:
@echo "--> Running Go formatter..."
@go run $(gofumpt_cmd) -l -w .
lint:
@echo "--> Running Go linter..."
@go run $(golangci_lint_cmd) run --exclude-dirs scripts --timeout=10m
.PHONY: format lint