Generating source code
When working on your project you write your proto files defining the message structure. Next, you would like to use them in your source code. This requires you to generate the code based on the definitions you have written. This is done using our plugin for the protoc compiler protoc-gen-eams.py
. Use the following command to generate the code:
On Linux:
protoc --plugin=protoc-gen-eams=protoc-gen-eams -I LOCATION/PROTO/FILES --eams_out=GENERATED/SRC/DIR PROTO_MESSAGE_FILE.proto
On Windows:
protoc --plugin=protoc-gen-eams=protoc-gen-eams.bat -I LOCATION\PROTO\FILES --eams_out=GENERATED/SRC/DIR PROTO_MESSAGE_FILE.proto
What happens is that protoc is instructed to use our plugin with the option --plugin
. Next, the standard option -I
includes the folder where your *.proto files are located. The option --eams_out
specifies the location where to store the generated source code. Finally, a specific proto file is set to be parsed.
As our plugin is a Python script and the protoc plugin should be an executable a small terminal script is included. This terminal script is called protoc-gen-eams
and is used to execute python with the Embedded Proto python script as a parameter. The main takeaway is that this script should be accessible when running your protoc command.
After running protoc without any errors the generated source code is located in the folder specified by --eams_out
. This folder is to be included in your project. This is not the only folder to be included. The generated source files depend on other headers and source files. These files can be found in EmbeddedProto/src. You are thus required to include this folder as well in your toolchain.
Various examples of how to use and integrate Embedded Proto in your project are given in the Examples section.