jasonjack2015 / protobuf

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

protoc: can't control output directory #673

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am working on integrating the protoc compiler to my build system, however I'm 
finding it difficult to control where the output files are saved.

What steps will reproduce the problem?

1. unzip project

2. change directories
    $ cd protobuf_bug

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

4. observe output files not placed in specified output directory:
    $ find .
    .
    ./src
    ./src/audacity
    ./src/audacity/messages
    ./src/audacity/messages/pb
    ./src/audacity/messages/pb/src
    ./src/audacity/messages/pb/src/audacity
    ./src/audacity/messages/pb/src/audacity/messages
    ./src/audacity/messages/pb/src/audacity/messages/pb
    ./src/audacity/messages/pb/src/audacity/messages/pb/Type.pb.h
    ./src/audacity/messages/pb/src/audacity/messages/pb/Type.pb.cc
    ./src/audacity/messages/pb/Type.proto

5. clean up the mess
    $ rm -rf src/audacity/messages/pb/src

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

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

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

    I expect the generated files to be placed in the directory specified, instead funny path manipulation is occurring.

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

    $ protoc --version
    libprotoc 2.5.0
    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 14.04.1 LTS
    Release:    14.04
    Codename:   trusty

Please provide any additional information below.

    Please add some option to explicitly place the generated files to specified location, similar to how gcc -o works, as protoc is advertised as a compiler.
    The location where protoc places output files isn't explained in the documentation, if the default is to always place the output files next to the .proto file, then there should be a set of --cpp, --python, --java switches which does this, rather some --XXX_out=DIR switch.

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

Attachments:

GoogleCodeExporter commented 9 years ago
This is just how protocol compiler is designed to work. For C++ and Python, it 
will generate a directory structure matching exactly the relative path of the 
input .proto file.

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

GoogleCodeExporter commented 9 years ago
Please document how it's designed to work.

Original comment by weegreen...@gmail.com on 18 Oct 2014 at 10:19