aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2020-08-21 17:25:53 +0200
committerOndrej Fabry <ofabry@cisco.com>2020-09-03 15:11:13 +0000
commitc94a962279858fb13eaacc689f47aed358373e44 (patch)
tree0cade1807c10ed53bf7c1b623f4d26da639356f6 /Makefile
parent42d11af03300fe0a3476c32ad8c70297862d9320 (diff)
Improve doc & fix import ordering
This also updates /binapi and adds a new make command to generate api files out of a local vpp repo clone Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com> Change-Id: Iff7965388a74ecd21af80f10b5a59d4ed8da6340
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile28
1 files changed, 25 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 5257617..0ae100b 100644
--- a/Makefile
+++ b/Makefile
@@ -35,10 +35,16 @@ ifeq ($(V),1)
GO_BUILD_ARGS += -v
endif
-VPP_VERSION = $(shell dpkg-query -f '\${Version}' -W vpp)
+VPP_VERSION ?= $(shell dpkg-query -f '\${Version}' -W vpp)
-VPP_IMG ?= ligato/vpp-base:latest
-BINAPI_DIR ?= ./binapi
+# 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
bin:
mkdir -p bin
@@ -47,6 +53,9 @@ build: ## Build all
@echo "# building ${VERSION}"
$(GO) build ${GO_BUILD_ARGS} ./...
+cmd-binapi-generator: bin ## Build commands
+ $(GO) build ${GO_BUILD_ARGS} -o bin ./cmd/binapi-generator
+
cmd: bin ## Build commands
$(GO) build ${GO_BUILD_ARGS} -o bin ./cmd/...
@@ -88,6 +97,19 @@ generate-binapi: install-generator ## Generate binapi code
@echo "# generating binapi VPP $(VPP_VERSION)"
$(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}"
$(eval cmds := $(shell go generate -n $(BINAPI_DIR) 2>&1 | tr "\n" ";"))