Command line protoc with nanopb_generator plugin

435 views
Skip to first unread message

kamat...@gmail.com

unread,
Apr 6, 2015, 11:27:58 PM4/6/15
to nan...@googlegroups.com
Are there any specific instructions on how to do this in general? We have never had problems passing in options directly to the nanopb_generator python script but when used as a plugin with protoc we get different behavior on Ubuntu/OSX machines.

I'm not at the right computers right now to grab all the output, (and this is almost certainly a google/protoc issue), but our build system is set up right now in such a way that we don't invoke protoc from the folder that our .protos are in. Our command line invocation looks like this:

$(NANOPB_SRC)/generator-bin/protoc --nanopb_out="-fsome/path/to/file.options:some/path/to/output/folder" -Isome/path/to/ some/path/to/file.proto

Or something along those lines. On my 64-bit Ubuntu machine, this works correctly and we get a .pb.c and .pb.c with the correct options in the right place. On OSX machines it fails complaining about either "invalid option -" or "-f/some/path/to/file.options/ not a valid file or directory."

We might just make our makefile a bit more hacky (cd $(proto_dir) && protoc --nanopb_out=. file.proto) or two step compile it (proto -> pb -> pb.c/h), but does anyone know more about passing in plugin options through protoc to nanopb?

Cheers,
Ben

Michael Haberler

unread,
Apr 7, 2015, 12:00:44 AM4/7/15
to nan...@googlegroups.com

> Am 07.04.2015 um 05:27 schrieb kamat...@gmail.com:
>
> Are there any specific instructions on how to do this in general? We have never had problems passing in options directly to the nanopb_generator python script but when used as a plugin with protoc we get different behavior on Ubuntu/OSX machines.
>
> I'm not at the right computers right now to grab all the output, (and this is almost certainly a google/protoc issue), but our build system is set up right now in such a way that we don't invoke protoc from the folder that our .protos are in. Our command line invocation looks like this:
>
> $(NANOPB_SRC)/generator-bin/protoc --nanopb_out="-fsome/path/to/file.options:some/path/to/output/folder" -Isome/path/to/ some/path/to/file.proto
>
> Or something along those lines.

like these lines? I never tried on Windows and OSX though:

https://github.com/machinekit/machinekit/blob/master/src/machinetalk/Submakefile#L221-L233

- Michael

> On my 64-bit Ubuntu machine, this works correctly and we get a .pb.c and .pb.c with the correct options in the right place. On OSX machines it fails complaining about either "invalid option -" or "-f/some/path/to/file.options/ not a valid file or directory."
>
> We might just make our makefile a bit more hacky (cd $(proto_dir) && protoc --nanopb_out=. file.proto) or two step compile it (proto -> pb -> pb.c/h), but does anyone know more about passing in plugin options through protoc to nanopb?
>
> Cheers,
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups "nanopb" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nanopb+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Petteri Aimonen

unread,
Apr 7, 2015, 1:50:44 AM4/7/15
to nan...@googlegroups.com
Hi,

> I'm not at the right computers right now to grab all the output

It would be quite helpful, though I can try to reproduce it on Mac
myself.

> On OSX machines it fails complaining about either "invalid option -"
> or "-f/some/path/to/file.options/ not a valid file or directory."

This does indeed point to a problem in protoc, or in the 'protoc'
wrapper script included in the generator-bin folder. Running this:
bash -x ...../generator-bin/protoc ....options....
might give more insight to whether some quotes are getting lost in the
wrapper.

--
Petteri

Petteri Aimonen

unread,
Apr 8, 2015, 11:13:19 AM4/8/15
to nan...@googlegroups.com
Hi,

> It would be quite helpful, though I can try to reproduce it on Mac
> myself.

Yeah, turned out to be a bug related to old versions of Python:
https://code.google.com/p/nanopb/issues/detail?id=153

Should be fixed here:
http://lakka.kapsi.fi:50140/job/nanopb-binary-macosx/

--
Petteri

ben.k...@synapse.com

unread,
Apr 10, 2015, 1:34:03 PM4/10/15
to nan...@googlegroups.com
This cleared up my issue, thanks!
Reply all
Reply to author
Forward
0 new messages