Last active
July 9, 2018 17:35
-
-
Save es0m/503823c1f2ff10a69b3c43e7bd09a486 to your computer and use it in GitHub Desktop.
adds a dependency on a swig task in gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| task runSwig(type: Exec) { | |
| def in_path = '../src/inlib' | |
| def wrapper_path = "./src/main/cpp" | |
| def wrapper_file = "${wrapper_path}/inlib_wrap.c" | |
| def out_path = './src/main/java/generated' | |
| inputs.files "${in_path}/java/inApi.i", "${in_path}/src/inlib/api.h" | |
| outputs.dir out_path, wrapper_path | |
| outputs.file wrapper_file | |
| mkdir(out_path) | |
| mkdir(wrapper_path) | |
| workingDir "." | |
| commandLine "swig", "-package", "com.blah.inlib.generated", "-o", wrapper_file, "-outdir", out_path, "-java", "${in_path}/java/inApi.i" | |
| } | |
| // need to add dependency on swig task: https://github.com/googlesamples/android-ndk/issues/284 | |
| android.libraryVariants.all { variant -> | |
| variant.externalNativeBuildTasks[0].dependsOn(runSwig) | |
| // apparently this is not early enough and we need to also add the following: | |
| generateJsonModelDebug.dependsOn(runSwig) | |
| generateJsonModelRelease.dependsOn(runSwig) | |
| } | |
| // why doesn't this work? project.getByName("generateJsonModel${variant.name.capitalize()}").dependsOn(runFaceSenseSwig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment