protocolbuffers / protocolbuffers/protobuf
Support maintaining source directory structure at generated location when using protobuf_generate
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 72k
- Forks
- 16.3k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 140
Description
What language does this apply to?
C++ but I suspect is it the same for all.
Describe the problem you are trying to solve.
I use protobuf_generate to generate the .pb.h and .pb.cc. They are generated but they appear all in the same directory location loosing the original directory structure. In other words, the output is a flat directory.
Now, this happens because I need to set multiple paths with IMPORT_DIRS so that the import statements in my .proto files succeed at finding the other source files. This works perfectly and is in line with the fact that the variable is indeed IMPORT_DIRS and not IMPORT_DIR. It is also in line with the fact that the name starts with IMPORT, implying that it relates to the IMPORT statement in the proto files.
However, it appears that protobuf_generate overloads the definition of IMPORT_DIRS with an alternate use by using it as a ROOT directory in order to maintain the directory structure.
Describe the solution you'd like
Use a discrete SRC_ROOT to specify the source base location.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the protobuf_generate entry point and trace how IMPORT_DIRS affects both import resolution and generated output paths. Review the related build-system tests if available, then verify that a separate source-root setting preserves the source directory structure without changing import lookup behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100