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/perf-bench && $(GO) build ${GO_BUILD_ARGS} -v
47 cd examples/rpc-service && $(GO) build ${GO_BUILD_ARGS} -v
48 cd examples/simple-client && $(GO) build ${GO_BUILD_ARGS} -v
49 cd examples/stats-client && $(GO) build ${GO_BUILD_ARGS} -v
50 cd examples/union-example && $(GO) build ${GO_BUILD_ARGS} -v
55 go clean -v ./examples/...
58 @echo "=> running tests"
59 $(GO) test ${GO_BUILD_ARGS} ./cmd/...
60 $(GO) test ${GO_BUILD_ARGS} ./ ./api ./adapter ./codec ./core
63 @echo "=> running integration tests"
64 $(GO) test ${GO_BUILD_ARGS} ./test/integration
67 @echo "=> running linter"
68 @golint ./... | grep -v vendor | grep -v /binapi/ || true
70 gen-binapi-docker: install
71 @echo "=> generating binapi in docker image ${VPP_IMG}"
72 $(eval cmds := $(shell go generate -n $(BINAPI_DIR) 2>&1 | tr "\n" ";"))
74 -v "$(shell which gofmt):/usr/local/bin/gofmt:ro" \
75 -v "$(shell which binapi-generator):/usr/local/bin/binapi-generator:ro" \
76 -v "$(shell pwd):/govpp" -w /govpp \
77 -u "$(shell id -u):$(shell id -g)" \
79 sh -xc "cd $(BINAPI_DIR) && $(cmds)"
81 generate-binapi: install
82 @echo "=> generating binapi VPP $(VPP_VERSION)"
83 $(GO) generate -x "$(BINAPI_DIR)"
86 @echo "=> generating code"
87 $(GO) generate -x ./...
94 install build examples clean test test-integration lint \
95 generate generate-binapi gen-binapi-docker \