-
Notifications
You must be signed in to change notification settings - Fork 825
/
Copy pathMakefile
158 lines (125 loc) · 4.74 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
#!/usr/bin/make -f
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
export PROJECT_HOME=$(shell git rev-parse --show-toplevel)
export GO_PKG_PATH=$(HOME)/go/pkg
export GO111MODULE = on
NITRO_RELEASE_PATH := $(PROJECT_HOME)/nitro-replayer/target/release
NITRO_LIB_PATH := $(PROJECT_HOME)/x/nitro/
# process build tags
LEDGER_ENABLED ?= true
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
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
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=sei \
-X github.com/cosmos/cosmos-sdk/version.ServerName=seid \
-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 ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
# BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' -race
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
#### Command List ####
all: lint install
install: go.sum
go install $(BUILD_FLAGS) ./cmd/seid
# In case when running seid fails with nitro issue or if you make changes to nitro, please use install-all
install-all: build-nitro install
install-price-feeder: go.sum
go install $(BUILD_FLAGS) ./oracle/price-feeder
loadtest: go.sum
go build $(BUILD_FLAGS) -o ./build/loadtest ./loadtest/
price-feeder: go.sum
go build $(BUILD_FLAGS) -o ./build/price-feeder ./oracle/price-feeder
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@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
build:
go build $(BUILD_FLAGS) -o ./build/seid ./cmd/seid
# In case running seid fails with nitro issue or if you make changes to nitro, please use build-all
build-all: build-nitro build
build-nitro:
@cd $(PROJECT_HOME)/nitro-replayer && cargo build --release
if [ -f "$(NITRO_RELEASE_PATH)/libnitro_replayer.dylib" ]; then \
cp $(NITRO_RELEASE_PATH)/libnitro_replayer.dylib $(NITRO_LIB_PATH)/replay; \
fi
if [ -f "$(NITRO_RELEASE_PATH)/libnitro_replayer.x86_64.so" ]; then \
cp $(NITRO_RELEASE_PATH)/libnitro_replayer.x86_64.so $(NITRO_LIB_PATH)/replay; \
fi
clean:
rm -rf ./build
###############################################################################
### Local testing using docker container ###
###############################################################################
# To start a 4-node cluster from scratch:
# make clean && make docker-cluster-start
# To stop the 4-node cluster:
# make docker-cluster-stop
# If you have already built the binary, you can skip the build:
# make docker-cluster-start-skipbuild
###############################################################################
# Build linux binary on other platforms
build-linux:
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 make build
.PHONY: build-linux
# Build docker image
build-docker-node:
@cd docker && docker build --tag sei-chain/localnode localnode
.PHONY: build-docker-localnode
# Run a single docker container
run-docker-node:
@rm -rf $(PROJECT_HOME)/build/generated
docker run --rm \
-v $(PROJECT_HOME):/sei-protocol/sei-chain:Z \
-v $(GO_PKG_PATH)/mod:/root/go/pkg/mod:Z \
sei-chain/localnode
.PHONY: run-docker-localnode
# Run a 4-node docker containers
docker-cluster-start: docker-cluster-stop build-docker-node
@rm -rf $(PROJECT_HOME)/build/generated
@cd docker && NUM_ACCOUNTS=10 docker-compose up
.PHONY: localnet-start
# Use this to skip the seid build process
docker-cluster-start-skipbuild: docker-cluster-stop build-docker-node
@rm -rf $(PROJECT_HOME)/build/generated
@cd docker && NUM_ACCOUNTS=10 SKIP_BUILD=true docker-compose up
.PHONY: localnet-start
# Stop 4-node docker containers
docker-cluster-stop:
@cd docker && docker-compose down
.PHONY: localnet-stop