简体   繁体   English

如何使用nanopb编译.proto + .options文件

[英]how to compile .proto + .options file using nanopb

i wrote an .options file and placed it in the same directory as the .proto file. 我写了一个.options文件并将其放在与.proto文件相同的目录中。 then, I tried to compile it (using nanopb compiler) by using the command 然后,我尝试使用该命令编译它(使用nanopb编译器)

generator-bin/protoc --nanopb_out=. message.proto -s message.options

and got this error: 并得到此错误:

Unknown flag: -s

so what am I doing wrong? 那么我做错了什么? do I need to import my options file in the .proto file? 我需要在.proto文件中导入我的选项文件吗? is there anything else I should do to make it work? 还有什么我应该做的才能让它发挥作用?

Google's protoc has a special syntax for passing options to the plugins. 谷歌的protoc有一个特殊的语法,用于将选项传递给插件。 The plugin options are put as argument to nanopb_out and separated from the actual destination path by colon ( : ). 该插件选项置为参数nanopb_out并通过从结肠的实际目标路径分开( : )。

generator-bin/protoc '--nanopb_out=-v -f message.options:.' message.proto

However, if your .options file has the same name as the .proto and is in the same directory, nanopb plugin should automatically find and use it. 但是,如果.options文件与.proto具有相同的名称并且位于同一目录中,则nanopb插件应自动查找并使用它。

Also note that the -s flag to nanopb expects a pair of settings on the command line, while -f takes a filename. 另请注意,nanopb的-s标志需要命令行上的一对设置,而-f需要一个文件名。 Specifying -v is also useful to get detailed messages whether it loaded the options file or not. 指定-v对于获取详细消息也很有用,无论它是否加载了选项文件。 You can get full list of command line options by running: 您可以通过运行获得命令行选项的完整列表:

generator-bin/nanopb_generator --help

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM