From 74de764ea9b37209587048d03c8ac7b06ab40c08 Mon Sep 17 00:00:00 2001 From: Yelin Jeong Date: Thu, 19 Dec 2024 18:15:21 +0900 Subject: [PATCH] Gradle/Android: Add an option to enable supporting llamacpp This patch adds an option to supporting llamacpp Signed-off-by: Yelin Jeong --- gradle.properties | 2 ++ nnstreamer-api/build.gradle.kts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/gradle.properties b/gradle.properties index f0f88c0..739f82a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,8 @@ dir.nnstreamerEdge=nnstreamer-edge dir.mlApi=ml-api # To use llama2.c uncomment the line below # dir.llama2c=llama2.c +# To use llamacpp uncomment the line below +# dir.llamacpp=llamacpp kotlin.code.style=official android.useAndroidX=true android.enableJetifier=true diff --git a/nnstreamer-api/build.gradle.kts b/nnstreamer-api/build.gradle.kts index 23292a8..1dd86ab 100644 --- a/nnstreamer-api/build.gradle.kts +++ b/nnstreamer-api/build.gradle.kts @@ -116,6 +116,25 @@ android { arguments("LLAMA2C_DIR=$rootPath") } } + + if (project.hasProperty("dir.llamacpp")) { + val llamacppDir = properties["dir.llamacpp"].toString() + + llamacppDir.also { dir -> + val rootPath = externalDirPath.resolve(dir) + val enableLlamacpp = rootPath.isDirectory() + + arguments("ENABLE_LLAMACPP=$enableLlamacpp") + if (!enableLlamacpp) { + val msg = + "The property, 'dir.llamacpp', is specified in 'gradle.properties', " + + "but failed to resolve it to $rootPath. llamacpp support will be disabled." + project.logger.lifecycle("WARNING: $msg") + return@also + } + arguments("LLAMACPP_DIR=$rootPath") + } + } } } }