summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2018-01-26 15:08:15 +0100
committerOndrej Fabry <ofabry@cisco.com>2018-01-26 15:08:15 +0100
commit2406041faa197799c7715f815cbd391a5c0e9ad3 (patch)
tree7eb82b3d0e155398ffb0c323c92be4568a91dd4b
parent8ca20507d15703412c18b07d4f4ce6b4de989de6 (diff)
Make including VlAPIVersion in generated file as opt-in
Change-Id: I6ce52a539afe8af90858718a788dd310e735dff5 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
-rw-r--r--cmd/binapi-generator/generator.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/cmd/binapi-generator/generator.go b/cmd/binapi-generator/generator.go
index 94ee177..15f6164 100644
--- a/cmd/binapi-generator/generator.go
+++ b/cmd/binapi-generator/generator.go
@@ -32,6 +32,13 @@ import (
"github.com/bennyscetbun/jsongo"
)
+var (
+ inputFile = flag.String("input-file", "", "Input JSON file.")
+ inputDir = flag.String("input-dir", ".", "Input directory with JSON files.")
+ outputDir = flag.String("output-dir", ".", "Output directory where package folders will be generated.")
+ includeAPIVer = flag.Bool("include-apiver", false, "Wether to include VlAPIVersion in generated file.")
+)
+
// MessageType represents the type of a VPP message.
type messageType int
@@ -60,9 +67,6 @@ type context struct {
}
func main() {
- inputFile := flag.String("input-file", "", "Input JSON file.")
- inputDir := flag.String("input-dir", ".", "Input directory with JSON files.")
- outputDir := flag.String("output-dir", ".", "Output directory where package folders will be generated.")
flag.Parse()
if *inputFile == "" && *inputDir == "" {
@@ -405,14 +409,14 @@ func generatePackageHeader(ctx *context, w io.Writer, rootNode *jsongo.JSONNode)
fmt.Fprintln(w, "package "+ctx.packageName)
fmt.Fprintln(w, "import \""+apiImportPath+"\"")
-
fmt.Fprintln(w)
- fmt.Fprintln(w, "// VlApiVersion contains version of the API.")
- vlAPIVersion := rootNode.Map("vl_api_version")
- if vlAPIVersion != nil {
- fmt.Fprintln(w, "const VlAPIVersion = ", vlAPIVersion.Get())
+
+ vlAPIVersion := rootNode.Map("vl_api_version").Get()
+ if *includeAPIVer {
+ fmt.Fprintln(w, "// VlApiVersion contains version of the API.")
+ fmt.Fprintln(w, "const VlAPIVersion = ", vlAPIVersion)
+ fmt.Fprintln(w)
}
- fmt.Fprintln(w)
}
// generateMessageComment generates comment for a message into provider writer