square / square/wire

Accept binary DescriptorProto as input

Open
#2,940 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

I would like to use a binary DescriptorProto as input to sourcePath or protoPath

wire {
    sourcePath {
        srcDir("my/dir")
        include("first_file.pb")
    }
}

Where first_file.pb is a serialized DescriptorProto.

I checked Wire's source code and I don't think there's a way to do this right now. ProtoParser expects .proto, and unfortunately protobuf-java does not support generating .proto files.

Since Wire can generate protobuf-compatible binary files, maybe it isn't too hard to accept binary as input too?

To expand on my use case, I receive a serialized FileDescriptorSet as input. On protoc, the call to generate code would be

protoc ... --descriptor_set_in=path/data_models.pb first_file_name.proto second_file_name.proto

Where first_file_name.proto and second_file_name.proto are DescriptorProto in data_models.pb, a FileDescriptorSet. When protoc doesn't find a .proto file in the filesystem, it looks if it exists in any of the descriptor_set_in parameters. If there's a FileDescriptorProto with that name, it generates the code.

Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the sourcePath and protoPath entry points into ProtoParser, then compare the requested behavior with protoc's descriptor_set_in handling. Use the protobuf-java types FileDescriptorSet and DescriptorProto as the stated input model; done means serialized descriptors can be accepted where the issue describes them instead of requiring .proto files.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
compilers, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.