Build: -Pmobilegl.androidApi=29 builds a separate API 29 library and plugin; the default stays 26.

This commit is contained in:
2026-10-09 20:27:53 -04:00
parent e70925d35b
commit dce02ae80e
3 changed files with 26 additions and 7 deletions
+7 -4
View File
@@ -118,12 +118,15 @@ if (ANDROID)
"(gradle builds get this from minSdk ${MOBILEGL_ANDROID_API_LEVEL}, so " "(gradle builds get this from minSdk ${MOBILEGL_ANDROID_API_LEVEL}, so "
"check that minSdk instead of adding an override).") "check that minSdk instead of adding an override).")
elseif (_mobilegl_android_api GREATER MOBILEGL_ANDROID_API_LEVEL) elseif (_mobilegl_android_api GREATER MOBILEGL_ANDROID_API_LEVEL)
# A higher level is a separate artifact of the SAME source (gradle -Pmobilegl.androidApi=29:
# native ELF TLS instead of emulated TLS). Any post-${MOBILEGL_ANDROID_API_LEVEL} API use must
# sit behind a compile-time __ANDROID_API__ gate and never replace the API
# ${MOBILEGL_ANDROID_API_LEVEL} path; the minSdk-${MOBILEGL_ANDROID_API_LEVEL} build stays the
# enforcing compile.
message(STATUS message(STATUS
"MobileGL: configuring at Android API ${_mobilegl_android_api} " "MobileGL: configuring at Android API ${_mobilegl_android_api} "
"(> shipping minimum ${MOBILEGL_ANDROID_API_LEVEL}). Allowed, but the " "(> shipping minimum ${MOBILEGL_ANDROID_API_LEVEL}): a separate artifact; "
"tree must not use post-${MOBILEGL_ANDROID_API_LEVEL} APIs - the " "post-${MOBILEGL_ANDROID_API_LEVEL} APIs only behind a compile-time __ANDROID_API__ gate.")
"minSdk-${MOBILEGL_ANDROID_API_LEVEL} gradle build is the enforcing "
"compile.")
endif() endif()
message(STATUS "MobileGL: Android API level ${_mobilegl_android_api}") message(STATUS "MobileGL: Android API level ${_mobilegl_android_api}")
+11 -2
View File
@@ -52,6 +52,12 @@ fun Project.mobileGlDisaggregatedEnabled(): Boolean {
fun Project.mobileGlApplicationIdSuffix(): String = fun Project.mobileGlApplicationIdSuffix(): String =
(findProperty("mobilegl.applicationIdSuffix") ?: "").toString().trim() (findProperty("mobilegl.applicationIdSuffix") ?: "").toString().trim()
// The Android API level of the build (the library's build.gradle reads the same property). Above
// the shipped 26 the APK is a separate artifact: it gets an ".apiNN" id suffix and "-apiNN" version
// suffix unless an explicit application-id suffix is given, so both installs can coexist.
fun Project.mobileGlAndroidApi(): Int =
(findProperty("mobilegl.androidApi") ?: System.getenv("MOBILEGL_ANDROID_API") ?: "26").toString().trim().toInt()
fun Project.runGit(vararg arguments: String): String? = runCatching { fun Project.runGit(vararg arguments: String): String? = runCatching {
ProcessBuilder("git", *arguments) ProcessBuilder("git", *arguments)
.directory(rootDir) .directory(rootDir)
@@ -123,8 +129,11 @@ android {
defaultConfig { defaultConfig {
applicationId = "top.mobilegl.plugin" applicationId = "top.mobilegl.plugin"
mobileGlApplicationIdSuffix().takeIf { it.isNotEmpty() }?.let { applicationIdSuffix = it } val androidApi = mobileGlAndroidApi()
minSdk = 26 val idSuffix = mobileGlApplicationIdSuffix().ifEmpty { if (androidApi > 26) ".api$androidApi" else "" }
idSuffix.takeIf { it.isNotEmpty() }?.let { applicationIdSuffix = it }
if (androidApi > 26) versionNameSuffix = "-api$androidApi"
minSdk = androidApi
targetSdk = 34 targetSdk = 34
versionCode = mobileGlVersionMajor * 1_000_000 + mobileGlVersionMinor * 10_000 + mobileGlMonthlyRevision versionCode = mobileGlVersionMajor * 1_000_000 + mobileGlVersionMinor * 10_000 + mobileGlMonthlyRevision
versionName = "%d.%02d.%s".format(mobileGlVersionMajor, mobileGlVersionMinor, mobileGlGitShortHash) versionName = "%d.%02d.%s".format(mobileGlVersionMajor, mobileGlVersionMinor, mobileGlGitShortHash)
+8 -1
View File
@@ -51,6 +51,13 @@ def mobileGlBuildDisaggregated = {
def mobileGlEnableLto = { def mobileGlEnableLto = {
(rootProject.findProperty('mobilegl.enableLto') ?: System.getenv('MOBILEGL_ENABLE_LTO') ?: 'ON') as String (rootProject.findProperty('mobilegl.enableLto') ?: System.getenv('MOBILEGL_ENABLE_LTO') ?: 'ON') as String
} }
// The Android API level the library is built for: minSdk, and with it the NDK's ANDROID_PLATFORM.
// 26 is the shipped build. 29 is a SEPARATE artifact (its own library, plugin APK and FCL-embedded
// copy, never selected at load time): at 29 the NDK uses native ELF TLS instead of emulated TLS.
// -Pmobilegl.androidApi=29 (or MOBILEGL_ANDROID_API=29) selects it; the source is the same.
def mobileGlAndroidApi = {
(rootProject.findProperty('mobilegl.androidApi') ?: System.getenv('MOBILEGL_ANDROID_API') ?: '26') as String
}
def mobileGlBuildDisaggregatedInproc = { def mobileGlBuildDisaggregatedInproc = {
(rootProject.findProperty('mobilegl.buildDisaggregatedInproc') ?: System.getenv('MOBILEGL_BUILD_DISAGGREGATED_INPROC') ?: mobileGlBuildDisaggregated()) as String (rootProject.findProperty('mobilegl.buildDisaggregatedInproc') ?: System.getenv('MOBILEGL_BUILD_DISAGGREGATED_INPROC') ?: mobileGlBuildDisaggregated()) as String
} }
@@ -60,7 +67,7 @@ android {
compileSdk 34 compileSdk 34
defaultConfig { defaultConfig {
minSdk 26 minSdk Integer.parseInt(mobileGlAndroidApi())
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"