forked from qt-creator/qt-creator
ProjectExplorer/Android: Some more use of Utils::CommandLine
And surrounding cosmetics. Change-Id: Iad3d2d43856b1fcd9530d4a209fff9887e6cec42 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -1536,4 +1536,9 @@ void CommandLine::addArgs(const QString &inArgs)
|
|||||||
QtcProcess::addArgs(&m_arguments, inArgs);
|
QtcProcess::addArgs(&m_arguments, inArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CommandLine::toUserOutput() const
|
||||||
|
{
|
||||||
|
return m_executable.toUserOutput() + ' ' + m_arguments;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public:
|
|||||||
void addArgs(const QStringList &inArgs);
|
void addArgs(const QStringList &inArgs);
|
||||||
void addArgs(const QString &inArgs);
|
void addArgs(const QString &inArgs);
|
||||||
|
|
||||||
|
QString toUserOutput() const;
|
||||||
|
|
||||||
FilePath executable() const { return m_executable; }
|
FilePath executable() const { return m_executable; }
|
||||||
QString arguments() const { return m_arguments; }
|
QString arguments() const { return m_arguments; }
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,10 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Android;
|
using namespace Utils;
|
||||||
using namespace Android::Internal;
|
|
||||||
|
namespace Android {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Q_LOGGING_CATEGORY(deployStepLog, "qtc.android.build.androiddeployqtstep", QtWarningMsg)
|
Q_LOGGING_CATEGORY(deployStepLog, "qtc.android.build.androiddeployqtstep", QtWarningMsg)
|
||||||
@@ -169,7 +171,7 @@ Core::Id AndroidDeployQtStep::stepId()
|
|||||||
|
|
||||||
bool AndroidDeployQtStep::init()
|
bool AndroidDeployQtStep::init()
|
||||||
{
|
{
|
||||||
m_androiddeployqtArgs.clear();
|
m_androiddeployqtArgs = CommandLine();
|
||||||
|
|
||||||
m_targetArch = AndroidManager::targetArch(target());
|
m_targetArch = AndroidManager::targetArch(target());
|
||||||
if (m_targetArch.isEmpty()) {
|
if (m_targetArch.isEmpty()) {
|
||||||
@@ -256,31 +258,24 @@ bool AndroidDeployQtStep::init()
|
|||||||
|
|
||||||
m_workingDirectory = bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
|
m_workingDirectory = bc->buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
|
||||||
|
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--verbose"));
|
m_androiddeployqtArgs.addArgs({"--verbose",
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--output"));
|
"--output", m_workingDirectory,
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, m_workingDirectory);
|
"--no-build",
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--no-build"));
|
"--input", jsonFile});
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--input"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, jsonFile);
|
|
||||||
if (androidBuildApkStep && androidBuildApkStep->useMinistro()) {
|
if (androidBuildApkStep && androidBuildApkStep->useMinistro()) {
|
||||||
qCDebug(deployStepLog) << "Using ministro";
|
qCDebug(deployStepLog) << "Using ministro";
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--deployment"));
|
m_androiddeployqtArgs.addArgs({"--deployment", "ministro"});
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("ministro"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--gradle"));
|
m_androiddeployqtArgs.addArg("--gradle");
|
||||||
|
|
||||||
if (androidBuildApkStep && androidBuildApkStep->signPackage()) {
|
if (androidBuildApkStep && androidBuildApkStep->signPackage()) {
|
||||||
// The androiddeployqt tool is not really written to do stand-alone installations.
|
// The androiddeployqt tool is not really written to do stand-alone installations.
|
||||||
// This hack forces it to use the correct filename for the apk file when installing
|
// This hack forces it to use the correct filename for the apk file when installing
|
||||||
// as a temporary fix until androiddeployqt gets the support. Since the --sign is
|
// as a temporary fix until androiddeployqt gets the support. Since the --sign is
|
||||||
// only used to get the correct file name of the apk, its parameters are ignored.
|
// only used to get the correct file name of the apk, its parameters are ignored.
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--sign"));
|
m_androiddeployqtArgs.addArgs({"--sign", "foo", "bar"});
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("foo"));
|
|
||||||
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("bar"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -303,18 +298,17 @@ bool AndroidDeployQtStep::init()
|
|||||||
|
|
||||||
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
||||||
{
|
{
|
||||||
QString args;
|
CommandLine cmd(Utils::FilePath::fromString(m_command), {});
|
||||||
if (m_useAndroiddeployqt && m_apkPath.isEmpty()) {
|
if (m_useAndroiddeployqt && m_apkPath.isEmpty()) {
|
||||||
args = m_androiddeployqtArgs;
|
cmd = m_androiddeployqtArgs;
|
||||||
if (m_uninstallPreviousPackageRun)
|
if (m_uninstallPreviousPackageRun)
|
||||||
Utils::QtcProcess::addArg(&args, QLatin1String("--install"));
|
cmd.addArg("--install");
|
||||||
else
|
else
|
||||||
Utils::QtcProcess::addArg(&args, QLatin1String("--reinstall"));
|
cmd.addArg("--reinstall");
|
||||||
|
|
||||||
|
if (!m_serialNumber.isEmpty() && !m_serialNumber.startsWith("????"))
|
||||||
|
cmd.addArgs({"--device", m_serialNumber});
|
||||||
|
|
||||||
if (!m_serialNumber.isEmpty() && !m_serialNumber.startsWith(QLatin1String("????"))) {
|
|
||||||
Utils::QtcProcess::addArg(&args, QLatin1String("--device"));
|
|
||||||
Utils::QtcProcess::addArg(&args, m_serialNumber);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
RunConfiguration *rc = target()->activeRunConfiguration();
|
RunConfiguration *rc = target()->activeRunConfiguration();
|
||||||
QTC_ASSERT(rc, return DeployErrorCode::Failure);
|
QTC_ASSERT(rc, return DeployErrorCode::Failure);
|
||||||
@@ -357,16 +351,12 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
|||||||
<< QLatin1String("uninstall") << packageName);
|
<< QLatin1String("uninstall") << packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &arg, AndroidDeviceInfo::adbSelector(m_serialNumber))
|
cmd.addArgs(AndroidDeviceInfo::adbSelector(m_serialNumber));
|
||||||
Utils::QtcProcess::addArg(&args, arg);
|
cmd.addArgs({"install", "-r", m_apkPath.toString()});
|
||||||
|
|
||||||
Utils::QtcProcess::addArg(&args, QLatin1String("install"));
|
|
||||||
Utils::QtcProcess::addArg(&args, QLatin1String("-r"));
|
|
||||||
Utils::QtcProcess::addArg(&args, m_apkPath.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_process = new Utils::QtcProcess;
|
m_process = new Utils::QtcProcess;
|
||||||
m_process->setCommand(Utils::CommandLine(Utils::FilePath::fromString(m_command), args));
|
m_process->setCommand(cmd);
|
||||||
m_process->setWorkingDirectory(m_workingDirectory);
|
m_process->setWorkingDirectory(m_workingDirectory);
|
||||||
m_process->setEnvironment(m_environment);
|
m_process->setEnvironment(m_environment);
|
||||||
|
|
||||||
@@ -381,8 +371,7 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
|
|||||||
|
|
||||||
m_process->start();
|
m_process->start();
|
||||||
|
|
||||||
emit addOutput(tr("Starting: \"%1\" %2")
|
emit addOutput(tr("Starting: \"%1\"").arg(cmd.toUserOutput()),
|
||||||
.arg(QDir::toNativeSeparators(m_command), args),
|
|
||||||
BuildStep::OutputFormat::NormalMessage);
|
BuildStep::OutputFormat::NormalMessage);
|
||||||
|
|
||||||
while (!m_process->waitForFinished(200)) {
|
while (!m_process->waitForFinished(200)) {
|
||||||
@@ -641,3 +630,6 @@ AndroidDeployQtStep::UninstallType AndroidDeployQtStep::uninstallPreviousPackage
|
|||||||
return ForceUnintall;
|
return ForceUnintall;
|
||||||
return m_uninstallPreviousPackage ? Uninstall : Keep;
|
return m_uninstallPreviousPackage ? Uninstall : Keep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Internal
|
||||||
|
} // Android
|
||||||
|
|||||||
@@ -33,8 +33,7 @@
|
|||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
namespace Utils { class QtcProcess; }
|
|
||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -118,7 +117,7 @@ private:
|
|||||||
bool m_useAndroiddeployqt = false;
|
bool m_useAndroiddeployqt = false;
|
||||||
bool m_askForUninstall = false;
|
bool m_askForUninstall = false;
|
||||||
static const Core::Id Id;
|
static const Core::Id Id;
|
||||||
QString m_androiddeployqtArgs;
|
Utils::CommandLine m_androiddeployqtArgs;
|
||||||
QString m_adbPath;
|
QString m_adbPath;
|
||||||
QString m_command;
|
QString m_command;
|
||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
|
|||||||
Reference in New Issue
Block a user