aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2022-04-27 18:39:03 +0200
committerNathan Skrzypczak <nathan.skrzypczak@gmail.com>2022-05-30 18:49:13 +0200
commit4102c72bce694babd94a481b1201d33895a6f9c5 (patch)
tree1b11238ca4706008c88712f26942dd74ab9c14a6 /Makefile
parenta4112fac7b86fe09650d2bb57969fe46404edd7d (diff)
Update generated binapi to v22.02 & makefile changes
This patch does some small updates to the Makefile. * `make gen-binapi-from-code` is removed, and moves to `gen-binapi-local` * `make build` is patched to build cmd & examples * `make binapi-generator` to build the api-generator without other binaries, as they typically require its output to build. * `make gen-binapi-local` runs the locally built binapi-generator to update the local bindings. It expects ${VPP_DIR} to be set and to point to a local vpp repository checked out with the right version * `make gen-binapi-internal` runs the locally built binapi-generator to update the bindings in `internal/testbinapi/binapi2001` Regarding VPP, notable changes when moving to v22.02 are : - ControlPing moved from vpe to memclnt - CliInband went from vpe to vlib Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com> Change-Id: Ie5cd2d5ded7ecaffd9abc3ca675df40be272b1fa
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile72
1 files changed, 44 insertions, 28 deletions
diff --git a/Makefile b/Makefile
index 46e04ec..c2342a0 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,8 @@ BUILD_USER ?= $(shell id -un)
GOVPP_PKG := git.fd.io/govpp.git
+VPP_API_DIR ?= ${VPP_DIR}/build-root/install-vpp-native/vpp/share/vpp/api
+
VERSION_PKG := $(GOVPP_PKG)/internal/version
LDFLAGS = \
-X $(VERSION_PKG).version=$(VERSION) \
@@ -47,62 +49,81 @@ BINAPI_DIR ?= ./binapi
# Binapi generator path
BINAPI_GENERATOR = ./bin/binapi-generator
+INTERNAL_BINAPI_DIR ?= ./internal/testbinapi/binapi2001
+
.DEFAULT_GOAL = help
+check-%:
+ @: $(if $(value $*),,$(error $* is undefined))
+
bin:
- mkdir -p bin
+ @mkdir -p bin
-build: ## Build all
- @echo "# building ${VERSION}"
- go build ${GO_BUILD_ARGS} ./...
+.PHONY: build
+build: cmd examples ## Build all
+.PHONY: cmd
cmd: bin ## Build commands
- go build ${GO_BUILD_ARGS} -o bin ./cmd/...
+ @go build ${GO_BUILD_ARGS} -o bin ./cmd/...
+.PHONY: binapi-generator
+binapi-generator: bin ## Build only the binapi generator
+ @go build ${GO_BUILD_ARGS} -o bin ./cmd/binapi-generator/
+
+.PHONY: examples
examples: bin ## Build examples
- go build ${GO_BUILD_ARGS} -o bin ./examples/...
+ @go build ${GO_BUILD_ARGS} -o bin ./examples/...
+.PHONY: test
test: ## Run unit tests
@echo "# running tests"
go test -tags="${GO_BUILD_TAGS}" ./...
+.PHONY: test-integration
test-integration: ## Run integration tests
@echo "# running integration tests"
go test -tags="integration ${GO_BUILD_TAGS}" ./test/integration
+.PHONY: lint
lint: ## Run code linter
@echo "# running linter"
@golint ./...
+.PHONY: install
install: install-generator install-proxy ## Install all
+.PHONY: install-generator
install-generator: ## Install binapi-generator
@echo "# installing binapi-generator ${VERSION}"
@go install ${GO_BUILD_ARGS} ./cmd/binapi-generator
+.PHONY: install-proxy
install-proxy: ## Install vpp-proxy
@echo "# installing vpp-proxy ${VERSION}"
- go install ${GO_BUILD_ARGS} ./cmd/vpp-proxy
+ @go install ${GO_BUILD_ARGS} ./cmd/vpp-proxy
+.PHONY: generate
generate: generate-binapi ## Generate all
+.PHONY: generate-binapi
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
-
+ @go generate -x "$(BINAPI_DIR)"
+
+.PHONY: gen-binapi-internal
+gen-binapi-internal:
+ @go generate $(INTERNAL_BINAPI_DIR)
+
+.PHONY: gen-binapi-local
+gen-binapi-local: binapi-generator check-VPP_DIR ## Generate binapi code (using locally cloned VPP)
+ @make -C ${VPP_DIR} json-api-files
+ @find $(BINAPI_DIR)/*/*.ba.go -delete
+ @find $(BINAPI_DIR)/* -type d -delete
+ @./bin/binapi-generator -input-dir=$(VPP_API_DIR) -output-dir=$(BINAPI_DIR) -gen=rpc
+ @./bin/binapi-generator -input-dir=$(VPP_API_DIR) -input-file=$(VPP_API_DIR)/core/vpe.api.json -output-dir=$(BINAPI_DIR) -gen=http
+ @sed -i 's@$(VPP_API_DIR)@/usr/share/vpp/api@g' $(BINAPI_DIR)/*/*.ba.go
+
+.PHONY: gen-binapi-docker
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" ";"))
@@ -115,13 +136,8 @@ gen-binapi-docker: install-generator ## Generate binapi code (using Docker)
"${VPP_IMG}" \
sh -ec "cd $(BINAPI_DIR) && $(cmds)"
+.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
-.PHONY: help \
- build cmd examples clean \
- lint test integration \
- install install-generator install-proxy \
- generate generate-binapi gen-binapi-docker \
- extras