Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept binary DescriptorProto as input #2940

Open
Maragues opened this issue May 14, 2024 · 4 comments
Open

Accept binary DescriptorProto as input #2940

Maragues opened this issue May 14, 2024 · 4 comments

Comments

@Maragues
Copy link

Maragues commented May 14, 2024

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!

@oldergod
Copy link
Member

There is indeed no way to do that right now. And although we have a SchemaEncoder which can somewhat encode a schema into protobuf's descriptor.proto, there's nothing to decode it.
It's unlikely that we implement something like that before a while unfortunately.

@Maragues
Copy link
Author

Thanks for the reply. I understand this is a specific need of mine.

@oldergod
Copy link
Member

No way for your source to expose .proto. files?

@Maragues
Copy link
Author

Maragues commented May 16, 2024

Long story short, a subset of our proto messages are not defined in .proto files.

Our source of truth is a proto message in protobuf text format. We digest that message and produce N binary files of protobuf types, which are then fed to different platforms for code generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants