-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
289 lines (234 loc) · 10.3 KB
/
Makefile
File metadata and controls
289 lines (234 loc) · 10.3 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/usr/bin/make -f
# set variables
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
ifeq (,$(VERSION))
VERSION := $(shell git describe --tags)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif
LEDGER_ENABLED ?= true
COSMOS_SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
CMT_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
DOCKER := $(shell which docker)
# process build tags
build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=safrochain \
-X github.com/cosmos/cosmos-sdk/version.AppName=safrochaind \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(CMT_VERSION)
ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
###############################################################################
### Build ###
###############################################################################
verify:
@echo "🔎 - Verifying Dependencies ..."
@go mod verify > /dev/null 2>&1
@go mod tidy
@echo "✅ - Verified dependencies successfully!"
@echo ""
go-cache: verify
@echo "📥 - Downloading and caching dependencies..."
@go mod download
@echo "✅ - Downloaded and cached dependencies successfully!"
@echo ""
install: go-cache
@echo "🔄 - Installing safrochain..."
@go install $(BUILD_FLAGS) -mod=readonly ./cmd/safrochaind
@mkdir -p ./go/bin
@cp $$(go env GOBIN 2>/dev/null || echo $$(go env GOPATH)/bin)/safrochaind ./go/bin/safrochaind || true
@echo "✅ - Installed safrochain successfully! Run it using 'safrochaind'!"
@echo ""
@echo "====== Install Summary ======"
@echo "safrochain: $(VERSION)"
@echo "Cosmos SDK: $(COSMOS_SDK_VERSION)"
@echo "Comet: $(CMT_VERSION)"
@echo "============================="
build: go-cache
@echo "🔄 - Building safrochain..."
@if [ "$(OS)" = "Windows_NT" ]; then \
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o bin/safrochaind.exe ./cmd/safrochaind; \
else \
go build -mod=readonly $(BUILD_FLAGS) -o bin/safrochaind ./cmd/safrochaind; \
fi
@echo "✅ - Built safrochain successfully! Run it using './bin/safrochaind'!"
@echo ""
@echo "====== Install Summary ======"
@echo "safrochain: $(VERSION)"
@echo "Cosmos SDK: $(COSMOS_SDK_VERSION)"
@echo "Comet: $(CMT_VERSION)"
@echo "============================="
test-node:
CHAIN_ID="local-1" HOME_DIR="~/.safrochain" TIMEOUT_COMMIT="500ms" CLEAN=true sh scripts/test_node.sh
.PHONY: verify go-cache install build test-node
###############################################################################
### Tooling ###
###############################################################################
gofumpt=mvdan.cc/gofumpt
gofumpt_version=v0.8.0
golangci_lint=github.com/golangci/golangci-lint/v2/cmd/golangci-lint
golangci_lint_version=v2.1.6
install-format:
@echo "🔄 - Installing gofumpt $(gofumpt_version)..."
@go install $(gofumpt)@$(gofumpt_version)
@echo "✅ - Installed gofumpt successfully!"
@echo ""
install-lint:
@echo "🔄 - Installing golangci-lint $(golangci_lint_version)..."
@go install $(golangci_lint)@$(golangci_lint_version)
@echo "✅ - Installed golangci-lint successfully!"
@echo ""
lint:
@if command -v golangci-lint >/dev/null 2>&1; then \
INSTALLED=$$(golangci-lint version | head -n1 | awk '{print $$4}'); \
echo "Detected golangci-lint $$INSTALLED, required $(golangci_lint_version)"; \
if [ "$$(printf '%s\n' "$(golangci_lint_version)" "$$INSTALLED" | sort -V | head -n1)" != "$(golangci_lint_version)" ]; then \
echo "Updating golangci-lint..."; \
$(MAKE) install-lint; \
fi; \
else \
echo "golangci-lint not found; installing..."; \
$(MAKE) install-lint; \
fi
@echo "🔄 - Linting code..."
@golangci-lint run
@echo "✅ - Linted code successfully!"
format:
@if command -v gofumpt >/dev/null 2>&1; then \
INSTALLED=$$(go version -m $$(command -v gofumpt) | awk '$$1=="mod" {print $$3; exit}'); \
echo "Detected gofumpt $$INSTALLED, required $(gofumpt_version)"; \
if [ "$$(printf '%s\n' "$(gofumpt_version)" "$$INSTALLED" | sort -V | head -n1)" != "$(gofumpt_version)" ]; then \
echo "Updating gofumpt..."; \
$(MAKE) install-format; \
fi; \
else \
echo "gofumpt not found; installing..."; \
$(MAKE) install-format; \
fi
@echo "🔄 - Formatting code..."
@gofumpt -l -w .
@echo "✅ - Formatted code successfully!"
.PHONY: install-format format install-lint lint
###############################################################################
### e2e interchain test ###
###############################################################################
ictest-basic: rm-testcache
cd interchaintest && go test -race -v -run TestBasicsafrochainStart .
ictest-statesync: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainStateSync .
ictest-ibchooks: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainIBCHooks .
ictest-tokenfactory: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainTokenFactory .
ictest-feeshare: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainFeeShare .
ictest-pfm: rm-testcache
cd interchaintest && go test -race -v -run TestPacketForwardMiddlewareRouter .
ictest-globalfee: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainGlobalFee .
ictest-upgrade: rm-testcache
cd interchaintest && go test -race -v -run TestBasicsafrochainUpgrade .
ictest-ibc: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainGaiaIBCTransfer .
ictest-unity-deploy: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainUnityContractDeploy .
ictest-drip: rm-testcache
cd interchaintest && go test -race -v -run Testsafrochaindrip .
ictest-feepay: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainFeePay .
ictest-burn: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainBurnModule .
ictest-cwhooks: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainCwHooks .
ictest-clock: rm-testcache
cd interchaintest && go test -race -v -run TestsafrochainClock .
ictest-gov-fix: rm-testcache
cd interchaintest && go test -race -v -run TestFixRemovedMsgTypeQueryPanic .
rm-testcache:
go clean -testcache
.PHONY: ictest-basic ictest-statesync ictest-ibchooks ictest-tokenfactory ictest-feeshare ictest-pfm ictest-globalfee ictest-upgrade ictest-upgrade-local ictest-ibc ictest-unity-deploy ictest-unity-gov ictest-drip ictest-burn ictest-feepay ictest-cwhooks ictest-clock ictest-gov-fix rm-testcache
###############################################################################
### heighliner ###
###############################################################################
heighliner=github.com/strangelove-ventures/heighliner
heighliner_version=v1.7.2
install-heighliner:
@if ! command -v heighliner > /dev/null; then \
echo "🔄 - Installing heighliner $(heighliner_version)..."; \
go install $(heighliner)@$(heighliner_version); \
echo "✅ - Installed heighliner successfully!"; \
echo ""; \
fi
local-image: install-heighliner
@echo "🔄 - Building Docker Image..."
heighliner build --chain safrochain --local -f ./chains.yaml
@echo "✅ - Built Docker Image successfully!"
.PHONY: install-heighliner local-image
###############################################################################
### Protobuf ###
###############################################################################
protoVer=0.17.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace -v /var/run/docker.sock:/var/run/docker.sock --workdir /workspace $(protoImageName)
proto-all: proto-format proto-lint proto-gen proto-gen-2 proto-swagger-gen
proto-gen:
@echo "🛠️ - Generating Protobuf"
@$(protoImage) sh ./scripts/protoc/protocgen.sh
@echo "✅ - Generated Protobuf successfully!"
proto-gen-2:
@echo "🛠️ - Generating Protobuf v2"
@$(protoImage) sh ./scripts/protoc/protocgen2.sh
@echo "✅ - Generated Protobuf v2 successfully!"
proto-swagger-gen:
@echo "📖 - Generating Protobuf Swagger"
@$(protoImage) sh ./scripts/protoc/protoc-swagger-gen.sh
@echo "✅ - Generated Protobuf Swagger successfully!"
proto-format:
@echo "🖊️ - Formatting Protobuf Swagger"
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
@echo "✅ - Formatted Protobuf successfully!"
proto-lint:
@echo "🔎 - Linting Protobuf"
@$(protoImage) buf lint --error-format=json
@echo "✅ - Linted Protobuf successfully!"
proto-check-breaking:
@echo "🔎 - Checking breaking Protobuf changes"
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main
@echo "✅ - Checked Protobuf changes successfully!"
.PHONY: proto-all proto-gen proto-gen-2 proto-swagger-gen proto-format proto-lint proto-check-breaking