| 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.0.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_DRIVERS_TO_BUILD=VMVX", |
| |
| // Disable all but the runtime components needed for the |
| // java bindings. |
| "-DIREE_BUILD_COMPILER=OFF", |
| "-DIREE_ENABLE_MLIR=OFF", |
| "-DIREE_BUILD_TESTS=OFF", |
| "-DIREE_BUILD_SAMPLES=OFF", |
| "-DIREE_BUILD_PYTHON_BINDINGS=OFF", |
| "-DIREE_HOST_BINARY_ROOT=${hostInstallDir}" |
| |
| 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'] |
| } |
| } |
| |
| 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_TARGET_BACKENDS_TO_BUILD=vmvx", |
| "-DIREE_HAL_DRIVERS_TO_BUILD=vmvx", |
| "-DIREE_BUILD_COMPILER=ON", |
| "-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 |