Compiling a proto that uses a vendored descriptor.proto
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
I am considering writing a protoc-gen plugin using wire for handling CodeGeneratorRequest. However, I'm having trouble getting the proto to compile due to interactions with handling of built-in types.
The protos I am trying to compile are the same as in the protobuf.dart project.
https://github.com/google/protobuf.dart/tree/master/protoc_plugin/protos
The compiler complains that google/protobuf/descriptor.proto isn't imported even though these are defined in the vendored descriptor.proto.
> descriptor.proto needs to import google/protobuf/descriptor.proto
for field file (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/descriptor.proto:58:3)
in message google.protobuf.FileDescriptorSet (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/descriptor.proto:57:1)
descriptor.proto needs to import google/protobuf/descriptor.proto
for field message_type (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/descriptor.proto:75:3)
in message google.protobuf.FileDescriptorProto (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/descriptor.proto:62:1)
plugin.proto needs to import google/protobuf/descriptor.proto
for field proto_file (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/plugin.proto:91:3)
in message google.protobuf.compiler.CodeGeneratorRequest (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/plugin.proto:68:1)
plugin.proto needs to import google/protobuf/descriptor.proto
for field generated_code_info (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/plugin.proto:180:5)
in message google.protobuf.compiler.CodeGeneratorResponse.File (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/plugin.proto:121:3)
in message google.protobuf.compiler.CodeGeneratorResponse (/Users/anuraag/git/connect-kotlin/protoc-gen-connect-kotlin/src/main/proto/plugin.proto:99:1)
If I remove descriptor.proto and change the import from vendored to standard google/protobuf/descriptor.proto, it succeeds and generates a file referencing descriptor.proto
package com.google.protobuf.compiler
import com.google.protobuf.FileDescriptorProto
import com.squareup.wire.FieldEncoding
import com.squareup.wire.Message
import com.squareup.wire.ProtoAdapter
But FileDescriptorProto doesn't exist, and I couldn't generate it because of the above error. I looked through wire-runtime and wire-schema and couldn't find the class published officially.
I can workaround by changing the package of the protos, but protoc can compile these files. I'm wondering if there is a metric that wire compiler is supposed to be able to compile any file that protoc can.
I'm wondering if either, the descriptor built-in-types are being eagerly used even when not relevant in this case? Or should the wire versions of these protos be published in an artifact?
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
Reproduce the failure with the vendored descriptor.proto and plugin.proto files described in the issue, then inspect wire-schema and wire-runtime for how built-in descriptor types are resolved or published. Done would require a documented resolution for compiling these protos, including whether Wire supports the protoc behavior or provides the missing generated types.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100