-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
98 lines (72 loc) · 3.16 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
PACKAGES=$(shell go list ./... | grep -v '/simulation')
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COSMOS_PKG_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
export GO111MODULE = on
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=decentr \
-X github.com/cosmos/cosmos-sdk/version.AppName=decentrd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
BUILD_FLAGS := -ldflags '$(ldflags)'
all: install
build: go.sum
ifeq ($(OS), Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/decentrd.exe ./cmd/decentrd
else
go build -mod=readonly $(BUILD_FLAGS) -o build/$(shell go env GOOS)/decentrd ./cmd/decentrd
endif
install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/decentrd
linux: go.sum
GOOS=linux GOARCH=amd64 $(MAKE) build
### tools ###
clean:
rm -rf build/
go.sum:
@echo "--> Ensure dependencies have not been modified"
go mod verify
vendor:
go mod tidy
go mod vendor
### qa ###
test:
@echo "--> Running tests"
go test -mod=readonly $(PACKAGES)
# look into .golangci.yml for enabling / disabling linters
lint:
@echo "--> Running linter"
@golangci-lint run
@go mod verify
start:
bash init.sh
### proto ###
docker_buf := docker run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
buildtools=decentr/buildtools:v0.1
containerProtoGen=decentr-buildtools-protogen
containerProtoSwaggerGen=decentr-buildtools-protoswaggergen
containerProtoFmt=decentr-buildtools-protofmt
proto-all: proto-lint proto-gen
proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(buildtools) \
sh ./scripts/protocgen.sh; fi
proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoSwaggerGen}$$"; then docker start -a $(containerProtoSwaggerGen); else docker run --name $(containerProtoSwaggerGen) -v $(CURDIR):/workspace --workdir /workspace $(buildtools) \
sh ./scripts/protoc-swagger-gen.sh; fi
proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -path "./proto/decentr/*" -name *.proto -exec clang-format -style=file -i {} \; ; fi
proto-lint:
@$(docker_buf) lint --error-format=json
proto-check-breaking:
@$(docker_buf) breaking --against $(HTTPS_GIT)
proto-update-deps:
rm -rf proto/3rdparty
mkdir proto/3rdparty
git clone --depth 1 --branch $(COSMOS_PKG_VERSION) git@github.com:cosmos/cosmos-sdk.git
mv cosmos-sdk/third_party/proto/* ./proto/3rdparty/
mv cosmos-sdk/proto/cosmos ./proto/3rdparty/cosmos
rm -rf cosmos-sdk
.PHONY: build vendor proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps