diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/binapi-generator/main.go | 46 | ||||
-rw-r--r-- | cmd/govpp/main.go | 21 | ||||
-rw-r--r-- | cmd/vpp-proxy/main.go | 25 |
3 files changed, 57 insertions, 35 deletions
diff --git a/cmd/binapi-generator/main.go b/cmd/binapi-generator/main.go index 732b4f3..3ccc138 100644 --- a/cmd/binapi-generator/main.go +++ b/cmd/binapi-generator/main.go @@ -24,29 +24,46 @@ import ( "github.com/sirupsen/logrus" - "git.fd.io/govpp.git/binapigen" - "git.fd.io/govpp.git/binapigen/vppapi" - "git.fd.io/govpp.git/internal/version" + "go.fd.io/govpp/binapigen" + "go.fd.io/govpp/binapigen/vppapi" + "go.fd.io/govpp/version" ) func init() { flag.Usage = func() { - fmt.Fprintf(os.Stderr, "Usage: %s [OPTION] API_FILES\n", os.Args[0]) - fmt.Fprintln(os.Stderr, "Parse API_FILES and generate Go bindings based on the options given:") + fmt.Fprintf(os.Stderr, "USAGE\n") + fmt.Fprintf(os.Stderr, " Parse API_FILES and generate Go bindings\n") + fmt.Fprintf(os.Stderr, " Provide API_FILES by file name, or with full path including extension.\n") + fmt.Fprintf(os.Stderr, " %s [OPTION] API_FILES\n\n", os.Args[0]) + fmt.Fprintf(os.Stderr, "OPTIONS\n") flag.PrintDefaults() + fmt.Fprintf(os.Stderr, "\nEXAMPLES:\n") + fmt.Fprintf(os.Stderr, " %s \\\n", os.Args[0]) + fmt.Fprintf(os.Stderr, " --input-dir=$VPP/build-root/install-vpp-native/vpp/share/vpp/api/ \\\n") + fmt.Fprintf(os.Stderr, " --output-dir=~/output \\\n") + fmt.Fprintf(os.Stderr, " interface ip\n") + fmt.Fprintf(os.Stderr, " Assuming --input-dir contains interface.api.json & ip.api.json\n") } } +func printErrorAndExit(msg string) { + fmt.Fprintf(os.Stderr, "Error: %s\n\n", msg) + flag.Usage() + os.Exit(1) +} + func main() { var ( - theApiDir = flag.String("input-dir", vppapi.DefaultDir, "Input directory containing API files.") - theInputFile = flag.String("input-file", "", "DEPRECATED: Use program arguments to define files to generate.") + theApiDir = flag.String("input-dir", vppapi.DefaultDir, "Input directory containing API files. (e.g. )") theOutputDir = flag.String("output-dir", "binapi", "Output directory where code will be generated.") - importPrefix = flag.String("import-prefix", "", "Define import path prefix to be used to import types.") + importPrefix = flag.String("import-prefix", "", "Prefix imports in the generated go code. \nE.g. other API Files (e.g. api_file.ba.go) will be imported with :\nimport (\n api_file \"<import-prefix>/api_file\"\n)") generatorPlugins = flag.String("gen", "rpc", "List of generator plugins to run for files.") + theInputFile = flag.String("input-file", "", "DEPRECATED: Use program arguments to define files to generate.") - 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() @@ -62,8 +79,7 @@ func main() { var filesToGenerate []string if *theInputFile != "" { if flag.NArg() > 0 { - fmt.Fprintln(os.Stderr, "input-file cannot be combined with files to generate in arguments") - os.Exit(1) + printErrorAndExit("input-file cannot be combined with files to generate in arguments") } filesToGenerate = append(filesToGenerate, *theInputFile) } else { @@ -71,8 +87,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" { diff --git a/cmd/govpp/main.go b/cmd/govpp/main.go index f1ad5d8..6deca09 100644 --- a/cmd/govpp/main.go +++ b/cmd/govpp/main.go @@ -28,11 +28,12 @@ import ( "strings" "text/tabwriter" - "git.fd.io/govpp.git" - "git.fd.io/govpp.git/adapter/socketclient" - "git.fd.io/govpp.git/binapi/vpe" - "git.fd.io/govpp.git/binapigen" - "git.fd.io/govpp.git/binapigen/vppapi" + "go.fd.io/govpp" + "go.fd.io/govpp/adapter/socketclient" + "go.fd.io/govpp/binapi/vlib" + "go.fd.io/govpp/binapi/vpe" + "go.fd.io/govpp/binapigen" + "go.fd.io/govpp/binapigen/vppapi" ) func main() { @@ -122,8 +123,8 @@ func showVPPAPI(out io.Writer, apifiles []*vppapi.File) { } imports := fmt.Sprintf("%d apis, %2d types", len(apifile.Imports), len(importedTypes)) path := strings.TrimPrefix(apifile.Path, vppapi.DefaultDir+"/") - types := fmt.Sprintf("%2d enum, %2d alias, %2d struct, %2d union, %2d msg", - len(apifile.EnumTypes), len(apifile.AliasTypes), len(apifile.StructTypes), len(apifile.UnionTypes), len(apifile.Messages)) + types := fmt.Sprintf("%2d enum, %2d enumflag, %2d alias, %2d struct, %2d union, %2d msg", + len(apifile.EnumTypes), len(apifile.EnumflagTypes), len(apifile.AliasTypes), len(apifile.StructTypes), len(apifile.UnionTypes), len(apifile.Messages)) fmt.Fprintf(w, " %s\t%s\t%s\t%s\t%v\t%s\t\n", apifile.Name, strings.Join(options, " "), apifile.CRC, path, imports, types) } @@ -154,8 +155,8 @@ func sendCLI(args []string) { log.Fatal(err) } - client := vpe.NewServiceClient(conn) - reply, err := client.CliInband(context.Background(), &vpe.CliInband{ + client := vlib.NewServiceClient(conn) + reply, err := client.CliInband(context.Background(), &vlib.CliInband{ Cmd: cmd, }) if err != nil { @@ -174,7 +175,7 @@ func runServer(apifiles []*vppapi.File, addr string) { } vpeRPC := vpe.NewServiceClient(conn) - c := vpe.RESTHandler(vpeRPC) + c := vpe.HTTPHandler(vpeRPC) http.Handle("/", c) diff --git a/cmd/vpp-proxy/main.go b/cmd/vpp-proxy/main.go index d1af5df..639f6cc 100644 --- a/cmd/vpp-proxy/main.go +++ b/cmd/vpp-proxy/main.go @@ -19,13 +19,14 @@ import ( "flag" "log" - "git.fd.io/govpp.git/adapter/socketclient" - "git.fd.io/govpp.git/adapter/statsclient" - "git.fd.io/govpp.git/api" - interfaces "git.fd.io/govpp.git/binapi/interface" - "git.fd.io/govpp.git/binapi/vpe" - _ "git.fd.io/govpp.git/core" - "git.fd.io/govpp.git/proxy" + "go.fd.io/govpp/adapter/socketclient" + "go.fd.io/govpp/adapter/statsclient" + "go.fd.io/govpp/api" + interfaces "go.fd.io/govpp/binapi/interface" + "go.fd.io/govpp/binapi/vlib" + "go.fd.io/govpp/binapi/vpe" + _ "go.fd.io/govpp/core" + "go.fd.io/govpp/proxy" ) var ( @@ -35,8 +36,10 @@ var ( ) func init() { - for _, msg := range api.GetRegisteredMessages() { - gob.Register(msg) + for _, msgList := range api.GetRegisteredMessages() { + for _, msg := range msgList { + gob.Register(msg) + } } } @@ -91,8 +94,8 @@ func runClient() { panic(err) } - req := &vpe.CliInband{Cmd: "show version"} - reply := new(vpe.CliInbandReply) + req := &vlib.CliInband{Cmd: "show version"} + reply := new(vlib.CliInbandReply) if err := binapiChannel.SendRequest(req).ReceiveReply(reply); err != nil { log.Fatalln("binapi request failed:", err) } |