uber / prototool

Your Swiss Army Knife for Protocol Buffers
MIT License
5.05k stars 345 forks source link

Can prototool take a FileDescriptorSet as input? #546

Open andremarianiello opened 4 years ago

andremarianiello commented 4 years ago

Is it possible to use a FileDescriptorSet as input for prototool? I have a FileDescriptorSet which I can use as input to protoc directly, but I like configuring stub generation with prototool, so it would be useful to me if prototool supported this.

smaye81 commented 4 years ago

Prototool does not support descriptor_set_in currently. I can wishlist this issue, but I don't know if we will be implementing that any time soon as we've never really had a need for it.

chrisstockton commented 3 years ago

I've recently come across a similar problem that I was able to get working by adding a --descriptor_set_in flag and passing the value along to protoc

Here are the changes just to get break check to work: https://github.com/uber/prototool/compare/dev...chrisstockton:add_descriptor_set_in?expand=1

Unfortunately, I didn't commit all of the licenses updates separately, but the changes to actually pass in descriptor sets are in:

internal/cmd/flags.go internal/cmd/templates.go internal/exec/exec.go internal/protoc/compiler.go internal/settings/config_provider.go internal/settings/settings.go

I wasn't able to use the makefile command to build and image because of this error:

 > [stage-1 3/5] RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories &&   apk add --update --no-cache bash curl git grpc=1.25.0-r1 protobuf=3.11.2-r1 &&   rm -rf /var/cache/apk/*:
#9 0.283 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
#9 0.888 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
#9 1.091 fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
#9 1.737 ERROR: unable to select packages:
#9 1.783   protobuf-3.15.7-r1:
#9 1.783     breaks: world[protobuf=3.11.2-r1]
#9 1.783     satisfies: grpc-1.36.4-r1[protobuf]
#9 1.783   grpc-1.36.4-r1:
#9 1.783     breaks: world[grpc=1.25.0-r1]
------
executor failed running [/bin/sh -c echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories &&   apk add --update --no-cache bash curl git grpc=${GRPC_VERSION}-${ALPINE_GRPC_VERSION_SUFFIX} protobuf=${PROTOBUF_VERSION}-${ALPINE_PROTOBUF_VERSION_SUFFIX} &&   rm -rf /var/cache/apk/*]: exit code: 2
make: *** [dockerbuild] Error 1

I ended up just replacing the binary in the current image published to docker.io.

I'd be happy to clean this up and make a proper PR if it's useful to anyone else, but would probably need a little help getting the build to work locally.