summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-11-22 19:19:58 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2021-12-02 14:28:09 +0100
commit6b025f9b27293a859519c24861a946197ef9914d (patch)
tree8b8f020ce7b880235d07a16f7b3fe964d1d88c94 /src
parent87db26bdfe56e9445c03623eb962f569b2570b92 (diff)
Use depfile to control ABI-specific builds of executable targets
qt_internal_${target}_copy_apk_dependencies should use CMake DEPFILE approach when it's possible. Since we don't have any specific artifact that androiddeployqt can produce when collecting dependencies this change adds simple timestamp file that is touched each time when androiddeployqt is running. The timestamp is used then as a file-level dependency for the qt_internal_${target}_copy_apk_dependencies target. Task-number: QTBUG-88841 Change-Id: I985535c7b6e471cb4cfbf90128628087dadc72d0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt6AndroidMacros.cmake58
-rw-r--r--src/tools/androiddeployqt/main.cpp17
2 files changed, 57 insertions, 18 deletions
diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake
index 447acbfc60..d2661022c2 100644
--- a/src/corelib/Qt6AndroidMacros.cmake
+++ b/src/corelib/Qt6AndroidMacros.cmake
@@ -331,8 +331,8 @@ function(qt6_android_add_apk_target target)
endif()
set(deployment_tool "${QT_HOST_PATH}/${QT6_HOST_INFO_BINDIR}/androiddeployqt")
- get_target_property(apk_final_dir ${target} BINARY_DIR)
- set(apk_final_dir "${apk_final_dir}/android-build")
+ get_target_property(target_binary_dir ${target} BINARY_DIR)
+ set(apk_final_dir "${target_binary_dir}/android-build")
set(apk_file_name "${target}.apk")
set(dep_file_name "${target}.d")
set(apk_final_file_path "${apk_final_dir}/${apk_file_name}")
@@ -371,8 +371,13 @@ function(qt6_android_add_apk_target target)
# The DEPFILE argument to add_custom_command is only available with Ninja or CMake>=3.20 and
# make.
+ set(has_depfile_support FALSE)
if(CMAKE_GENERATOR MATCHES "Ninja" OR
(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20 AND CMAKE_GENERATOR MATCHES "Makefiles"))
+ set(has_depfile_support TRUE)
+ endif()
+
+ if(has_depfile_support)
cmake_policy(PUSH)
if(POLICY CMP0116)
# Without explicitly setting this policy to NEW, we get a warning
@@ -445,18 +450,43 @@ function(qt6_android_add_apk_target target)
file(RELATIVE_PATH androiddeployqt_output_path "${CMAKE_BINARY_DIR}" "${apk_final_dir}")
set(androiddeployqt_output_path
"${QT_INTERNAL_ANDROID_MULTI_ABI_BINARY_DIR}/${androiddeployqt_output_path}")
- add_custom_target(qt_internal_${target}_copy_apk_dependencies
- DEPENDS ${target} ${extra_deps}
- COMMAND ${CMAKE_COMMAND}
- -E copy_if_different $<TARGET_FILE:${target}>
- "${androiddeployqt_output_path}/${target_file_copy_relative_path}"
- COMMAND ${deployment_tool}
- --input ${deployment_file}
- --output ${androiddeployqt_output_path}
- --copy-dependencies-only
- ${extra_args}
- COMMENT "Resolving ${CMAKE_ANDROID_ARCH_ABI} dependencies for the ${target} APK"
- )
+ if(has_depfile_support)
+ set(deploy_android_deps_dir "${apk_final_dir}/${target}_deploy_android")
+ set(timestamp_file "${deploy_android_deps_dir}/timestamp")
+ set(dep_file "${deploy_android_deps_dir}/${target}.d")
+ add_custom_command(OUTPUT "${timestamp_file}"
+ DEPENDS ${target} ${extra_deps}
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${deploy_android_deps_dir}"
+ COMMAND ${CMAKE_COMMAND} -E touch "${timestamp_file}"
+ COMMAND ${CMAKE_COMMAND}
+ -E copy_if_different $<TARGET_FILE:${target}>
+ "${androiddeployqt_output_path}/${target_file_copy_relative_path}"
+ COMMAND ${deployment_tool}
+ --input ${deployment_file}
+ --output ${androiddeployqt_output_path}
+ --copy-dependencies-only
+ ${extra_args}
+ --depfile "${dep_file}"
+ --builddir "${CMAKE_BINARY_DIR}"
+ COMMENT "Resolving ${CMAKE_ANDROID_ARCH_ABI} dependencies for the ${target} APK"
+ DEPFILE "${dep_file}"
+ )
+ add_custom_target(qt_internal_${target}_copy_apk_dependencies
+ DEPENDS "${timestamp_file}")
+ else()
+ add_custom_target(qt_internal_${target}_copy_apk_dependencies
+ DEPENDS ${target} ${extra_deps}
+ COMMAND ${CMAKE_COMMAND}
+ -E copy_if_different $<TARGET_FILE:${target}>
+ "${androiddeployqt_output_path}/${target_file_copy_relative_path}"
+ COMMAND ${deployment_tool}
+ --input ${deployment_file}
+ --output ${androiddeployqt_output_path}
+ --copy-dependencies-only
+ ${extra_args}
+ COMMENT "Resolving ${CMAKE_ANDROID_ARCH_ABI} dependencies for the ${target} APK"
+ )
+ endif()
endif()
set_property(GLOBAL APPEND PROPERTY _qt_apk_targets ${target})
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp
index 4e54c41801..8fc3fa8d05 100644
--- a/src/tools/androiddeployqt/main.cpp
+++ b/src/tools/androiddeployqt/main.cpp
@@ -3110,12 +3110,19 @@ bool writeDependencyFile(const Options &options)
if (options.verbose)
fprintf(stdout, "Writing dependency file.\n");
- QFile depFile(options.depFilePath);
-
- QString relativeApkPath = QDir(options.buildDirectory).relativeFilePath(options.apkPath);
+ QString relativeTargetPath;
+ if (options.copyDependenciesOnly) {
+ // When androiddeploy Qt is running in copyDependenciesOnly mode we need to use
+ // the timestamp file as the target to collect dependencies.
+ QString timestampAbsPath = QFileInfo(options.depFilePath).absolutePath() + QLatin1String("/timestamp");
+ relativeTargetPath = QDir(options.buildDirectory).relativeFilePath(timestampAbsPath);
+ } else {
+ relativeTargetPath = QDir(options.buildDirectory).relativeFilePath(options.apkPath);
+ }
+ QFile depFile(options.depFilePath);
if (depFile.open(QIODevice::WriteOnly)) {
- depFile.write(escapeAndEncodeDependencyPath(relativeApkPath));
+ depFile.write(escapeAndEncodeDependencyPath(relativeTargetPath));
depFile.write(": ");
for (const auto &file : dependenciesForDepfile) {
@@ -3227,6 +3234,8 @@ int main(int argc, char *argv[])
}
if (options.copyDependenciesOnly) {
+ if (!options.depFilePath.isEmpty())
+ writeDependencyFile(options);
return 0;
}