@@ -17,6 +17,16 @@ BUILD_PATH = $(REPO)/cmd/operator-sdk
17
17
PKGS = $(shell go list ./... | grep -v /vendor/)
18
18
TEST_PKGS = $(shell go list ./... | grep -v -E 'github.com/operator-framework/operator-sdk/test/')
19
19
SOURCES = $(shell find . -name '* .go' -not -path "* /vendor/* ")
20
+ # GO_BUILD_ARGS should be set when running 'go build' or 'go install'.
21
+ GO_BUILD_ARGS = \
22
+ -gcflags "all=-trimpath=$(shell go env GOPATH) " \
23
+ -asmflags "all=-trimpath=$(shell go env GOPATH) " \
24
+ -ldflags " \
25
+ -X '$(REPO ) /version.GitVersion=$(VERSION ) ' \
26
+ -X '$(REPO ) /version.GitCommit=$(GIT_COMMIT ) ' \
27
+ -X '$(REPO ) /version.KubernetesVersion=$(K8S_VERSION ) ' \
28
+ " \
29
+
20
30
21
31
ANSIBLE_BASE_IMAGE = quay.io/operator-framework/ansible-operator
22
32
HELM_BASE_IMAGE = quay.io/operator-framework/helm-operator
@@ -55,8 +65,7 @@ help: ## Show this help screen
55
65
all : format test build/operator-sdk # # Test and Build the Operator SDK
56
66
57
67
install : # # Install the operator-sdk binary
58
- make build/operator-sdk
59
- cp ./build/operator-sdk $(shell go env GOPATH) /bin/operator-sdk
68
+ $(Q )$(GOARGS ) go install $(GO_BUILD_ARGS ) $(BUILD_PATH )
60
69
61
70
# Code management.
62
71
.PHONY : format tidy clean cli-doc lint
@@ -127,15 +136,7 @@ build/operator-sdk-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x
127
136
build/operator-sdk-% -linux-gnu : GOARGS = GOOS=linux
128
137
129
138
build/% : $(SOURCES ) # # Build the operator-sdk binary
130
- $(Q )$(GOARGS ) go build \
131
- -gcflags " all=-trimpath=${GOPATH} " \
132
- -asmflags " all=-trimpath=${GOPATH} " \
133
- -ldflags " \
134
- -X ' ${REPO}/version.GitVersion=${VERSION}' \
135
- -X ' ${REPO}/version.GitCommit=${GIT_COMMIT}' \
136
- -X ' ${REPO}/version.KubernetesVersion=${K8S_VERSION}' \
137
- " \
138
- -o $@ $(BUILD_PATH )
139
+ $(Q )$(GOARGS ) go build $(GO_BUILD_ARGS ) -o $@ $(BUILD_PATH )
139
140
140
141
build/% .asc : # # Create release signatures for operator-sdk release binaries
141
142
$(Q ) { \
0 commit comments