Skip to content

Commit

Permalink
Makefile: build targets use go build directly
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford committed Jun 6, 2023
1 parent 22afecf commit 2bc81d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v4
with:
Expand Down
8 changes: 5 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ builds:
- id: operator-controller
main: ./cmd/manager/
binary: bin/manager
tags: $GO_BUILD_TAGS
asmflags: "{{ .Env.GO_BUILD_ASMFLAGS }}"
gcflags: "{{ .Env.GO_BUILD_GCFLAGS }}"
ldflags: "{{ .Env.GO_BUILD_LDFLAGS }}"
tags:
- "{{ .Env.GO_BUILD_TAGS }}"
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
ldflags:
- -X main.Version={{ .Version }}
dockers:
- image_templates:
- "{{ .Env.IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"
Expand Down
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Image URL to use all building/pushing image targets
export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
export IMAGE_TAG ?= devel
export GO_BUILD_TAGS ?= upstream
export CERT_MGR_VERSION ?= v1.9.0
export CATALOGD_VERSION ?= v0.2.0
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
Expand Down Expand Up @@ -112,17 +111,26 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into

##@ Build

BUILDCMD = sh -c 'mkdir -p $(BUILDBIN) && $(GORELEASER) build ${GORELEASER_ARGS} --single-target -o $(BUILDBIN)/manager'
BUILDDEPS = manifests generate fmt vet $(GORELEASER)
export GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD}
export GO_BUILD_LDFLAGS ?= -s -w -X $(shell go list -m)/version.Version=$(VERSION)
export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD}
export GO_BUILD_TAGS ?= upstream

BUILDCMD = go build -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o $(BUILDBIN)/manager ./cmd/manager

.PHONY: build-deps
build-deps: manifests generate fmt vet

.PHONY: build
build: BUILDBIN = bin
build: $(BUILDDEPS) ## Build manager binary using goreleaser for current GOOS and GOARCH.
.PHONY: build go-build-local
build: build-deps go-build-local ## Build manager binary using goreleaser for current GOOS and GOARCH.
go-build-local: BUILDBIN = bin
go-build-local:
$(BUILDCMD)

.PHONY: build-linux
build-linux: BUILDBIN = bin/linux
build-linux: $(BUILDDEPS) ## Build manager binary using goreleaser for GOOS=linux and local GOARCH.
.PHONY: build-linux go-build-linux
build-linux: build-deps go-build-linux ## Build manager binary using goreleaser for GOOS=linux and local GOARCH.
go-build-linux: BUILDBIN = bin/linux
go-build-linux:
GOOS=linux $(BUILDCMD)

.PHONY: run
Expand Down

0 comments on commit 2bc81d4

Please sign in to comment.