0

A lot of libraries/frameworks use some kind of code generator to convert easy-to-read IDL files into source code. A few that I've used with C++ projects include:

Using CMake, it's relatively straightforward to set up a custom target for running the code generator and make the application target depend on it, so that the generator will be re-run automatically if the IDL file changes.

Now, I need to do the same thing for an Android application, and I'm not finding much help for this online. The closest question I found on this site was:

But the OP for that question just wanted to run the code generator manually and include it in his project. I've already figured out how to do that, now I want Android Studio/Gradle do it for me.

To make the question more concrete, I'm currently running this command to generate FacialRecognitionContext.java from the file FacialRecognition.sm:

$ java ./smc/bin/Smc.jar -java FacialRecognition.sm

How can I instruct Gradle to do this for me automatically whenever FacialRecognition.sm changes?

UPDATE

Further searching led to this SO question and this tutorial, both of which seem to imply that the 'best'(?) way to handle .proto files is using the Protobuf Plugin for Gradle. I have to say, this is rather vexing. When I look at the sources for the protobuf plugin, I see that it contains nine Groovy files(?!) Do I really need to write an entire SMC plugin just to generate a single file?

evadeflow
  • 4,704
  • 38
  • 51
  • 1
    How about a bash script that protoc's all the proto files in a folder structure. (https://stackoverflow.com/questions/24949801/how-to-compile-multiple-proto-files-in-single-command & https://stackoverflow.com/a/10883887/794088 should do it) – petey Feb 02 '18 at 22:34
  • @petey, thanks for the links. It looks like I could assemble _most_ of a solution from them. The thing I'm still not sure about is: how do I tell Gradle that my `compileProtos` task depends on, say, `foo.proto`, `bar.proto` and `baz.proto` (or whatever) so that it gets re-run _automatically_ whenever those files have been modified? – evadeflow Feb 03 '18 at 16:08

0 Answers0