-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (111 loc) · 4.86 KB
/
Makefile
File metadata and controls
133 lines (111 loc) · 4.86 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
.PHONY: build_linux_amd64 build dbuild dinit dup ddown duprefresh run
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git log -1 --format='%H')
BUILDDIR := ./build
DOCKER := $(shell which docker)
UNAME_S ?= $(shell uname -s)
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 :=
empty = $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags))
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=shareledger \
-X github.com/cosmos/cosmos-sdk/version.AppName=shareledgerd \
-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)"
# Linux-only static linking flags (macOS linkers don't support these options)
ifeq ($(UNAME_S),Linux)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)' -trimpath
# Extra args passed to `docker build` for dbuild targets.
# Usage:
# make dbuild DOCKER_BUILD_ARGS="--no-cache --progress=plain"
# The Makefile may append some build-args when you override variables like VERSION/COMMIT.
DOCKER_BUILD_ARGS ?=
ifneq ($(filter command line environment,$(origin VERSION)),)
DOCKER_BUILD_ARGS += --build-arg VERSION=$(VERSION)
endif
ifneq ($(filter command line environment,$(origin COMMIT)),)
DOCKER_BUILD_ARGS += --build-arg COMMIT=$(COMMIT)
endif
ifneq ($(filter command line environment,$(origin BUILD_FLAGS)),)
DOCKER_BUILD_ARGS += --build-arg BUILD_FLAGS=$(BUILD_FLAGS)
endif
run:
go run ./cmd/Shareledgerd/main.go start
build_linux_amd64:
env GOOS=linux GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/shareledger_linux_amd64 ./cmd/Shareledgerd
build:
go build -mod=readonly $(BUILD_FLAGS) -o build/shareledger ./cmd/Shareledgerd
dbuild:
docker build -t sharering/shareledger -f ./deploy/docker/Dockerfile . --platform linux/amd64 $(DOCKER_BUILD_ARGS)
mkdir -p $(BUILDDIR)
docker create --name shareledger-extract sharering/shareledger
docker cp shareledger-extract:/bin/shareledger $(BUILDDIR)/shareledger_linux_amd64
docker rm shareledger-extract
dbuild-mac-local:
docker build -t sharering/shareledger -f ./deploy/docker/Dockerfile .
build-linux:
echo $(BUILDDIR)
mkdir -p $(BUILDDIR)
$(DOCKER) build -f Dockerfile.ubuntu --rm --tag sharering/builder:latest .
$(DOCKER) create --name shareledger sharering/builder
$(DOCKER) cp shareledger:/usr/bin/shareledger $(BUILDDIR)/shareledger
$(DOCKER) rm shareledger
dinit:
rm -rf ./deploy/testnet && \
cp -r ./deploy/testnet_config ./deploy/testnet && \
cp ./deploy/testnet/genesis.json ./deploy/testnet/node0/config && \
cp ./deploy/testnet/genesis.json ./deploy/testnet/node1/config && \
cp ./deploy/testnet/genesis.json ./deploy/testnet/node2/config && \
cp ./deploy/testnet/genesis.json ./deploy/testnet/node3/config && \
cp ./deploy/testnet/genesis.json ./deploy/testnet/node4/config
dup:
cd ./deploy && \
docker compose up -d --force-recreate
dup-local-mac:
cd ./deploy && \
docker compose -f docker-compose-dev.yaml up -d --force-recreate
ddown:
cd ./deploy && \
docker compose down
duprefreshall: ddownswap ddown dinit dup dupswap
test:
go test ./... -v
sim-export-import:
@echo "Run Shareledger simulation test WARNING.If there are Insufficient error when run simulation please check the ante/ante.go find the NewDeductFeeDecorator and remove it"
go test ./app/sim_test.go -run=TestAppImportExport -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v skip-checking-voter-role true
sim-full:
@echo "Run Shareledger simulation test WARNING.If there are Insufficient error when run simulation please check the ante/ante.go find the NewDeductFeeDecorator and remove it"
go test ./app/sim_test.go -run=TestAppFullSimulation -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v skip-checking-voter-role true
sim: sim-export-import sim-full
run-test:
go test $$(go list ./... | grep -v /tests/e2e ) -coverprofile .testCoverage.out