Make android function sequence mutable
When building Qt itself or Qt standalone tests (but not user projects), qt6_android_add_apk_target and qt6_android_generate_deployment_setting can now be called at any time after the Android executable target is created. Note: Because we're now using genexes when we build Qt as described above, Qt developers are required to use Unix-style paths for the following target properties: QT_QML_IMPORT_PATH QT_QML_ROOT_PATH QT_ANDROID_PACKAGE_SOURCE_DIR Pick-to: 6.3 Fixes: QTBUG-100796 Change-Id: Ida788f0d58bc0c028a89eed9d115babe27144325 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
1ba56134f5
commit
4b8bc8b5bb
@ -151,12 +151,16 @@ function(qt6_android_generate_deployment_settings target)
|
|||||||
" \"sdk\": \"${android_sdk_root_native}\",\n")
|
" \"sdk\": \"${android_sdk_root_native}\",\n")
|
||||||
|
|
||||||
# Android SDK Build Tools Revision
|
# Android SDK Build Tools Revision
|
||||||
get_target_property(android_sdk_build_tools ${target} QT_ANDROID_SDK_BUILD_TOOLS_REVISION)
|
_qt_internal_android_get_sdk_build_tools_revision(android_sdk_build_tools)
|
||||||
if (NOT android_sdk_build_tools)
|
set(android_sdk_build_tools_genex "")
|
||||||
_qt_internal_android_get_sdk_build_tools_revision(android_sdk_build_tools)
|
string(APPEND android_sdk_build_tools_genex
|
||||||
endif()
|
"$<IF:$<BOOL:$<TARGET_PROPERTY:${target},QT_ANDROID_SDK_BUILD_TOOLS_REVISION>>,"
|
||||||
|
"$<TARGET_PROPERTY:${target},QT_ANDROID_SDK_BUILD_TOOLS_REVISION>,"
|
||||||
|
"${android_sdk_build_tools}"
|
||||||
|
">"
|
||||||
|
)
|
||||||
string(APPEND file_contents
|
string(APPEND file_contents
|
||||||
" \"sdkBuildToolsRevision\": \"${android_sdk_build_tools}\",\n")
|
" \"sdkBuildToolsRevision\": \"${android_sdk_build_tools_genex}\",\n")
|
||||||
|
|
||||||
# Android NDK
|
# Android NDK
|
||||||
file(TO_CMAKE_PATH "${CMAKE_ANDROID_NDK}" android_ndk_root_native)
|
file(TO_CMAKE_PATH "${CMAKE_ANDROID_NDK}" android_ndk_root_native)
|
||||||
@ -323,6 +327,9 @@ function(qt6_android_add_apk_target target)
|
|||||||
if (NOT deployment_file)
|
if (NOT deployment_file)
|
||||||
message(FATAL_ERROR "Target ${target} is not a valid android executable target\n")
|
message(FATAL_ERROR "Target ${target} is not a valid android executable target\n")
|
||||||
endif()
|
endif()
|
||||||
|
# Use genex to get path to the deployment settings, the above check only to confirm that
|
||||||
|
# qt6_android_add_apk_target is called on an android executable target.
|
||||||
|
set(deployment_file "$<TARGET_PROPERTY:${target},QT_ANDROID_DEPLOYMENT_SETTINGS_FILE>")
|
||||||
|
|
||||||
# Make global apk and aab targets depend on the current apk target.
|
# Make global apk and aab targets depend on the current apk target.
|
||||||
if(TARGET aab)
|
if(TARGET aab)
|
||||||
@ -334,6 +341,7 @@ function(qt6_android_add_apk_target target)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(deployment_tool "${QT_HOST_PATH}/${QT6_HOST_INFO_BINDIR}/androiddeployqt")
|
set(deployment_tool "${QT_HOST_PATH}/${QT6_HOST_INFO_BINDIR}/androiddeployqt")
|
||||||
|
# No need to use genex for the BINARY_DIR since it's read-only.
|
||||||
get_target_property(target_binary_dir ${target} BINARY_DIR)
|
get_target_property(target_binary_dir ${target} BINARY_DIR)
|
||||||
set(apk_final_dir "${target_binary_dir}/android-build")
|
set(apk_final_dir "${target_binary_dir}/android-build")
|
||||||
set(apk_file_name "${target}.apk")
|
set(apk_file_name "${target}.apk")
|
||||||
@ -655,7 +663,7 @@ endfunction()
|
|||||||
# The function converts the target property to a json record and appends it to the output
|
# The function converts the target property to a json record and appends it to the output
|
||||||
# variable.
|
# variable.
|
||||||
function(_qt_internal_add_android_deployment_property out_var json_key target property)
|
function(_qt_internal_add_android_deployment_property out_var json_key target property)
|
||||||
set(property_genex "$<TARGET_PROPERTY:${target},${property}>")
|
set(property_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:${target},${property}>>")
|
||||||
string(APPEND ${out_var}
|
string(APPEND ${out_var}
|
||||||
"$<$<BOOL:${property_genex}>:"
|
"$<$<BOOL:${property_genex}>:"
|
||||||
" \"${json_key}\": \"${property_genex}\"\,\n"
|
" \"${json_key}\": \"${property_genex}\"\,\n"
|
||||||
@ -699,7 +707,7 @@ function(_qt_internal_add_android_deployment_list_property out_var json_key)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(property_genex
|
set(property_genex
|
||||||
"$<TARGET_PROPERTY:${target},${property}>"
|
"$<GENEX_EVAL:$<TARGET_PROPERTY:${target},${property}>>"
|
||||||
)
|
)
|
||||||
set(add_quote_genex
|
set(add_quote_genex
|
||||||
"$<$<BOOL:${property_genex}>:\">"
|
"$<$<BOOL:${property_genex}>:\">"
|
||||||
@ -708,7 +716,7 @@ function(_qt_internal_add_android_deployment_list_property out_var json_key)
|
|||||||
"${list_join_genex}"
|
"${list_join_genex}"
|
||||||
"${add_comma_genex}${add_quote_genex}"
|
"${add_comma_genex}${add_quote_genex}"
|
||||||
"$<JOIN:"
|
"$<JOIN:"
|
||||||
"$<GENEX_EVAL:${property_genex}>,"
|
"${property_genex},"
|
||||||
"\",\""
|
"\",\""
|
||||||
">"
|
">"
|
||||||
"${add_quote_genex}"
|
"${add_quote_genex}"
|
||||||
@ -748,14 +756,28 @@ endfunction()
|
|||||||
# It doesn't overwrite public properties, but instead writes formatted values to internal
|
# It doesn't overwrite public properties, but instead writes formatted values to internal
|
||||||
# properties.
|
# properties.
|
||||||
function(_qt_internal_android_format_deployment_paths target)
|
function(_qt_internal_android_format_deployment_paths target)
|
||||||
_qt_internal_android_format_deployment_path_property(${target}
|
if(QT_BUILD_STANDALONE_TESTS OR QT_BUILDING_QT)
|
||||||
QT_QML_IMPORT_PATH _qt_native_qml_import_paths)
|
# When building standalone tests or Qt itself we obligate developers to not use
|
||||||
|
# windows paths when setting QT_* properties below, so their values are used as is when
|
||||||
|
# generating deployment settings.
|
||||||
|
set_target_properties(${target} PROPERTIES
|
||||||
|
_qt_native_qml_import_paths "$<TARGET_PROPERTY:${target},QT_QML_IMPORT_PATH>"
|
||||||
|
_qt_android_native_qml_root_paths "$<TARGET_PROPERTY:${target},QT_QML_ROOT_PATH>"
|
||||||
|
_qt_android_native_package_source_dir
|
||||||
|
"$<TARGET_PROPERTY:${target},QT_ANDROID_PACKAGE_SOURCE_DIR>"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# User projects still may use windows paths inside the QT_* properties below, with
|
||||||
|
# obligation to run the finalizer code.
|
||||||
|
_qt_internal_android_format_deployment_path_property(${target}
|
||||||
|
QT_QML_IMPORT_PATH _qt_native_qml_import_paths)
|
||||||
|
|
||||||
_qt_internal_android_format_deployment_path_property(${target}
|
_qt_internal_android_format_deployment_path_property(${target}
|
||||||
QT_QML_ROOT_PATH _qt_android_native_qml_root_paths)
|
QT_QML_ROOT_PATH _qt_android_native_qml_root_paths)
|
||||||
|
|
||||||
_qt_internal_android_format_deployment_path_property(${target}
|
_qt_internal_android_format_deployment_path_property(${target}
|
||||||
QT_ANDROID_PACKAGE_SOURCE_DIR _qt_android_native_package_source_dir)
|
QT_ANDROID_PACKAGE_SOURCE_DIR _qt_android_native_package_source_dir)
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# The function converts the value of target property to JSON compatible path and writes the
|
# The function converts the value of target property to JSON compatible path and writes the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user