-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
84 lines (62 loc) · 1.94 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
74
75
76
77
78
79
80
81
82
83
84
# Makefile templete reference
# https://gist.github.com/turtlemonvh/38bd3d73e61769767c35931d8c70ccb4
BINARY = network-controller
VET_REPORT = vet.report
VERSION?=?
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
# Symlink into GOPATH
GITHUB_USERNAME=linkernetworks
BUILD_DIR=${GOPATH}/src/github.com/${GITHUB_USERNAME}/${BINARY}
CURRENT_DIR=$(shell pwd)
BUILD_DIR_LINK=$(shell readlink ${BUILD_DIR})
# Setup the -ldflags option for go build here, interpolate the variable values
LDFLAGS = -ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BRANCH=${BRANCH}"
DOCKER_PATH="$(shell which docker)"
OVS_PATH="$(shell which ovs-vsctl)"
ifneq ($(DOCKER_PATH),"")
TEST_DOCKER=TEST_DOCKER=1
endif
ifneq ($(OVS_PATH),"")
TEST_OVS=TEST_OVS=1
endif
# Build the project
all: clean vet pb client server
pb:
protoc ./messages/messages.proto --go_out=plugins=grpc:.
server: pb
cd ${BUILD_DIR}/server; \
go build ${LDFLAGS} -o ${BINARY}-server . ; \
cd - >/dev/null
client: pb
cd ${BUILD_DIR}/client; \
go build ${LDFLAGS} -o ${BINARY}-client . ; \
cd - >/dev/null
vet: pb
go vet ./... > ${VET_REPORT} 2>&1 ;
clean:
-rm -f messages/messages.pb.go
-rm -f client/${BINARY}-*
-rm -f server/${BINARY}-*
-rm -f ${VET_REPORT}
test: pb client server
go clean -testcache
sudo -E env PATH=$$PATH TEST_VETH=1 $(TEST_OVS) $(TEST_DOCKER) go test -parallel=1 -v ./...
.PHONY: server client vet test clean
# Vagrant
VAGRANT :=$(shell which vagrant)
ifneq ($(VAGRAMT), "")
VAGRANT_SCP := $(shell vagrant plugin list | grep vagrant-scp)
endif
vagrant:
@if [ "$(VAGRANT)" == "" ] ; then echo "You need to install the vagrant first"; exit 1; fi
vagrant-scp: vagrant
@if [ "$(VAGRANT_SCP)" == "" ]; then vagrant plugin install vagrant-scp ;fi
up: clean-tmp vagrant-scp
vagrant up
mkdir tmp
vagrant scp network_controller:/home/vagrant/.kube/config tmp/admin.conf
clean-tmp:
rm -rf tmp
vagrant-clean: clean-tmp
vagrant destroy -f