Move the Android deployment config type detecting to a separate function

Since the deployment config type detecting is generic, move it a
separate function.

Pick-to: 6.8
Change-Id: If925b6e14ba0d64a003e7f9ae2a5d701b7886920
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit f10f609db9488629a1abf8c363f32dbd3abdf456)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2025-03-03 13:00:48 +01:00 committed by Qt Cherry-pick Bot
parent 1aed8b0b75
commit 2eff82ea39

View File

@ -587,25 +587,8 @@ function(qt6_android_add_apk_target target)
list(APPEND extra_args "--verbose")
endif()
if(QT_ANDROID_DEPLOY_RELEASE)
message(WARNING "QT_ANDROID_DEPLOY_RELEASE is not a valid Qt variable."
" Please set QT_ANDROID_DEPLOYMENT_TYPE to RELEASE instead.")
endif()
# Setting QT_ANDROID_DEPLOYMENT_TYPE to a value other than Release disables
# release package signing regardless of the build type.
if(QT_ANDROID_DEPLOYMENT_TYPE)
string(TOUPPER "${QT_ANDROID_DEPLOYMENT_TYPE}" deployment_type_upper)
if("${deployment_type_upper}" STREQUAL "RELEASE")
list(APPEND extra_args "--release")
endif()
elseif(NOT QT_BUILD_TESTS)
# Workaround for tests: do not set automatically --release flag if QT_BUILD_TESTS is set.
# Release package need to be signed. Signing is currently not supported by CI.
# What is more, also androidtestrunner is not working on release APKs,
# For example running "adb shell run-as" on release APK will finish with the error:
# run-as: Package '[PACKAGE-NAME]' is not debuggable
list(APPEND extra_args $<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>:--release>)
endif()
_qt_internal_android_get_deployment_type_option(android_deployment_type_option "--release" "")
list(APPEND extra_args "${android_deployment_type_option}")
_qt_internal_check_depfile_support(has_depfile_support)
@ -1772,5 +1755,40 @@ function(_qt_internal_expose_android_package_source_dir_to_ide target)
endif()
endfunction()
# Return the one of the deployment flags either release or debug depending on
# the preferred config. The returned "flags" are wrapped into generator
# expression so only usable at the generator stage.
function(_qt_internal_android_get_deployment_type_option out_var release_flag debug_flag)
if(QT_ANDROID_DEPLOY_RELEASE)
message(WARNING "QT_ANDROID_DEPLOY_RELEASE is not a valid Qt variable."
" Please set QT_ANDROID_DEPLOYMENT_TYPE to RELEASE instead.")
endif()
# Setting QT_ANDROID_DEPLOYMENT_TYPE to a value other than Release disables
# release package signing regardless of the build type.
if(QT_ANDROID_DEPLOYMENT_TYPE)
string(TOUPPER "${QT_ANDROID_DEPLOYMENT_TYPE}" deployment_type_upper)
if("${deployment_type_upper}" STREQUAL "RELEASE")
set(${out_var} "${release_flag}" PARENT_SCOPE)
else()
set(${out_var} "${debug_flag}" PARENT_SCOPE)
endif()
elseif(NOT QT_BUILD_TESTS)
# Workaround for tests: do not set automatically --release flag if QT_BUILD_TESTS is set.
# Release package need to be signed. Signing is currently not supported by CI.
# What is more, also androidtestrunner is not working on release APKs,
# For example running "adb shell run-as" on release APK will finish with the error:
# run-as: Package '[PACKAGE-NAME]' is not debuggable
string(JOIN "" ${out_var}
"$<IF:$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>,"
"${release_flag},"
"${debug_flag}"
">"
)
set(${out_var} "${${out_var}}" PARENT_SCOPE)
else()
set(${out_var} "${debug_flag}" PARENT_SCOPE)
endif()
endfunction()
set(QT_INTERNAL_ANDROID_TARGET_BUILD_DIR_SUPPORT ON CACHE INTERNAL
"Indicates that Qt supports per-target Android build directories")