Skip to content

Commit 87132ce

Browse files
authored
Makefile: use go install with same args as go build (#3127)
1 parent 013896a commit 87132ce

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Makefile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ BUILD_PATH = $(REPO)/cmd/operator-sdk
1717
PKGS = $(shell go list ./... | grep -v /vendor/)
1818
TEST_PKGS = $(shell go list ./... | grep -v -E 'github.com/operator-framework/operator-sdk/test/')
1919
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+
2030

2131
ANSIBLE_BASE_IMAGE = quay.io/operator-framework/ansible-operator
2232
HELM_BASE_IMAGE = quay.io/operator-framework/helm-operator
@@ -55,8 +65,7 @@ help: ## Show this help screen
5565
all: format test build/operator-sdk ## Test and Build the Operator SDK
5666

5767
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)
6069

6170
# Code management.
6271
.PHONY: format tidy clean cli-doc lint
@@ -127,15 +136,7 @@ build/operator-sdk-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x
127136
build/operator-sdk-%-linux-gnu: GOARGS = GOOS=linux
128137

129138
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)
139140

140141
build/%.asc: ## Create release signatures for operator-sdk release binaries
141142
$(Q){ \

0 commit comments

Comments
 (0)