make+build: compile build tags into binary
This commit is contained in:
parent
75a1a1fbab
commit
07420835d0
18
Makefile
18
Makefile
@ -23,8 +23,6 @@ ANDROID_BUILD := $(ANDROID_BUILD_DIR)/Lndmobile.aar
|
|||||||
|
|
||||||
COMMIT := $(shell git describe --abbrev=40 --dirty)
|
COMMIT := $(shell git describe --abbrev=40 --dirty)
|
||||||
COMMIT_HASH := $(shell git rev-parse HEAD)
|
COMMIT_HASH := $(shell git rev-parse HEAD)
|
||||||
LDFLAGS := -ldflags "-X $(PKG)/build.Commit=$(COMMIT) \
|
|
||||||
-X $(PKG)/build.CommitHash=$(COMMIT_HASH)"
|
|
||||||
|
|
||||||
BTCD_COMMIT := $(shell cat go.mod | \
|
BTCD_COMMIT := $(shell cat go.mod | \
|
||||||
grep $(BTCD_PKG) | \
|
grep $(BTCD_PKG) | \
|
||||||
@ -53,6 +51,14 @@ include make/testing_flags.mk
|
|||||||
|
|
||||||
DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
|
DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS))
|
||||||
|
|
||||||
|
make_ldflags = $(shell echo -ldflags \"-X $(PKG)/build.Commit=$(COMMIT) \
|
||||||
|
-X $(PKG)/build.CommitHash=$(COMMIT_HASH) \
|
||||||
|
-X $(PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g')\")
|
||||||
|
|
||||||
|
LDFLAGS := $(call make_ldflags, ${tags})
|
||||||
|
DEV_LDFLAGS := $(call make_ldflags, $(DEV_TAGS))
|
||||||
|
ITEST_LDFLAGS := $(call make_ldflags, $(ITEST_TAGS))
|
||||||
|
|
||||||
# Linting uses a lot of memory, so keep it under control by limiting the number
|
# Linting uses a lot of memory, so keep it under control by limiting the number
|
||||||
# of workers if requested.
|
# of workers if requested.
|
||||||
ifneq ($(workers),)
|
ifneq ($(workers),)
|
||||||
@ -97,13 +103,13 @@ btcd:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
@$(call print, "Building debug lnd and lncli.")
|
@$(call print, "Building debug lnd and lncli.")
|
||||||
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(LDFLAGS) $(PKG)/cmd/lnd
|
$(GOBUILD) -tags="$(DEV_TAGS)" -o lnd-debug $(DEV_LDFLAGS) $(PKG)/cmd/lnd
|
||||||
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(LDFLAGS) $(PKG)/cmd/lncli
|
$(GOBUILD) -tags="$(DEV_TAGS)" -o lncli-debug $(DEV_LDFLAGS) $(PKG)/cmd/lncli
|
||||||
|
|
||||||
build-itest:
|
build-itest:
|
||||||
@$(call print, "Building itest lnd and lncli.")
|
@$(call print, "Building itest lnd and lncli.")
|
||||||
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest $(LDFLAGS) $(PKG)/cmd/lnd
|
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lnd-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lnd
|
||||||
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest $(LDFLAGS) $(PKG)/cmd/lncli
|
$(GOBUILD) -tags="$(ITEST_TAGS)" -o lncli-itest $(ITEST_LDFLAGS) $(PKG)/cmd/lncli
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@$(call print, "Installing lnd and lncli.")
|
@$(call print, "Installing lnd and lncli.")
|
||||||
|
@ -20,6 +20,10 @@ var (
|
|||||||
// CommitHash stores the current commit hash of this build, this should
|
// CommitHash stores the current commit hash of this build, this should
|
||||||
// be set using the -ldflags during compilation.
|
// be set using the -ldflags during compilation.
|
||||||
CommitHash string
|
CommitHash string
|
||||||
|
|
||||||
|
// RawTags contains the raw set of build tags, separated by commas. This
|
||||||
|
// should be set using -ldflags during compilation.
|
||||||
|
RawTags string
|
||||||
)
|
)
|
||||||
|
|
||||||
// semanticAlphabet is the set of characters that are permitted for use in an
|
// semanticAlphabet is the set of characters that are permitted for use in an
|
||||||
@ -74,3 +78,12 @@ func Version() string {
|
|||||||
|
|
||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tags returns the list of build tags that were compiled into the executable.
|
||||||
|
func Tags() []string {
|
||||||
|
if len(RawTags) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Split(RawTags, ",")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user