2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
#include "androidpackageinstallationstep.h"
|
2014-06-25 15:42:11 +02:00
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
#include "androidconstants.h"
|
|
|
|
#include "androidmanager.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2020-02-20 17:02:59 +01:00
|
|
|
#include <projectexplorer/abstractprocessstep.h>
|
2013-06-04 16:42:26 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2020-02-20 17:02:59 +01:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <projectexplorer/gnumakeparser.h>
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
#include <projectexplorer/processparameters.h>
|
2016-12-16 00:43:14 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2020-02-20 17:02:59 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2013-10-10 16:12:16 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2017-12-07 15:30:16 +01:00
|
|
|
|
2020-07-03 19:57:35 +03:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
2013-06-04 16:42:26 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2013-06-04 16:42:26 +02:00
|
|
|
|
|
|
|
#include <QDir>
|
2020-07-03 19:57:35 +03:00
|
|
|
#include <QLoggingCategory>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
using namespace Utils;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2020-07-03 19:57:35 +03:00
|
|
|
namespace {
|
|
|
|
static Q_LOGGING_CATEGORY(packageInstallationStepLog, "qtc.android.packageinstallationstep", QtWarningMsg)
|
|
|
|
}
|
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
namespace Android {
|
2020-02-20 17:02:59 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
class AndroidPackageInstallationStep final : public AbstractProcessStep
|
|
|
|
{
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(Android::AndroidPackageInstallationStep)
|
|
|
|
|
|
|
|
public:
|
2020-07-28 17:28:51 +02:00
|
|
|
AndroidPackageInstallationStep(BuildStepList *bsl, Id id);
|
2020-02-20 17:02:59 +01:00
|
|
|
|
2020-06-15 14:51:00 +03:00
|
|
|
QString nativeAndroidBuildPath() const;
|
|
|
|
|
2020-02-20 17:02:59 +01:00
|
|
|
private:
|
|
|
|
bool init() final;
|
2020-07-28 17:28:51 +02:00
|
|
|
void setupOutputFormatter(OutputFormatter *formatter) final;
|
2020-02-20 17:02:59 +01:00
|
|
|
void doRun() final;
|
|
|
|
|
|
|
|
QStringList m_androidDirsToClean;
|
|
|
|
};
|
|
|
|
|
2020-07-28 17:28:51 +02:00
|
|
|
AndroidPackageInstallationStep::AndroidPackageInstallationStep(BuildStepList *bsl, Id id)
|
2019-12-20 17:05:30 +01:00
|
|
|
: AbstractProcessStep(bsl, id)
|
2012-05-25 16:21:19 +02:00
|
|
|
{
|
2012-08-09 01:56:51 +02:00
|
|
|
const QString name = tr("Copy application data");
|
2012-05-25 16:21:19 +02:00
|
|
|
setDefaultDisplayName(name);
|
|
|
|
setDisplayName(name);
|
2018-10-19 17:40:33 +02:00
|
|
|
setWidgetExpandedByDefault(false);
|
2018-10-22 17:56:04 +02:00
|
|
|
setImmutable(true);
|
2020-07-28 17:28:51 +02:00
|
|
|
setSummaryUpdater([this] {
|
|
|
|
return tr("<b>Make install:</b> Copy App Files to %1").arg(nativeAndroidBuildPath());
|
|
|
|
});
|
2020-08-13 16:47:33 +02:00
|
|
|
setUseEnglishOutput();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool AndroidPackageInstallationStep::init()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2020-02-18 18:25:26 +01:00
|
|
|
ToolChain *tc = ToolChainKitAspect::cxxToolChain(target()->kit());
|
2019-03-06 14:17:17 +02:00
|
|
|
QTC_ASSERT(tc, return false);
|
2013-10-10 16:12:16 +02:00
|
|
|
|
2020-06-15 14:51:00 +03:00
|
|
|
QString dirPath = nativeAndroidBuildPath();
|
2019-06-21 08:31:37 +02:00
|
|
|
const QString innerQuoted = QtcProcess::quoteArg(dirPath);
|
|
|
|
const QString outerQuoted = QtcProcess::quoteArg("INSTALL_ROOT=" + innerQuoted);
|
2020-06-15 14:51:00 +03:00
|
|
|
|
|
|
|
CommandLine cmd{tc->makeCommand(buildEnvironment())};
|
2019-06-21 08:31:37 +02:00
|
|
|
cmd.addArgs(outerQuoted + " install", CommandLine::Raw);
|
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
ProcessParameters *pp = processParameters();
|
2020-08-13 16:47:33 +02:00
|
|
|
setupProcessParameters(pp);
|
2019-06-21 08:31:37 +02:00
|
|
|
pp->setCommandLine(cmd);
|
2015-05-06 18:14:35 +02:00
|
|
|
|
2014-09-22 16:20:51 +03:00
|
|
|
m_androidDirsToClean.clear();
|
|
|
|
// don't remove gradle's cache, it takes ages to rebuild it.
|
2017-09-08 23:36:13 +02:00
|
|
|
m_androidDirsToClean << dirPath + "/assets";
|
|
|
|
m_androidDirsToClean << dirPath + "/libs";
|
2013-10-10 16:30:56 +02:00
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
return AbstractProcessStep::init();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2020-06-15 14:51:00 +03:00
|
|
|
QString AndroidPackageInstallationStep::nativeAndroidBuildPath() const
|
|
|
|
{
|
|
|
|
QString buildPath = buildDirectory().pathAppended(Constants::ANDROID_BUILDDIRECTORY).toString();
|
|
|
|
if (HostOsInfo::isWindowsHost())
|
|
|
|
if (buildEnvironment().searchInPath("sh.exe").isEmpty())
|
|
|
|
buildPath = QDir::toNativeSeparators(buildPath);
|
|
|
|
|
|
|
|
return buildPath;
|
|
|
|
}
|
|
|
|
|
2020-04-16 13:53:05 +02:00
|
|
|
void AndroidPackageInstallationStep::setupOutputFormatter(OutputFormatter *formatter)
|
|
|
|
{
|
|
|
|
formatter->addLineParser(new GnuMakeParser);
|
|
|
|
formatter->addLineParsers(target()->kit()->createOutputParsers());
|
|
|
|
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
|
|
|
|
AbstractProcessStep::setupOutputFormatter(formatter);
|
|
|
|
}
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void AndroidPackageInstallationStep::doRun()
|
2013-10-10 16:30:56 +02:00
|
|
|
{
|
|
|
|
QString error;
|
2014-09-22 16:20:51 +03:00
|
|
|
foreach (const QString &dir, m_androidDirsToClean) {
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath androidDir = FilePath::fromString(dir);
|
2014-10-24 13:15:54 +02:00
|
|
|
if (!dir.isEmpty() && androidDir.exists()) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Removing directory %1").arg(dir), OutputFormat::NormalMessage);
|
2017-12-07 15:30:16 +01:00
|
|
|
if (!FileUtils::removeRecursively(androidDir, &error)) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(error, OutputFormat::Stderr);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit finished(false);
|
2014-09-22 16:20:51 +03:00
|
|
|
return;
|
|
|
|
}
|
2013-10-10 16:30:56 +02:00
|
|
|
}
|
|
|
|
}
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
AbstractProcessStep::doRun();
|
2020-07-03 19:57:35 +03:00
|
|
|
|
|
|
|
// 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::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target()->kit());
|
|
|
|
if (version && version->qtVersion() >= QtSupport::QtVersionNumber{5, 14}
|
|
|
|
&& version->qtVersion() <= QtSupport::QtVersionNumber{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, "Cound't add %s to the package. The QML debugger might not work properly.", qPrintable(file.fileName()));
|
|
|
|
}
|
|
|
|
}
|
2013-10-10 16:30:56 +02:00
|
|
|
}
|
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
//
|
|
|
|
// AndroidPackageInstallationStepFactory
|
|
|
|
//
|
|
|
|
|
|
|
|
AndroidPackageInstallationFactory::AndroidPackageInstallationFactory()
|
|
|
|
{
|
|
|
|
registerStep<AndroidPackageInstallationStep>(Constants::ANDROID_PACKAGE_INSTALLATION_STEP_ID);
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
2017-12-19 10:32:39 +01:00
|
|
|
setSupportedDeviceType(Android::Constants::ANDROID_DEVICE_TYPE);
|
2017-12-07 15:30:16 +01:00
|
|
|
setRepeatable(false);
|
2018-05-14 17:50:56 +02:00
|
|
|
setDisplayName(AndroidPackageInstallationStep::tr("Deploy to device"));
|
2017-12-07 15:30:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
} // namespace Android
|