User
User

Reputation: 1236

Problem with Custom protobuf CodeGenerator

I am undergoing trouble writing the custom protoc plugin. I posted this question but no response. Atleast Kindly please let me know answers to few questions. I really need to do this. I havent gone past first step itself.

  1. From this question, how do they link shell script with plugin name protoc-gen-code.

    java -cp ./codegen.jar CodeGeneratorMain "$@"

  2. With respect to the above implementation in the question and google proto buffer documentation, what exactly would be there in the path.. is it the path of the Shell Script? would the shell script be named as protoc-gen-code?

Can someone please respond to these queries.

Upvotes: 0

Views: 308

Answers (1)

Willis Blackburn
Willis Blackburn

Reputation: 8204

protoc can generate code for several different languages with one invocation. The way you specify which languages you want is to use the command line arguments of the form --LANG_out where LANG is the language you want. So --cpp_out gives you C++ code, directory, --js_out gives you JavaScript etc. If protoc doesn't recognize LANG then it looks for a plugin called protoc-gen-LANG and uses it as the code generator.

The shell script can be called whatever. Let's say you call it mygen.sh and you decide you want to use mylang as LANG. Then the protoc invocation looks like:

protoc --plugin=protoc-gen-mylang=/path/to/mygen.sh --mylang_out=/some/dir some.proto

Upvotes: 0

Related Questions