From 63a94ad9873cf6837227d29d17b8a4e3d8624e98 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 4 Oct 2023 15:41:19 -0700 Subject: [PATCH] build: build+install using GOEXPERIMENT=loopvar We also update the release script to do the same as well. --- Makefile | 14 +++++++++++--- scripts/release.sh | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 6c526f67b..0ed697d4b 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,17 @@ ANDROID_BUILD := $(ANDROID_BUILD_DIR)/Lndmobile.aar COMMIT := $(shell git describe --tags --dirty) -GOBUILD := go build -v -GOINSTALL := go install -v -GOTEST := GOEXPERIMENT=loopvar go test +GO_VERSION := $(shell go version | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p') +GO_VERSION_MINOR := $(shell echo $(GO_VERSION) | cut -d. -f2) + +LOOPVARFIX := +ifeq ($(shell expr $(GO_VERSION_MINOR) \>= 21), 1) + LOOPVARFIX := GOEXPERIMENT=loopvar +endif + +GOBUILD := $(LOOPVARFIX) go build -v +GOINSTALL := $(LOOPVARFIX) go install -v +GOTEST := $(LOOPVARFIX) go test GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name "*pb.go" -not -name "*pb.gw.go" -not -name "*.pb.json.go") diff --git a/scripts/release.sh b/scripts/release.sh index 930d680e3..0f6b44cff 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -98,7 +98,7 @@ function check_tag_correct() { fi # Build lnd to extract version. - go build ${PKG}/cmd/lnd + env GOEXPERIMENT=loopvar go build ${PKG}/cmd/lnd # Extract version command output. lnd_version_output=$(./lnd --version) @@ -177,8 +177,8 @@ function build_release() { pushd "${dir}" green " - Building: ${os} ${arch} ${arm} with build tags '${buildtags}'" - env CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lnd - env CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lncli + env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lnd + env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lncli popd # Add the hashes for the individual binaries as well for easy verification