From 151da936ea8952dd57261f2038fc2dcb78e8dcd7 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Mon, 17 Jan 2022 11:17:56 +0100 Subject: Update README Change-Id: Id070a39c871a1d428523cbf2eec58dcb51e2c14a Signed-off-by: Ondrej Fabry --- docs/GENERATOR.md | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'docs/GENERATOR.md') diff --git a/docs/GENERATOR.md b/docs/GENERATOR.md index d7832ac..9cc40fc 100644 --- a/docs/GENERATOR.md +++ b/docs/GENERATOR.md @@ -1,20 +1,46 @@ -# Binapi Generator +# Generator -## Install the binary API generator +This document contains information about GoVPP generator which is used for generating Go bindings for VPP binary API. + +## Installation + +### Prerequisites + +- Go 1.13+ ([download](https://golang.org/dl)) + +### Install via Go toolchain + +```shell +# Latest version (most recent tag) +go install git.fd.io/govpp.git/cmd/binapi-generator@latest + +# Development version (master branch) +go install git.fd.io/govpp.git/cmd/binapi-generator@master +``` + +NOTE: Using `go install` to install programs is only supported in Go 1.16+ ([more info](https://go.dev/doc/go1.16#go-command)). For Go 1.15 or older, use `go get` instead of `go install`. + +### Install from source ```sh -# Install binapi generator +# Clone repository anywhere +git clone https://gerrit.fd.io/r/govpp.git +cd govpp + +# Install binapi-generator make install-generator ``` -> NOTE: This installs `binapi-generator` to `$GOPATH/bin` directory, ensure -> it is in your `$PATH` before running the command. +NOTE: There is no need to setup or clone inside `GOPATH` for Go 1.13+ ([more info](https://go.dev/doc/go1.13#modules)) +and you can simply clone the repository _anywhere_ you want. + +### Generating binapi -## Install vpp binary artifacts +### Install vpp binary artifacts Build locally, or download from packagecloud. Read more: https://fd.io/docs/vpp/master/gettingstarted/installing -## Generate binapi (Go bindings) +### Generate binapi (Go bindings) Generating Go bindings for VPP binary API from the JSON files installed with the vpp binary artifacts - located in `/usr/share/vpp/api/`. @@ -27,7 +53,7 @@ INFO[0000] Generating 203 files The generated files will be generated under `binapi` directory. -## Generate VPP binary API code (Go bindings) +### Generate VPP binary API code (Go bindings) Once you have `binapi-generator` installed, you can use it to generate Go bindings for VPP binary API using VPP APIs in JSON format. The JSON input can be specified as a single file (`input-file` argument), or @@ -48,7 +74,7 @@ that are dependent on generated code using special comments: //go:generate binapi-generator --input-dir=bin_api --output-dir=bin_api ``` -## Tracking down generated go code for a specific binary API +### Tracking down generated go code for a specific binary API Golang uses capitalization to indicate exported names, so you'll have to divide through by binapi-generator transformations. Example: -- cgit 1.2.3-korg