Android: Extend make_apk target with the sign option

Commit contains the new QT_ANDROID_SIGN_APK variable. It extends
*make_apk target by signing the package with the specified key.

For key setup these environment variables must be set:
    - QT_ANDROID_KEYSTORE_PATH
    - QT_ANDROID_KEYSTORE_STORE_PASS
    - QT_ANDROID_KEYSTORE_ALIAS
    - QT_ANDROID_KEYSTORE_KEY_PASS

Task-number: QTBUG-97107
Change-Id: If42c74298c1b385889b32517ab7f1f5b0628b487
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Bartlomiej Moskal 2022-05-19 08:07:56 +02:00
parent 296c3776a8
commit 5398eb55ed
2 changed files with 32 additions and 1 deletions

View File

@ -388,6 +388,10 @@ function(qt6_android_add_apk_target target)
COMMENT "Copying ${target} binary to apk folder" COMMENT "Copying ${target} binary to apk folder"
) )
if(QT_ANDROID_SIGN_APK)
set(sign_apk "--sign")
endif()
set(extra_args "") set(extra_args "")
if(QT_INTERNAL_NO_ANDROID_RCC_BUNDLE_CLEANUP) if(QT_INTERNAL_NO_ANDROID_RCC_BUNDLE_CLEANUP)
list(APPEND extra_args "--no-rcc-bundle-cleanup") list(APPEND extra_args "--no-rcc-bundle-cleanup")
@ -422,6 +426,7 @@ function(qt6_android_add_apk_target target)
--apk "${apk_final_file_path}" --apk "${apk_final_file_path}"
--depfile "${dep_file_path}" --depfile "${dep_file_path}"
--builddir "${relative_to_dir}" --builddir "${relative_to_dir}"
${sign_apk}
${extra_args} ${extra_args}
COMMENT "Creating APK for ${target}" COMMENT "Creating APK for ${target}"
DEPENDS "${target}" "${deployment_file}" ${extra_deps} DEPENDS "${target}" "${deployment_file}" ${extra_deps}
@ -439,6 +444,7 @@ function(qt6_android_add_apk_target target)
--input ${deployment_file} --input ${deployment_file}
--output ${apk_final_dir} --output ${apk_final_dir}
--apk ${apk_final_file_path} --apk ${apk_final_file_path}
${sign_apk}
${extra_args} ${extra_args}
COMMENT "Creating APK for ${target}" COMMENT "Creating APK for ${target}"
) )

View File

@ -1,4 +1,4 @@
// Copyright (C) 2021 The Qt Company Ltd. // Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/* NOTE: The variables documented here are available when running CMake, they /* NOTE: The variables documented here are available when running CMake, they
@ -155,6 +155,31 @@ Each variable can be used to specify the path to Qt for Android for the correspo
\sa{cmake-variable-QT_ANDROID_ABIS}{QT_ANDROID_ABIS} \sa{cmake-variable-QT_ANDROID_ABIS}{QT_ANDROID_ABIS}
*/ */
/*!
\page cmake-variable-QT_ANDROID_SIGN_APK.html
\ingroup cmake-variables-qtcore
\title QT_ANDROID_SIGN_APK
\target cmake-variable-QT_ANDROID_SIGN_APK
\summary {Sign the package with the specified keystore, alias and store password.}
\cmakevariablesince 6.4
\preliminarycmakevariable
\cmakevariableandroidonly
Sign the resulting package. The path of the keystore file, the alias of the key and passwords
have to be specified by additional environment variables:
\badcode
QT_ANDROID_KEYSTORE_PATH
QT_ANDROID_KEYSTORE_ALIAS
QT_ANDROID_KEYSTORE_STORE_PASS
QT_ANDROID_KEYSTORE_KEY_PASS
\endcode
Mentioned variables are used internally by \l{androiddeployqt}.
\sa{androiddeployqt}
*/
/*! /*!
\page cmake-variable-QT_HOST_PATH.html \page cmake-variable-QT_HOST_PATH.html
\ingroup cmake-variables-qtcore \ingroup cmake-variables-qtcore