Qt Creator: cross-plugin dependency, specifically between Android and Qbs plugins
-
I'm working on Android Qbs support.
Currently Qbs has very primitive support of Android APK. You cannot build Qt Android application using Qbs. Moreover, if you build non-Qt Android APK you will not be able to deploy/run/debug it using Qt Creator.I have just finished building problem. So I introduced several Qbs modules which allow me to build Qt Android application with all required Qt libraries and assets packaged.
Now I'm trying to integrate this into QtCreator.Current implementation of Android plugin fails to deploy the project in AndroidDeployQtStep::init. This step tries to find AndroidBuildApkStep in build configuration, but it is absent because apk was built using Qbs.
Luckily the only important information from AndroidBuildApkStep is APK path. So AndroidDeployQtStep might be re-implemented without AndroidBuildApkStep dependency quite easy.However I still need to know apk path. Qbs uses complex build folders structure, so I cannot just combine general buildPath with some project name to get apk path. I have to analyze Qbs project for that.
The code is quite simple here:
bool AndroidQbsDeployQtStep::init() { ....... QbsProjectManager::Internal::QbsProject *pro = static_cast<QbsProjectManager::Internal::QbsProject *>(target()->project()); foreach (const qbs::ProductData &product, pro->qbsProjectData().allProducts()) { if (product.type().contains(QStringLiteral("android.apk"))) { m_apkPath = pro->qbsProject().targetExecutable(product, qbs::InstallOptions()); } } ...... }
It casts target()->project() to QbsProjectManager::Internal::QbsProject (I cheched - I really have QbsProject in target()->project()). Then it iterates over all Qbs products to find Android APK and gets artifact path.
Unfortunately I'm not able to build this code, because AndroidQbsDeployQtStep and QbsProject live in different plugins - I'm getting link errors. Moreover both are Internal classes. I tried to add qbsprojectmanager dependency to android_dependencies.pri but this doesn't help.
I have several questions:
- Is it correct approach to introduce a new deployment step in Android plugin?
- How to get access to QbsProject instance which is hidden target()->project()?
- Maybe I need to extend Qbs plugin as well? For example add some interface for getting build artifact path to QbsBuildStep?
Environment:
- Ubuntu 15.04 x64
- QtCreator 3.4.0 x64
- Qt 5.4.1 x64
- QBS 1.4.0 x64