jasonjack2015 / protobuf

Automatically exported from code.google.com/p/protobuf
Other
0 stars 0 forks source link

protoc: can't control output directory #674

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
May be related to #693.

What steps will reproduce the problem?

1. unzip project

2. change dir
    $ cd protobuf_bug

3. execute expected use case:
    $ protoc -Isrc --cpp_out=. src/audacity/messages/pb/Emitter.proto 

4. observe output is unexpected:
    $ find .
    .
    ./audacity
    ./audacity/messages
    ./audacity/messages/pb
    ./audacity/messages/pb/Emitter.pb.h
    ./audacity/messages/pb/Emitter.pb.cc
    ./src
    ./src/audacity
    ./src/audacity/messages
    ./src/audacity/messages/pb
    ./src/audacity/messages/pb/Type.proto
    ./src/audacity/messages/pb/Emitter.proto

5. clean up mess:
    $ rm -rf ./audacity

6. execute next expected use case:
    $ protoc -Isrc --cpp_out=src src/audacity/messages/pb/Emitter.proto

7. observe expected output:
    $ find .
    .
    ./src
    ./src/audacity
    ./src/audacity/messages
    ./src/audacity/messages/pb
    ./src/audacity/messages/pb/Emitter.pb.h
    ./src/audacity/messages/pb/Emitter.pb.cc
    ./src/audacity/messages/pb/Type.proto
    ./src/audacity/messages/pb/Emitter.proto

What is the expected output? What do you see instead?

    From my learning experience with documenting issue #693, I thought --cpp_out=. would always work, but once I started getting more complicated, when using -Isrc, everything gets hosed.  It seems like -IDIR and --cpp_out=DIR must always occur in pairs, this is very unexpected as gcc and visual studio compilers have no such behavior.  If multiple -I flags are specified, I have no idea how to manipulate --cpp_out.

What version of the product are you using? On what operating system?
    See #693.

Please provide any additional information below.
    See #693.

Original issue reported on code.google.com by weegreen...@gmail.com on 18 Oct 2014 at 7:44

Attachments:

GoogleCodeExporter commented 9 years ago
Here is how it works:

Support you invoke protoc as:
protoc -Ipath1 --cpp_out=path2 path1/path3/test.proto

protoc will generate:
path2/path3/test.pb.h
path2/path3/test.pb.cc

The canonical name of the .proto file will be "path3/test.proto" and that's the 
name used to refer to this file in protobuf runtime (e.g., you need to use this 
name in DescriptorPool::FindFileByName()).

We should document this better but this is working as intended.

Original comment by xiaof...@google.com on 18 Oct 2014 at 10:21

GoogleCodeExporter commented 9 years ago
Why not improve the documentation with this ticket?

Original comment by weegreen...@gmail.com on 19 Oct 2014 at 3:50