6.7.0 - Alpha6 - Gradle 构建脚本转换 (Groovy -> Kotlin DSL)
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
plugins {
|
||||
id 'org.autojs.build.utils'
|
||||
id 'org.autojs.build.properties'
|
||||
id 'org.autojs.build.jvm-convention'
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
ext {
|
||||
projectName = "Image Quantization"
|
||||
}
|
||||
|
||||
def versionMap = [
|
||||
"libimagequant": "2.17.0",
|
||||
"libpng" : "1.6.49",
|
||||
|
||||
"MIN_SDK" : props["MIN_SDK"] as Integer,
|
||||
"COMPILE_SDK" : props["COMPILE_SDK"] as Integer,
|
||||
"TARGET_SDK" : props["TARGET_SDK"] as Integer,
|
||||
|
||||
"NDK" : props["IMAGE_QUANT/NDK"],
|
||||
"CMAKE" : props["IMAGE_QUANT/CMAKE"],
|
||||
]
|
||||
|
||||
def nameMap = [
|
||||
"PROJECT": ext["projectName"],
|
||||
"NDK" : "NDK",
|
||||
"CMAKE" : "Cmake",
|
||||
]
|
||||
|
||||
utils.configureLibraryLifecycleHooks(project, nameMap.PROJECT, [
|
||||
"libimagequant",
|
||||
"libpng",
|
||||
"NDK",
|
||||
"CMAKE",
|
||||
].collect { "${nameMap[it] ?: it}: ${versionMap[it]}" }, Collections.emptyList(), null, [".cxx"])
|
||||
|
||||
android {
|
||||
|
||||
namespace = "org.pngquant"
|
||||
|
||||
ndkVersion versionMap.NDK
|
||||
compileSdk versionMap.COMPILE_SDK
|
||||
|
||||
defaultConfig {
|
||||
minSdk versionMap.MIN_SDK
|
||||
targetSdk versionMap.TARGET_SDK
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags "-std=c++17"
|
||||
|
||||
// @Hint by SuperMonster003 on Aug 28, 2025.
|
||||
// ! Moved into `target_link_libraries(pngquant_bridge ...)` in `CMakeLists.txt`.
|
||||
// ! zh-CN: 移至 `CMakeLists.txt` 文件 `target_link_libraries(pngquant_bridge ...)` 代码中.
|
||||
// # cFlags "-ljnigraphics"
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
version versionMap.CMAKE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
86
libs/imagequant/build.gradle.kts
Normal file
86
libs/imagequant/build.gradle.kts
Normal file
@@ -0,0 +1,86 @@
|
||||
plugins {
|
||||
id("org.autojs.build.utils")
|
||||
id("org.autojs.build.properties")
|
||||
id("org.autojs.build.jvm-convention")
|
||||
id("com.android.library")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
}
|
||||
|
||||
ext {
|
||||
set("projectName", "Image Quantization")
|
||||
}
|
||||
|
||||
val versionMap = mapOf(
|
||||
"libimagequant" to "2.17.0",
|
||||
"libpng" to "1.6.49",
|
||||
|
||||
"MIN_SDK" to props["MIN_SDK"].toInt(),
|
||||
"COMPILE_SDK" to props["COMPILE_SDK"].toInt(),
|
||||
"TARGET_SDK" to props["TARGET_SDK"].toInt(),
|
||||
|
||||
"NDK" to props["IMAGE_QUANT/NDK"],
|
||||
"CMAKE" to props["IMAGE_QUANT/CMAKE"],
|
||||
)
|
||||
|
||||
val nameMap = mapOf(
|
||||
"PROJECT" to extensions.extraProperties.get("projectName") as String,
|
||||
"NDK" to "NDK",
|
||||
"CMAKE" to "Cmake",
|
||||
)
|
||||
|
||||
utils.configureLibraryLifecycleHooks(
|
||||
project,
|
||||
nameMap["PROJECT"] as String,
|
||||
listOf("libimagequant", "libpng", "NDK", "CMAKE").map { "${nameMap[it] ?: it}: ${versionMap[it]}" },
|
||||
emptyList(),
|
||||
null,
|
||||
listOf(".cxx"),
|
||||
)
|
||||
|
||||
android {
|
||||
|
||||
namespace = "org.pngquant"
|
||||
|
||||
ndkVersion = versionMap["NDK"] as String
|
||||
compileSdk = versionMap["COMPILE_SDK"] as Int
|
||||
|
||||
defaultConfig {
|
||||
minSdk = versionMap["MIN_SDK"] as Int
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags += "-std=c++17"
|
||||
|
||||
// @Hint by SuperMonster003 on Aug 28, 2025.
|
||||
// ! Moved into `target_link_libraries(pngquant_bridge ...)` in `CMakeLists.txt`.
|
||||
// ! zh-CN: 移至 `CMakeLists.txt` 文件 `target_link_libraries(pngquant_bridge ...)` 代码中.
|
||||
// # cFlags "-ljnigraphics"
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
|
||||
}
|
||||
|
||||
lint {
|
||||
targetSdk = versionMap["TARGET_SDK"] as Int
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path = file("CMakeLists.txt")
|
||||
version = versionMap["CMAKE"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
2
libs/imagequant/proguard-rules.pro
vendored
2
libs/imagequant/proguard-rules.pro
vendored
@@ -1,6 +1,6 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
# proguardFiles setting in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
/**
|
||||
* Paddle OCR (https://github.com/PaddlePaddle/PaddleOCR) build script (Groovy).
|
||||
*
|
||||
* Created by TonyJiangWJ (https://github.com/TonyJiangWJ) on Aug 7, 2023.
|
||||
* Modified by TonyJiangWJ (https://github.com/TonyJiangWJ) as of Aug 11, 2023.
|
||||
* Modified by SuperMonster003 as of Sep 4, 2023.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'org.autojs.build.utils'
|
||||
id 'org.autojs.build.properties'
|
||||
id 'org.autojs.build.jvm-convention'
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
ext {
|
||||
projectName = "Paddle OCR"
|
||||
}
|
||||
|
||||
def versionMap = [
|
||||
"MIN_SDK" : props["MIN_SDK"] as Integer,
|
||||
"COMPILE_SDK": props["COMPILE_SDK"] as Integer,
|
||||
"TARGET_SDK" : props["TARGET_SDK"] as Integer,
|
||||
"NDK" : props["PADDLE_OCR/NDK"],
|
||||
"CMAKE" : props["PADDLE_OCR/CMAKE"],
|
||||
"OPENCV" : props["PADDLE_OCR/OPENCV"],
|
||||
]
|
||||
|
||||
def nameMap = [
|
||||
"PROJECT": ext["projectName"],
|
||||
"OPENCV" : "OpenCV",
|
||||
"NDK" : "NDK",
|
||||
"CMAKE" : "Cmake",
|
||||
]
|
||||
|
||||
def libsToDeploy = [
|
||||
// @Hint by TonyJiangWJ (https://github.com/TonyJiangWJ) on Aug 7, 2023.
|
||||
// ! 下载 OpenCV 源码包 (默认为 4.2.0).
|
||||
// ! 和 Auto.js 中的版本 (如 4.8.0) 不匹配会产生冲突,
|
||||
// ! 可按需修改 version.properties 中对应内容.
|
||||
// ! en-US (translated by SuperMonster003 on Oct 22, 2024):
|
||||
// ! Download the archive for source code of OpenCV (defaults to 4.2.0).
|
||||
// ! Not matching the version in Auto.js (e.g., 4.8.0) will cause conflicts.
|
||||
// ! Adjust the corresponding content in version.properties as needed.
|
||||
utils.newLibDeployer(project, nameMap.OPENCV, "https://github.com/opencv/opencv/releases/download" +
|
||||
"/${versionMap.OPENCV}/opencv-${versionMap.OPENCV}-android-sdk.zip")
|
||||
.setSourceDir("/OpenCV-android-sdk/sdk/native/")
|
||||
.setDestDir("/src/sdk/native/")
|
||||
]
|
||||
|
||||
utils.configureLibraryLifecycleHooks(project, nameMap.PROJECT, [
|
||||
"OPENCV",
|
||||
"NDK",
|
||||
"CMAKE",
|
||||
].collect { "${nameMap[it]}: ${versionMap[it]}" }, libsToDeploy, "isCleanupPaddleOcr", [".cxx"])
|
||||
|
||||
android {
|
||||
|
||||
namespace = "com.baidu.paddle.lite.ocr"
|
||||
|
||||
ndkVersion versionMap.NDK
|
||||
compileSdk versionMap.COMPILE_SDK
|
||||
|
||||
defaultConfig {
|
||||
minSdk versionMap.MIN_SDK
|
||||
targetSdk versionMap.TARGET_SDK
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags(([
|
||||
"-std": "c++11",
|
||||
].collect { "$it.key=$it.value" } + [
|
||||
"-f": ["rtti", "exceptions"],
|
||||
"-W": "no-format",
|
||||
].collect {
|
||||
it.value instanceof List
|
||||
? it.value.collect { opt -> (it.key + opt) }.join("\u0020")
|
||||
: it.key + it.value
|
||||
}).join("\u0020"))
|
||||
|
||||
arguments(*[
|
||||
// @Hint by LZX284 (https://github.com/LZX284) on Sep 30, 2023.
|
||||
// ! "ANDROID_PLATFORM" 默认为 "android-23", 这里修改为与 AutoJs6 最低 SDK 版本一致的 `versionMap.MIN_SDK`.
|
||||
// ! en-US (translated by SuperMonster003 on Oct 22, 2024):
|
||||
// ! "ANDROID_PLATFORM" with default value "android-23" was changed to `versionMap.MIN_SDK`
|
||||
// ! to align with the min SDK version of AutoJs6.
|
||||
ANDROID_PLATFORM: "android-${versionMap.MIN_SDK}",
|
||||
ANDROID_STL : "c++_shared",
|
||||
ANDROID_ARM_NEON: "TRUE",
|
||||
].collect {
|
||||
// @Hint by SuperMonster003 on Nov 12, 2023.
|
||||
// ! Do not add a space (nbsp) after "-D".
|
||||
// ! Reference: https://stackoverflow.com/questions/14887438/spacing-in-d-option-in-cmake
|
||||
// ! zh-CN:
|
||||
// ! 在 "-D" 后不要添加空格 (不间断空格).
|
||||
// ! 参阅: https://stackoverflow.com/questions/14887438/spacing-in-d-option-in-cmake
|
||||
"-D$it.key=$it.value"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
// @Hint by SuperMonster003 on Jan 2, 2024.
|
||||
// ! Supported architectures: armv7, armv8.
|
||||
// ! References:
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/blob/develop/lite/tools/build_android.sh#L7
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/issues/80
|
||||
// ! zh-CN:
|
||||
// ! 支持的架构: armv7, armv8.
|
||||
// ! 参阅:
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/blob/develop/lite/tools/build_android.sh#L7
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/issues/80
|
||||
// noinspection ChromeOsAbiSupport
|
||||
abiFilters "arm64-v8a", "armeabi-v7a"
|
||||
ldLibs "jnigraphics"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
}
|
||||
debug {
|
||||
minifyEnabled false
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
version versionMap.CMAKE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation fileTree(include: ["*.jar"], dir: "libs")
|
||||
|
||||
implementation project(path: ":libs:org.opencv-${versionMap.OPENCV}")
|
||||
|
||||
implementation libs.core.ktx
|
||||
implementation libs.preference.ktx
|
||||
|
||||
}
|
||||
169
libs/paddleocr/build.gradle.kts
Normal file
169
libs/paddleocr/build.gradle.kts
Normal file
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* Paddle OCR (https://github.com/PaddlePaddle/PaddleOCR) build script (Kotlin DSL).
|
||||
*
|
||||
* Created by TonyJiangWJ (https://github.com/TonyJiangWJ) on Aug 7, 2023.
|
||||
* Modified by TonyJiangWJ (https://github.com/TonyJiangWJ) as of Aug 11, 2023.
|
||||
* Modified by SuperMonster003 as of Sep 4, 2023.
|
||||
* Transformed by SuperMonster003 on Sep 30, 2025.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("org.autojs.build.utils")
|
||||
id("org.autojs.build.properties")
|
||||
id("org.autojs.build.jvm-convention")
|
||||
id("com.android.library")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
}
|
||||
|
||||
ext {
|
||||
set("projectName", "Paddle OCR")
|
||||
}
|
||||
|
||||
val versionMap = mapOf(
|
||||
"MIN_SDK" to props["MIN_SDK"].toInt(),
|
||||
"COMPILE_SDK" to props["COMPILE_SDK"].toInt(),
|
||||
"TARGET_SDK" to props["TARGET_SDK"].toInt(),
|
||||
"NDK" to props["PADDLE_OCR/NDK"],
|
||||
"CMAKE" to props["PADDLE_OCR/CMAKE"],
|
||||
"OPENCV" to props["PADDLE_OCR/OPENCV"],
|
||||
)
|
||||
|
||||
val nameMap = mapOf(
|
||||
"PROJECT" to extensions.extraProperties.get("projectName") as String,
|
||||
"OPENCV" to "OpenCV",
|
||||
"NDK" to "NDK",
|
||||
"CMAKE" to "Cmake",
|
||||
)
|
||||
|
||||
val libsToDeploy = listOf(
|
||||
// @Hint by TonyJiangWJ (https://github.com/TonyJiangWJ) on Aug 7, 2023.
|
||||
// ! 下载 OpenCV 源码包 (默认为 4.2.0).
|
||||
// ! 和 Auto.js 中的版本 (如 4.8.0) 不匹配会产生冲突,
|
||||
// ! 可按需修改 version.properties 中对应内容.
|
||||
// ! en-US (translated by SuperMonster003 on Oct 22, 2024):
|
||||
// ! Download the archive for source code of OpenCV (defaults to 4.2.0).
|
||||
// ! Not matching the version in Auto.js (e.g., 4.8.0) will cause conflicts.
|
||||
// ! Adjust the corresponding content in version.properties as needed.
|
||||
utils.newLibDeployer(
|
||||
project,
|
||||
nameMap["OPENCV"] as String,
|
||||
"https://github.com/opencv/opencv/releases/download/${versionMap["OPENCV"]}/opencv-${versionMap["OPENCV"]}-android-sdk.zip",
|
||||
).apply {
|
||||
setSourceDir("/OpenCV-android-sdk/sdk/native/")
|
||||
setDestDir("/src/sdk/native/")
|
||||
}
|
||||
)
|
||||
|
||||
val argsMap = mapOf(
|
||||
// @Hint by LZX284 (https://github.com/LZX284) on Sep 30, 2023.
|
||||
// ! "ANDROID_PLATFORM" 默认为 "android-23", 这里修改为与 AutoJs6 最低 SDK 版本一致的 `versionMap.MIN_SDK`.
|
||||
// ! en-US (translated by SuperMonster003 on Oct 22, 2024):
|
||||
// ! "ANDROID_PLATFORM" with default value "android-23" was changed to `versionMap.MIN_SDK`
|
||||
// ! to align with the min SDK version of AutoJs6.
|
||||
"ANDROID_PLATFORM" to "android-${versionMap["MIN_SDK"]}",
|
||||
"ANDROID_STL" to "c++_shared",
|
||||
"ANDROID_ARM_NEON" to "TRUE",
|
||||
)
|
||||
|
||||
// @Hint by SuperMonster003 on Nov 12, 2023.
|
||||
// ! Do not add a space (nbsp) after "-D".
|
||||
// ! Reference: https://stackoverflow.com/questions/14887438/spacing-in-d-option-in-cmake
|
||||
// ! zh-CN:
|
||||
// ! 在 "-D" 后不要添加空格 (不间断空格).
|
||||
// ! 参阅: https://stackoverflow.com/questions/14887438/spacing-in-d-option-in-cmake
|
||||
val args = argsMap.entries.map { (k, v) -> "-D$k=$v" }
|
||||
|
||||
utils.configureLibraryLifecycleHooks(
|
||||
project,
|
||||
nameMap["PROJECT"] as String,
|
||||
listOf("OPENCV", "NDK", "CMAKE").map { "${nameMap[it]}: ${versionMap[it]}" },
|
||||
libsToDeploy,
|
||||
"isCleanupPaddleOcr",
|
||||
listOf(".cxx")
|
||||
)
|
||||
|
||||
android {
|
||||
namespace = "com.baidu.paddle.lite.ocr"
|
||||
|
||||
ndkVersion = versionMap["NDK"] as String
|
||||
compileSdk = versionMap["COMPILE_SDK"] as Int
|
||||
|
||||
defaultConfig {
|
||||
minSdk = versionMap["MIN_SDK"] as Int
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
val cppFlagsMap = mapOf(
|
||||
"-std" to "c++11"
|
||||
)
|
||||
val cppListFlags = mapOf(
|
||||
"-f" to listOf("rtti", "exceptions"),
|
||||
"-W" to "no-format"
|
||||
)
|
||||
|
||||
// 组装等价于 Groovy 脚本中的拼接逻辑
|
||||
val cppFlagsJoined = buildString {
|
||||
append(
|
||||
cppFlagsMap.entries.joinToString(" ") { (k, v) -> "$k=$v" }
|
||||
)
|
||||
append(" ")
|
||||
append(
|
||||
cppListFlags.entries.joinToString(" ") { (k, v) ->
|
||||
when (v) {
|
||||
is List<*> -> v.joinToString(" ") { opt -> k + opt }
|
||||
else -> "$k$v"
|
||||
}
|
||||
}
|
||||
)
|
||||
}.trim()
|
||||
|
||||
cppFlags += cppFlagsJoined
|
||||
arguments += args
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
// @Hint by SuperMonster003 on Jan 2, 2024.
|
||||
// ! Supported architectures: arm-v7, arm-v8.
|
||||
// ! References:
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/blob/develop/lite/tools/build_android.sh#L7
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/issues/80
|
||||
// ! zh-CN:
|
||||
// ! 支持的架构: arm-v7, arm-v8.
|
||||
// ! 参阅:
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/blob/develop/lite/tools/build_android.sh#L7
|
||||
// ! https://github.com/PaddlePaddle/Paddle-Lite/issues/80
|
||||
// noinspection ChromeOsAbiSupport
|
||||
abiFilters += listOf("arm64-v8a", "armeabi-v7a")
|
||||
@Suppress("DEPRECATION")
|
||||
ldLibs?.add("jnigraphics")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
debug {
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path = file("src/main/cpp/CMakeLists.txt")
|
||||
version = versionMap["CMAKE"] as String
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
targetSdk = versionMap["TARGET_SDK"] as Int
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
|
||||
implementation(project(mapOf("path" to ":libs:org.opencv-${versionMap["OPENCV"]}")))
|
||||
implementation(libs.core.ktx)
|
||||
implementation(libs.preference.ktx)
|
||||
}
|
||||
2
libs/paddleocr/proguard-rules.pro
vendored
2
libs/paddleocr/proguard-rules.pro
vendored
@@ -1,6 +1,6 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
# proguardFiles setting in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/**
|
||||
* Rapid OCR (https://github.com/RapidAI/RapidOCR) build script (Groovy).
|
||||
*
|
||||
* Created by SuperMonster003 on Sep 19, 2024.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'org.autojs.build.utils'
|
||||
id 'org.autojs.build.properties'
|
||||
id 'org.autojs.build.jvm-convention'
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'kotlin-parcelize'
|
||||
}
|
||||
|
||||
ext["projectName"] = "Rapid OCR"
|
||||
|
||||
def versionMap = [
|
||||
"OFFICIAL_NAME" : "1.3.0", /* From original build.gradle file. */
|
||||
"MIN_SDK" : props["MIN_SDK"] as Integer,
|
||||
"COMPILE_SDK" : props["COMPILE_SDK"] as Integer,
|
||||
"TARGET_SDK" : props["TARGET_SDK"] as Integer,
|
||||
"NDK" : props["RAPID_OCR/NDK"],
|
||||
"CMAKE" : props["RAPID_OCR/CMAKE"],
|
||||
"OPENCV_MOBILE" : props["RAPID_OCR/OPENCV_MOBILE"],
|
||||
"OPENCV_MOBILE_LABEL": props["RAPID_OCR/OPENCV_MOBILE_LABEL"],
|
||||
"ONNX" : props["RAPID_OCR/ONNX"],
|
||||
"ONNX_RUNTIME" : props["RAPID_OCR/ONNX_RUNTIME"],
|
||||
]
|
||||
|
||||
def nameMap = [
|
||||
"PROJECT" : ext["projectName"],
|
||||
"OPENCV_MOBILE" : "OpenCV Mobile",
|
||||
"OPENCV_MOBILE_LABEL": "OpenCV Mobile Label",
|
||||
"ONNX" : "Onnx",
|
||||
"ONNX_RUNTIME" : "Onnx Runtime",
|
||||
"NDK" : "NDK",
|
||||
"CMAKE" : "Cmake",
|
||||
]
|
||||
|
||||
def libsToDeploy = [
|
||||
utils.newLibDeployer(project, nameMap.OPENCV_MOBILE, "https://github.com/nihui/opencv-mobile/releases/download" +
|
||||
"/v${versionMap.OPENCV_MOBILE_LABEL}/opencv-mobile-${versionMap.OPENCV_MOBILE}-android.zip")
|
||||
.setSourceDir("/opencv-mobile-${versionMap.OPENCV_MOBILE}-android/sdk/native/")
|
||||
.setDestDir("/src/sdk/native/"),
|
||||
utils.newLibDeployer(project, nameMap.ONNX, "https://github.com/RapidAI/RapidOcrOnnx/releases/download" +
|
||||
"/${versionMap.ONNX}/Project_RapidOcrOnnx-${versionMap.ONNX}.7z")
|
||||
.setSourceDir("/Project_RapidOcrOnnx-${versionMap.ONNX}/models/")
|
||||
.setDestDir("/src/main/assets/models/"),
|
||||
utils.newLibDeployer(project, nameMap.ONNX_RUNTIME, "https://github.com/RapidAI/OnnxruntimeBuilder/releases/download" +
|
||||
"/${versionMap.ONNX_RUNTIME}/onnxruntime-${versionMap.ONNX_RUNTIME}-android-shared.7z")
|
||||
.setSourceDir("/onnxruntime-shared/")
|
||||
.setDestDir("/src/main/onnxruntime-shared/"),
|
||||
]
|
||||
|
||||
utils.configureLibraryLifecycleHooks(project, nameMap.PROJECT, [
|
||||
"OPENCV_MOBILE",
|
||||
"OPENCV_MOBILE_LABEL",
|
||||
"ONNX",
|
||||
"ONNX_RUNTIME",
|
||||
"NDK",
|
||||
"CMAKE",
|
||||
].collect { "${nameMap[it]}: ${versionMap[it]}" }, libsToDeploy, "isCleanupRapidOcr", [".cxx"])
|
||||
|
||||
android {
|
||||
|
||||
namespace = "com.benjaminwan.ocrlibrary"
|
||||
|
||||
ndkVersion versionMap.NDK
|
||||
compileSdk versionMap.COMPILE_SDK
|
||||
|
||||
defaultConfig {
|
||||
minSdk versionMap.MIN_SDK
|
||||
targetSdk versionMap.TARGET_SDK
|
||||
versionName versionMap.OFFICIAL_NAME
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64', 'x86'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "src/main/cpp/CMakeLists.txt"
|
||||
version versionMap.CMAKE
|
||||
}
|
||||
}
|
||||
|
||||
libraryVariants.all {
|
||||
variant ->
|
||||
variant.outputs.all {
|
||||
outputFileName = "${project.name}-${defaultConfig.versionName}-${variant.buildType.name}.aar"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
|
||||
testImplementation libs.junit
|
||||
androidTestImplementation libs.test.ext.junit
|
||||
androidTestImplementation libs.test.espresso.core
|
||||
|
||||
implementation libs.core.ktx
|
||||
implementation libs.appcompat
|
||||
|
||||
}
|
||||
133
libs/rapidocr/build.gradle.kts
Normal file
133
libs/rapidocr/build.gradle.kts
Normal file
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* Rapid OCR (https://github.com/RapidAI/RapidOCR) build script (Kotlin DSL).
|
||||
*
|
||||
* Created by SuperMonster003 on Sep 19, 2024.
|
||||
* Transformed by SuperMonster003 on Sep 30, 2025.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("org.autojs.build.utils")
|
||||
id("org.autojs.build.properties")
|
||||
id("org.autojs.build.jvm-convention")
|
||||
id("com.android.library")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("kotlin-parcelize")
|
||||
}
|
||||
|
||||
ext {
|
||||
set("projectName", "Rapid OCR")
|
||||
}
|
||||
|
||||
val versionMap = mapOf(
|
||||
"OFFICIAL_NAME" to "1.3.0", /* From original build.gradle file. */
|
||||
"MIN_SDK" to props["MIN_SDK"].toInt(),
|
||||
"COMPILE_SDK" to props["COMPILE_SDK"].toInt(),
|
||||
"TARGET_SDK" to props["TARGET_SDK"].toInt(),
|
||||
"NDK" to props["RAPID_OCR/NDK"],
|
||||
"CMAKE" to props["RAPID_OCR/CMAKE"],
|
||||
"OPENCV_MOBILE" to props["RAPID_OCR/OPENCV_MOBILE"],
|
||||
"OPENCV_MOBILE_LABEL" to props["RAPID_OCR/OPENCV_MOBILE_LABEL"],
|
||||
"ONNX" to props["RAPID_OCR/ONNX"],
|
||||
"ONNX_RUNTIME" to props["RAPID_OCR/ONNX_RUNTIME"],
|
||||
)
|
||||
|
||||
val nameMap = mapOf(
|
||||
"PROJECT" to extensions.extraProperties["projectName"] as String,
|
||||
"OPENCV_MOBILE" to "OpenCV Mobile",
|
||||
"OPENCV_MOBILE_LABEL" to "OpenCV Mobile Label",
|
||||
"ONNX" to "Onnx",
|
||||
"ONNX_RUNTIME" to "Onnx Runtime",
|
||||
"NDK" to "NDK",
|
||||
"CMAKE" to "Cmake",
|
||||
)
|
||||
|
||||
val libsToDeploy = listOf(
|
||||
utils.newLibDeployer(
|
||||
project,
|
||||
nameMap["OPENCV_MOBILE"] as String,
|
||||
"https://github.com/nihui/opencv-mobile/releases/download/v${versionMap["OPENCV_MOBILE_LABEL"]}/opencv-mobile-${versionMap["OPENCV_MOBILE"]}-android.zip",
|
||||
).apply {
|
||||
setSourceDir("/opencv-mobile-${versionMap["OPENCV_MOBILE"]}-android/sdk/native/")
|
||||
setDestDir("/src/sdk/native/")
|
||||
},
|
||||
utils.newLibDeployer(
|
||||
project,
|
||||
nameMap["ONNX"] as String,
|
||||
"https://github.com/RapidAI/RapidOcrOnnx/releases/download/${versionMap["ONNX"]}/Project_RapidOcrOnnx-${versionMap["ONNX"]}.7z",
|
||||
).apply {
|
||||
setSourceDir("/Project_RapidOcrOnnx-${versionMap["ONNX"]}/models/")
|
||||
setDestDir("/src/main/assets/models/")
|
||||
},
|
||||
utils.newLibDeployer(
|
||||
project,
|
||||
nameMap["ONNX_RUNTIME"] as String,
|
||||
"https://github.com/RapidAI/OnnxruntimeBuilder/releases/download/${versionMap["ONNX_RUNTIME"]}/onnxruntime-${versionMap["ONNX_RUNTIME"]}-android-shared.7z",
|
||||
).apply {
|
||||
setSourceDir("/onnxruntime-shared/")
|
||||
setDestDir("/src/main/onnxruntime-shared/")
|
||||
},
|
||||
)
|
||||
|
||||
utils.configureLibraryLifecycleHooks(
|
||||
project,
|
||||
nameMap["PROJECT"] as String,
|
||||
listOf("OPENCV_MOBILE", "OPENCV_MOBILE_LABEL", "ONNX", "ONNX_RUNTIME", "NDK", "CMAKE")
|
||||
.map { "${nameMap[it] ?: it}: ${versionMap[it]}" },
|
||||
libsToDeploy,
|
||||
"isCleanupRapidOcr",
|
||||
listOf(".cxx"),
|
||||
)
|
||||
|
||||
android {
|
||||
|
||||
namespace = "com.benjaminwan.ocrlibrary"
|
||||
version = versionMap["OFFICIAL_NAME"] as String
|
||||
|
||||
ndkVersion = versionMap["NDK"] as String
|
||||
compileSdk = versionMap["COMPILE_SDK"] as Int
|
||||
|
||||
defaultConfig {
|
||||
minSdk = versionMap["MIN_SDK"] as Int
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles("consumer-rules.pro")
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86_64", "x86")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
targetSdk = versionMap["TARGET_SDK"] as Int
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path = file("src/main/cpp/CMakeLists.txt")
|
||||
version = versionMap["CMAKE"] as String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
|
||||
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.test.ext.junit)
|
||||
androidTestImplementation(libs.test.espresso.core)
|
||||
|
||||
implementation(libs.core.ktx)
|
||||
implementation(libs.appcompat)
|
||||
}
|
||||
2
libs/rapidocr/proguard-rules.pro
vendored
2
libs/rapidocr/proguard-rules.pro
vendored
@@ -1,6 +1,6 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
# proguardFiles setting in build.gradle.kts.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
Reference in New Issue
Block a user