Commit 85fff529 authored by BogDan Vatra's avatar BogDan Vatra

Use androiddeployqt to install the package when using Qt >= 5.4

On Qt < 5.4 androiddeployqt can't be used to only install the package
(and qt libs if the debug deployment was chose).

Change-Id: Ia7939e7988163ec04bdc7a927fd3a89e4d824782
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent d7449a00
......@@ -36,6 +36,7 @@
#include "javaparser.h"
#include "androidmanager.h"
#include "androidconstants.h"
#include "androidglobal.h"
#include <coreplugin/fileutils.h>
#include <coreplugin/icore.h>
......@@ -202,19 +203,66 @@ bool AndroidDeployQtStep::init()
return false;
}
}
ProjectExplorer::ProcessParameters *pp = processParameters();
pp->setCommand(AndroidConfigurations::currentConfig().adbToolPath().toString());
m_useAndroiddeployqt = version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0);
if (m_useAndroiddeployqt) {
AndroidBuildApkStep *androidBuildApkStep
= AndroidGlobal::buildStep<AndroidBuildApkStep>(target()->activeBuildConfiguration());
if (!androidBuildApkStep) {
emit addOutput(tr("Cannot find the android build step."), ErrorOutput);
return false;
}
Utils::FileName tmp = AndroidManager::androidQtSupport(target())->androiddeployqtPath(target());
if (tmp.isEmpty()) {
emit addOutput(tr("Cannot find the androiddeployqt tool."), ErrorOutput);
return false;
}
pp->setCommand(tmp.toString());
const QString output(bc->buildDirectory().appendPath(QLatin1String(Constants::ANDROID_BUILDDIRECTORY)).toString());
pp->setWorkingDirectory(output);
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--verbose"));
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--output"));
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, output);
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--no-build"));
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--input"));
tmp = AndroidManager::androidQtSupport(target())->androiddeployJsonPath(target());
if (tmp.isEmpty()) {
emit addOutput(tr("Cannot find the androiddeploy Json file."), ErrorOutput);
return false;
}
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, tmp.toString());
if (m_uninstallPreviousPackageRun)
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--install"));
else
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--reinstall"));
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--deployment"));
switch (androidBuildApkStep->deployAction()) {
case AndroidBuildApkStep::MinistroDeployment:
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("ministro"));
break;
case AndroidBuildApkStep::DebugDeployment:
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("debug"));
break;
case AndroidBuildApkStep::BundleLibrariesDeployment:
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("bundled"));
break;
}
} else {
pp->setCommand(AndroidConfigurations::currentConfig().adbToolPath().toString());
m_apkPath = AndroidManager::androidQtSupport(target())->apkPath(target(), AndroidManager::signPackage(target())
? AndroidQtSupport::ReleaseBuildSigned
: AndroidQtSupport::DebugBuild).toString();
pp->setWorkingDirectory(bc->buildDirectory().toString());
}
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString());
Utils::Environment env = bc->environment();
pp->setEnvironment(env);
m_apkPath = AndroidManager::androidQtSupport(target())->apkPath(target(), AndroidManager::signPackage(target())
? AndroidQtSupport::ReleaseBuildSigned
: AndroidQtSupport::DebugBuild).toString();
m_buildDirectory = bc->buildDirectory().toString();
bool result = AbstractProcessStep::init();
if (!result)
return false;
......@@ -238,22 +286,30 @@ void AndroidDeployQtStep::run(QFutureInterface<bool> &fi)
AndroidManager::setDeviceSerialNumber(target(), serialNumber);
}
if (m_uninstallPreviousPackageRun) {
emit addOutput(tr("Uninstall previous package %1.").arg(m_packageName), MessageOutput);
runCommand(AndroidConfigurations::currentConfig().adbToolPath().toString(),
AndroidDeviceInfo::adbSelector(m_serialNumber)
<< QLatin1String("uninstall") << m_packageName);
}
ProjectExplorer::ProcessParameters *pp = processParameters();
QString args;
foreach (const QString &arg, AndroidDeviceInfo::adbSelector(m_serialNumber))
Utils::QtcProcess::addArg(&args, arg);
Utils::QtcProcess::addArg(&args, QLatin1String("install"));
Utils::QtcProcess::addArg(&args, QLatin1String("-r"));
Utils::QtcProcess::addArg(&args, m_apkPath);
pp->setArguments(args);
if (m_useAndroiddeployqt) {
if (!m_serialNumber.isEmpty() && !m_serialNumber.startsWith(QLatin1String("????"))) {
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--device"));
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, m_serialNumber);
}
pp->setArguments(m_androiddeployqtArgs);
} else {
if (m_uninstallPreviousPackageRun) {
emit addOutput(tr("Uninstall previous package %1.").arg(m_packageName), MessageOutput);
runCommand(AndroidConfigurations::currentConfig().adbToolPath().toString(),
AndroidDeviceInfo::adbSelector(m_serialNumber)
<< QLatin1String("uninstall") << m_packageName);
}
QString args;
foreach (const QString &arg, AndroidDeviceInfo::adbSelector(m_serialNumber))
Utils::QtcProcess::addArg(&args, arg);
Utils::QtcProcess::addArg(&args, QLatin1String("install"));
Utils::QtcProcess::addArg(&args, QLatin1String("-r"));
Utils::QtcProcess::addArg(&args, m_apkPath);
pp->setArguments(args);
}
pp->resolveAll();
AbstractProcessStep::run(fi);
......
......@@ -31,6 +31,7 @@
#ifndef ANDROIDDEPLOYQTSTEP_H
#define ANDROIDDEPLOYQTSTEP_H
#include "androidbuildapkstep.h"
#include "androidconfigurations.h"
#include <projectexplorer/abstractprocessstep.h>
......@@ -108,6 +109,9 @@ private:
bool m_uninstallPreviousPackageRun;
static const Core::Id Id;
bool m_installOk;
bool m_useAndroiddeployqt;
AndroidBuildApkStep::AndroidDeployAction m_deployAction;
QString m_androiddeployqtArgs;
};
}
......
......@@ -39,7 +39,6 @@
AndroidGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)
namespace Android {
namespace Internal {
class AndroidGlobal
{
......@@ -78,7 +77,6 @@ public:
}
};
} // namespace Internal
} // namespace Android
#endif // ANDROIDGLOBAL_H
......@@ -63,6 +63,8 @@ public:
virtual QStringList soLibSearchPath(const ProjectExplorer::Target *target) const = 0;
virtual QStringList projectTargetApplications(const ProjectExplorer::Target *target) const = 0;
virtual Utils::FileName apkPath(ProjectExplorer::Target *target, BuildType buildType) const = 0;
virtual Utils::FileName androiddeployqtPath(ProjectExplorer::Target *target) const = 0;
virtual Utils::FileName androiddeployJsonPath(ProjectExplorer::Target *target) const = 0;
virtual void resetBuild(const ProjectExplorer::Target *target) = 0;
};
......
......@@ -28,9 +28,11 @@
****************************************************************************/
#include "androidpackageinstallationstep.h"
#include "qmakeandroidbuildapkstep.h"
#include "qmakeandroidsupport.h"
#include <android/androidconstants.h>
#include <android/androidglobal.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/deployconfiguration.h>
......@@ -108,6 +110,39 @@ Utils::FileName QmakeAndroidSupport::apkPath(ProjectExplorer::Target *target, An
.arg(buildTypeName));
}
Utils::FileName QmakeAndroidSupport::androiddeployqtPath(ProjectExplorer::Target *target) const
{
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target->kit());
if (!version)
return Utils::FileName();
QString command = version->qmakeProperty("QT_HOST_BINS");
if (!command.endsWith(QLatin1Char('/')))
command += QLatin1Char('/');
command += Utils::HostOsInfo::withExecutableSuffix(QLatin1String("androiddeployqt"));
return Utils::FileName::fromString(command);
}
Utils::FileName QmakeAndroidSupport::androiddeployJsonPath(ProjectExplorer::Target *target) const
{
const auto *pro = static_cast<QmakeProjectManager::QmakeProject *>(target->project());
QmakeAndroidBuildApkStep *buildApkStep
= Android::AndroidGlobal::buildStep<QmakeAndroidBuildApkStep>(target->activeBuildConfiguration());
if (!buildApkStep) // should never happen
return Utils::FileName();
const QmakeProjectManager::QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(buildApkStep->proFilePathForInputFile());
if (!node) // should never happen
return Utils::FileName();
QString inputFile = node->singleVariableValue(QmakeProjectManager::AndroidDeploySettingsFile);
if (inputFile.isEmpty()) // should never happen
return Utils::FileName();
return Utils::FileName::fromString(inputFile);
}
void QmakeAndroidSupport::resetBuild(const ProjectExplorer::Target *target)
{
QmakeBuildConfiguration *bc = qobject_cast<QmakeBuildConfiguration*>(target->activeBuildConfiguration());
......
......@@ -43,6 +43,8 @@ public:
QStringList soLibSearchPath(const ProjectExplorer::Target *target) const;
QStringList projectTargetApplications(const ProjectExplorer::Target *target) const;
Utils::FileName apkPath(ProjectExplorer::Target *target, BuildType buildType) const;
Utils::FileName androiddeployqtPath(ProjectExplorer::Target *target) const;
Utils::FileName androiddeployJsonPath(ProjectExplorer::Target *target) const;
void resetBuild(const ProjectExplorer::Target *target);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment