[Refactor] (Android plugin): unify renderer APK with Plugin V2 DSL

This commit is contained in:
2026-07-14 23:37:21 -04:00
parent 15580ff6a6
commit 7ebaf43282
11 changed files with 425 additions and 253 deletions
+44
View File
@@ -0,0 +1,44 @@
import com.android.build.gradle.LibraryExtension
plugins {
id("com.android.application") version "8.6.0" apply false
id("com.android.library") version "8.6.0" apply false
}
fun Project.mobileGlAbiFilters(): List<String> {
val abiList = (findProperty("mobilegl.abis") ?: System.getenv("MOBILEGL_ABIS") ?: "arm64-v8a").toString()
return if (abiList.equals("all", ignoreCase = true)) {
listOf("arm64-v8a", "x86_64")
} else {
abiList.split(',').map(String::trim).filter(String::isNotEmpty)
}
}
fun Project.mobileGlLogActiveLevel(): String =
(findProperty("mobilegl.logLevel") ?: System.getenv("MOBILEGL_LOG_ACTIVE_LEVEL") ?: "MOBILEGL_LOG_LEVEL_INFO").toString()
fun Project.mobileGlCmakeCompilerLauncher(): String =
(findProperty("mobilegl.cmakeCompilerLauncher") ?: System.getenv("MOBILEGL_CMAKE_COMPILER_LAUNCHER") ?: "").toString().trim()
subprojects {
plugins.withId("com.android.library") {
extensions.configure<LibraryExtension> {
defaultConfig {
ndk {
abiFilters += mobileGlAbiFilters()
}
externalNativeBuild {
cmake {
mobileGlCmakeCompilerLauncher().takeIf(String::isNotEmpty)?.let { compilerLauncher ->
arguments += listOf(
"-DCMAKE_C_COMPILER_LAUNCHER=$compilerLauncher",
"-DCMAKE_CXX_COMPILER_LAUNCHER=$compilerLauncher",
)
}
cppFlags += "-DMOBILEGL_LOG_ACTIVE_LEVEL=${mobileGlLogActiveLevel()}"
}
}
}
}
}
}