@@ -75,6 +75,7 @@ GOARCH ?= amd64
7575
7676# Build directories.
7777ROOT_DIR = $(shell pwd)
78+ REPO_ROOT = $(shell git rev-parse --show-toplevel)
7879CNM_DIR = cnm/plugin
7980CNI_NET_DIR = cni/network/plugin
8081CNI_IPAM_DIR = cni/ipam/plugin
@@ -98,6 +99,8 @@ CNS_BUILD_DIR = $(BUILD_DIR)/cns
9899CNMS_BUILD_DIR = $(BUILD_DIR ) /cnms
99100NPM_BUILD_DIR = $(BUILD_DIR ) /npm
100101NPM_TELEMETRY_DIR = $(NPM_BUILD_DIR ) /telemetry
102+ TOOLS_DIR = $(REPO_ROOT ) /build/tools
103+ TOOLS_BIN_DIR = $(TOOLS_DIR ) /bin
101104CNI_AI_ID = 5515a1eb-b2bc-406a-98eb-ba462e6f0411
102105NPM_AI_ID = 014c22bd-4107-459e-8475-67909e96edcb
103106ACN_PACKAGE_PATH = github.com/Azure/azure-container-networking
@@ -195,6 +198,7 @@ endif
195198.PHONY : clean
196199clean :
197200 rm -rf $(OUTPUT_DIR )
201+ rm -rf $(TOOLS_BIN_DIR )
198202
199203# Build the Azure CNM plugin.
200204$(CNM_BUILD_DIR ) /azure-vnet-plugin$(EXE_EXT ) : $(CNMFILES )
@@ -471,4 +475,12 @@ test-cyclonus:
471475.PHONY : kind
472476kind :
473477 kind create cluster --config ./test/kind/kind.yaml
474-
478+
479+ $(TOOLS_DIR ) /go.mod :
480+ cd $(TOOLS_DIR ) ; go mod init && go mod tidy
481+
482+ CONTROLLER_GEN := $(TOOLS_BIN_DIR ) /controller-gen
483+ $(CONTROLLER_GEN ) : $(TOOLS_DIR ) /go.mod # Build controller-gen
484+ cd $(TOOLS_DIR ) ; go mod download; go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
485+
486+ controller-gen : $(CONTROLLER_GEN )
0 commit comments