forked from qt-creator/qt-creator
AndroidPackageInstallationStep: Employ task tree for running
Task-number: QTCREATORBUG-29168 Change-Id: I18d1188a18559bb8030a2c966ea3764833ad96f8 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -122,53 +122,56 @@ 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;
|
||||
}
|
||||
using namespace Tasking;
|
||||
|
||||
QString error;
|
||||
for (const QString &dir : std::as_const(m_androidDirsToClean)) {
|
||||
FilePath androidDir = FilePath::fromString(dir);
|
||||
if (!dir.isEmpty() && androidDir.exists()) {
|
||||
emit addOutput(Tr::tr("Removing directory %1").arg(dir), OutputFormat::NormalMessage);
|
||||
if (!androidDir.removeRecursively(&error)) {
|
||||
reportWarningOrError(Tr::tr("Failed to clean \"%1\" from the previous build, with "
|
||||
"error:\n%2").arg(androidDir.toUserOutput()).arg(error),
|
||||
Task::TaskType::Error);
|
||||
emit finished(false);
|
||||
return;
|
||||
const auto onSetup = [this] {
|
||||
if (AndroidManager::skipInstallationAndPackageSteps(target())) {
|
||||
reportWarningOrError(Tr::tr("Product type is not an application, not running the "
|
||||
"Make install step."), Task::Warning);
|
||||
return SetupResult::StopWithDone;
|
||||
}
|
||||
|
||||
for (const QString &dir : std::as_const(m_androidDirsToClean)) {
|
||||
const FilePath androidDir = FilePath::fromString(dir);
|
||||
if (!dir.isEmpty() && androidDir.exists()) {
|
||||
emit addOutput(Tr::tr("Removing directory %1").arg(dir), OutputFormat::NormalMessage);
|
||||
QString error;
|
||||
if (!androidDir.removeRecursively(&error)) {
|
||||
reportWarningOrError(Tr::tr("Failed to clean \"%1\" from the previous build, "
|
||||
"with error:\n%2").arg(androidDir.toUserOutput()).arg(error),
|
||||
Task::TaskType::Error);
|
||||
return SetupResult::StopWithError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AbstractProcessStep::doRun();
|
||||
|
||||
// NOTE: This is a workaround for QTCREATORBUG-24155
|
||||
// Needed for Qt 5.15.0 and Qt 5.14.x versions
|
||||
if (buildType() == BuildConfiguration::BuildType::Debug) {
|
||||
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
|
||||
if (version && version->qtVersion() >= QVersionNumber(5, 14)
|
||||
&& version->qtVersion() <= QVersionNumber(5, 15, 0)) {
|
||||
const QString assetsDebugDir = nativeAndroidBuildPath().append(
|
||||
"/assets/--Added-by-androiddeployqt--/");
|
||||
QDir dir;
|
||||
if (!dir.exists(assetsDebugDir))
|
||||
dir.mkpath(assetsDebugDir);
|
||||
// NOTE: This is a workaround for QTCREATORBUG-24155
|
||||
// Needed for Qt 5.15.0 and Qt 5.14.x versions
|
||||
if (buildType() == BuildConfiguration::BuildType::Debug) {
|
||||
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
|
||||
if (version && version->qtVersion() >= QVersionNumber(5, 14)
|
||||
&& version->qtVersion() <= QVersionNumber(5, 15, 0)) {
|
||||
const QString assetsDebugDir = nativeAndroidBuildPath().append(
|
||||
"/assets/--Added-by-androiddeployqt--/");
|
||||
QDir dir;
|
||||
if (!dir.exists(assetsDebugDir))
|
||||
dir.mkpath(assetsDebugDir);
|
||||
|
||||
QFile file(assetsDebugDir + "debugger.command");
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
qCDebug(packageInstallationStepLog, "Successful added %s to the package.",
|
||||
qPrintable(file.fileName()));
|
||||
} else {
|
||||
qCDebug(packageInstallationStepLog,
|
||||
"Cannot add %s to the package. The QML debugger might not work properly.",
|
||||
qPrintable(file.fileName()));
|
||||
QFile file(assetsDebugDir + "debugger.command");
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
qCDebug(packageInstallationStepLog, "Successful added %s to the package.",
|
||||
qPrintable(file.fileName()));
|
||||
} else {
|
||||
qCDebug(packageInstallationStepLog,
|
||||
"Cannot add %s to the package. The QML debugger might not work properly.",
|
||||
qPrintable(file.fileName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SetupResult::Continue;
|
||||
};
|
||||
|
||||
runTaskTree({onGroupSetup(onSetup), defaultProcessTask()});
|
||||
}
|
||||
|
||||
void AndroidPackageInstallationStep::reportWarningOrError(const QString &message,
|
||||
|
Reference in New Issue
Block a user