Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (37 loc) · 1.46 KB
/
Copy pathMakefile
File metadata and controls
47 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Makefile for the installer CLI.
#
# The output binary is `bin/installer` because the cub plugin protocol
# names the plugin after its entrypoint basename: invoking it via cub
# reads as `cub installer ...`, matching the standalone form.
GO ?= go
BIN ?= bin/installer
PKG ?= ./cmd/installer
# kustomize_disable_go_plugin_support drops kustomize's import of Go's plugin
# package, which only loads .so Go plugins. The installer never does: its
# transform step is an exec KRM function. With cgo on, the import keeps every
# exported method in the binary (7 MB); with cgo off, it costs nothing, but the
# builds stay alike.
TAGS ?= kustomize_disable_go_plugin_support
.PHONY: all build release-build test vet fmt clean
all: build
build: $(BIN)
$(BIN): $(shell find . -name '*.go' -not -path './bin/*')
$(GO) build -tags '$(TAGS)' -o $(BIN) $(PKG)
# Release-style build: cross-compile with version injection, used by the
# release workflow. Override GOOS, GOARCH, VERSION; OUT defaults to a per-arch
# binary name (installer-<goos>-<goarch>).
#
# Example: make release-build VERSION=0.4.0 GOOS=darwin GOARCH=arm64
release-build:
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) \
$(GO) build -trimpath -tags '$(TAGS)' \
-ldflags "-s -w -X github.com/confighub/installer/internal/version.Version=$(VERSION)" \
-o $(or $(OUT),installer-$(GOOS)-$(GOARCH)) $(PKG)
test:
$(GO) test ./...
vet:
$(GO) vet ./...
fmt:
$(GO) fmt ./...
clean:
rm -f bin/install bin/installer