Add _make_aab target

Add target triggering AAB creation. Since the _make_aab target is
not added to the ALL set, we may avoid dependency check for it and
admit that the target is "always out of date".

[ChangeLog][Android][Platform Specific Changes] Add the extra
_make_aab targets for each executable target, that can be used
to generate android app bundles. Also add aab metatarget to build
all _make_aab targets that are created in the project.

Pick-to: 6.2
Fixes: QTBUG-96710
Change-Id: I3b0c7fbb5a7dd493ca7a124c4e4b91fd857386bd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2021-11-18 10:27:47 +01:00
parent 54536bb5ae
commit d162ce3732
3 changed files with 35 additions and 9 deletions

View File

@ -117,7 +117,7 @@ if(NOT QT_BUILD_STANDALONE_TESTS)
# Needed when building qtbase for android. # Needed when building qtbase for android.
if(ANDROID) if(ANDROID)
include(src/corelib/Qt6AndroidMacros.cmake) include(src/corelib/Qt6AndroidMacros.cmake)
_qt_internal_create_global_apk_target() _qt_internal_create_global_android_targets()
endif() endif()
if(WASM) if(WASM)

View File

@ -322,9 +322,10 @@ function(qt6_android_add_apk_target target)
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()
# Make global apk target depend on the current apk target. # Make global apk and aab targets depend on the current apk target.
if(TARGET apk) if(TARGET apk)
add_dependencies(apk ${target}_make_apk) add_dependencies(apk ${target}_make_apk)
add_dependencies(aab ${target}_make_aab)
_qt_internal_create_global_apk_all_target_if_needed() _qt_internal_create_global_apk_all_target_if_needed()
endif() endif()
@ -407,19 +408,44 @@ function(qt6_android_add_apk_target target)
COMMENT "Creating APK for ${target}" COMMENT "Creating APK for ${target}"
) )
endif() endif()
# Add target triggering AAB creation. Since the _make_aab target is not added to the ALL
# set, we may avoid dependency check for it and admit that the target is "always out
# of date".
add_custom_target(${target}_make_aab
DEPENDS ${target}_prepare_apk_dir
COMMAND ${deployment_tool}
--input ${deployment_file}
--output ${apk_final_dir}
--apk ${apk_final_file_path}
--aab
${extra_args}
COMMENT "Creating AAB for ${target}"
)
set_property(GLOBAL APPEND PROPERTY _qt_apk_targets ${target}) set_property(GLOBAL APPEND PROPERTY _qt_apk_targets ${target})
_qt_internal_collect_target_apk_dependencies_defer(${target}) _qt_internal_collect_target_apk_dependencies_defer(${target})
endfunction() endfunction()
function(_qt_internal_create_global_apk_target) function(_qt_internal_create_global_android_targets)
macro(_qt_internal_create_global_android_targets_impl target)
string(TOUPPER "${target}" target_upper)
if(NOT QT_NO_GLOBAL_${target_upper}_TARGET)
if(NOT TARGET ${target})
add_custom_target(${target} COMMENT "Building all apks")
endif()
endif()
endmacro()
# Create a top-level "apk" target for convenience, so that users can call 'ninja apk'. # Create a top-level "apk" target for convenience, so that users can call 'ninja apk'.
# It will trigger building all the apk build targets that are added as part of the project. # It will trigger building all the apk build targets that are added as part of the project.
# Allow opting out. # Allow opting out.
if(NOT QT_NO_GLOBAL_APK_TARGET) _qt_internal_create_global_android_targets_impl(apk)
if(NOT TARGET apk)
add_custom_target(apk COMMENT "Building all apks") # Create a top-level "aab" target for convenience, so that users can call 'ninja aab'.
endif() # It will trigger building all the apk build targets that are added as part of the project.
endif() # Allow opting out.
_qt_internal_create_global_android_targets_impl(aab)
endfunction() endfunction()
# The function collects all known non-imported shared libraries that are created in the build tree. # The function collects all known non-imported shared libraries that are created in the build tree.

View File

@ -46,7 +46,7 @@ set(_Qt6CTestMacros "${_Qt6CoreConfigDir}/Qt6CTestMacros.cmake")
if(ANDROID_PLATFORM) if(ANDROID_PLATFORM)
include("${CMAKE_CURRENT_LIST_DIR}/@QT_CMAKE_EXPORT_NAMESPACE@AndroidMacros.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@QT_CMAKE_EXPORT_NAMESPACE@AndroidMacros.cmake")
_qt_internal_create_global_apk_target() _qt_internal_create_global_android_targets()
_qt_internal_collect_default_android_abis() _qt_internal_collect_default_android_abis()
endif() endif()