cmd/protoc-gen-dump
contains a protoc compiler plugin for generating protobuf-encoded dumps of protoc
plugin generation requests, i.e. the literal request to the protoc-gen-dump
command from protoc
.
As it is literally the protobuf-encoded form of plugin.CodeGeneratorRequest, it can be unmarshaled into the same exact structure which is useful for writing tests without invoking protoc
directly (and attemping to detect plugin failure through the compiler proxy).
First install Go and Protobuf itself, then install the plugin using go get:
go get -u sourcegraph.com/sourcegraph/prototools/cmd/protoc-gen-dump
Simply invoke protoc
with the --dump_out
command-line parameter:
protoc --dump_out="<OUT_DIR>" input.proto
protoc --dump_out="<OPTIONS>:<OUT_DIR>" input.proto
Where <OPTIONS>
is a comma-seperated list of key=value,key2=value2
options (which are listed in detail below). For example:
protoc --dump_out="dump/" a.proto b.proto
Would produce a protobuf-encoded dump file (out.dump
) for both a.proto
and b.proto
inside the dump/
directory.
Option | Default | Description |
---|---|---|
out |
out.dump |
Output file name (not directory). |
If you run into trouble or have questions, please open an issue.