Android toolchain: allow to specify extra libs manually
ClosedPublic

Authored by alexeymin on May 29 2018, 3:36 PM.

Details

Summary

Add new variable ANDROID_EXTRA_LIBS, which can contain list of full paths to libs to include in resulting APK file. This can be used to include plugins that are not directly liked to executable, for example OpenSSL libs for QtNetwork SSL/HTTPS support.

Test Plan

Build project with -DANDROID_EXTRA_LIBS="/path/to/lib.so;/path/to/other_lib.so". Build without it. In both cases verify APK contents.

Diff Detail

Repository
R240 Extra CMake Modules
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
alexeymin created this revision.May 29 2018, 3:36 PM
Restricted Application added projects: Frameworks, Build System. · View Herald TranscriptMay 29 2018, 3:36 PM
Restricted Application added a subscriber: kde-buildsystem. · View Herald Transcript
alexeymin requested review of this revision.May 29 2018, 3:36 PM

http://doc.qt.io/qt-5/deployment-android.html at the bottom of the page there is an example of usage scenario for qmake project:

ANDROID_EXTRA_LIBS: A list of external libraries that will be copied into your application's library folder and loaded on start-up. This can be used, for instance, to enable OpenSSL in your application. Simply set the paths to the required libssl.so and libcrypto.so libraries here and OpenSSL should be enabled automatically.

In Qt Creator you can manually specify extra libs in project build settings:


After that, the following is added to *.pro file for qmake:

contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
    ANDROID_EXTRA_LIBS = \
        $$PWD/android/arm-linux-androideabi-4.9/libcrypto.so \
        $$PWD/android/arm-linux-androideabi-4.9/libssl.so
}

With this variable qmake generates a proper JSON file for androiddeplyoqt, containing "android-extra-libs" with full path to specified libs, and so they are included in result APK.

Step above work for qmake project. For cmake, using ECM Android toolchain file you have no way to specify dependencies manually, without this patch.

apol accepted this revision.May 30 2018, 11:16 PM

Interesting! This is probably a better way to solve the problem than the CMAKE_EXE_LINKER_FLAGS workaround we are doing currently.

https://phabricator.kde.org/source/sysadmin-binary-factory-tooling/browse/master/android/current-jobs.json;ea960395b94d5af18cb7d9af8d80fde87019f471$8

This revision is now accepted and ready to land.May 30 2018, 11:16 PM
Closed by commit R240:0dc051905ae9: Android toolchain: allow to specify extra libs manually (authored by Alexey Minnekhanov <a.minnekhanov@omprussia.ru>, committed by alexeymin). · Explain WhyMay 31 2018, 8:10 AM
This revision was automatically updated to reflect the committed changes.