Skip to content

Commit 8c922b9

Browse files
committed
Makefile: build targets use go build directly
Signed-off-by: Joe Lanford <[email protected]>
1 parent 22afecf commit 8c922b9

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

.github/workflows/e2e.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
steps:
1414

1515
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
1618

1719
- uses: actions/setup-go@v4
1820
with:

.goreleaser.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ builds:
1010
- id: operator-controller
1111
main: ./cmd/manager/
1212
binary: bin/manager
13-
tags: $GO_BUILD_TAGS
13+
asmflags: "{{ .Env.GO_BUILD_ASMFLAGS }}"
14+
gcflags: "{{ .Env.GO_BUILD_GCFLAGS }}"
15+
ldflags: "{{ .Env.GO_BUILD_LDFLAGS }}"
16+
tags:
17+
- "{{ .Env.GO_BUILD_TAGS }}"
1418
goos:
1519
- linux
1620
goarch:
1721
- amd64
1822
- arm64
1923
- ppc64le
2024
- s390x
21-
ldflags:
22-
- -X main.Version={{ .Version }}
2325
dockers:
2426
- image_templates:
2527
- "{{ .Env.IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"

Makefile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Image URL to use all building/pushing image targets
55
export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
66
export IMAGE_TAG ?= devel
7-
export GO_BUILD_TAGS ?= upstream
87
export CERT_MGR_VERSION ?= v1.9.0
98
export CATALOGD_VERSION ?= v0.2.0
109
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
@@ -112,17 +111,26 @@ 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 GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD}
115+
export GO_BUILD_LDFLAGS ?= -s -w -X $(shell go list -m)/version.Version=$(VERSION)
116+
export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD}
117+
export GO_BUILD_TAGS ?= upstream
118+
119+
BUILDCMD = go build -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o $(BUILDBIN)/manager ./cmd/manager
120+
121+
.PHONY: build-deps
122+
build-deps: manifests generate fmt vet
117123

118-
.PHONY: build
119-
build: BUILDBIN = bin
120-
build: $(BUILDDEPS) ## Build manager binary using goreleaser for current GOOS and GOARCH.
124+
.PHONY: build go-build-local
125+
build: build-deps go-build-local ## Build manager binary for current GOOS and GOARCH.
126+
go-build-local: BUILDBIN = bin
127+
go-build-local:
121128
$(BUILDCMD)
122129

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.
130+
.PHONY: build-linux go-build-linux
131+
build-linux: build-deps go-build-linux ## Build manager binary for GOOS=linux and local GOARCH.
132+
go-build-linux: BUILDBIN = bin/linux
133+
go-build-linux:
126134
GOOS=linux $(BUILDCMD)
127135

128136
.PHONY: run

0 commit comments

Comments
 (0)