Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API/Gradle: Add an option to enable supporting SNPE
Browse files Browse the repository at this point in the history
This patch updates the Gradle build script to support SNPE. The version
of SNPE must be above 2.10.

Signed-off-by: Wook Song <[email protected]>
wooksong committed Jun 25, 2024
1 parent e44d066 commit c4c3fce
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions nnstreamer-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:Suppress("UnstableApiUsage")

import kotlin.io.path.createDirectories
import kotlin.io.path.isDirectory

plugins {
id(libs.plugins.androidLibrary.get().pluginId)
@@ -50,6 +51,32 @@ android {
arguments("TFLITE_ROOT_ANDROID=$tfliteRootPath")
arguments("TFLITE_VERSION=$tfliteVersion")
}

if (project.hasProperty("dir.snpe")) {
val snpeDir = properties["dir.snpe"].toString()

snpeDir.also { dir ->
val rootPath = externalDirPath.resolve(dir)
val enableSnpe = rootPath.isDirectory()

arguments("ENABLE_SNPE=$enableSnpe")
if (!enableSnpe) {
val msg = "The property, 'dir.snpe', is specified in 'gradle.properties', " +
"but failed to resolve it to $rootPath. SNPE support will be disabled."
project.logger.lifecycle("WARNING: $msg")
return@also
}

arguments("SNPE_DIR=$rootPath")
/**
* lib/aarch64-android is the default lib path for SNPE from v2.11 to v.2.19
* If it exists and is a directory, use it. Otherwise, SNPE_LIB_PATH is set by Android-snpe.mk.
*/
if (rootPath.resolve("lib").resolve("aarch64-android").isDirectory()) {
arguments("SNPE_LIB_PATH=$rootPath/lib/aarch64-android")
}
}
}
}
}
}

0 comments on commit c4c3fce

Please sign in to comment.