Skip to content

Commit

Permalink
fix(Makefile)!: add ledger build flag to build with ledger support by… (
Browse files Browse the repository at this point in the history
#2415)

… default (#2014)

## Overview

Mainly add ledger flag to add ledger support by default.

fixes #1658

---------

<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [ ] New and updated code has appropriate documentation
- [ ] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords

Co-authored-by: Rootul P <[email protected]>
  • Loading branch information
liamsi and rootulp authored Sep 4, 2023
1 parent 6639c1a commit cd48a95
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ FROM docker.io/golang:1.21.0-alpine3.17 as builder
RUN apk update && apk add --no-cache \
gcc \
git \
# linux-headers are needed for Ledger support
linux-headers \
make \
musl-dev
COPY . /celestia-app
Expand Down
38 changes: 37 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@ DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bu
IMAGE := ghcr.io/tendermint/docker-build-proto:latest
DOCKER_PROTO_BUILDER := docker run -v $(shell pwd):/workspace --workdir /workspace $(IMAGE)
PROJECTNAME=$(shell basename "$(PWD)")
LEDGER_ENABLED ?= true


# process build tags
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
build_tags := $(strip $(build_tags))

empty :=
whitespace := $(empty) $(empty)
comma := ,

# convert build_tags from a whitespace seperated list to a comma seperated list
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))


# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \
Expand All @@ -14,7 +50,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
ldflags += $(LDFLAGS)

BUILD_FLAGS := -ldflags '$(ldflags)'
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'

## help: Get more info on make commands.
help: Makefile
Expand Down

0 comments on commit cd48a95

Please sign in to comment.