build: more flexible handling of go build tags; added ceph_preview

ceph_preview tag is needed to make new go-ceph's RADOS read/write ops available

Signed-off-by: Robert Vasek <robert.vasek@cern.ch>
This commit is contained in:
Robert Vasek 2022-02-16 15:10:51 +01:00 committed by mergify[bot]
parent afeae03069
commit 8fb5739f21
2 changed files with 12 additions and 11 deletions

View File

@ -46,22 +46,19 @@ endif
GO_PROJECT=github.com/ceph/ceph-csi GO_PROJECT=github.com/ceph/ceph-csi
CEPH_VERSION ?= $(shell . $(CURDIR)/build.env ; echo $${CEPH_VERSION})
# TODO: ceph_preview tag may be removed with go-ceph 0.16.0
GO_TAGS_LIST ?= $(CEPH_VERSION) ceph_preview
# go build flags # go build flags
LDFLAGS ?= LDFLAGS ?=
LDFLAGS += -X $(GO_PROJECT)/internal/util.GitCommit=$(GIT_COMMIT) LDFLAGS += -X $(GO_PROJECT)/internal/util.GitCommit=$(GIT_COMMIT)
# CSI_IMAGE_VERSION will be considered as the driver version # CSI_IMAGE_VERSION will be considered as the driver version
LDFLAGS += -X $(GO_PROJECT)/internal/util.DriverVersion=$(CSI_IMAGE_VERSION) LDFLAGS += -X $(GO_PROJECT)/internal/util.DriverVersion=$(CSI_IMAGE_VERSION)
GO_TAGS ?= -tags=$(shell echo $(GO_TAGS_LIST) | tr ' ' ',')
BASE_IMAGE ?= $(shell . $(CURDIR)/build.env ; echo $${BASE_IMAGE}) BASE_IMAGE ?= $(shell . $(CURDIR)/build.env ; echo $${BASE_IMAGE})
ifndef CEPH_VERSION
CEPH_VERSION = $(shell . $(CURDIR)/build.env ; echo $${CEPH_VERSION})
endif
ifdef CEPH_VERSION
# pass -tags to go commands (for go-ceph build constraints)
GO_TAGS = -tags=$(CEPH_VERSION)
endif
# passing TARGET=static-check on the 'make containerized-test' or 'make # passing TARGET=static-check on the 'make containerized-test' or 'make
# containerized-build' commandline will run the selected target instead of # containerized-build' commandline will run the selected target instead of
# 'make test' in the container. Obviously other targets can be passed as well, # 'make test' in the container. Obviously other targets can be passed as well,
@ -109,8 +106,12 @@ mod-check: check-env
@echo 'running: go mod verify' @echo 'running: go mod verify'
@go mod verify && [ "$(shell sha512sum go.mod)" = "`sha512sum go.mod`" ] || ( echo "ERROR: go.mod was modified by 'go mod verify'" && false ) @go mod verify && [ "$(shell sha512sum go.mod)" = "`sha512sum go.mod`" ] || ( echo "ERROR: go.mod was modified by 'go mod verify'" && false )
scripts/golangci.yml: build.env scripts/golangci.yml.in scripts/golangci.yml: scripts/golangci.yml.in
sed "s/@@CEPH_VERSION@@/$(CEPH_VERSION)/g" < scripts/golangci.yml.in > scripts/golangci.yml rm -f scripts/golangci.yml.buildtags.in
for tag in $(GO_TAGS_LIST); do \
echo " - $$tag" >> scripts/golangci.yml.buildtags.in ; \
done
sed "/@@BUILD_TAGS@@/r scripts/golangci.yml.buildtags.in" scripts/golangci.yml.in | sed '/@@BUILD_TAGS@@/d' > scripts/golangci.yml
go-lint: scripts/golangci.yml go-lint: scripts/golangci.yml
./scripts/lint-go.sh ./scripts/lint-go.sh

View File

@ -6,7 +6,7 @@
# options for analysis running # options for analysis running
run: run:
build-tags: build-tags:
- @@CEPH_VERSION@@ @@BUILD_TAGS@@
# default concurrency is a available CPU number # default concurrency is a available CPU number
concurrency: 4 concurrency: 4