1

Lets say I have a folder of some .proto files:

Message.proto
Conversation.proto

For every .proto file for python, I need to do this:

protoc --python_out=. XXXXXXX.proto

For every .proto file for swift, I need to do this:

protoc --swift_out=. XXXXXXX.proto

Is there any easy way to autocompile every .proto file to multiple languages in a folder? I have a lot of .proto files which I use for both languages, now I need to compile every file twice (for python and swift (but can you imagine the pain if I add more languages?)).

I am wondering what the fastest way there is to compile .proto files to multiple languages. Ideally, I want a generated folder of .swift/.py files of the .proto files.

J. Doe
  • 12,159
  • 9
  • 60
  • 114

2 Answers2

2

If you run protoc in a shell, then you can use wildcards *.proto , like this:

protoc C:\your_absolute _path\*.proto --python_out=C:\python_source\

See this link

If you need to support multiple languages, then you need to create script(or custom command) with a glob pattern what matches all the *.proto files in your build system, and run the command in a loop.

Just like the add_custom_command in cmake build system.

Wei Guo
  • 544
  • 3
  • 15
0

Any traditional build system should be able to do this.

For example, Makefiles, scons, cmake or similar. The process is the same you would use to compile multiple .c files to multiple .o files with a C compiler, and there are plenty of examples for that.

jpa
  • 10,351
  • 1
  • 28
  • 45