Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (119 loc) · 5.94 KB
/
Copy pathMakefile
File metadata and controls
147 lines (119 loc) · 5.94 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# AKT_ROOT is normally exported by .envrc (direnv). Fall back to this
# Makefile's own directory so `make` works in a bare checkout — CI has no
# direnv, and without this every `include $(AKT_ROOT)/make/*.mk` resolves to
# an absolute /make/... path that does not exist.
# := not ?=: the value must be captured while MAKEFILE_LIST still ends with
# this file. A deferred (?=) assignment is expanded at first use — inside the
# include lines below — by which point the last word is the included file.
ifeq ($(origin AKT_ROOT), undefined)
AKT_ROOT := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
endif
# .envrc normally loads these paths from .env. Keep the same layout when make
# runs without direnv so build and coverage targets share one cache.
AKT_DEVCACHE_BASE ?= $(AKT_ROOT)/.cache
AKT_DEVCACHE ?= $(AKT_DEVCACHE_BASE)
AKT_DEVCACHE_BIN ?= $(AKT_DEVCACHE)/bin
AKT_DEVCACHE_LIB ?= $(AKT_DEVCACHE)/lib
AKT_DEVCACHE_INCLUDE ?= $(AKT_DEVCACHE)/include
AKT_DEVCACHE_VERSIONS ?= $(AKT_DEVCACHE)/versions
AKT_DEVCACHE_NODE_MODULES ?= $(AKT_DEVCACHE)
AKT_DEVCACHE_NODE_BIN ?= $(AKT_DEVCACHE_NODE_MODULES)/node_modules/.bin
AKT_RUN ?= $(AKT_DEVCACHE)/run
AKT_RUN_BIN ?= $(AKT_RUN)/bin
AKT ?= $(AKT_DEVCACHE_BIN)/akt
SEMVER ?= $(AKT_ROOT)/script/semver.sh
# Must be built with Go >= the go directive in go.mod: older golangci-lint
# releases refuse to load a config targeting a newer language version
# (v2.3.0 is built with go1.24 and cannot run against go 1.26.1).
GOLANGCI_LINT_VERSION ?= v2.11.4
GIT_CHGLOG_VERSION ?= v0.15.
# Generates install.sh from .config/binstaller.yml. Its output is committed and
# checked byte-for-byte, so a version bump means `make installer` in the same
# change.
BINST_VERSION ?= v0.12.0
GIT_CHGLOG_VERSION_FILE := $(AKT_DEVCACHE_VERSIONS)/git-chglog/$(GIT_CHGLOG_VERSION)
GOLANGCI_LINT_VERSION_FILE := $(AKT_DEVCACHE_VERSIONS)/golangci-lint/$(GOLANGCI_LINT_VERSION)
BINST_VERSION_FILE := $(AKT_DEVCACHE_VERSIONS)/binst/$(BINST_VERSION)
GIT_CHGLOG := $(AKT_DEVCACHE_BIN)/git-chglog
GOLANGCI_LINT := $(AKT_DEVCACHE_BIN)/golangci-lint
BINST := $(AKT_DEVCACHE_BIN)/binst
GOMOD ?= readonly
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)
# Version derived from the nearest tag. A checkout without tags (CI does not
# fetch them by default) has no describable version, so fall back rather than
# emitting a git fatal and an empty -X value.
AKT_VERSION := $(shell git describe --tags 2>/dev/null | sed 's/^v//')
ifeq ($(AKT_VERSION),)
AKT_VERSION := dev
endif
GIT_HEAD_COMMIT_LONG := $(shell git log -1 --format='%H')
GIT_HEAD_COMMIT_SHORT := $(shell git rev-parse --short HEAD)
GIT_HEAD_ABBREV := $(shell git rev-parse --abbrev-ref HEAD)
NULL :=
SPACE := $(NULL)
WHITESPACE := $(NULL) $(NULL)
COMMA := ,
ifneq ($(UNAME_OS),Darwin)
BUILD_OPTIONS ?= static-link
endif
# nolink_libwasmvm keeps the CosmWasm VM out of the binary. akt only builds
# and queries wasm messages over gRPC -- it never executes a contract -- so the
# VM is dead weight that would otherwise force static libwasmvm archives, cgo
# cross-compilation and ~18 MB of binary. cgo itself is still needed, for the
# ledger HID bindings and the cosmos keyring.
# Omit netgo so Go can use macOS system DNS and Linux libc/NSS when needed.
BUILD_TAGS := osusergo ledger muslc gcc nolink_libwasmvm
ifneq (,$(findstring cgotrace,$(BUILD_OPTIONS)))
BUILD_TAGS += cgotrace
endif
build_tags := $(strip $(BUILD_TAGS))
build_tags_cs := $(subst $(WHITESPACE),$(COMMA),$(build_tags))
# Release builds do NOT reuse the flags computed below: goreleaser cross
# compiles from a container with its own toolchain, so .goreleaser.yaml carries
# its own copy of the build tags and the -X flags. Keep the two in sync -- see
# the header comment in .goreleaser.yaml.
ldflags :=
ifneq (,$(findstring static-link,$(BUILD_OPTIONS)))
ldflags += -extldflags "-L$(AKT_DEVCACHE_LIB) -lm -Wl,-z,muldefs"
else
ldflags += -linkmode=external -extldflags "-L$(AKT_DEVCACHE_LIB)"
endif
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=akt \
-X github.com/cosmos/cosmos-sdk/version.AppName=akt \
-X github.com/cosmos/cosmos-sdk/version.BuildTags="$(build_tags_cs)" \
-X github.com/cosmos/cosmos-sdk/version.Version=$(AKT_VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_HEAD_COMMIT_LONG)
# akt's own build info. The cosmos-sdk vars above feed the SDK's version
# machinery; `akt version` reads these, so both must be injected or the
# binary reports dev/none/unknown regardless of how it was built.
ldflags += -X main.version=$(AKT_VERSION) \
-X main.commit=$(GIT_HEAD_COMMIT_LONG) \
-X main.date=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)
# check for nostrip option
ifeq (,$(findstring nostrip,$(BUILD_OPTIONS)))
ldflags += -s -w
BUILD_FLAGS += -trimpath
endif
ifeq (delve,$(findstring delve,$(BUILD_OPTIONS)))
BUILD_FLAGS += -gcflags "all=-N -l"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS += -mod=$(GOMOD) -tags='$(build_tags_cs)' -ldflags '$(ldflags)'
GO := GOWORK=off GO111MODULE=$(GO111MODULE) go
GO_BUILD := $(GO) build -mod=$(GOMOD)
GO_TEST := $(GO) test -mod=$(GOMOD)
GO_VET := $(GO) vet -mod=$(GOMOD)
GO_MOD_NAME := $(shell GOWORK=off go list -m 2>/dev/null)
.PHONY: test test-e2e
test:
$(GO_TEST) ./...
test-e2e: akt
$(GO_TEST) ./e2e/... -v -count=1
include $(AKT_ROOT)/make/setup-cache.mk
include $(AKT_ROOT)/make/releasing.mk
include $(AKT_ROOT)/make/testing.mk
# The binary target lives in make/releasing.mk. Its output directory and link
# search path must exist before a build from a checkout with no .cache tree.
$(AKT): | $(AKT_DEVCACHE)