mlot / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

*.option is searched in the execution directory instead of directory where the *.proto is #116

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a make file project where the make file and the *.proto / *.option 
file is not in the same directory
e.g.
Build/Makefile
Config/alltypes.proto
Config/alltypes.option
2. command in the Makefile is:
$(NANOPB_SRC_GEN)/%.pb.c $(NANOPB_SRC_GEN)/%.pb.h: $(NANOPB_INPUT)/%.proto 
$(wildcard $(NANOPB_INPUT)/%.options)
    $(PROTOC) -I$(NANOPB_INPUT) --nanopb_out=$(NANOPB_SRC_GEN) $<
3. by calling the generator the *option file is ignored
4. change the command in the Makefile to:
$(NANOPB_SRC_GEN)/%.pb.c $(NANOPB_SRC_GEN)/%.pb.h: $(NANOPB_INPUT)/%.proto 
$(wildcard $(NANOPB_INPUT)/%.options)
    cd $(NANOPB_INPUT); $(PROTOC) -I$(NANOPB_INPUT) --nanopb_out=$(NANOPB_SRC_GEN) $<
the difference is the "cd $(NANOPB_INPUT); " before the generator call
5. the *.option file is used

What is the expected output? What do you see instead?
I expect as documented that the *option file is searched in the same directory 
as the *.proto file.

What version of the product are you using? On what operating system?
0.2.7 on Windows

Please provide any additional information below.

Original issue reported on code.google.com by andreas....@gmail.com on 30 Apr 2014 at 1:06

GoogleCodeExporter commented 9 years ago
I was able to reproduce the issue. Unfortunately, it seems that the best I can 
do is to update the documentation.

Looks like the protoc compiler strips the path before passing it to the plugins:

protoc -I ../Config --test_out=. ../Config/test.proto
file_to_generate: "test.proto"
proto_file {
  name: "test.proto"
  message_type {
    name: "foo"
    field {
      name: "bar"
      number: 1
      label: LABEL_REPEATED
      type: TYPE_INT32
    }
  }
}

Original comment by Petteri.Aimonen on 2 May 2014 at 7:07