|  | repositories { | 
|  | google() | 
|  | jcenter() | 
|  | } | 
|  |  | 
|  | buildscript { | 
|  | repositories { | 
|  | google() | 
|  | // TODO: jcenter will soon go away. Find a replacement: https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ | 
|  | jcenter() | 
|  | } | 
|  |  | 
|  | dependencies { | 
|  | classpath 'com.android.tools.build:gradle:4.2.0' | 
|  | } | 
|  | } | 
|  |  | 
|  | apply plugin: 'com.android.library' | 
|  |  | 
|  | def cmakeListDir = "${rootDir}/../../../.." | 
|  | def hostBuildDir = "${cmakeListDir}/../iree-build-host" | 
|  | def hostInstallDir = "${hostBuildDir}/install" | 
|  |  | 
|  | android { | 
|  | compileSdkVersion 29 | 
|  | defaultConfig { | 
|  | minSdkVersion 28 | 
|  | targetSdkVersion 29 | 
|  |  | 
|  | externalNativeBuild { | 
|  | cmake { | 
|  | arguments "-DIREE_BUILD_BINDINGS_TFLITE=ON", | 
|  | "-DIREE_BUILD_BINDINGS_TFLITE_JAVA=ON", | 
|  | "-DIREE_HAL_DRIVER_DEFAULTS=OFF", | 
|  | "-DIREE_HAL_DRIVER_LOCAL_TASK=ON", | 
|  | "-DIREE_HAL_EXECUTABLE_LOADER_DEFAULTS=OFF", | 
|  | "-DIREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE=ON", | 
|  | "-DIREE_HAL_EXECUTABLE_PLUGIN_DEFAULTS=OFF", | 
|  |  | 
|  | // Disable all but the runtime components needed for the | 
|  | // java bindings. | 
|  | "-DIREE_BUILD_COMPILER=OFF", | 
|  | "-DIREE_BUILD_TESTS=OFF", | 
|  | "-DIREE_BUILD_SAMPLES=OFF", | 
|  | "-DIREE_BUILD_PYTHON_BINDINGS=OFF", | 
|  | "-DIREE_HOST_BIN_DIR=${hostInstallDir}/bin" | 
|  |  | 
|  | targets "iree-tflite-bindings" | 
|  | } | 
|  | } | 
|  | } | 
|  |  | 
|  | sourceSets { | 
|  | main { | 
|  | manifest.srcFile 'org/tensorflow/lite/AndroidManifest.xml' | 
|  | java { | 
|  | srcDirs('org/tensorflow/lite') | 
|  | exclude('tests/**') // Don't build tests into the library | 
|  | } | 
|  | jni.srcDirs = ['org/tensorflow/lite/native'] | 
|  | jniLibs.srcDirs = ['jniLibs/'] | 
|  | } | 
|  | } | 
|  |  | 
|  | externalNativeBuild { | 
|  | cmake { | 
|  | version "3.13.4.0+" | 
|  | path "../../../../CMakeLists.txt" | 
|  | } | 
|  | } | 
|  | } | 
|  |  | 
|  | dependencies { | 
|  | implementation 'com.android.support:support-annotations:22.2.0' | 
|  | } | 
|  |  | 
|  | // Task to cmake configure the host | 
|  | task cmakeConfigureHost(type: Exec) { | 
|  | doFirst { | 
|  | println "Configuring host tools with cmake..." | 
|  | } | 
|  | workingDir cmakeListDir | 
|  | commandLine "cmake", | 
|  | "-G" , "Ninja", | 
|  | "-B", hostBuildDir , | 
|  | "-DIREE_HAL_DRIVER_DEFAULTS=OFF", | 
|  | "-DIREE_HAL_DRIVER_LOCAL_TASK=ON", | 
|  | "-DIREE_HAL_EXECUTABLE_LOADER_DEFAULTS=OFF", | 
|  | "-DIREE_HAL_EXECUTABLE_LOADER_VMVX_MODULE=ON", | 
|  | "-DIREE_HAL_EXECUTABLE_PLUGIN_DEFAULTS=OFF", | 
|  | "-DIREE_BUILD_COMPILER=OFF", | 
|  | "-DIREE_BUILD_TESTS=OFF ", | 
|  | "-DIREE_BUILD_SAMPLES=OFF", | 
|  | "-DCMAKE_INSTALL_PREFIX=${hostInstallDir}", | 
|  | "." | 
|  | } | 
|  |  | 
|  | // Task to cmake build the host | 
|  | task cmakeBuildHost(type: Exec) { | 
|  | doFirst { | 
|  | println "Building host tools with cmake..." | 
|  | } | 
|  | workingDir cmakeListDir | 
|  | commandLine "cmake", "--build", hostBuildDir, "--target", "install" | 
|  | } | 
|  |  | 
|  | // Build host tools before building the app | 
|  | preBuild.dependsOn cmakeBuildHost | 
|  | cmakeBuildHost.dependsOn cmakeConfigureHost |