@@ -4,59 +4,116 @@ GOLANG_CROSS_VERSION = v1.18
4
4
5
5
6
6
VERSION := $(shell echo $(shell git describe --tags 2>/dev/null ) | sed 's/^v//')
7
+ TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
7
8
COMMIT := $(shell git log -1 --format='% H')
8
9
NETWORK ?= mainnet
9
10
COVERAGE ?= coverage.txt
10
11
BUILDDIR ?= $(CURDIR ) /build
11
12
LEDGER_ENABLED ?= true
13
+ # RocksDB is a native dependency, so we don't assume the library is installed.
14
+ # Instead, it must be explicitly enabled and we warn when it is not.
15
+ ENABLE_ROCKSDB ?= false
16
+
17
+ export GO111MODULE = on
18
+
19
+ build_tags = netgo
20
+ ifeq ($(LEDGER_ENABLED ) ,true)
21
+ ifeq ($(OS),Windows_NT)
22
+ GCCEXE = $(shell where gcc.exe 2> NUL)
23
+ ifeq ($(GCCEXE),)
24
+ $(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
25
+ else
26
+ build_tags += ledger
27
+ endif
28
+ else
29
+ UNAME_S = $(shell uname -s)
30
+ ifeq ($(UNAME_S),OpenBSD)
31
+ $(warning OpenBSD detected, disabling ledger support (https ://github.com/cosmos/cosmos-sdk/issues/1988))
32
+ else
33
+ GCC = $(shell command -v gcc 2> /dev/null)
34
+ ifeq ($(GCC),)
35
+ $(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
36
+ else
37
+ build_tags += ledger
38
+ endif
39
+ endif
40
+ endif
41
+ endif
42
+
43
+ ifeq (secp,$(findstring secp,$(COSMOS_BUILD_OPTIONS ) ) )
44
+ build_tags += libsecp256k1_sdk
45
+ endif
46
+
47
+ ifeq ($(ENABLE_ROCKSDB ) ,true)
48
+ BUILD_TAGS += rocksdb_build
49
+ test_tags += rocksdb_build
50
+ else
51
+ $(warning RocksDB support is disabled; to build and test with RocksDB support, set ENABLE_ROCKSDB=true)
52
+ endif
12
53
13
54
# DB backend selection
14
55
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS ) ) )
15
- ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
56
+ build_tags += gcc
16
57
endif
17
58
ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS ) ) )
18
- ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=badgerdb
19
- BUILD_TAGS := $(BUILD_TAGS ) ,badgerdb
59
+ BUILD_TAGS += badgerdb
20
60
endif
21
61
# handle rocksdb
22
62
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS ) ) )
23
- $(info # ###############################################################)
24
- $(info To use rocksdb, you need to install rocksdb first)
25
- $(info Please follow this guide https ://github.com/rockset/rocksdb-cloud/blob/master/INSTALL.md)
26
- $(info # ###############################################################)
63
+ ifneq ($(ENABLE_ROCKSDB),true)
64
+ $(error Cannot use RocksDB backend unless ENABLE_ROCKSDB=true)
65
+ endif
27
66
CGO_ENABLED =1
28
- BUILD_TAGS := $(BUILD_TAGS ) ,rocksdb
29
- ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
67
+ BUILD_TAGS += rocksdb
30
68
endif
31
69
# handle boltdb
32
70
ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS ) ) )
33
- BUILD_TAGS := $(BUILD_TAGS ) ,boltdb
34
- ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=boltdb
71
+ BUILD_TAGS += boltdb
72
+ endif
73
+
74
+ ifeq ($(NETWORK ) ,testnet)
75
+ BUILD_TAGS += testnet
76
+ test_tags += testnet
35
77
endif
36
78
37
- ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=crypto-org-chain-chain \
79
+ build_tags += $(BUILD_TAGS )
80
+ build_tags := $(strip $(build_tags ) )
81
+
82
+ whitespace :=
83
+ whitespace += $(whitespace )
84
+ comma := ,
85
+ build_tags_comma_sep := $(subst $(whitespace ) ,$(comma ) ,$(build_tags ) )
86
+
87
+ # process linker flags
88
+
89
+ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=crypto-org-chain-chain \
38
90
-X github.com/cosmos/cosmos-sdk/version.AppName=chain-maind \
39
91
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION ) \
40
- -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT )
92
+ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT ) \
93
+ -X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION ) \
94
+ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep ) "
41
95
42
- BUILD_FLAGS := -ldflags '$(ldflags ) '
43
- TESTNET_FLAGS ?=
96
+ ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS ) ) )
97
+ ldflags += -w -s
98
+ endif
99
+ ldflags += $(LDFLAGS )
100
+ ldflags := $(strip $(ldflags ) )
44
101
45
- ledger ?= HID
46
- ifeq ($(LEDGER_ENABLED ) ,true)
47
- BUILD_TAGS := -tags $(BUILD_TAGS),cgo,ledger,!test_ledger_mock,!ledger_mock
48
- ifeq ($(ledger), ZEMU)
49
- BUILD_TAGS := $(BUILD_TAGS),ledger_zemu
50
- else
51
- BUILD_TAGS := $(BUILD_TAGS),!ledger_zemu
52
- endif
102
+ BUILD_FLAGS := -tags "$(build_tags ) " -ldflags '$(ldflags ) '
103
+ # check for nostrip option
104
+ ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS ) ) )
105
+ BUILD_FLAGS += -trimpath
53
106
endif
54
107
55
- ifeq ( $( NETWORK ) ,testnet)
56
- BUILD_TAGS := $(BUILD_TAGS),testnet
57
- TEST_TAGS := "--tags=testnet "
108
+ # Check for debug option
109
+ ifeq (debug, $( findstring debug, $( COSMOS_BUILD_OPTIONS ) ) )
110
+ BUILD_FLAGS += -gcflags "all=-N -l "
58
111
endif
59
112
113
+ TEST_FLAGS := -tags "$(test_tags ) "
114
+
115
+ TESTNET_FLAGS ?=
116
+
60
117
SIMAPP = github.com/crypto-org-chain/chain-main/v4/app
61
118
BINDIR ?= ~/go/bin
62
119
@@ -68,13 +125,13 @@ download:
68
125
git submodule update --init --recursive
69
126
70
127
install : check-network go.sum
71
- go install -mod=readonly $(BUILD_FLAGS ) $( BUILD_TAGS ) ./cmd/chain-maind
128
+ go install -mod=readonly $(BUILD_FLAGS ) ./cmd/chain-maind
72
129
73
130
build : check-network go.sum
74
- go build -mod=readonly $(BUILD_FLAGS ) $( BUILD_TAGS ) -o $(BUILDDIR ) /chain-maind ./cmd/chain-maind
131
+ go build -mod=readonly $(BUILD_FLAGS ) -o $(BUILDDIR ) /chain-maind ./cmd/chain-maind
75
132
76
133
buildwindows : check-network go.sum
77
- go build -buildmode=exe -mod=readonly $(BUILD_FLAGS ) $( BUILD_TAGS ) -o $(BUILDDIR ) /chain-maind ./cmd/chain-maind
134
+ go build -buildmode=exe -mod=readonly $(BUILD_FLAGS ) -o $(BUILDDIR ) /chain-maind ./cmd/chain-maind
78
135
79
136
80
137
.PHONY : build
@@ -98,7 +155,7 @@ go.sum: go.mod
98
155
GO111MODULE=on go mod verify
99
156
100
157
test : check-network
101
- @go test $(TEST_TAGS ) -v -mod=readonly $(PACKAGES ) -coverprofile=$(COVERAGE ) -covermode=atomic
158
+ @go test $(TEST_FLAGS ) -v -mod=readonly $(PACKAGES ) -coverprofile=$(COVERAGE ) -covermode=atomic
102
159
.PHONY : test
103
160
104
161
# look into .golangci.yml for enabling / disabling linters
@@ -117,22 +174,22 @@ lint-ci:
117
174
118
175
test-sim-nondeterminism : check-network
119
176
@echo " Running non-determinism test..."
120
- @go test $(TEST_TAGS ) -mod=readonly $(SIMAPP ) -run TestAppStateDeterminism -Enabled=true \
177
+ @go test $(TEST_FLAGS ) -mod=readonly $(SIMAPP ) -run TestAppStateDeterminism -Enabled=true \
121
178
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
122
179
123
180
test-sim-custom-genesis-fast : check-network
124
181
@echo " Running custom genesis simulation..."
125
182
@echo " By default, ${HOME} /.chain-maind/config/genesis.json will be used."
126
- @go test $(TEST_TAGS ) -mod=readonly $(SIMAPP ) -run TestFullAppSimulation -Genesis=${HOME} /.gaiad/config/genesis.json \
127
- -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h
183
+ @go test $(TEST_FLAGS ) -mod=readonly $(SIMAPP ) -run TestFullAppSimulation -Genesis=${HOME} /.gaiad/config/genesis.json \
184
+ -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h -ExitOnFail
128
185
129
186
test-sim-import-export :
130
187
@echo " Running Chain import/export simulation. This may take several minutes..."
131
- @$(BINDIR ) /runsim -Jobs=4 -SimAppPkg=$(SIMAPP ) 25 5 TestAppImportExport
188
+ @$(BINDIR ) /runsim -Jobs=4 -SimAppPkg=$(SIMAPP ) -ExitOnFail 25 5 TestAppImportExport
132
189
133
190
test-sim-after-import :
134
191
@echo " Running application simulation-after-import. This may take several minutes..."
135
- @$(BINDIR ) /runsim -Jobs=4 -SimAppPkg=$(SIMAPP ) 50 5 TestAppSimulationAfterImport
192
+ @$(BINDIR ) /runsim -Jobs=4 -SimAppPkg=$(SIMAPP ) -ExitOnFail 50 5 TestAppSimulationAfterImport
136
193
137
194
# ##############################################################################
138
195
# ## Localnet ###
0 commit comments