-
Notifications
You must be signed in to change notification settings - Fork 49
/
Makefile
94 lines (79 loc) · 3.25 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
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
VERSION := $(shell echo $(shell git describe --tags --always --dirty --match "v*") | sed 's/^v//')
LEDGER_ENABLED ?= true
# process build tags
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
whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=Noble \
-X github.com/cosmos/cosmos-sdk/version.AppName=nobled \
-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)"
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
###############################################################################
### Build ###
###############################################################################
build:
@echo "🤖 Building nobled..."
@go build -mod=readonly $(BUILD_FLAGS) -o "$(PWD)/build" ./cmd/nobled
@echo "✅ Completed build!"
install:
@echo "🤖 Installing nobled..."
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/nobled
@echo "✅ Completed install!"
###############################################################################
### Tooling ###
###############################################################################
gofumpt_cmd=mvdan.cc/gofumpt
golangci_lint_cmd=github.com/golangci/golangci-lint/cmd/golangci-lint
FILES := $(shell find $(shell go list -f '{{.Dir}}' ./...) -name "*.go" -a -not -name "*.pb.go" -a -not -name "*.pb.gw.go" -a -not -name "*.pulsar.go" | sed "s|$(shell pwd)/||g")
license:
@go-license --config .github/license.yml $(FILES)
format:
@echo "🤖 Running formatter..."
@go run $(gofumpt_cmd) -l -w .
@echo "✅ Completed formatting!"
lint:
@echo "🤖 Running linter..."
@go run $(golangci_lint_cmd) run --timeout=10m
@echo "✅ Completed linting!"
###############################################################################
### Testing ###
###############################################################################
local-image:
ifeq (,$(shell which heighliner))
@echo heighliner not found. https://github.com/strangelove-ventures/heighliner
else
@echo "🤖 Building image..."
@heighliner build --chain noble --local
@echo "✅ Completed build!"
endif
.PHONY: license format lint build install local-image