i wrote an .options file and placed it in the same directory as the .proto file. then, I tried to compile it (using nanopb compiler) by using the command
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? is there anything else I should do to make it work?
Google's protoc
has a special syntax for passing options to the plugins. The plugin options are put as argument to nanopb_out
and separated from the actual destination path by colon (:
).
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.
Also note that the -s
flag to nanopb expects a pair of settings on the command line, while -f
takes a filename. Specifying -v
is also useful to get detailed messages whether it loaded the options file or not. You can get full list of command line options by running:
generator-bin/nanopb_generator --help