mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (CMake): the Android API guard holds a floor of 26, not an exact pin - higher platforms may configure, the minSdk-26 gradle build enforces API usage
This commit is contained in:
+17
-13
@@ -21,10 +21,13 @@ if (ANDROID)
|
|||||||
set(MOBILEGL_BUILD_TEST OFF CACHE BOOL "Build MobileGL tests" FORCE)
|
set(MOBILEGL_BUILD_TEST OFF CACHE BOOL "Build MobileGL tests" FORCE)
|
||||||
set(MOBILEGL_BUILD_BENCHMARK OFF CACHE BOOL "Build MobileGL benchmarks" FORCE)
|
set(MOBILEGL_BUILD_BENCHMARK OFF CACHE BOOL "Build MobileGL benchmarks" FORCE)
|
||||||
|
|
||||||
# ------- Android API level policy: exactly 26, decided here and only here -------
|
# ------- Android API level policy: minimum 26, decided here and only here -------
|
||||||
# MobileGL ships against API 26. That is a product constraint, so the build
|
# MobileGL ships against API 26: the codebase must not use any API introduced
|
||||||
# refuses to proceed at any other level rather than quietly producing a
|
# after 26. That usage constraint is enforced where it is real - the shipping
|
||||||
# library with a different libc contract.
|
# gradle build compiles at minSdk 26, where a newer API is simply undeclared
|
||||||
|
# and fails to compile. Configuring at a HIGHER level is therefore allowed
|
||||||
|
# (nothing in the tree may rely on it), but a LOWER level would change the
|
||||||
|
# libc contract underneath the shipped library and is refused.
|
||||||
#
|
#
|
||||||
# This has to live at configure time because the level cannot be corrected
|
# This has to live at configure time because the level cannot be corrected
|
||||||
# from a source header. A `#define __ANDROID_API__ 26` in a common header
|
# from a source header. A `#define __ANDROID_API__ 26` in a common header
|
||||||
@@ -71,19 +74,20 @@ if (ANDROID)
|
|||||||
"MobileGL: could not determine the Android API level (got "
|
"MobileGL: could not determine the Android API level (got "
|
||||||
"\"${_mobilegl_android_api}\"). Configure with the NDK toolchain "
|
"\"${_mobilegl_android_api}\"). Configure with the NDK toolchain "
|
||||||
"file and -DANDROID_PLATFORM=android-${MOBILEGL_ANDROID_API_LEVEL}.")
|
"file and -DANDROID_PLATFORM=android-${MOBILEGL_ANDROID_API_LEVEL}.")
|
||||||
elseif (NOT _mobilegl_android_api EQUAL MOBILEGL_ANDROID_API_LEVEL)
|
elseif (_mobilegl_android_api LESS MOBILEGL_ANDROID_API_LEVEL)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"MobileGL targets Android API ${MOBILEGL_ANDROID_API_LEVEL} exactly, "
|
"MobileGL requires at least Android API ${MOBILEGL_ANDROID_API_LEVEL}, "
|
||||||
"but this build resolved to API ${_mobilegl_android_api}.\n"
|
"but this build resolved to API ${_mobilegl_android_api}.\n"
|
||||||
"Configure with -DANDROID_PLATFORM=android-${MOBILEGL_ANDROID_API_LEVEL} "
|
"Configure with -DANDROID_PLATFORM=android-${MOBILEGL_ANDROID_API_LEVEL} "
|
||||||
"(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).\n"
|
"check that minSdk instead of adding an override).")
|
||||||
"Raising the level is not a local build choice: it changes which libc "
|
elseif (_mobilegl_android_api GREATER MOBILEGL_ANDROID_API_LEVEL)
|
||||||
"symbols the shipped library binds to, and the resulting .so would "
|
message(STATUS
|
||||||
"fail to load on the API ${MOBILEGL_ANDROID_API_LEVEL} devices "
|
"MobileGL: configuring at Android API ${_mobilegl_android_api} "
|
||||||
"MobileGL supports. If you genuinely need another level for a "
|
"(> shipping minimum ${MOBILEGL_ANDROID_API_LEVEL}). Allowed, but the "
|
||||||
"standalone tool, build that tool as its own CMake project - do not "
|
"tree must not use post-${MOBILEGL_ANDROID_API_LEVEL} APIs - the "
|
||||||
"relax this check.")
|
"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}")
|
||||||
|
|||||||
Reference in New Issue
Block a user