Files
FastDeploy/java/android/fastdeploy/build.gradle
DefTruth 2613e9c5d0 [Android] support fastdeploy build with static deps(60Mb->29~31Mb) (#1176)
* [Android] support fastdeploy build with static deps(70Mb->17~19Mb)

* [Android] support fastdeploy build with static deps(60Mb->29~30Mb)

* fixed ci

* fixed ci

* [staticlib] support fd android static lib

* [static] optimize bundle_static_library func

* [staticlib] add api_helpers.h -> staticlib headers

* [staticlib] add api_helpers.h -> staticlib headers

* [staticlib] add api_helpers.h -> staticlib headers

* [staticlib] Fixed Paddle Lite paddle_use_kernels.h to support fd armv7 static lib

* [staticlib] Add strip -> fd static lib target

* [staticlib] optimize bundle_static_library func

* [staticlib] add strip for fd static lib on  mac osx

* [staticlib] move api_helpers -> lite/option

* [staticlib] optimize bundle_static_library

* [staticlib] add Android limit
2023-01-30 19:39:56 +08:00

113 lines
3.6 KiB
Groovy

apply plugin: 'com.android.library'
android {
compileSdk 28
defaultConfig {
minSdk 15
targetSdk 28
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-21', '-DANDROID_STL=c++_shared', "-DANDROID_TOOLCHAIN=clang"
abiFilters 'armeabi-v7a', 'arm64-v8a'
cppFlags "-std=c++11"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.22.1"
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
ndkVersion '25.1.8937393'
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
def FD_CXX_LIB = [
[
'src' : 'https://bj.bcebos.com/fastdeploy/dev/android/fastdeploy-android-with-text-0.0.0-shared.tgz',
'dest': 'libs',
'name': 'fastdeploy-android-latest-shared-dev'
]
]
task downloadAndExtractLibs(type: DefaultTask) {
doFirst {
println "[INFO] Downloading and extracting fastdeploy android c++ lib ..."
}
doLast {
String cachePath = "cache"
if (!file("${cachePath}").exists()) {
mkdir "${cachePath}"
}
FD_CXX_LIB.eachWithIndex { lib, index ->
String[] libPaths = lib.src.split("/")
String sdkName = lib.name
String libName = libPaths[libPaths.length - 1]
libName = libName.substring(0, libName.indexOf("tgz") - 1)
String cacheName = cachePath + "/" + "${libName}.tgz"
String libDir = lib.dest + "/" + libName
String sdkDir = lib.dest + "/" + sdkName
boolean copyFiles = false
if (!file("${sdkDir}").exists()) {
// Download lib and rename to sdk name later.
if (!file("${cacheName}").exists()) {
println "[INFO] Downloading ${lib.src} -> ${cacheName}"
ant.get(src: lib.src, dest: file("${cacheName}"))
}
copyFiles = true
}
if (copyFiles) {
println "[INFO] Taring ${cacheName} -> ${libDir}"
copy { from(tarTree("${cacheName}")) into("${lib.dest}") }
if (!libName.equals(sdkName)) {
if (file("${sdkDir}").exists()) {
delete("${sdkDir}")
println "[INFO] Remove old ${sdkDir}"
}
mkdir "${sdkDir}"
println "[INFO] Coping ${libDir} -> ${sdkDir}"
copy { from("${libDir}") into("${sdkDir}") }
delete("${libDir}")
println "[INFO] Removed ${libDir}"
println "[INFO] Update ${sdkDir} done!"
}
} else {
println "[INFO] ${sdkDir} already exists!"
println "[WARN] Please delete ${cacheName} and ${sdkDir} " +
"if you want to UPDATE ${sdkName} c++ lib. Then, rebuild this sdk."
}
}
}
}
preBuild.dependsOn downloadAndExtractLibs