[Android] Add CxxBuffer to native and Java PaddleSegModel (#677)

[Android] Add CxxBuffer to native PaddleSegModel
This commit is contained in:
DefTruth
2022-11-23 16:10:11 +08:00
committed by GitHub
parent b5b2732366
commit ff5fb248ff
8 changed files with 254 additions and 20 deletions

View File

@@ -1,5 +1,3 @@
import java.security.MessageDigest
apply plugin: 'com.android.library'
@@ -56,26 +54,23 @@ task downloadAndExtractLibs(type: DefaultTask) {
println "Downloading and extracting fastdeploy android c++ lib ..."
}
doLast {
// Prepare cache folder for archives
String cachePath = "cache"
if (!file("${cachePath}").exists()) {
mkdir "${cachePath}"
}
FD_CXX_LIB.eachWithIndex { lib, index ->
MessageDigest messageDigest = MessageDigest.getInstance('MD5')
messageDigest.update(lib.src.bytes)
String cacheName = new BigInteger(1, messageDigest.digest()).toString(32)
// Download the target archive if not exists
boolean copyFiles = !file("${lib.dest}").exists()
if (!file("${cachePath}/${cacheName}.tgz").exists()) {
ant.get(src: lib.src, dest: file("${cachePath}/${cacheName}.tgz"))
String[] libPaths = lib.src.split("/")
String libName = libPaths[libPaths.length - 1]
libName = libName.split("\\.")[0]
boolean copyFiles = !file("${lib.dest}/${libName}").exists()
if (!file("${cachePath}/${libName}.tgz").exists()) {
println "Downloading ${lib.src} -> ${cachePath}/${libName}.tgz"
ant.get(src: lib.src, dest: file("${cachePath}/${libName}.tgz"))
copyFiles = true
// force to copy files from the latest archive files
}
// Extract the target archive if its dest path does not exists
if (copyFiles) {
copy {
from tarTree("${cachePath}/${cacheName}.tgz")
from tarTree("${cachePath}/${libName}.tgz")
into "${lib.dest}"
}
}