Merge pull request #39 from OlivierLDff/support-multi-abi-qt

Support build with Qt5.14, 5.15 with new qtandroiddeploy config file.
This commit is contained in:
Laurent Gomila 2020-06-02 20:53:54 +02:00 committed by GitHub
commit 5a62962dbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 22 deletions

View File

@ -71,6 +71,16 @@ macro(add_qt_android_apk TARGET SOURCE_TARGET)
# extract the full path of the source target binary
set(QT_ANDROID_APP_PATH "$<TARGET_FILE:${SOURCE_TARGET}>") # full file path to the app's main shared library
if(${Qt5Core_VERSION} VERSION_GREATER_EQUAL 5.14)
set(QT_ANDROID_SUPPORT_MULTI_ABI ON)
endif()
if(QT_ANDROID_SUPPORT_MULTI_ABI)
# qtandroideploy will append by itself the ANDROID_ABI to the target name
set(QT_ANDROID_APPLICATION_BINARY "${SOURCE_TARGET}")
else()
set(QT_ANDROID_APPLICATION_BINARY ${QT_ANDROID_APP_PATH})
endif()
# define the application name
if(ARG_NAME)
@ -155,22 +165,35 @@ macro(add_qt_android_apk TARGET SOURCE_TARGET)
message(WARNING "Failed to determine ANDROID_STL_PREFIX value for ANDROID_STL=${ANDROID_STL}")
endif()
# define the STL shared library path
# up until NDK r18, ANDROID_STL_SHARED_LIBRARIES is populated by the NDK's toolchain file
# since NDK r19, the only option for a shared STL library is libc++_shared
if(ANDROID_STL_SHARED_LIBRARIES)
list(GET ANDROID_STL_SHARED_LIBRARIES 0 STL_LIBRARY_NAME) # we can only give one to androiddeployqt
if(ANDROID_STL_PATH)
set(QT_ANDROID_STL_PATH "${ANDROID_STL_PATH}/libs/${ANDROID_ABI}/lib${ANDROID_STL}.so")
else()
set(QT_ANDROID_STL_PATH "${QT_ANDROID_NDK_ROOT}/sources/cxx-stl/${ANDROID_STL_PREFIX}/libs/${ANDROID_ABI}/lib${ANDROID_STL}.so")
endif()
elseif(ANDROID_STL STREQUAL c++_shared)
set(QT_ANDROID_STL_PATH "${QT_ANDROID_NDK_ROOT}/sources/cxx-stl/${ANDROID_STL_PREFIX}/libs/${ANDROID_ABI}/libc++_shared.so")
if(QT_ANDROID_SUPPORT_MULTI_ABI)
# from Qt 5.14 qtandroideploy will find the correct stl.
set(QT_ANDROID_STL_PATH "${QT_ANDROID_NDK_ROOT}/sources/cxx-stl/${ANDROID_STL_PREFIX}/libs")
else()
message(WARNING "ANDROID_STL (${ANDROID_STL}) isn't a known shared stl library."
"You should consider setting ANDROID_STL to c++_shared (like Qt).")
set(QT_ANDROID_STL_PATH "${QT_ANDROID_NDK_ROOT}/sources/cxx-stl/${ANDROID_STL_PREFIX}/libs/${ANDROID_ABI}/libc++_shared.so")
# define the STL shared library path
# up until NDK r18, ANDROID_STL_SHARED_LIBRARIES is populated by the NDK's toolchain file
# since NDK r19, the only option for a shared STL library is libc++_shared
if(ANDROID_STL_SHARED_LIBRARIES)
list(GET ANDROID_STL_SHARED_LIBRARIES 0 STL_LIBRARY_NAME) # we can only give one to androiddeployqt
if(ANDROID_STL_PATH)
set(QT_ANDROID_STL_PATH "${ANDROID_STL_PATH}/libs/${ANDROID_ABI}/lib${ANDROID_STL}.so")
else()
set(QT_ANDROID_STL_PATH "${QT_ANDROID_NDK_ROOT}/sources/cxx-stl/${ANDROID_STL_PREFIX}/libs/${ANDROID_ABI}/lib${ANDROID_STL}.so")
endif()
elseif(ANDROID_STL STREQUAL c++_shared)
set(QT_ANDROID_STL_PATH "${QT_ANDROID_NDK_ROOT}/sources/cxx-stl/${ANDROID_STL_PREFIX}/libs/${ANDROID_ABI}/libc++_shared.so")
else()
message(WARNING "ANDROID_STL (${ANDROID_STL}) isn't a known shared stl library."
"You should consider setting ANDROID_STL to c++_shared (like Qt).")
set(QT_ANDROID_STL_PATH "${QT_ANDROID_NDK_ROOT}/sources/cxx-stl/${ANDROID_STL_PREFIX}/libs/${ANDROID_ABI}/libc++_shared.so")
endif()
endif()
# From Qt 5.14 qtandroideploy "target-architecture" is no longer valid in input file
# It have been replaced by "architectures": { "${ANDROID_ABI}": "${ANDROID_ABI}" }
# This allow to package multiple ABI in a single apk
# For now we only support single ABI build with this script (to ensure it work with Qt5.14 & Qt5.15)
if(QT_ANDROID_SUPPORT_MULTI_ABI)
set(QT_ANDROID_ARCHITECTURES "\"${ANDROID_ABI}\":\"${ANDROID_ABI}\"")
endif()
# set the list of dependant libraries

View File

@ -4,6 +4,7 @@
android:installLocation="auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="@QT_ANDROID_APP_VERSION_CODE@">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
<application
android:label="@QT_ANDROID_APP_NAME@"
android:name="org.qtproject.qt5.android.bindings.QtApplication">
@ -18,6 +19,10 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
@ -25,17 +30,21 @@
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->

View File

@ -54,8 +54,13 @@ android {
lintOptions {
abortOnError false
}
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
minSdkVersion 16
targetSdkVersion @QT_ANDROID_NATIVE_API_LEVEL@
resConfigs "en"
}
}

View File

@ -8,8 +8,11 @@
"tool-prefix": "@QT_ANDROID_TOOL_PREFIX@",
"toolchain-version": "@QT_ANDROID_TOOLCHAIN_VERSION@",
"ndk-host": "@ANDROID_NDK_HOST_SYSTEM_NAME@",
"architectures": {
@QT_ANDROID_ARCHITECTURES@
},
"target-architecture": "@ANDROID_ABI@",
"application-binary": "@QT_ANDROID_APP_PATH@",
"application-binary": "@QT_ANDROID_APPLICATION_BINARY@",
"android-package": "@QT_ANDROID_APP_PACKAGE_NAME@",
"android-app-name": "@QT_ANDROID_APP_NAME@",
"qml-root-path": "@CMAKE_SOURCE_DIR@",