-all: test build examples
-
-install:
- @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}"
+# VPP Docker image to use for api generation (gen-binapi-docker)
+VPP_IMG ?= ligato/vpp-base:latest
+# Local VPP directory used for binary api generation (gen-binapi-from-code)
+VPP_DIR ?=
+# Target directory for generated go api bindings
+BINAPI_DIR ?= ./binapi
+# Binapi generator path
+BINAPI_GENERATOR = ./bin/binapi-generator
+
+.DEFAULT_GOAL = 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/...
+
+test: ## Run unit tests
+ @echo "# running tests"
+ go test -tags="${GO_BUILD_TAGS}" ./...
+
+test-integration: ## Run integration tests
+ @echo "# running integration tests"
+ go test -tags="integration ${GO_BUILD_TAGS}" ./test/integration
+
+lint: ## Run code linter
+ @echo "# running linter"
+ @golint ./...
+
+install: install-generator install-proxy ## Install all
+
+install-generator: ## Install binapi-generator
+ @echo "# installing binapi-generator ${VERSION}"
+ @go install ${GO_BUILD_ARGS} ./cmd/binapi-generator
+
+install-proxy: ## Install vpp-proxy
+ @echo "# installing vpp-proxy ${VERSION}"
+ go install ${GO_BUILD_ARGS} ./cmd/vpp-proxy
+
+generate: generate-binapi ## Generate all
+
+generate-binapi: install-generator ## Generate binapi code
+ @echo "# generating binapi"
+ go generate -x "$(BINAPI_DIR)"
+
+gen-binapi-from-code: cmd-binapi-generator
+ $(eval VPP_API_DIR := ${VPP_DIR}/build-root/install-vpp-native/vpp/share/vpp/api/)
+ @echo "Generating vpp API.json and go bindings"
+ @echo "Vpp Directory ${VPP_DIR}"
+ @echo "Vpp API files ${VPP_API_DIR}"
+ @echo "Go bindings ${BINAPI_DIR}"
+ @cd ${VPP_DIR} && make json-api-files
+ @${BINAPI_GENERATOR} \
+ --input-dir=${VPP_API_DIR} \
+ --output-dir=${BINAPI_DIR} \
+ --gen rpc,rest \
+ --no-source-path-info
+
+gen-binapi-docker: install-generator ## Generate binapi code (using Docker)
+ @echo "# generating binapi in docker image ${VPP_IMG}"