3 GO ?= GO111MODULE=on go
4 GOVPP_PKG := $(shell go list)
6 VERSION ?= $(shell git describe --always --tags --dirty)
7 COMMIT ?= $(shell git rev-parse HEAD)
8 BUILD_STAMP ?= $(shell git log -1 --format="%ct")
9 BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
10 BUILD_HOST ?= $(shell hostname)
11 BUILD_USER ?= $(shell id -un)
13 VPP_VERSION = $(shell dpkg-query -f '\${Version}' -W vpp)
15 VPP_IMG ?= ligato/vpp-base:latest
16 BINAPI_DIR ?= ./examples/binapi
19 -X ${GOVPP_PKG}/version.version=$(VERSION) \
20 -X ${GOVPP_PKG}/version.commitHash=$(COMMIT) \
21 -X ${GOVPP_PKG}/version.buildStamp=$(BUILD_STAMP) \
22 -X ${GOVPP_PKG}/version.buildBranch=$(BUILD_BRANCH) \
23 -X ${GOVPP_PKG}/version.buildUser=$(BUILD_USER) \
24 -X ${GOVPP_PKG}/version.buildHost=$(BUILD_HOST)
26 GO_BUILD_ARGS = -ldflags "${LDFLAGS}"
30 ifneq ($(GO_BUILD_TAGS),)
31 GO_BUILD_ARGS += -tags="${GO_BUILD_TAGS}"
34 all: test build examples
37 @echo "=> installing binapi-generator ${VERSION}"
38 $(GO) install ${GO_BUILD_ARGS} ./cmd/binapi-generator
41 @echo "=> building binapi-generator ${VERSION}"
42 cd cmd/binapi-generator && $(GO) build ${GO_BUILD_ARGS}
45 @echo "=> building examples"
46 cd examples/simple-client && $(GO) build ${GO_BUILD_ARGS} -v
47 cd examples/stats-api && $(GO) build ${GO_BUILD_ARGS} -v
48 cd examples/perf-bench && $(GO) build ${GO_BUILD_ARGS} -v
49 cd examples/union-example && $(GO) build ${GO_BUILD_ARGS} -v
50 cd examples/rpc-service && $(GO) build ${GO_BUILD_ARGS} -v
55 go clean -v ./examples/...
58 @echo "=> running tests"
59 $(GO) test -v ./cmd/...
60 $(GO) test -v ./ ./api ./adapter ./codec ./core
63 @echo "=> running linter"
64 @golint ./... | grep -v vendor | grep -v /binapi/ || true
66 gen-binapi-docker: install
67 @echo "=> generating binapi in docker image ${VPP_IMG}"
68 $(eval cmds := $(shell go generate -n $(BINAPI_DIR) 2>&1 | tr "\n" ";"))
70 -v "$(shell which gofmt):/usr/local/bin/gofmt:ro" \
71 -v "$(shell which binapi-generator):/usr/local/bin/binapi-generator:ro" \
72 -v "$(shell pwd):/govpp" -w /govpp \
73 -u "$(shell id -u):$(shell id -g)" \
75 sh -xc "cd $(BINAPI_DIR) && $(cmds)"
77 generate-binapi: install
78 @echo "=> generating binapi VPP $(VPP_VERSION)"
79 $(GO) generate -x "$(BINAPI_DIR)"
82 @echo "=> generating code"
83 $(GO) generate -x ./...
90 install build examples clean test lint \
91 generate generate-binapi gen-binapi-docker \