Skip to content

Commit

Permalink
Android: Fix building apps when Qt is configured with one ABI
Browse files Browse the repository at this point in the history
When configuring with Qt only with one ABI, certain code paths were
not triggered, which led to a few issues:
- The deployment json file generated by androiddeployqt listed
  no architectures.
- The compiled shared library did not have a lib prefix and arch suffix,
  which androiddeployqt during the deployment / make apk step.

To fix the architectures missing in the json file, ANDROID_ABIS needs
to be set in android/resolve_config.prf also in the single abi case.

To get the correct file names, android.prf needs to apply the prefixes
and suffixes not only in the build_pass case (multi-abi) but also in
the single abi case (except for config.tests).

The application-binary entry in the json file needs to be without the
extra prefixes and suffixes though, so make a copy of the TARGET value
to be used in the json file, before the name manipulations are
applied.

Pick-to: 5.15
Task-number: QTBUG-85399
Change-Id: Idde92ab7fe883636ccc65a87b91c8a3fc72eefbb
Reviewed-by: Alessandro Portale <[email protected]>
  • Loading branch information
alcroito committed Aug 25, 2020
1 parent d5dc0b6 commit b455331
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
9 changes: 8 additions & 1 deletion mkspecs/features/android/android.prf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
APK_PATH = $$shell_path($$OUT_PWD/android-build/$${TARGET}.apk)
TARGET_FOR_ANDROID_DEPLOYMENT_SETTINGS = $$TARGET

!contains(TEMPLATE, subdirs): {
apk_install_target.target = apk_install_target
apk_install_target.depends = first
Expand All @@ -21,7 +23,12 @@ APK_PATH = $$shell_path($$OUT_PWD/android-build/$${TARGET}.apk)
prepareRecursiveTarget(apk_install_target)
}

build_pass {
# Apply Android arch specific settings in the following cases:
# - build_pass == true aka Qt was configured with multi-ABI (2+ arches)
# - single_android_abi == true aka Qt was configuring with a single ABI / arch
# modifications are omitted when building config.tests
# during Qt configuration, by checkking for the presence of single_arch
build_pass|if(single_android_abi:!single_arch) {
contains(TEMPLATE, ".*app") {
!android_app {
!contains(TARGET, ".so") {
Expand Down
4 changes: 2 additions & 2 deletions mkspecs/features/android/android_deployment_settings.prf
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-embedded {
FILE_CONTENT += " \"qrcFiles\": $$emitString($$join(rescopy, ",")),"
}
FILE_CONTENT += ""
FILE_CONTENT += " \"application-binary\": $$emitString($$TARGET)"
FILE_CONTENT += " \"application-binary\": $$emitString($$TARGET_FOR_ANDROID_DEPLOYMENT_SETTINGS)"
FILE_CONTENT += "}"

isEmpty(ANDROID_DEPLOYMENT_SETTINGS_FILE): ANDROID_DEPLOYMENT_SETTINGS_FILE = $$OUT_PWD/android-$$TARGET-deployment-settings.json
isEmpty(ANDROID_DEPLOYMENT_SETTINGS_FILE): ANDROID_DEPLOYMENT_SETTINGS_FILE = $$OUT_PWD/android-$$TARGET_FOR_ANDROID_DEPLOYMENT_SETTINGS-deployment-settings.json

write_file($$ANDROID_DEPLOYMENT_SETTINGS_FILE, FILE_CONTENT)|error()
}
19 changes: 19 additions & 0 deletions mkspecs/features/android/resolve_config.prf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,23 @@ load(resolve_config)
CONFIG += $$ALL_ABIS build_all
addExclusiveBuildsProper($$ALL_ABIS, $$ANDROID_ABIS)
unset(ALL_ABIS)
CONFIG += multi_android_abi
}

# single_arch is set qtConfTest_compile and is a marker that a config test is being built, and
# thus all Android ABI file name modifications should be avoided (prefix / suffix of
# the built binary).
# single_android_abi means ANDROID_ABI only has one value
# multi_android_abi means ANDROID_ABI has more than one value (Qt configured with 2+ arches)
#
# Assign $$ALL_ANDROID_ABIS to ANDROID_ABIS only if ANDROID_ABIS was not provided by the user
# on the qmake command line and Qt was not configured with 2+ arches.
#
# Note that in config.tests, ANDROID_ABIS ends up being empty (due to !single_arch check) regardless
# of how many ABIs Qt is configured with, which in turns causes the 'architectures' field in
# in android-arch-deployment-settings.json be empty.
!equals(TEMPLATE, aux):!host_build:!single_arch:!java:!multi_android_abi:android:isEmpty(ANDROID_ABIS) {
# Needed for the generated deployment-settings.json not to have an empty list
# of architectures.
ANDROID_ABIS = $$ALL_ANDROID_ABIS
}

0 comments on commit b455331

Please sign in to comment.