44# Image URL to use all building/pushing image targets
55export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
66export IMAGE_TAG ?= devel
7- export GO_BUILD_TAGS ?= upstream
87export CERT_MGR_VERSION ?= v1.9.0
98export CATALOGD_VERSION ?= v0.2.0
109export RUKPAK_VERSION =$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
@@ -112,17 +111,28 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into
112111
113112# #@ Build
114113
115- BUILDCMD = sh -c 'mkdir -p $(BUILDBIN ) && $(GORELEASER ) build ${GORELEASER_ARGS} --single-target -o $(BUILDBIN ) /manager'
116- BUILDDEPS = manifests generate fmt vet $(GORELEASER )
114+ export VERSION ?= $(shell git describe --tags --always --dirty)
115+ export CGO_ENABLED ?= 0
116+ export GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD}
117+ export GO_BUILD_LDFLAGS ?= -s -w -X $(shell go list -m) /version.Version=$(VERSION )
118+ export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD}
119+ export GO_BUILD_TAGS ?= upstream
117120
118- .PHONY : build
119- build : BUILDBIN = bin
120- build : $(BUILDDEPS ) # # Build manager binary using goreleaser for current GOOS and GOARCH.
121+ BUILDCMD = go build -tags '$(GO_BUILD_TAGS ) ' -ldflags '$(GO_BUILD_LDFLAGS ) ' -gcflags '$(GO_BUILD_GCFLAGS ) ' -asmflags '$(GO_BUILD_ASMFLAGS ) ' -o $(BUILDBIN ) /manager ./cmd/manager
122+
123+ .PHONY : build-deps
124+ build-deps : manifests generate fmt vet
125+
126+ .PHONY : build go-build-local
127+ build : build-deps go-build-local # # Build manager binary for current GOOS and GOARCH.
128+ go-build-local : BUILDBIN = bin
129+ go-build-local :
121130 $(BUILDCMD )
122131
123- .PHONY : build-linux
124- build-linux : BUILDBIN = bin/linux
125- build-linux : $(BUILDDEPS ) # # Build manager binary using goreleaser for GOOS=linux and local GOARCH.
132+ .PHONY : build-linux go-build-linux
133+ build-linux : build-deps go-build-linux # # Build manager binary for GOOS=linux and local GOARCH.
134+ go-build-linux : BUILDBIN = bin/linux
135+ go-build-linux :
126136 GOOS=linux $(BUILDCMD )
127137
128138.PHONY : run
@@ -143,7 +153,6 @@ docker-build: build-linux ## Build docker image for operator-controller with GOO
143153# #@ Release:
144154export ENABLE_RELEASE_PIPELINE ?= false
145155export GORELEASER_ARGS ?= --snapshot --clean
146- export VERSION ?= $(shell git describe --abbrev=0 --tags)
147156
148157release : $(GORELEASER ) # # Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
149158 $(GORELEASER ) $(GORELEASER_ARGS )
0 commit comments