This repository was archived by the owner on Mar 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
177 lines (128 loc) · 3.74 KB
/
Makefile
File metadata and controls
177 lines (128 loc) · 3.74 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Copyright The containerd Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PROTO_SOURCES = $(shell find . -name '*.proto' | grep -v /vendor/)
PROTO_GOFILES = $(patsubst %.proto,%.pb.go,$(PROTO_SOURCES))
PROTO_INCLUDE = -I$(PWD):/usr/local/include:/usr/include
PROTO_OPTIONS = --proto_path=. $(PROTO_INCLUDE) \
--go_opt=paths=source_relative --go_out=. \
--go-ttrpc_opt=paths=source_relative --go-ttrpc_out=.
PROTO_COMPILE = PATH=$(PATH):$(shell go env GOPATH)/bin; protoc $(PROTO_OPTIONS)
GO_CMD := go
GO_BUILD := $(GO_CMD) build
GO_INSTALL := $(GO_CMD) install
GO_TEST := $(GO_CMD) test
GO_LINT := golint -set_exit_status
GO_FMT := gofmt
GO_VET := $(GO_CMD) vet
GO_MODULES := $(shell $(GO_CMD) list ./pkg/...)
GOLANG_CILINT := golangci-lint
GINKGO := ginkgo
BUILD_PATH := $(shell pwd)/build
BIN_PATH := $(BUILD_PATH)/bin
COVERAGE_PATH := $(BUILD_PATH)/coverage
PLUGIN = $(BIN_PATH)/mixedcpu
COMMONENVVAR = GOOS=linux GOARCH=amd64
BUILDENVVAR = CGO_ENABLED=0
RUNTIME ?= docker
REPOOWNER ?= openshift-kni
IMAGENAME ?= mixed-cpu-node-plugin
IMAGETAG ?= latest
MIXED_CPUS_CONTAINER_IMAGE ?= quay.io/${REPOOWNER}/${IMAGENAME}:${IMAGETAG}
CLIENT ?= oc
KUSTOMIZE_DEPLOY_DIR ?= default
ifneq ($(V),1)
Q := @
endif
# E2E configuration
E2E_SHARED_CPUS ?= 0
E2E_SETUP ?= FALSE
E2E_TEARDOWN ?= FALSE
#
# top-level targets
#
all: build build-plugin
build: build-proto build-check
clean: clean-plugins
allclean: clean clean-cache
test: test-gopkgs
#
# build targets
#
build-proto: $(PROTO_GOFILES)
mkdir:
mkdir -p build/bin || true
build-plugin: mkdir
$(COMMONENVVAR) $(BUILDENVVAR) $(GO_BUILD) -o $(PLUGIN) ./cmd/main.go
build-check:
$(Q)$(GO_BUILD) -v $(GO_MODULES)
build-e2e:
$(GO_CMD) test -c -o build/bin/e2e_test test/e2e/*.go
#
# other validation targets
#
fmt format:
$(Q)$(GO_FMT) -s -d -e pkg/ cmd/
lint:
$(Q)$(GO_LINT) -set_exit_status ./...
vet:
$(Q)$(GO_VET) ./...
golangci-lint:
$(Q)$(GOLANG_CILINT) run
#
# proto generation targets
#
%.pb.go: %.proto
$(Q)echo "Generating $@..."; \
$(PROTO_COMPILE) $<
#
# targets for installing dependencies
#
install-protoc install-protobuf:
$(Q)./scripts/install-protobuf && \
install-ttrpc-plugin:
$(Q)$(GO_INSTALL) github.com/containerd/ttrpc/cmd/protoc-gen-go-ttrpc@74421d10189e8c118870d294c9f7f62db2d33ec1
install-protoc-dependencies:
$(Q)$(GO_INSTALL) google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.0
install-ginkgo:
$(Q)$(GO_INSTALL) -mod=mod github.com/onsi/ginkgo/v2/ginkgo
#
# targets for building container
#
.PHONY: image
image: all
@echo "building image"
$(RUNTIME) build -t $(MIXED_CPUS_CONTAINER_IMAGE) .
.PHONY: push
push: image
@echo "pushing image"
$(RUNTIME) push $(MIXED_CPUS_CONTAINER_IMAGE)
#
# targets for deployment
#
.PHONY: deploy
deploy:
@echo "Deploying mixed-cpus plugin"
$(CLIENT) apply -k deployment/kustomize/overlays/$(KUSTOMIZE_DEPLOY_DIR)
.PHONY: undeploy
undeploy:
@echo "Deleting mixed-cpus plugin"
$(CLIENT) delete -k deployment/kustomize/overlays/$(KUSTOMIZE_DEPLOY_DIR)
#
# test targets
#
test-unit:
$(GO_CMD) test -v ./pkg/...
test-e2e: build-e2e
hack/e2e-run-test.sh $(E2E_SHARED_CPUS) $(E2E_SETUP) $(E2E_TEARDOWN)
deps-update:
$(GO_CMD) mod tidy && $(GO_CMD) mod vendor
e2e-wait-for-ds:
hack/wait-for-ds.sh