forked from terra-money/classic-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·180 lines (140 loc) · 5.51 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
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
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
GOTOOLS = \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/rakyll/statik
GOBIN ?= $(GOPATH)/bin
SHASUM := $(shell which sha256sum)
export GO111MODULE = on
# 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
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
ifeq ($(WITH_CLEVELDB),yes)
build_tags += gcc
endif
# process linker flags
ldflags = -X github.com/terra-project/core/version.Version=$(VERSION) \
-X github.com/terra-project/core/version.Commit=$(COMMIT) \
-X "github.com/terra-project/core/version.BuildTags=$(build_tags)" \
ifneq ($(SHASUM),)
ldflags += -X github.com/terra-project/core/version.GoSumHash=$(shell sha256sum go.sum | cut -d ' ' -f1)
endif
ifeq ($(WITH_CLEVELDB),yes)
build_tags += gcc
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
########################################
### All
all: clean go-mod-cache install lint test
########################################
### CI
ci: get_tools install lint test
########################################
### Build/Install
build: update_terra_lite_docs
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/terrad.exe ./cmd/terrad
go build $(BUILD_FLAGS) -o build/terracli.exe ./cmd/terracli
go build $(BUILD_FLAGS) -o build/terrakeyutil.exe ./cmd/terrakeyutil
else
go build $(BUILD_FLAGS) -o build/terrad ./cmd/terrad
go build $(BUILD_FLAGS) -o build/terracli ./cmd/terracli
go build $(BUILD_FLAGS) -o build/terrakeyutil ./cmd/terrakeyutil
endif
build-linux:
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
update_terra_lite_docs:
@statik -src=client/lcd/swagger-ui -dest=client/lcd -f
install: update_terra_lite_docs
go install $(BUILD_FLAGS) ./cmd/terrad
go install $(BUILD_FLAGS) ./cmd/terracli
go install $(BUILD_FLAGS) ./cmd/terrakeyutil
########################################
### Tools & dependencies
get_tools:
go get github.com/rakyll/statik
go get github.com/golangci/golangci-lint/cmd/golangci-lint
update_tools:
@echo "--> Updating tools to correct version"
$(MAKE) --always-make get_tools
go-mod-cache: go-sum
@echo "--> Download go modules to local cache"
@go mod download
go-sum: get_tools
@echo "--> Ensure dependencies have not been modified"
@go mod verify
go-release:
@echo "--> Dry run for go-release"
BUILD_TAGS=$(shell echo \"$(build_tags)\") GOSUM=$(shell sha256sum go.sum | cut -d ' ' -f1) goreleaser release --skip-publish --rm-dist --debug
clean:
rm -rf ./dist
rm -rf ./build
distclean: clean
rm -rf vendor/
########################################
### Testing
test: test_unit
test_unit:
@VERSION=$(VERSION) go test $(PACKAGES_NOSIMULATION)
test_race:
@VERSION=$(VERSION) go test -race $(PACKAGES_NOSIMULATION)
format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/terra-project/core
benchmark:
@go test -bench=. $(PACKAGES_NOSIMULATION)
lint: get_tools ci-lint
ci-lint:
@echo "--> Running lint..."
golangci-lint run
go vet -composites=false -tests=false ./...
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify
########################################
### Local validator nodes using docker and docker-compose
build-docker-terradnode:
$(MAKE) -C networks/local
# Run a 4-node testnet locally
localnet-start: localnet-stop
@if ! [ -f build/node0/terrad/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/terrad:Z tendermint/terradnode testnet --v 5 -o . --starting-ip-address 192.168.10.2; fi
# replace docker ip to local port, mapped
sed -i -e 's/192.168.10.2:26656/localhost:26656/g; s/192.168.10.3:26656/localhost:26659/g; s/192.168.10.4:26656/localhost:26661/g; s/192.168.10.5:26656/localhost:26663/g' $(CURDIR)/build/node4/terrad/config/config.toml
# change allow duplicated ip option to prevent the error : cant not route ~
sed -i -e 's/allow_duplicate_ip \= false/allow_duplicate_ip \= true/g' `find $(CURDIR)/build -name "config.toml"`
docker-compose up -d
# Stop testnet
localnet-stop:
docker-compose down
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build install clean distclean update_terra_lite_docs \
get_tools update_tools \
test test_cli test_unit benchmark \
build-linux build-docker-terradnode localnet-start localnet-stop \
format update_dev_tools lint ci ci-lint\
go-mod-cache go-sum