forked from qt-creator/qt-creator
AndroidBuildApkStep: Employ task tree for running
Task-number: QTCREATORBUG-29168 Change-Id: I40fb62ae33e436ba79cad852bf4661f72fb45bda Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -484,11 +484,6 @@ AndroidBuildApkStep::AndroidBuildApkStep(BuildStepList *parent, Utils::Id id)
|
||||
if (format == OutputFormat::Stderr)
|
||||
stdError(string);
|
||||
});
|
||||
|
||||
setDoneHook([this](bool success) {
|
||||
if (m_openPackageLocationForRun && success)
|
||||
QTimer::singleShot(0, this, &AndroidBuildApkStep::showInGraphicalShell);
|
||||
});
|
||||
}
|
||||
|
||||
bool AndroidBuildApkStep::init()
|
||||
@@ -703,24 +698,9 @@ static bool copyFileIfNewer(const FilePath &sourceFilePath,
|
||||
|
||||
void AndroidBuildApkStep::doRun()
|
||||
{
|
||||
if (m_skipBuilding) {
|
||||
reportWarningOrError(Tr::tr("Android deploy settings file not found, not building an APK."),
|
||||
Task::Error);
|
||||
emit finished(true);
|
||||
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();
|
||||
using namespace Tasking;
|
||||
|
||||
const auto setupHelper = [this] {
|
||||
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
|
||||
if (!version) {
|
||||
reportWarningOrError(Tr::tr("The Qt version for kit %1 is invalid.")
|
||||
@@ -728,6 +708,8 @@ void AndroidBuildApkStep::doRun()
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto androidAbis = AndroidManager::applicationAbis(target());
|
||||
const QString buildKey = target()->activeBuildKey();
|
||||
const FilePath buildDir = buildDirectory();
|
||||
const FilePath androidBuildDir = AndroidManager::androidBuildDirectory(target());
|
||||
for (const auto &abi : androidAbis) {
|
||||
@@ -758,10 +740,9 @@ void AndroidBuildApkStep::doRun()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool inputExists = m_inputFile.exists();
|
||||
const bool inputExists = m_inputFile.exists();
|
||||
if (inputExists && !AndroidManager::isQtCreatorGenerated(m_inputFile))
|
||||
return true; // use the generated file if it was not generated by qtcreator
|
||||
|
||||
@@ -819,15 +800,15 @@ void AndroidBuildApkStep::doRun()
|
||||
}
|
||||
deploySettings["application-binary"] = applicationBinary;
|
||||
|
||||
QString extraLibs = bs->extraData(buildKey, Android::Constants::AndroidExtraLibs).toString();
|
||||
const QString extraLibs = bs->extraData(buildKey, Android::Constants::AndroidExtraLibs).toString();
|
||||
if (!extraLibs.isEmpty())
|
||||
deploySettings["android-extra-libs"] = extraLibs;
|
||||
|
||||
QString androidSrcs = bs->extraData(buildKey, Android::Constants::AndroidPackageSourceDir).toString();
|
||||
const QString androidSrcs = bs->extraData(buildKey, Android::Constants::AndroidPackageSourceDir).toString();
|
||||
if (!androidSrcs.isEmpty())
|
||||
deploySettings["android-package-source-directory"] = androidSrcs;
|
||||
|
||||
QString qmlImportPath = bs->extraData(buildKey, "QML_IMPORT_PATH").toString();
|
||||
const QString qmlImportPath = bs->extraData(buildKey, "QML_IMPORT_PATH").toString();
|
||||
if (!qmlImportPath.isEmpty())
|
||||
deploySettings["qml-import-paths"] = qmlImportPath;
|
||||
|
||||
@@ -846,14 +827,34 @@ void AndroidBuildApkStep::doRun()
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!setup()) {
|
||||
reportWarningOrError(Tr::tr("Cannot set up \"%1\", not building an APK.").arg(displayName()),
|
||||
Task::Error);
|
||||
emit finished(false);
|
||||
return;
|
||||
const auto onSetup = [this, setupHelper] {
|
||||
if (m_skipBuilding) {
|
||||
reportWarningOrError(Tr::tr("Android deploy settings file not found, "
|
||||
"not building an APK."), Task::Error);
|
||||
return SetupResult::StopWithDone;
|
||||
}
|
||||
if (AndroidManager::skipInstallationAndPackageSteps(target())) {
|
||||
reportWarningOrError(Tr::tr("Product type is not an application, not building an APK."),
|
||||
Task::Warning);
|
||||
return SetupResult::StopWithDone;
|
||||
}
|
||||
if (setupHelper())
|
||||
return SetupResult::Continue;
|
||||
reportWarningOrError(Tr::tr("Cannot set up \"%1\", not building an APK.")
|
||||
.arg(displayName()), Task::Error);
|
||||
return SetupResult::StopWithError;
|
||||
};
|
||||
const auto onDone = [this] {
|
||||
if (m_openPackageLocationForRun)
|
||||
QTimer::singleShot(0, this, &AndroidBuildApkStep::showInGraphicalShell);
|
||||
};
|
||||
|
||||
AbstractProcessStep::doRun();
|
||||
const Group root {
|
||||
onGroupSetup(onSetup),
|
||||
onGroupDone(onDone),
|
||||
defaultProcessTask()
|
||||
};
|
||||
runTaskTree(root);
|
||||
}
|
||||
|
||||
void AndroidBuildApkStep::reportWarningOrError(const QString &message, Task::TaskType type)
|
||||
|
Reference in New Issue
Block a user