aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: abc200b467ff93023457fde559181d4eb4f0979f (plain)
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
VERSION ?= $(shell git describe --always --tags --dirty)

BINAPI_DIR ?= $(shell cd examples/bin_api && pwd)
VPP_VERSION := $(shell apt-cache show vpp | grep Version: | cut -d' ' -f2-)

all: test build examples

install:
	@echo "=> installing binapi generator ${VERSION}"
	go install ./cmd/binapi-generator

build:
	@echo "=> building binapi generator ${VERSION}"
	cd cmd/binapi-generator && go build -v

examples:
	@echo "=> building examples"
	cd examples/simple-client && go build -v
	cd examples/stats-api && go build -v
	cd examples/perf-bench && go build -v
	cd examples/union-example && go build -v

test:
	@echo "=> running tests"
	go test -cover ./cmd/...
	go test -cover ./ ./adapter ./core ./api ./codec

extras:
	@echo "=> building extras"
	cd extras/libmemif/examples/gopacket && go build -v
	cd extras/libmemif/examples/icmp-responder && go build -v
	cd extras/libmemif/examples/jumbo-frames && go build -v
	cd extras/libmemif/examples/raw-data && go build -v

clean:
	@echo "=> cleaning"
	rm -f cmd/binapi-generator/binapi-generator
	rm -f examples/perf-bench/perf-bench
	rm -f examples/simple-client/simple-client
	rm -f examples/stats-api/stats-api
	rm -f examples/union-example/union-example
	rm -f extras/libmemif/examples/gopacket/gopacket
	rm -f extras/libmemif/examples/icmp-responder/icmp-responder
	rm -f extras/libmemif/examples/jumbo-frames/jumbo-frames
	rm -f extras/libmemif/examples/raw-data/raw-data

generate-binapi:
	@echo "=> generating binapi"
	@go generate "${BINAPI_DIR}"

generate: install
	@echo "=> generating code"
	cd examples && go generate -x ./...

update-vppapi:
	@echo "=> updating API JSON files using installed VPP ${VPP_VERSION}"
	@cd ${BINAPI_DIR} && find . -type f -name '*.api.json' -exec cp /usr/share/vpp/api/'{}' '{}' \;
	@echo ${VPP_VERSION} > ${BINAPI_DIR}/VPP_VERSION

lint:
	@echo "=> running linter"
	@golint ./... | grep -v vendor | grep -v bin_api || true

.PHONY: all \
	install build examples test \
	extras clean generate lint