-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
153 lines (122 loc) · 4.26 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
# include Makefile.ledger
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
ifeq ($(WITH_CLEVELDB),yes)
build_tags += gcc cleveldb
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sgn \
-X github.com/cosmos/cosmos-sdk/version.ServerName=sgnd \
-X github.com/cosmos/cosmos-sdk/version.ClientName=sgncli \
-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)"
ifeq ($(WITH_CLEVELDB),yes)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
.PHONY: all
all: lint install
.PHONY: install
install: go.sum
go install $(BUILD_FLAGS) ./cmd/sgnd
go install $(BUILD_FLAGS) ./cmd/sgncli
install-cli: go.sum
go install $(BUILD_FLAGS) ./cmd/sgncli
install-ops: go.sum
go install $(BUILD_FLAGS) ./cmd/sgnops
install-tools: go.sum
go install $(BUILD_FLAGS) ./cmd/sgncli
go install $(BUILD_FLAGS) ./cmd/sgnops
install-all: go.sum
go install $(BUILD_FLAGS) ./cmd/sgnd
go install $(BUILD_FLAGS) ./cmd/sgncli
go install $(BUILD_FLAGS) ./cmd/sgnops
generate-docs: go.sum
go run ./cmd/gendocs ./docs
find ./docs -type f | xargs sed -i '' 's|'"$$HOME"'|\$$HOME|g'
find ./docs -type f | xargs sed -i '' 's|'"$$HOSTNAME"'|\$$HOSTNAME|g'
find ./docs -type f | xargs sed -i '' 's|'"The node\'s public IP.*"'|'"The node\'s public IP"'|g'
find ./docs -type f | xargs sed -i '' 's|'"Auto generated by spf13/cobra.*"'|Auto generated by spf13/cobra|g'
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify
lint:
golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify
copy-test-data:
cp -r test/data/sgnd ~/.sgnd
cp -r test/data/sgncli ~/.sgncli
remove-test-data:
rm -rf ~/.sgnd ~/.sgncli
.PHONY: reset-test-data
reset-test-data: remove-test-data copy-test-data
################################ Docker related ################################
.PHONY: build
build: go.sum
mkdir -p ./build
go build -o ./build/sgnd ./cmd/sgnd
go build -o ./build/sgncli ./cmd/sgncli
.PHONY: build-linux
build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build
.PHONY: build-dockers
build-dockers:
DOCKER_BUILDKIT=1 docker build --tag celer-network/geth networks/local/geth
DOCKER_BUILDKIT=1 docker build --tag celer-network/sgnnode .
# $(MAKE) -C networks/local
.PHONY: build-node
build-node:
DOCKER_BUILDKIT=1 docker build --tag celer-network/sgnnode .
# Prepare docker environment for multinode testing
.PHONY: prepare-docker-env
prepare-docker-env: build-dockers build-linux prepare-geth-data
# Run geth
.PHONY: localnet-start-geth
localnet-start-geth:
docker-compose stop geth
docker-compose rm -f geth
docker-compose up -d geth
# Run a 3-node sgn testnet locally
.PHONY: localnet-up-nodes
localnet-up-nodes: localnet-down-nodes
docker-compose up -d sgnnode0 sgnnode1 sgnnode2 sgnnode3
# Stop sgn testnet
.PHONY: localnet-down-nodes
localnet-down-nodes:
docker-compose stop sgnnode0 sgnnode1 sgnnode2 sgnnode3
docker-compose rm -f sgnnode0 sgnnode1 sgnnode2 sgnnode3
# Stop both geth and sgn testnet
.PHONY: localnet-down
localnet-down:
docker-compose down
# Prepare geth data
.PHONY: prepare-geth-data
prepare-geth-data:
rm -rf ./docker-volumes/geth-env
mkdir -p ./docker-volumes
cp -r ./test/multi-node-data/geth-env ./docker-volumes/
# Prepare sgn nodes' data
.PHONY: prepare-sgn-data
prepare-sgn-data:
rm -rf ./docker-volumes/node*
mkdir -p ./docker-volumes
cp -r ./test/multi-node-data/node* ./docker-volumes/
# Make a copy of config files for local manual test
.PHONY: copy-manual-test-data
copy-manual-test-data:
rm -rf ./test/e2e/manual/data/node*
cp -r ./docker-volumes/node* ./test/e2e/manual/data/
rm -rf ./test/e2e/manual/data/node*/sgnd
# Clean test data
.PHONY: clean-test
clean-test:
rm -rf ./docker-volumes ./build