Skip to content

Commit

Permalink
Makefile: simpily ledger build tags (backport #2449) (#2612)
Browse files Browse the repository at this point in the history
This is an automatic backport of pull request #2449 done by
[Mergify](https://mergify.com).

Closes #2597

---------

Co-authored-by: Matthew Sevey <[email protected]>
Co-authored-by: Rootul P <[email protected]>
  • Loading branch information
3 people authored Oct 5, 2023
1 parent 9791d95 commit 637aa3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
40 changes: 1 addition & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,14 @@ 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 \
-X github.com/cosmos/cosmos-sdk/version.AppName=celestia-appd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
ldflags += $(LDFLAGS)

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

## help: Get more info on make commands.
help: Makefile
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ node | | | |
make install
```

### Ledger Support

Ledger is not supported on Windows and OpenBSD.

## Usage

```sh
Expand Down

0 comments on commit 637aa3e

Please sign in to comment.