Skip to content

Commit a6228c3

Browse files
committed
feat: refactor build system
Signed-off-by: Artur Troian <[email protected]>
1 parent a42de2b commit a6228c3

28 files changed

+516
-241
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ROOT_DIR=${AKASH_ROOT}
66
AKASH_DEVCACHE_BASE=${AKASH_ROOT}/.cache
77
AKASH_DEVCACHE=${AKASH_DEVCACHE_BASE}
88
AKASH_DEVCACHE_BIN=${AKASH_DEVCACHE}/bin
9+
AKASH_DEVCACHE_LIB=${AKASH_DEVCACHE}/lib
910
AKASH_DEVCACHE_INCLUDE=${AKASH_DEVCACHE}/include
1011
AKASH_DEVCACHE_VERSIONS=${AKASH_DEVCACHE}/versions
1112
AKASH_DEVCACHE_NODE_MODULES=${AKASH_DEVCACHE}

.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ export GOTOOLCHAIN
9999
export GOTOOLCHAIN_SEMVER
100100
export GOWORK
101101

102-
PATH_add "$AKASH_DEVCACHE_NODE_BIN"
103102
PATH_add "$AKASH_DEVCACHE_BIN"
103+
PATH_add "$AKASH_DEVCACHE_NODE_BIN"
104104

105105
AKASH_DIRENV_SET=1
106106
AKASH=$AKASH_DEVCACHE_BIN/akash

.goreleaser-docker.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ builds:
2020
- "-tags={{ .Env.BUILD_TAGS }}"
2121
- -trimpath
2222
ldflags:
23-
- "{{ .Env.BUILD_VARS }}"
24-
- "{{ .Env.STRIP_FLAGS }}"
25-
- "-linkmode={{ .Env.LINKMODE }}"
26-
- -extldflags "-lc -lrt -lpthread --static"
23+
- "{{ .Env.BUILD_LDFLAGS }}"
24+
- -s -w
25+
- -linkmode=external
26+
- -extldflags "-L./.cache/lib -lwasmvm_muslc.x86_64 -Wl,-z,muldefs -lm -lrt -lc -static"
2727
- id: akash-linux-arm64
2828
binary: akash
2929
main: ./cmd/akash
@@ -39,12 +39,12 @@ builds:
3939
- "-tags={{ .Env.BUILD_TAGS }}"
4040
- -trimpath
4141
ldflags:
42-
- "{{ .Env.BUILD_VARS }}"
43-
- "{{ .Env.STRIP_FLAGS }}"
44-
- "-linkmode={{ .Env.LINKMODE }}"
45-
- -extldflags "-lc -lrt -lpthread --static"
42+
- "{{ .Env.BUILD_LDFLAGS }}"
43+
- -s -w
44+
- -linkmode=external
45+
- -extldflags "-L./.cache/lib -lwasmvm_muslc.aarch64 -Wl,-z,muldefs -lm -lrt -lc -static"
4646
dockers:
47-
- dockerfile: _build/Dockerfile.akash
47+
- dockerfile: _build/akash.Dockerfile
4848
use: buildx
4949
goarch: amd64
5050
goos: linux
@@ -59,7 +59,7 @@ dockers:
5959
- --label=org.opencontainers.image.revision={{ .FullCommit }}
6060
image_templates:
6161
- '{{ .Env.DOCKER_IMAGE }}:latest-amd64'
62-
- dockerfile: _build/Dockerfile.akash
62+
- dockerfile: _build/akash.Dockerfile
6363
use: buildx
6464
goarch: arm64
6565
goos: linux

.goreleaser-test-bins.yaml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ builds:
1616
env:
1717
- CC=o64-clang
1818
- CXX=o64-clang++
19+
- CGO_CFLAGS=-mmacosx-version-min=10.12
20+
- CGO_LDFLAGS=-L./.cache/lib -mmacosx-version-min=10.12
1921
flags:
2022
- "-mod={{ .Env.MOD }}"
21-
- "-tags={{ .Env.BUILD_TAGS }}"
23+
- "-tags={{ .Env.BUILD_TAGS }} static_wasm"
2224
- -trimpath
2325
ldflags:
24-
- "{{ .Env.BUILD_VARS }}"
25-
- "{{ .Env.STRIP_FLAGS }}"
26-
- "-linkmode={{ .Env.LINKMODE }}"
26+
- "{{ .Env.BUILD_LDFLAGS }}"
27+
- -s -w
28+
- -linkmode=external
2729
- id: akash-darwin-arm64
2830
binary: akash
2931
main: ./cmd/akash
@@ -34,14 +36,16 @@ builds:
3436
env:
3537
- CC=oa64-clang
3638
- CXX=oa64-clang++
39+
- CGO_CFLAGS=-mmacosx-version-min=10.12
40+
- CGO_LDFLAGS=-L./.cache/lib -mmacosx-version-min=10.12
3741
flags:
3842
- "-mod={{ .Env.MOD }}"
39-
- "-tags={{ .Env.BUILD_TAGS }}"
43+
- "-tags={{ .Env.BUILD_TAGS }} static_wasm"
4044
- -trimpath
4145
ldflags:
42-
- "{{ .Env.BUILD_VARS }}"
43-
- "{{ .Env.STRIP_FLAGS }}"
44-
- "-linkmode={{ .Env.LINKMODE }}"
46+
- "{{ .Env.BUILD_LDFLAGS }}"
47+
- -s -w
48+
- -linkmode=external
4549
- id: akash-linux-amd64
4650
binary: akash
4751
main: ./cmd/akash
@@ -57,10 +61,10 @@ builds:
5761
- "-tags={{ .Env.BUILD_TAGS }}"
5862
- -trimpath
5963
ldflags:
60-
- "{{ .Env.BUILD_VARS }}"
61-
- "{{ .Env.STRIP_FLAGS }}"
62-
- "-linkmode={{ .Env.LINKMODE }}"
63-
- -extldflags "-lc -lrt -lpthread --static"
64+
- "{{ .Env.BUILD_LDFLAGS }}"
65+
- -s -w
66+
- -linkmode=external
67+
- -extldflags "-L./.cache/lib -lwasmvm_muslc.x86_64 -Wl,-z,muldefs -lm -lrt -lc -static"
6468
- id: akash-linux-arm64
6569
binary: akash
6670
main: ./cmd/akash
@@ -76,10 +80,10 @@ builds:
7680
- "-tags={{ .Env.BUILD_TAGS }}"
7781
- -trimpath
7882
ldflags:
79-
- "{{ .Env.BUILD_VARS }}"
80-
- "{{ .Env.STRIP_FLAGS }}"
81-
- "-linkmode={{ .Env.LINKMODE }}"
82-
- -extldflags "-lc -lrt -lpthread --static"
83+
- "{{ .Env.BUILD_LDFLAGS }}"
84+
- -s -w
85+
- -linkmode=external
86+
- -extldflags "-L./.cache/lib -lwasmvm_muslc.aarch64 -Wl,-z,muldefs -lm -lrt -lc -static"
8387
universal_binaries:
8488
- id: akash-darwin-universal
8589
ids:

.goreleaser.yaml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ builds:
1616
env:
1717
- CC=o64-clang
1818
- CXX=o64-clang++
19+
- CGO_CFLAGS=-mmacosx-version-min=10.12
20+
- CGO_LDFLAGS=-L./.cache/lib -mmacosx-version-min=10.12
1921
flags:
2022
- "-mod={{ .Env.MOD }}"
21-
- "-tags={{ .Env.BUILD_TAGS }}"
23+
- "-tags={{ .Env.BUILD_TAGS }} static_wasm"
2224
- -trimpath
2325
ldflags:
24-
- "{{ .Env.BUILD_VARS }}"
25-
- "{{ .Env.STRIP_FLAGS }}"
26-
- "-linkmode={{ .Env.LINKMODE }}"
26+
- "{{ .Env.BUILD_LDFLAGS }}"
27+
- -s -w
28+
- -linkmode=external
2729
- id: akash-darwin-arm64
2830
binary: akash
2931
main: ./cmd/akash
@@ -34,14 +36,16 @@ builds:
3436
env:
3537
- CC=oa64-clang
3638
- CXX=oa64-clang++
39+
- CGO_CFLAGS=-mmacosx-version-min=10.12
40+
- CGO_LDFLAGS=-L./.cache/lib -mmacosx-version-min=10.12
3741
flags:
3842
- "-mod={{ .Env.MOD }}"
39-
- "-tags={{ .Env.BUILD_TAGS }}"
43+
- "-tags={{ .Env.BUILD_TAGS }} static_wasm"
4044
- -trimpath
4145
ldflags:
42-
- "{{ .Env.BUILD_VARS }}"
43-
- "{{ .Env.STRIP_FLAGS }}"
44-
- "-linkmode={{ .Env.LINKMODE }}"
46+
- "{{ .Env.BUILD_LDFLAGS }}"
47+
- -s -w
48+
- -linkmode=external
4549
- id: akash-linux-amd64
4650
binary: akash
4751
main: ./cmd/akash
@@ -57,10 +61,10 @@ builds:
5761
- "-tags={{ .Env.BUILD_TAGS }}"
5862
- -trimpath
5963
ldflags:
60-
- "{{ .Env.BUILD_VARS }}"
61-
- "{{ .Env.STRIP_FLAGS }}"
62-
- "-linkmode={{ .Env.LINKMODE }}"
63-
- -extldflags "-lc -lrt -lpthread --static"
64+
- "{{ .Env.BUILD_LDFLAGS }}"
65+
- -s -w
66+
- -linkmode=external
67+
- -extldflags "-L./.cache/lib -lwasmvm_muslc.x86_64 -Wl,-z,muldefs -lm -lrt -lc -static"
6468
- id: akash-linux-arm64
6569
binary: akash
6670
main: ./cmd/akash
@@ -76,10 +80,10 @@ builds:
7680
- "-tags={{ .Env.BUILD_TAGS }}"
7781
- -trimpath
7882
ldflags:
79-
- "{{ .Env.BUILD_VARS }}"
80-
- "{{ .Env.STRIP_FLAGS }}"
81-
- "-linkmode={{ .Env.LINKMODE }}"
82-
- -extldflags "-lc -lrt -lpthread --static"
83+
- "{{ .Env.BUILD_LDFLAGS }}"
84+
- -s -w
85+
- -linkmode=external
86+
- -extldflags "-L./.cache/lib -lwasmvm_muslc.aarch64 -Wl,-z,muldefs -lm -lrt -lc -static"
8387
universal_binaries:
8488
- id: akash-darwin-universal
8589
ids:
@@ -117,7 +121,7 @@ checksum:
117121
name_template: "akash_{{ .Version }}_checksums.txt"
118122

119123
dockers:
120-
- dockerfile: _build/Dockerfile.akash
124+
- dockerfile: _build/akash.Dockerfile
121125
use: buildx
122126
goarch: amd64
123127
goos: linux
@@ -134,7 +138,7 @@ dockers:
134138
- '{{ .Env.DOCKER_IMAGE }}:{{ .ShortCommit }}-amd64'
135139
- '{{ .Env.DOCKER_IMAGE }}:{{ replace .Version "+" "-" }}-amd64'
136140
- '{{ .Env.DOCKER_IMAGE }}:{{if eq .Env.STABLE "true"}}stable{{else}}latest{{end}}-amd64'
137-
- dockerfile: _build/Dockerfile.akash
141+
- dockerfile: _build/akash.Dockerfile
138142
use: buildx
139143
goarch: arm64
140144
goos: linux

Makefile

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ APP_DIR := ./app
22

33
GOBIN ?= $(shell go env GOPATH)/bin
44

5-
KIND_APP_IP ?= $(shell make -sC _run/kube kind-k8s-ip)
6-
KIND_APP_PORT ?= $(shell make -sC _run/kube app-http-port)
7-
KIND_VARS ?= KUBE_INGRESS_IP="$(KIND_APP_IP)" KUBE_INGRESS_PORT="$(KIND_APP_PORT)"
8-
95
include make/init.mk
106

117
.DEFAULT_GOAL := bins
@@ -22,46 +18,56 @@ GIT_HEAD_ABBREV := $(shell git rev-parse --abbrev-ref HEAD)
2218

2319
IS_PREREL := $(shell $(ROOT_DIR)/script/is_prerelease.sh "$(RELEASE_TAG)" && echo "true" || echo "false")
2420
IS_MAINNET := $(shell $(ROOT_DIR)/script/mainnet-from-tag.sh "$(RELEASE_TAG)" && echo "true" || echo "false")
25-
IS_STABLE ?= false
2621

27-
GO_LINKMODE ?= external
2822
GOMOD ?= readonly
29-
BUILD_TAGS ?= osusergo,netgo,ledger
23+
BUILD_OPTIONS ?= static-link
24+
BUILD_TAGS := osusergo netgo ledger muslc gcc
25+
DB_BACKEND := goleveldb
26+
BUILD_FLAGS :=
27+
3028
GORELEASER_STRIP_FLAGS ?=
3129

32-
ifeq ($(IS_MAINNET), true)
33-
ifeq ($(IS_PREREL), false)
34-
IS_STABLE := true
35-
endif
30+
ifeq (cleveldb,$(findstring cleveldb,$(BUILD_OPTIONS)))
31+
DB_BACKEND=cleveldb
32+
else ifeq (rocksdb,$(findstring rocksdb,$(BUILD_OPTIONS)))
33+
DB_BACKEND=rocksdb
34+
else ifeq (goleveldb,$(findstring goleveldb,$(BUILD_OPTIONS)))
35+
DB_BACKEND=goleveldb
3636
endif
3737

3838
ifneq (,$(findstring cgotrace,$(BUILD_OPTIONS)))
39-
BUILD_TAGS := $(BUILD_TAGS),cgotrace
39+
BUILD_TAGS += cgotrace
4040
endif
4141

42-
GORELEASER_BUILD_VARS := \
43-
-X github.com/cosmos/cosmos-sdk/version.Name=akash \
44-
-X github.com/cosmos/cosmos-sdk/version.AppName=akash \
45-
-X github.com/cosmos/cosmos-sdk/version.BuildTags=\"$(BUILD_TAGS)\" \
46-
-X github.com/cosmos/cosmos-sdk/version.Version=$(RELEASE_TAG) \
47-
-X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_HEAD_COMMIT_LONG)
42+
build_tags := $(strip $(BUILD_TAGS))
43+
build_tags_cs := $(subst $(WHITESPACE),$(COMMA),$(build_tags))
4844

49-
ldflags = -linkmode=$(GO_LINKMODE) -X github.com/cosmos/cosmos-sdk/version.Name=akash \
45+
ldflags := -X github.com/cosmos/cosmos-sdk/version.Name=akash \
5046
-X github.com/cosmos/cosmos-sdk/version.AppName=akash \
51-
-X github.com/cosmos/cosmos-sdk/version.BuildTags="$(BUILD_TAGS)" \
47+
-X github.com/cosmos/cosmos-sdk/version.BuildTags="$(build_tags_cs)" \
5248
-X github.com/cosmos/cosmos-sdk/version.Version=$(shell git describe --tags | sed 's/^v//') \
53-
-X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_HEAD_COMMIT_LONG)
49+
-X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_HEAD_COMMIT_LONG) \
50+
-X github.com/cosmos/cosmos-sdk/types.DBBackend=$(DB_BACKEND)
51+
52+
GORELEASER_LDFLAGS := $(ldflags)
53+
54+
ifeq (,$(findstring static-link,$(BUILD_OPTIONS)))
55+
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
56+
endif
5457

5558
# check for nostrip option
5659
ifeq (,$(findstring nostrip,$(BUILD_OPTIONS)))
57-
ldflags += -s -w
58-
GORELEASER_STRIP_FLAGS += -s -w
60+
ldflags += -s -w
61+
BUILD_FLAGS += -trimpath
5962
endif
6063

6164
ldflags += $(LDFLAGS)
6265
ldflags := $(strip $(ldflags))
6366

64-
BUILD_FLAGS := -mod=$(GOMOD) -tags='$(BUILD_TAGS)' -ldflags '$(ldflags)'
67+
GORELEASER_TAGS := $(BUILD_TAGS)
68+
GORELEASER_FLAGS := $(BUILD_FLAGS) -mod=$(GOMOD) -tags='$(build_tags)'
69+
70+
BUILD_FLAGS += -mod=$(GOMOD) -tags='$(build_tags_cs)' -ldflags '$(ldflags)'
6571

6672
.PHONY: all
6773
all: build bins
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM debian:bullseye
22
LABEL "org.opencontainers.image.source"="https://github.com/akash-network/node"
33

4+
ARG WASMVM_VERSION
5+
46
COPY ./akash /bin/
57

68
EXPOSE 26656 26657 26658

_run/.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
AKASH_KEYRING_BACKEND=test
2+
AKASH_GAS_ADJUSTMENT=2
3+
AKASH_CHAIN_ID=local
4+
AKASH_YES=true
5+
AKASH_GAS_PRICES=0.025uakt
6+
AKASH_GAS=auto
7+
AKASH_NODE=http://localhost:26657

_run/.envrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
source_up .envrc
2+
3+
if ! has grpcurl ; then
4+
echo -e "\033[31mgrpcurl is not installed"; exit 1
5+
fi
6+
7+
if ! has tqdm ; then
8+
echo -e "\033[31mtqdm is not installed. https://github.com/tqdm/tqdm"; exit 1
9+
fi
10+
11+
dotenv .env

0 commit comments

Comments
 (0)