-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
73 lines (58 loc) · 2.03 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
64
65
66
67
68
69
70
71
72
73
# Source files common to all targets.
COREFILES = \
$(wildcard common/*.go) \
$(wildcard network/*.go) \
# Source files for building CNI plugin.
CNIFILES = \
$(wildcard cni/*.go) \
$(wildcard cni/network/*.go) \
$(wildcard plugins/*.go) \
$(COREFILES)
GOCMD=go
GOLOCALENV=GO111MODULE=on GOARCH=amd64 GOOS=windows
GOBUILD=$(GOLOCALENV) $(GOCMD) build -v -mod=vendor
GOTEST=$(GOLOCALENV) $(GOCMD) test -v -p 1 -mod=vendor
CNI_NET_DIR = plugins
OUTPUTDIR = out
# Containerized build parameters.
# Based on Azure/aks-engine Makefile
REPO_PATH := github.com/Microsoft/windows-container-networking
DEV_ENV_IMAGE := golang:1.12.2
DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
DEV_ENV_OPTS := --rm -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR} ${DEV_ENV_VARS}
DEV_ENV_CMD := docker run ${DEV_ENV_OPTS} ${DEV_ENV_IMAGE}
DEV_ENV_CMD_IT := docker run -it ${DEV_ENV_OPTS} ${DEV_ENV_IMAGE}
DEV_CMD_RUN := docker run ${DEV_ENV_OPTS}
# Docker plugin image parameters.
VERSION ?= $(shell git describe --tags --always --dirty)
ENSURE_OUTPUTDIR_EXISTS := $(shell mkdir -p $(OUTPUTDIR))
# Shorthand target names for convenience.
sdnbridge: $(OUTPUTDIR)/sdnbridge
sdnoverlay: $(OUTPUTDIR)/sdnoverlay
nat: $(OUTPUTDIR)/nat
all: sdnbridge sdnoverlay nat
cp scripts/autogencniconf/generateCNIConfig.ps1 out/
# Containerized Build Environment
.PHONY: dev
dev:
$(DEV_ENV_CMD_IT) bash
# Clean all build artifacts.
.PHONY: clean
clean:
rm -rf $(OUTPUTDIR) release vendor
$(OUTPUTDIR)/sdnbridge $(OUTPUTDIR)/sdnoverlay $(OUTPUTDIR)/nat : $(CNIFILES)
$(GOBUILD) -o $(OUTPUTDIR)/$(subst $(OUTPUTDIR)/,,$@).exe -ldflags "-X main.version=$(VERSION) -s -w" $(CNI_NET_DIR)/$(subst $(OUTPUTDIR)/,,$@)/*.go
.PHONY: test
test :
$(GOTEST) ./...
.PHONY : format
format :
gofmt -s -l -w ./common/* ./cni/* ./network/* ./plugins/* ./test/*
.PHONY : vendor
vendor :
go mod vendor
.PHONY : release
release : all
mkdir -p release; \
zip -jrmv release/windows-container-networking-cni-amd64-$(VERSION).zip out; \
for file in ./release/*.zip ; do shasum -a 512 $$file > $$file.sha512 ; done