Files
comaps/android/sdk/build.gradle
Andrei Shkrob c600a4fd5d [android][sdk] Move drawables into sdk lib
Signed-off-by: Andrei Shkrob <github@shkrob.dev>
2025-07-31 07:19:55 +02:00

122 lines
3.5 KiB
Groovy

plugins {
id 'com.android.library'
}
android {
namespace = 'app.organicmaps.sdk'
compileSdk = propCompileSdkVersion.toInteger()
ndkVersion = '28.2.13676358'
defaultConfig {
minSdk = propMinSdkVersion.toInteger()
targetSdk = propTargetSdkVersion.toInteger()
externalNativeBuild {
def pchFlag = 'OFF'
if (project.hasProperty('pch')) pchFlag = 'ON'
def njobs = ''
if (project.hasProperty('njobs')) njobs = project.getProperty('njobs')
def enableVulkanDiagnostics = 'OFF'
if (project.hasProperty('enableVulkanDiagnostics')) {
enableVulkanDiagnostics = project.getProperty('enableVulkanDiagnostics')
}
def enableTrace = 'OFF'
if (project.hasProperty('enableTrace')) {
enableTrace = project.getProperty('enableTrace')
}
cmake {
cppFlags '-fexceptions', '-frtti'
// There is no sense to enable sections without gcc's --gc-sections flag.
cFlags '-fno-function-sections', '-fno-data-sections',
'-Wno-extern-c-compat'
arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static',
'-DSKIP_TESTS=ON', '-DSKIP_TOOLS=ON', "-DUSE_PCH=$pchFlag",
"-DNJOBS=$njobs", "-DENABLE_VULKAN_DIAGNOSTICS=$enableVulkanDiagnostics",
"-DENABLE_TRACE=$enableTrace"
targets 'organicmaps'
}
}
// Use, for example, -Parm32 gradle parameter to build only for armeabi-v7a.
ndk {
abiFilters = new HashSet<>()
if (project.hasProperty('arm32') || project.hasProperty('armeabi-v7a')) {
abiFilters.add('armeabi-v7a')
}
if (project.hasProperty('arm64') || project.hasProperty('arm64-v8a')) {
abiFilters.add('arm64-v8a')
}
if (project.hasProperty('x86')) {
abiFilters.add('x86')
}
if (project.hasProperty('x86_64') || project.hasProperty('x64')) {
abiFilters.add('x86_64')
}
if (abiFilters.isEmpty()) {
abiFilters.add('armeabi-v7a')
abiFilters.add('arm64-v8a')
// For the emulator, chromebooks and some Intel Atom devices.
abiFilters.add('x86_64')
}
println('Building for ' + abiFilters + ' archs.')
}
}
buildTypes {
debug {
jniDebuggable true // Enable jni debug build
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
beta {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
matchingFallbacks = ['release']
}
}
externalNativeBuild {
cmake {
version = '3.22.1+'
buildStagingDirectory './nativeOutputs'
path '../../CMakeLists.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}
dependencies {
}
// TODO: Running lint task triggers native build. Find a better solution.
project.afterEvaluate {
boolean isLintRun = project.gradle.startParameter.taskNames.any { it.toLowerCase().contains('lint') }
if (isLintRun) {
tasks.findAll { task ->
(task.name.startsWith('Native') || task.name.contains('CMake')) &&
task.project == project
}.each { nativeTask ->
logger.warn("Disabling task ${nativeTask.path} because lint is running.")
nativeTask.onlyIf { false }
}
}
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}