Makefile: refactor build flags and fix 1.17 (#3930)

This commit is contained in:
battlmonstr 2022-04-22 02:15:23 +02:00 committed by GitHub
parent cedb4865c3
commit a8f20f01c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
GO = go
GOBIN = $(CURDIR)/build/bin
GOTEST = GODEBUG=cgocheck=0 $(GO) test -tags nosqlite,noboltdb -buildvcs=false -trimpath ./... -p 2
GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
@ -11,11 +10,21 @@ CGO_CFLAGS += -DMDBX_FORCE_ASSERTIONS=1 # Enable MDBX's asserts by default in 'd
CGO_CFLAGS := CGO_CFLAGS="$(CGO_CFLAGS)"
DBG_CGO_CFLAGS += -DMDBX_DEBUG=1
GOBUILD = $(CGO_CFLAGS) $(GO) build -tags nosqlite,noboltdb -buildvcs=false -trimpath -ldflags "-X github.com/ledgerwatch/erigon/params.GitCommit=${GIT_COMMIT} -X github.com/ledgerwatch/erigon/params.GitBranch=${GIT_BRANCH} -X github.com/ledgerwatch/erigon/params.GitTag=${GIT_TAG}"
GO_DBG_BUILD = $(DBG_CGO_CFLAGS) $(GO) build -tags nosqlite,noboltdb,debug -buildvcs=false -trimpath -ldflags "-X github.com/ledgerwatch/erigon/params.GitCommit=${GIT_COMMIT} -X github.com/ledgerwatch/erigon/params.GitBranch=${GIT_BRANCH} -X github.com/ledgerwatch/erigon/params.GitTag=${GIT_TAG}" -gcflags=all="-N -l" # see delve docs
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 16-17)
BUILD_TAGS = nosqlite,noboltdb
PACKAGE = github.com/ledgerwatch/erigon
GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1)
GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
GO_FLAGS += -tags $(BUILD_TAGS)
GO_FLAGS += -trimpath
GO_FLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} -X ${PACKAGE}/params.GitBranch=${GIT_BRANCH} -X ${PACKAGE}/params.GitTag=${GIT_TAG}"
ifeq ($(shell test $(GO_MINOR_VERSION) -ge 18; echo $$?), 0)
GO_FLAGS += -buildvcs=false
endif
GOBUILD = $(CGO_CFLAGS) $(GO) build $(GO_FLAGS)
GO_DBG_BUILD = $(DBG_CGO_CFLAGS) $(GO) build $(GO_FLAGS) -tags $(BUILD_TAGS),debug -gcflags=all="-N -l" # see delve docs
GOTEST = GODEBUG=cgocheck=0 $(GO) test $(GO_FLAGS) ./... -p 2
default: all