On 03/26/2012 04:02 PM, cb132 wrote:
> 
> I am using Google protobuf to generate C++ and/or python code, and compiling
> the python using python_PYTHON - but it's not working.
> 
> Makefile.am looks like this;
> 
> <code>
> if GEN_PROTOC_CPP
>   include $(srcdir)/Makefile-cpp.am
> endif
> if GEN_PROTOC_PY
>   include $(srcdir)/Makefile-py.am
> endif
> </code>
> 
> Makefile-py.am looks like this;
> 
> <code>
> ## list of .proto files
> include $(srcdir)/Protos.am
> 
> ## proto compiler support
> include $(top_srcdir)/.am/protoc.am
> 
> ##  compile python
> python_PYTHON = \
>     __init__.py \
>     $(PROTO_PYS) 
> </code>
> 
> Protos.am provides a list of protos, and rules;
> 
> <code>
> PROTO_PYS=$(PROTOS:.proto=_pb2.py)
> 
> MsgHeaderProto_pb2.py : MsgHeaderProto.proto
>       @echo '  PROTOP MsgHeaderProto.proto'
>       protoc --python_out=.. -$I(topsrcdir)  $(PROTOC_PYFLAGS) $<
> </code>
>
This seems all good and correct, but for one thing: I don't see the '$(PROTOS)'
variable defined anywhere.  If it actually isn't defined, '$(PROTO_PYS)' will
end up being empty, so no surprise no '.py' files gets generated.  On the other
hand, if $(PROTOS) is correctly defined, the problem might be more subtle, or
you might even have found an automake bug.

> Problem one is the .py rules are never triggered to generate the .py files.  
> The C++ makefile is very similar, and works fine.
>
> I have tried using BUILT_SOURCES, but it does not work if I use
> 
> <code>BUILT_SOURCES = $(PROTO_PYS) </code>
> 
> and it does not work unless it's in Makefile.am.  Since python_PYTHON
> doesn't seem to actually compile until I do a 'make install', I've also
> tried
> 
> <code>all-local : $(PROTO_PYS) <code>
>
If you add a rule like this:

  debug:
          @echo PROTOS: $(PROTOS)
          @echo PROTO_PYS: $(PROTO_PYS)

then what does "make debug" print?

Regards,
  Stefano

Reply via email to