Skip to content

Commit 09994d5

Browse files
committed
build(project): define MAX_WASM_SIZE (1MB) and pass it via ldflags
1 parent caa0403 commit 09994d5

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

Makefile

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ DAEMON_NAME := axoned
5353
DAEMON_HOME := `pwd`/${CHAIN_HOME}
5454

5555
# Binary information
56-
VERSION := $(shell cat version)
57-
COMMIT := $(shell git log -1 --format='%H')
56+
VERSION := $(shell cat version)
57+
MAJOR_VERSION := $(shell cat version | cut -d. -f1)
58+
COMMIT := $(shell git log -1 --format='%H')
59+
60+
# Modules
61+
MODULE_COSMOS_SDK := github.com/cosmos/cosmos-sdk
62+
MODULE_AXONED := github.com/axone-protocol/axoned/v$(MAJOR_VERSION)
63+
64+
# Build options
65+
MAX_WASM_SIZE := $(shell echo "$$((1 * 1024 * 1024))")
5866

5967
build_tags += netgo
6068
build_tags := $(strip $(build_tags))
@@ -69,7 +77,7 @@ ifeq ($(LEDGER_ENABLED),true)
6977
else
7078
UNAME_S = $(shell uname -s)
7179
ifeq ($(UNAME_S),OpenBSD)
72-
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
80+
$(warning OpenBSD detected, disabling ledger support (https://$(MODULE_COSMOS_SDK)/issues/1988))
7381
else
7482
GCC = $(shell command -v gcc 2> /dev/null)
7583
ifeq ($(GCC),)
@@ -89,13 +97,14 @@ build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
8997

9098
# Flags
9199
ldflags = \
92-
-X github.com/cosmos/cosmos-sdk/version.AppName=axoned \
93-
-X github.com/cosmos/cosmos-sdk/version.Name=axoned \
94-
-X github.com/cosmos/cosmos-sdk/version.ServerName=axoned \
95-
-X github.com/cosmos/cosmos-sdk/version.ClientName=axoned \
96-
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
97-
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
98-
-X github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)
100+
-X $(MODULE_COSMOS_SDK)/version.AppName=axoned \
101+
-X $(MODULE_COSMOS_SDK)/version.Name=axoned \
102+
-X $(MODULE_COSMOS_SDK)/version.ServerName=axoned \
103+
-X $(MODULE_COSMOS_SDK)/version.ClientName=axoned \
104+
-X $(MODULE_COSMOS_SDK)/version.Version=$(VERSION) \
105+
-X $(MODULE_COSMOS_SDK)/version.Commit=$(COMMIT) \
106+
-X $(MODULE_COSMOS_SDK)/version.BuildTags=$(build_tags_comma_sep) \
107+
-X $(MODULE_AXONED)/app.MaxWasmSize=$(MAX_WASM_SIZE) \
99108

100109
ifeq (,$(findstring nostrip,$(BUILD_OPTIONS)))
101110
ldflags += -w -s
@@ -177,7 +186,7 @@ build: build-go build-docker ## Build all available artefacts (executable, docke
177186

178187
.PHONY: build-go
179188
build-go: ## Build node executable for the current environment (default build)
180-
@echo "${COLOR_CYAN} 🏗️ Building project ${COLOR_RESET}${CMD_ROOT}${COLOR_CYAN}${COLOR_RESET} into ${COLOR_YELLOW}${DIST_FOLDER}${COLOR_RESET}"
189+
@echo "${COLOR_CYAN} 🏗️ Building project ${COLOR_RESET}${CMD_ROOT}${COLOR_CYAN} ${COLOR_GREEN}(v${VERSION})${COLOR_RESET} into ${COLOR_YELLOW}${DIST_FOLDER}${COLOR_RESET}"
181190
@$(call build-go,"","",${DIST_FOLDER}/${BINARY_NAME})
182191

183192
build-go-all: $(ENVIRONMENTS_TARGETS) ## Build node executables for all available environments
@@ -268,7 +277,7 @@ chain-upgrade: build-go ## Test the chain upgrade from the given FROM_VERSION to
268277
@echo "${COLOR_CYAN} ⬆️ Upgrade the chain ${COLOR_RESET}${CHAIN}${COLOR_CYAN} from ${COLOR_YELLOW}${FROM_VERSION}${COLOR_RESET}${COLOR_CYAN} to ${COLOR_YELLOW}${TO_VERSION}${COLOR_RESET}"
269278
@killall cosmovisor || \
270279
rm -rf ${TARGET_FOLDER}/${FROM_VERSION}; \
271-
git clone -b ${FROM_VERSION} https://github.com/axone-protocol/axoned.git ${TARGET_FOLDER}/${FROM_VERSION}; \
280+
git clone -b ${FROM_VERSION} https://$(MODULE_AXONED).git ${TARGET_FOLDER}/${FROM_VERSION}; \
272281
echo "${COLOR_CYAN} 🏗 Build the ${COLOR_YELLOW}${FROM_VERSION}${COLOR_RESET}${COLOR_CYAN} binary...${COLOR_RESET}"; \
273282
cd ${TARGET_FOLDER}/${FROM_VERSION}; \
274283
make build-go; \
@@ -397,7 +406,7 @@ mock: ## Generate all the mocks (for tests)
397406
@mockgen -destination x/logic/testutil/gas_mocks.go -package testutil cosmossdk.io/store/types GasMeter
398407
@mockgen -destination x/logic/testutil/fs_mocks.go -package testutil io/fs FS
399408
@mockgen -destination x/logic/testutil/read_file_fs_mocks.go -package testutil io/fs ReadFileFS
400-
@mockgen -source "$$(go list -f '{{.Dir}}' github.com/cosmos/cosmos-sdk/codec/types)/interface_registry.go" \
409+
@mockgen -source "$$(go list -f '{{.Dir}}' $(MODULE_COSMOS_SDK)/codec/types)/interface_registry.go" \
401410
-package testutil \
402411
-destination x/logic/testutil/interface_registry_mocks.go
403412

0 commit comments

Comments
 (0)