4
4
# Image URL to use all building/pushing image targets
5
5
export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
6
6
export IMAGE_TAG ?= devel
7
- export GO_BUILD_TAGS ?= upstream
8
7
export CERT_MGR_VERSION ?= v1.9.0
9
8
export CATALOGD_VERSION ?= v0.2.0
10
9
export 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
112
111
113
112
# #@ Build
114
113
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
117
120
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 :
121
130
$(BUILDCMD )
122
131
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 :
126
136
GOOS=linux $(BUILDCMD )
127
137
128
138
.PHONY : run
@@ -143,7 +153,6 @@ docker-build: build-linux ## Build docker image for operator-controller with GOO
143
153
# #@ Release:
144
154
export ENABLE_RELEASE_PIPELINE ?= false
145
155
export GORELEASER_ARGS ?= --snapshot --clean
146
- export VERSION ?= $(shell git describe --abbrev=0 --tags)
147
156
148
157
release : $(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.
149
158
$(GORELEASER ) $(GORELEASER_ARGS )
0 commit comments