From 8fb5739f21b58d0a388c1af60e05d8033cbd26a4 Mon Sep 17 00:00:00 2001 From: Robert Vasek Date: Wed, 16 Feb 2022 15:10:51 +0100 Subject: [PATCH] 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 --- Makefile | 21 +++++++++++---------- scripts/golangci.yml.in | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index b0c1c8023..3fa146818 100644 --- a/Makefile +++ b/Makefile @@ -46,22 +46,19 @@ endif 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 LDFLAGS ?= LDFLAGS += -X $(GO_PROJECT)/internal/util.GitCommit=$(GIT_COMMIT) # CSI_IMAGE_VERSION will be considered as the driver 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}) -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 # containerized-build' commandline will run the selected target instead of # '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' @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 - sed "s/@@CEPH_VERSION@@/$(CEPH_VERSION)/g" < scripts/golangci.yml.in > scripts/golangci.yml +scripts/golangci.yml: scripts/golangci.yml.in + 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 ./scripts/lint-go.sh diff --git a/scripts/golangci.yml.in b/scripts/golangci.yml.in index f926cbc36..7af2c05b2 100644 --- a/scripts/golangci.yml.in +++ b/scripts/golangci.yml.in @@ -6,7 +6,7 @@ # options for analysis running run: build-tags: - - @@CEPH_VERSION@@ +@@BUILD_TAGS@@ # default concurrency is a available CPU number concurrency: 4