forked from qt-creator/qt-creator
Android: expose deployment warnings and errors to issues pane
This makes the deployment process more transparent and easy to follow warnings and/or errors. Change-Id: Ie6a7bde4dfb5748adff1be077299ecdceb0e3930 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
@@ -133,9 +134,11 @@ bool AndroidBuildApkStep::init()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buildType() != BuildConfiguration::Release)
|
||||
emit addOutput(tr("Warning: Signing a debug or profile package."),
|
||||
OutputFormat::ErrorMessage);
|
||||
if (buildType() != BuildConfiguration::Release) {
|
||||
const QString error = tr("Warning: Signing a debug or profile package.");
|
||||
emit addOutput(error, OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Warning, error));
|
||||
}
|
||||
}
|
||||
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
|
||||
@@ -146,23 +149,33 @@ bool AndroidBuildApkStep::init()
|
||||
if (sdkToolsVersion >= gradleScriptRevokedSdkVersion
|
||||
|| AndroidConfigurations::currentConfig().isCmdlineSdkToolsInstalled()) {
|
||||
if (!version->sourcePath().pathAppended("src/3rdparty/gradle").exists()) {
|
||||
emit addOutput(tr("The installed SDK tools version (%1) does not include Gradle "
|
||||
"scripts. The minimum Qt version required for Gradle build to work "
|
||||
"is %2").arg(sdkToolsVersion.toString()).arg("5.9.0/5.6.3"),
|
||||
OutputFormat::Stderr);
|
||||
const QString error
|
||||
= tr("The installed SDK tools version (%1) does not include Gradle "
|
||||
"scripts. The minimum Qt version required for Gradle build to work "
|
||||
"is %2")
|
||||
.arg(sdkToolsVersion.toString())
|
||||
.arg("5.9.0/5.6.3");
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
} else if (version->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) {
|
||||
emit addOutput(tr("The minimum Qt version required for Gradle build to work is %1. "
|
||||
"It is recommended to install the latest Qt version.")
|
||||
.arg("5.4.0"), OutputFormat::Stderr);
|
||||
const QString error = tr("The minimum Qt version required for Gradle build to work is %1. "
|
||||
"It is recommended to install the latest Qt version.")
|
||||
.arg("5.4.0");
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
|
||||
const int minSDKForKit = AndroidManager::minimumSDK(kit());
|
||||
if (AndroidManager::minimumSDK(target()) < minSDKForKit) {
|
||||
emit addOutput(tr("The API level set for the APK is less than the minimum required by the kit."
|
||||
"\nThe minimum API level required by the kit is %1.").arg(minSDKForKit), OutputFormat::Stderr);
|
||||
const QString error
|
||||
= tr("The API level set for the APK is less than the minimum required by the kit."
|
||||
"\nThe minimum API level required by the kit is %1.")
|
||||
.arg(minSDKForKit);
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -203,8 +216,9 @@ bool AndroidBuildApkStep::init()
|
||||
m_skipBuilding = false;
|
||||
|
||||
if (m_buildTargetSdk.isEmpty()) {
|
||||
emit addOutput(tr("Android build SDK not defined. Check Android settings."),
|
||||
OutputFormat::Stderr);
|
||||
const QString error = tr("Android build SDK not defined. Check Android settings.");
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -295,8 +309,10 @@ void AndroidBuildApkStep::processFinished(int exitCode, QProcess::ExitStatus sta
|
||||
bool AndroidBuildApkStep::verifyKeystorePassword()
|
||||
{
|
||||
if (!m_keystorePath.exists()) {
|
||||
emit addOutput(tr("Cannot sign the package. Invalid keystore path (%1).")
|
||||
.arg(m_keystorePath.toString()), OutputFormat::ErrorMessage);
|
||||
const QString error = tr("Cannot sign the package. Invalid keystore path (%1).")
|
||||
.arg(m_keystorePath.toString());
|
||||
emit addOutput(error, OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -315,8 +331,10 @@ bool AndroidBuildApkStep::verifyCertificatePassword()
|
||||
{
|
||||
if (!AndroidManager::checkCertificateExists(m_keystorePath.toString(), m_keystorePasswd,
|
||||
m_certificateAlias)) {
|
||||
emit addOutput(tr("Cannot sign the package. Certificate alias %1 does not exist.")
|
||||
.arg(m_certificateAlias), OutputFormat::ErrorMessage);
|
||||
const QString error = tr("Cannot sign the package. Certificate alias %1 does not exist.")
|
||||
.arg(m_certificateAlias);
|
||||
emit addOutput(error, OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -359,7 +377,9 @@ static bool copyFileIfNewer(const QString &sourceFileName,
|
||||
void AndroidBuildApkStep::doRun()
|
||||
{
|
||||
if (m_skipBuilding) {
|
||||
emit addOutput(tr("Android deploy settings file not found, not building an APK."), BuildStep::OutputFormat::ErrorMessage);
|
||||
const QString error = tr("Android deploy settings file not found, not building an APK.");
|
||||
emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
emit finished(true);
|
||||
return;
|
||||
}
|
||||
@@ -449,7 +469,9 @@ void AndroidBuildApkStep::doRun()
|
||||
};
|
||||
|
||||
if (!setup()) {
|
||||
emit addOutput(tr("Cannot set up Android, not building an APK."), BuildStep::OutputFormat::ErrorMessage);
|
||||
const QString error = tr("Cannot set up Android, not building an APK.");
|
||||
emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
emit finished(false);
|
||||
return;
|
||||
}
|
||||
@@ -502,6 +524,18 @@ void AndroidBuildApkStep::setBuildTargetSdk(const QString &sdk)
|
||||
m_buildTargetSdk = sdk;
|
||||
}
|
||||
|
||||
void AndroidBuildApkStep::stdError(const QString &output)
|
||||
{
|
||||
AbstractProcessStep::stdError(output);
|
||||
if (output == "\n")
|
||||
return;
|
||||
|
||||
if (output.startsWith("warning", Qt::CaseInsensitive) || output.startsWith("note", Qt::CaseInsensitive))
|
||||
TaskHub::addTask(BuildSystemTask(Task::Warning, output));
|
||||
else
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, output));
|
||||
}
|
||||
|
||||
QVariant AndroidBuildApkStep::data(Utils::Id id) const
|
||||
{
|
||||
if (id == Constants::AndroidNdkPlatform) {
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
QString buildTargetSdk() const;
|
||||
void setBuildTargetSdk(const QString &sdk);
|
||||
|
||||
void stdError(const QString &output) override;
|
||||
|
||||
QVariant data(Utils::Id id) const override;
|
||||
private:
|
||||
void showInGraphicalShell();
|
||||
|
||||
@@ -111,7 +111,9 @@ bool AndroidDeployQtStep::init()
|
||||
|
||||
m_androidABIs = AndroidManager::applicationAbis(target());
|
||||
if (m_androidABIs.isEmpty()) {
|
||||
emit addOutput(tr("No Android arch set by the .pro file."), OutputFormat::Stderr);
|
||||
const QString error = tr("No Android arch set by the .pro file.");
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,12 +189,16 @@ bool AndroidDeployQtStep::init()
|
||||
} else {
|
||||
QString jsonFile = node->data(Constants::AndroidDeploySettingsFile).toString();
|
||||
if (jsonFile.isEmpty()) {
|
||||
emit addOutput(tr("Cannot find the androiddeploy Json file."), OutputFormat::Stderr);
|
||||
const QString error = tr("Cannot find the androiddeploy Json file.");
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
m_command = version->hostBinPath();
|
||||
if (m_command.isEmpty()) {
|
||||
emit addOutput(tr("Cannot find the androiddeployqt tool."), OutputFormat::Stderr);
|
||||
const QString error = tr("Cannot find the androiddeployqt tool.");
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
return false;
|
||||
}
|
||||
m_command = m_command.pathAppended(HostOsInfo::withExecutableSuffix("androiddeployqt"));
|
||||
@@ -252,7 +258,9 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
||||
if (m_uninstallPreviousPackageRun) {
|
||||
packageName = AndroidManager::packageName(m_manifestName);
|
||||
if (packageName.isEmpty()) {
|
||||
emit addOutput(tr("Cannot find the package name."), OutputFormat::Stderr);
|
||||
const QString error = tr("Cannot find the package name.");
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
return Failure;
|
||||
}
|
||||
qCDebug(deployStepLog) << "Uninstalling previous package";
|
||||
@@ -316,12 +324,14 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
||||
emit addOutput(tr("The process \"%1\" exited normally.").arg(m_command.toUserOutput()),
|
||||
BuildStep::OutputFormat::NormalMessage);
|
||||
} else if (exitStatus == QProcess::NormalExit) {
|
||||
emit addOutput(tr("The process \"%1\" exited with code %2.")
|
||||
.arg(m_command.toUserOutput(), QString::number(exitCode)),
|
||||
BuildStep::OutputFormat::ErrorMessage);
|
||||
const QString error = tr("The process \"%1\" exited with code %2.")
|
||||
.arg(m_command.toUserOutput(), QString::number(exitCode));
|
||||
emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
} else {
|
||||
emit addOutput(tr("The process \"%1\" crashed.").arg(m_command.toUserOutput()),
|
||||
BuildStep::OutputFormat::ErrorMessage);
|
||||
const QString error = tr("The process \"%1\" crashed.").arg(m_command.toUserOutput());
|
||||
emit addOutput(error, BuildStep::OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
}
|
||||
|
||||
if (deployError != NoError) {
|
||||
@@ -404,9 +414,11 @@ bool AndroidDeployQtStep::runImpl()
|
||||
AndroidDeviceInfo::adbSelector(m_serialNumber)
|
||||
<< "pull" << itr.key() << itr.value()});
|
||||
if (!QFileInfo::exists(itr.value())) {
|
||||
emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
|
||||
.arg(itr.key())
|
||||
.arg(itr.value()), OutputFormat::ErrorMessage);
|
||||
const QString error = tr("Package deploy: Failed to pull \"%1\" to \"%2\".")
|
||||
.arg(itr.key())
|
||||
.arg(itr.value());
|
||||
emit addOutput(error, OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,9 +469,11 @@ void AndroidDeployQtStep::runCommand(const CommandLine &command)
|
||||
emit addOutput(tr("Package deploy: Running command \"%1\".").arg(command.toUserOutput()),
|
||||
OutputFormat::NormalMessage);
|
||||
SynchronousProcessResponse response = buildProc.run(command);
|
||||
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0)
|
||||
emit addOutput(response.exitMessage(command.executable().toString(), 2 * 60),
|
||||
OutputFormat::ErrorMessage);
|
||||
if (response.result != SynchronousProcessResponse::Finished || response.exitCode != 0) {
|
||||
const QString error = response.exitMessage(command.executable().toString(), 2 * 60);
|
||||
emit addOutput(error, OutputFormat::ErrorMessage);
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, error));
|
||||
}
|
||||
}
|
||||
|
||||
BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget()
|
||||
@@ -533,6 +547,13 @@ void AndroidDeployQtStep::processReadyReadStdError(DeployErrorCode &errorCode)
|
||||
void AndroidDeployQtStep::stdError(const QString &line)
|
||||
{
|
||||
emit addOutput(line, BuildStep::OutputFormat::Stderr, BuildStep::DontAppendNewline);
|
||||
if (line == "\n")
|
||||
return;
|
||||
|
||||
if (line.startsWith("warning", Qt::CaseInsensitive) || line.startsWith("note", Qt::CaseInsensitive))
|
||||
TaskHub::addTask(DeploymentTask(Task::Warning, line));
|
||||
else
|
||||
TaskHub::addTask(DeploymentTask(Task::Error, line));
|
||||
}
|
||||
|
||||
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::parseDeployErrors(QString &deployOutputLine) const
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/taskhub.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
@@ -139,6 +140,7 @@ void AndroidPackageInstallationStep::doRun()
|
||||
emit addOutput(tr("Removing directory %1").arg(dir), OutputFormat::NormalMessage);
|
||||
if (!FileUtils::removeRecursively(androidDir, &error)) {
|
||||
emit addOutput(error, OutputFormat::Stderr);
|
||||
TaskHub::addTask(BuildSystemTask(Task::Error, error));
|
||||
emit finished(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user