CMake: fix sdkBuildToolsRevision not being set for user apps

Add qt6_android_get_sdk_build_tools_revision() function to get the
Android SDK build tools revision, the logic is moved from
QtPlatformAndroid to Qt6AndroidMacros. The update QtPlatformAndroid
header comments.

Task-number: QTBUG-85982
Change-Id: If3e5b46fa583f929a24794792c9d5a52beb83990
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Assam Boudjelthia 2020-09-28 20:19:05 +03:00
parent 2271d998d4
commit 7a41b928d4
2 changed files with 25 additions and 26 deletions

View File

@ -1,22 +1,15 @@
#
# Self contained Platform Settings for Android
#
# Note: This file is used both by the internal and public builds.
# Note: This file is used by the internal builds.
#
#
# Public variables:
# Variables:
# QT_ANDROID_JAR
# Location of the adroid sdk jar for java code
# QT_ANDROID_APIVERSION
# QT_ANDROID_API_VERSION
# Android API version
# QT_ANDROID_SDK_BUILD_TOOLS_VERSION
# Detected Android sdk build tools version
#
# Public functions:
#
# qt_android_generate_deployment_settings()
# Generate the deployment settings json file for a cmake target.
#
if (NOT DEFINED ANDROID_SDK_ROOT)
@ -72,21 +65,6 @@ include(UseJava)
# Find JDK 8.0
find_package(Java 1.8 COMPONENTS Development REQUIRED)
# Locate newest android sdk build tools
if (NOT QT_ANDROID_SDK_BUILD_TOOLS_VERSION)
file(GLOB android_build_tools
LIST_DIRECTORIES true
RELATIVE "${ANDROID_SDK_ROOT}/build-tools"
"${ANDROID_SDK_ROOT}/build-tools/*")
if (NOT android_build_tools)
message(FATAL_ERROR "Could not locate Android SDK build tools under \"${ANDROID_SDK_ROOT}/build-tools\"")
endif()
list(SORT android_build_tools)
list(REVERSE android_build_tools)
list(GET android_build_tools 0 android_build_tools_latest)
set(QT_ANDROID_SDK_BUILD_TOOLS_VERSION ${android_build_tools_latest})
endif()
# Ensure we are using the shared version of libc++
if(NOT ANDROID_STL STREQUAL c++_shared)
message(FATAL_ERROR "The Qt libraries on Android only supports the shared library configuration of stl. Please use -DANDROID_STL=\"c++_shared\" as configuration argument.")

View File

@ -1,4 +1,24 @@
# Generate deployment tool json
# Locate newest Android sdk build tools revision
function(qt6_android_get_sdk_build_tools_revision out_var)
if (NOT QT_ANDROID_SDK_BUILD_TOOLS_REVISION)
file(GLOB android_build_tools
LIST_DIRECTORIES true
RELATIVE "${ANDROID_SDK_ROOT}/build-tools"
"${ANDROID_SDK_ROOT}/build-tools/*")
if (NOT android_build_tools)
message(FATAL_ERROR "Could not locate Android SDK build tools under \"${ANDROID_SDK_ROOT}/build-tools\"")
endif()
list(SORT android_build_tools)
list(REVERSE android_build_tools)
list(GET android_build_tools 0 android_build_tools_latest)
set(QT_ANDROID_SDK_BUILD_TOOLS_REVISION ${android_build_tools_latest})
endif()
set(${out_var} "${QT_ANDROID_SDK_BUILD_TOOLS_REVISION}" PARENT_SCOPE)
endfunction()
# Generate the deployment settings json file for a cmake target.
function(qt6_android_generate_deployment_settings target)
# Information extracted from mkspecs/features/android/android_deployment_settings.prf
if (NOT TARGET ${target})
@ -59,8 +79,9 @@ Please recheck your build configuration.")
" \"sdk\": \"${android_sdk_root_native}\",\n")
# Android SDK Build Tools Revision
qt6_android_get_sdk_build_tools_revision(QT_ANDROID_SDK_BUILD_TOOLS_REVISION)
string(APPEND file_contents
" \"sdkBuildToolsRevision\": \"${QT_ANDROID_SDK_BUILD_TOOLS_VERSION}\",\n")
" \"sdkBuildToolsRevision\": \"${QT_ANDROID_SDK_BUILD_TOOLS_REVISION}\",\n")
# Android NDK
file(TO_NATIVE_PATH "${ANDROID_NDK}" android_ndk_root_native)