forked from aws-controllers-k8s/code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (48 loc) · 2.48 KB
/
Makefile
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
SHELL := /bin/bash # Use bash syntax
# Set up variables
GO111MODULE=on
AWS_SERVICE=$(shell echo $(SERVICE) | tr '[:upper:]' '[:lower:]')
# Build ldflags
VERSION ?= $(shell git describe --tags --always --dirty)
GITCOMMIT=$(shell git rev-parse HEAD)
BUILDDATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
IMPORT_PATH=github.com/aws-controllers-k8s/code-generator
GO_LDFLAGS=-ldflags "-X $(IMPORT_PATH)/pkg/version.Version=$(VERSION) \
-X $(IMPORT_PATH)/pkg/version.BuildHash=$(GITCOMMIT) \
-X $(IMPORT_PATH)/pkg/version.BuildDate=$(BUILDDATE)"
# We need to use the codegen tag when building and testing because the
# aws-sdk-go/private/model/api package is gated behind a build tag "codegen"...
GO_CMD_FLAGS=-tags codegen
GO_CMD_LOCAL_FLAGS=-modfile=go.local.mod $(GO_CMD_FLAGS)
.PHONY: all local-build-ack-generate build-ack-generate local-build-controller \
build-controller test local-test build-controller-image \
local-build-controller-image
all: test
build-ack-generate: ## Build ack-generate binary
@echo -n "building ack-generate ... "
@go build ${GO_CMD_FLAGS} ${GO_LDFLAGS} -o bin/ack-generate cmd/ack-generate/main.go
@echo "ok."
local-build-ack-generate: ## Build ack-generate binary using the local go.mod
@echo -n "building ack-generate ... "
@go build ${GO_CMD_LOCAL_FLAGS} ${GO_LDFLAGS} -o bin/ack-generate cmd/ack-generate/main.go
@echo "ok."
build-controller: build-ack-generate ## Generate controller code for SERVICE
@./scripts/install-controller-gen.sh
@echo "==== building $(AWS_SERVICE)-controller ===="
@./scripts/build-controller.sh $(AWS_SERVICE)
@echo "==== building $(AWS_SERVICE)-controller release artifacts ===="
@./scripts/build-controller-release.sh $(AWS_SERVICE)
local-build-controller: local-build-ack-generate build-controller ## Generate controller code for SERVICE using the local go.mod
build-controller-image: export LOCAL_MODULES = false
build-controller-image: ## Build container image for SERVICE
@./scripts/build-controller-image.sh $(AWS_SERVICE)
local-build-controller-image: export LOCAL_MODULES = true
local-build-controller-image: ## Build container image for SERVICE allowing local modules
@./scripts/build-controller-image.sh $(AWS_SERVICE)
test: ## Run code tests
go test ${GO_CMD_FLAGS} ./...
local-test: ## Run code tests using the local go.mod
go test ${GO_CMD_LOCAL_FLAGS} ./...
help: ## Show this help.
@grep -F -h "##" $(MAKEFILE_LIST) | grep -F -v grep | sed -e 's/\\$$//' \
| awk -F'[:#]' '{print $$1 = sprintf("%-30s", $$1), $$4}'