From 2bc81d4d4f9b5245abfab5fac35e165e99cd98b1 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Tue, 6 Jun 2023 15:25:35 -0400 Subject: [PATCH] Makefile: build targets use go build directly Signed-off-by: Joe Lanford --- .github/workflows/e2e.yaml | 2 ++ .goreleaser.yml | 8 +++++--- Makefile | 26 +++++++++++++++++--------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2a9b349e0..d562d21fd 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-go@v4 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index b299174f4..7058d6fc8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -10,7 +10,11 @@ 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: @@ -18,8 +22,6 @@ builds: - arm64 - ppc64le - s390x - ldflags: - - -X main.Version={{ .Version }} dockers: - image_templates: - "{{ .Env.IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64" diff --git a/Makefile b/Makefile index 8830526a3..cf8dc7810 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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