Skip to content

Commit

Permalink
feat(ledger): add build dependancies and follow sdk standards
Browse files Browse the repository at this point in the history
Add build-base and linux-header dependancies in the Dockerfile
Use the cosmos-sdk Makefile snippet to enable Ledger

Signed-off-by: dpierret <[email protected]>
  • Loading branch information
dpierret committed Oct 12, 2022
1 parent bff91ba commit dcd4135
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#--- Build stage
FROM golang:1.19-alpine3.16 AS go-builder

# install Linux header and build-base for native C codes
RUN apk add --no-cache \
ca-certificates \
build-base \
linux-headers

WORKDIR /src

# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
Expand Down
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ DOCKER_IMAGE_GOLANG_CI = golangci/golangci-lint:v1.49
DOCKER_IMAGE_BUF = okp4/buf-cosmos:0.3.1
DOCKER_BUILDX_BUILDER = okp4-builder
CMD_ROOT :=./cmd/${BINARY_NAME}
LEDGER_ENABLED ?= true

# Some colors
COLOR_GREEN = $(shell tput -Txterm setaf 2)
Expand All @@ -19,8 +20,30 @@ COLOR_CYAN = $(shell tput -Txterm setaf 6)
COLOR_RED = $(shell tput -Txterm setaf 1)
COLOR_RESET = $(shell tput -Txterm sgr0)

BUILD_TAGS += netgo ledger
BUILD_TAGS += netgo
BUILD_TAGS := $(strip $(BUILD_TAGS))
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

# Flags
WHITESPACE := $(subst ,, )
Expand Down

0 comments on commit dcd4135

Please sign in to comment.