aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2019-11-05 00:16:25 +0100
committerOndrej Fabry <ofabry@cisco.com>2019-11-05 00:16:25 +0100
commit2f75863ba9bff2d2f3488b70e441b5eefc91dfd2 (patch)
tree5c54cbb3ceb47f18c9baf5c477607c212c3bcb06 /Makefile
parent73733b0a8ab8612233c98f9828f5f563c69fc2b7 (diff)
Begin development of next release 0.3.0
- update info in package ./version - update to Go 1.13 - regenerate ./examples/binapi for latest VPP: 19.08.1-release - clean code in proxy - refactor Makefile Change-Id: Ibf5c2682c2f4b3cbbea4aa1e35d3f02175d40a9b Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile130
1 files changed, 72 insertions, 58 deletions
diff --git a/Makefile b/Makefile
index 5354609..1c4f97b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,74 +1,94 @@
-SHELL = /bin/bash
-
-GO ?= GO111MODULE=on go
-GOVPP_PKG := $(shell go list)
+SHELL := /usr/bin/env bash -o pipefail
VERSION ?= $(shell git describe --always --tags --dirty)
COMMIT ?= $(shell git rev-parse HEAD)
BUILD_STAMP ?= $(shell git log -1 --format="%ct")
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
+
BUILD_HOST ?= $(shell hostname)
BUILD_USER ?= $(shell id -un)
-VPP_VERSION = $(shell dpkg-query -f '\${Version}' -W vpp)
-
-VPP_IMG ?= ligato/vpp-base:latest
-BINAPI_DIR ?= ./examples/binapi
+GO ?= go
-LDFLAGS = -w -s \
+GOVPP_PKG := $(shell go list)
+LDFLAGS = \
-X ${GOVPP_PKG}/version.version=$(VERSION) \
-X ${GOVPP_PKG}/version.commitHash=$(COMMIT) \
-X ${GOVPP_PKG}/version.buildStamp=$(BUILD_STAMP) \
-X ${GOVPP_PKG}/version.buildBranch=$(BUILD_BRANCH) \
-X ${GOVPP_PKG}/version.buildUser=$(BUILD_USER) \
-X ${GOVPP_PKG}/version.buildHost=$(BUILD_HOST)
+ifeq ($(NOSTRIP),)
+LDFLAGS += -w -s
+endif
+
+GO_BUILD_TAGS ?= novpp
GO_BUILD_ARGS = -ldflags "${LDFLAGS}"
-ifeq ($(V),1)
-GO_BUILD_ARGS += -v
-endif
ifneq ($(GO_BUILD_TAGS),)
GO_BUILD_ARGS += -tags="${GO_BUILD_TAGS}"
endif
+ifneq ($(GO_NOTRIM),0)
+GO_BUILD_ARGS += -trimpath
+endif
+ifeq ($(V),1)
+GO_BUILD_ARGS += -v
+endif
+
+VPP_VERSION = $(shell dpkg-query -f '\${Version}' -W vpp)
+
+VPP_IMG ?= ligato/vpp-base:latest
+BINAPI_DIR ?= ./examples/binapi
+
+help:
+ @echo "List of make targets:"
+ grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
+
+.DEFAULT = help
+
+bin:
+ mkdir -p bin
+
+build: ## Build all
+ @echo "# building ${VERSION}"
+ $(GO) build ${GO_BUILD_ARGS} ./...
+
+cmd: bin ## Build commands
+ $(GO) build ${GO_BUILD_ARGS} -o bin ./cmd/...
+
+examples: bin ## Build examples
+ $(GO) build ${GO_BUILD_ARGS} -o bin ./examples/...
+
+clean: ## Clean all
+ @echo "# cleaning"
+ $(GO) clean -v ./...
+
+test: ## Run unit tests
+ @echo "# running tests"
+ $(GO) test -tags="${GO_BUILD_TAGS}" ./...
-all: test build examples
+integration: ## Run integration tests
+ @echo "# running integration tests"
+ $(GO) test -tags="integration ${GO_BUILD_TAGS}" ./test/integration
-install:
- @echo "=> installing binapi-generator ${VERSION}"
+lint: ## Run code linter
+ @echo "# running linter"
+ @golint ./...
+
+install-generator: ## Install binapi-generator
+ @echo "# installing binapi-generator ${VERSION}"
$(GO) install ${GO_BUILD_ARGS} ./cmd/binapi-generator
-build:
- @echo "=> building binapi-generator ${VERSION}"
- cd cmd/binapi-generator && $(GO) build ${GO_BUILD_ARGS}
-
-examples:
- @echo "=> building examples"
- cd examples/perf-bench && $(GO) build ${GO_BUILD_ARGS} -v
- cd examples/rpc-service && $(GO) build ${GO_BUILD_ARGS} -v
- cd examples/simple-client && $(GO) build ${GO_BUILD_ARGS} -v
- cd examples/stats-client && $(GO) build ${GO_BUILD_ARGS} -v
- cd examples/union-example && $(GO) build ${GO_BUILD_ARGS} -v
-
-clean:
- @echo "=> cleaning"
- go clean -v ./cmd/...
- go clean -v ./examples/...
-
-test:
- @echo "=> running tests"
- $(GO) test ${GO_BUILD_ARGS} ./cmd/...
- $(GO) test ${GO_BUILD_ARGS} ./ ./api ./adapter ./codec ./core
-
-test-integration:
- @echo "=> running integration tests"
- $(GO) test ${GO_BUILD_ARGS} ./test/integration
-
-lint:
- @echo "=> running linter"
- @golint ./... | grep -v vendor | grep -v /binapi/ || true
-
-gen-binapi-docker: install
- @echo "=> generating binapi in docker image ${VPP_IMG}"
+generate: ## Generate code
+ @echo "# generating code"
+ $(GO) generate -x ./...
+
+generate-binapi: install-generator
+ @echo "# generating binapi VPP $(VPP_VERSION)"
+ $(GO) generate -x "$(BINAPI_DIR)"
+
+gen-binapi-docker: install-generator
+ @echo "# generating binapi in docker image ${VPP_IMG}"
$(eval cmds := $(shell go generate -n $(BINAPI_DIR) 2>&1 | tr "\n" ";"))
docker run -t --rm \
-v "$(shell which gofmt):/usr/local/bin/gofmt:ro" \
@@ -78,19 +98,13 @@ gen-binapi-docker: install
"${VPP_IMG}" \
sh -xc "cd $(BINAPI_DIR) && $(cmds)"
-generate-binapi: install
- @echo "=> generating binapi VPP $(VPP_VERSION)"
- $(GO) generate -x "$(BINAPI_DIR)"
-
-generate:
- @echo "=> generating code"
- $(GO) generate -x ./...
-
extras:
@make -C extras
-.PHONY: all \
- install build examples clean test test-integration lint \
- generate generate-binapi gen-binapi-docker \
+.PHONY: help \
+ build cmd examples clean \
+ lint test integration \
+ install-generator generate generate-binapi gen-binapi-docker \
extras
+