From: Nathan Skrzypczak Date: Fri, 21 Aug 2020 15:30:05 +0000 (+0200) Subject: Expose version info control flags X-Git-Tag: v0.4.0~51 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=commitdiff_plain;h=ff0a39377533365e128c3364395c6bfbae8d5b1a Expose version info control flags Signed-off-by: Nathan Skrzypczak Change-Id: Ida098149bdf23dccafb7b1f2ac2bb83f21f918c9 --- diff --git a/binapigen/generate.go b/binapigen/generate.go index 679dd54..698c798 100644 --- a/binapigen/generate.go +++ b/binapigen/generate.go @@ -55,7 +55,9 @@ func GenerateAPI(gen *Generator, file *File) *GenFile { g.P("// versions:") g.P("// binapi-generator: ", version.Version()) g.P("// VPP: ", g.gen.vppVersion) - g.P("// source: ", g.file.Desc.Path) + if !gen.opts.NoSourcePathInfo { + g.P("// source: ", g.file.Desc.Path) + } } g.P() diff --git a/binapigen/run.go b/binapigen/run.go index d3a181a..f7776c9 100644 --- a/binapigen/run.go +++ b/binapigen/run.go @@ -29,9 +29,10 @@ import ( ) type Options struct { - OutputDir string // output directory for generated files - ImportPrefix string // prefix for import paths - NoVersionInfo bool // disables generating version info + OutputDir string // output directory for generated files + ImportPrefix string // prefix for import paths + NoVersionInfo bool // disables generating version info + NoSourcePathInfo bool // disables the 'source: /path' comment } func Run(apiDir string, filesToGenerate []string, opts Options, f func(*Generator) error) { diff --git a/cmd/binapi-generator/main.go b/cmd/binapi-generator/main.go index 732b4f3..3dc2c08 100644 --- a/cmd/binapi-generator/main.go +++ b/cmd/binapi-generator/main.go @@ -45,8 +45,10 @@ func main() { importPrefix = flag.String("import-prefix", "", "Define import path prefix to be used to import types.") generatorPlugins = flag.String("gen", "rpc", "List of generator plugins to run for files.") - printVersion = flag.Bool("version", false, "Prints version and exits.") - debugLog = flag.Bool("debug", false, "Enable verbose logging.") + printVersion = flag.Bool("version", false, "Prints version and exits.") + debugLog = flag.Bool("debug", false, "Enable verbose logging.") + noVersionInfo = flag.Bool("no-version-info", false, "Disable version info in generated files.") + noSourcePathInfo = flag.Bool("no-source-path-info", false, "Disable source path info in generated files.") ) flag.Parse() @@ -71,8 +73,10 @@ func main() { } opts := binapigen.Options{ - ImportPrefix: *importPrefix, - OutputDir: *theOutputDir, + ImportPrefix: *importPrefix, + OutputDir: *theOutputDir, + NoVersionInfo: *noVersionInfo, + NoSourcePathInfo: *noSourcePathInfo, } if opts.OutputDir == "binapi" { if wd, _ := os.Getwd(); filepath.Base(wd) == "binapi" {