forked from qt-creator/qt-creator
Android: Skip "Make Install" and "Build APK" if not ProductType::App
If the target's product type is not "App", the "Make Install" and "Build Android APK" build steps need to be skipped. Fixes: QTCREATORBUG-26980 Change-Id: Ia8bb61d407d040b851a74bad3d23876a7d31af73 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
@@ -711,6 +711,13 @@ void AndroidBuildApkStep::doRun()
|
||||
return;
|
||||
}
|
||||
|
||||
if (AndroidManager::skipInstallationAndPackageSteps(target())) {
|
||||
reportWarningOrError(Tr::tr("Product type is not an application, not building an APK."),
|
||||
Task::Warning);
|
||||
emit finished(true);
|
||||
return;
|
||||
}
|
||||
|
||||
auto setup = [this] {
|
||||
const auto androidAbis = AndroidManager::applicationAbis(target());
|
||||
const QString buildKey = target()->activeBuildKey();
|
||||
|
||||
@@ -359,6 +359,21 @@ Abi AndroidManager::androidAbi2Abi(const QString &androidAbi)
|
||||
}
|
||||
}
|
||||
|
||||
bool AndroidManager::skipInstallationAndPackageSteps(const Target *target)
|
||||
{
|
||||
const Project *p = target->project();
|
||||
|
||||
const Core::Context cmakeCtx = Core::Context(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||
const bool isCmakeProject = p->projectContext() == cmakeCtx;
|
||||
if (isCmakeProject)
|
||||
return false; // CMake reports ProductType::Other for Android Apps
|
||||
|
||||
const ProjectNode *n = p->rootProjectNode()->findProjectNode([] (const ProjectNode *n) {
|
||||
return n->productType() == ProductType::App;
|
||||
});
|
||||
return n == nullptr; // If no Application target found, then skip steps
|
||||
}
|
||||
|
||||
FilePath AndroidManager::manifestSourcePath(const Target *target)
|
||||
{
|
||||
if (const ProjectNode *node = currentProjectNode(target)) {
|
||||
|
||||
@@ -82,6 +82,7 @@ public:
|
||||
static bool matchedAbis(const QStringList &deviceAbis, const QStringList &appAbis);
|
||||
static QString devicePreferredAbi(const QStringList &deviceAbis, const QStringList &appAbis);
|
||||
static ProjectExplorer::Abi androidAbi2Abi(const QString &androidAbi);
|
||||
static bool skipInstallationAndPackageSteps(const ProjectExplorer::Target *target);
|
||||
|
||||
static QString androidNameForApiLevel(int x);
|
||||
|
||||
|
||||
@@ -122,6 +122,14 @@ void AndroidPackageInstallationStep::setupOutputFormatter(OutputFormatter *forma
|
||||
|
||||
void AndroidPackageInstallationStep::doRun()
|
||||
{
|
||||
if (AndroidManager::skipInstallationAndPackageSteps(target())) {
|
||||
reportWarningOrError(Tr::tr("Product type is not an application, not running the "
|
||||
"Make install step."),
|
||||
Task::Warning);
|
||||
emit finished(true);
|
||||
return;
|
||||
}
|
||||
|
||||
QString error;
|
||||
for (const QString &dir : std::as_const(m_androidDirsToClean)) {
|
||||
FilePath androidDir = FilePath::fromString(dir);
|
||||
|
||||
Reference in New Issue
Block a user