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
|
|
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2013-06-04 16:42:26 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2016-12-16 00:43:14 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-10-10 16:12:16 +02:00
|
|
|
#include <projectexplorer/toolchain.h>
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
#include <projectexplorer/gnumakeparser.h>
|
2017-12-07 15:30:16 +01:00
|
|
|
|
2013-06-04 16:42:26 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
|
|
|
#include <QDir>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
using namespace Utils;
|
|
|
|
using namespace Android::Internal;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
namespace Android {
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
AndroidPackageInstallationStep::AndroidPackageInstallationStep(BuildStepList *bsl)
|
|
|
|
: AbstractProcessStep(bsl, Constants::ANDROID_PACKAGE_INSTALLATION_STEP_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);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
bool AndroidPackageInstallationStep::init(QList<const BuildStep *> &earlierSteps)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2017-12-07 15:30:16 +01:00
|
|
|
BuildConfiguration *bc = buildConfiguration();
|
|
|
|
QString dirPath = bc->buildDirectory().appendPath(Constants::ANDROID_BUILDDIRECTORY).toString();
|
|
|
|
if (HostOsInfo::isWindowsHost())
|
2017-06-12 14:23:34 +02:00
|
|
|
if (bc->environment().searchInPath("sh.exe").isEmpty())
|
2013-06-04 16:42:26 +02:00
|
|
|
dirPath = QDir::toNativeSeparators(dirPath);
|
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(),
|
|
|
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2013-10-10 16:12:16 +02:00
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
ProcessParameters *pp = processParameters();
|
2013-10-10 16:12:16 +02:00
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
|
|
|
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
|
|
|
pp->setCommand(tc->makeCommand(bc->environment()));
|
2017-12-07 15:30:16 +01:00
|
|
|
Environment env = bc->environment();
|
|
|
|
Environment::setupEnglishOutput(&env);
|
2013-10-10 16:12:16 +02:00
|
|
|
pp->setEnvironment(env);
|
2017-12-07 15:30:16 +01:00
|
|
|
const QString innerQuoted = QtcProcess::quoteArg(dirPath);
|
|
|
|
const QString outerQuoted = QtcProcess::quoteArg("INSTALL_ROOT=" + innerQuoted);
|
|
|
|
pp->setArguments(outerQuoted + " install");
|
2015-05-06 18:14:35 +02:00
|
|
|
|
2013-10-10 16:12:16 +02:00
|
|
|
pp->resolveAll();
|
2017-12-07 15:30:16 +01:00
|
|
|
setOutputParser(new GnuMakeParser());
|
|
|
|
IOutputParser *parser = target()->kit()->createOutputParser();
|
2013-10-10 16:12:16 +02:00
|
|
|
if (parser)
|
|
|
|
appendOutputParser(parser);
|
|
|
|
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
|
|
|
|
|
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
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
return AbstractProcessStep::init(earlierSteps);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
2013-09-17 18:24:57 +02:00
|
|
|
|
2013-10-10 16:30:56 +02:00
|
|
|
void AndroidPackageInstallationStep::run(QFutureInterface<bool> &fi)
|
|
|
|
{
|
|
|
|
QString error;
|
2014-09-22 16:20:51 +03:00
|
|
|
foreach (const QString &dir, m_androidDirsToClean) {
|
2017-12-07 15:30:16 +01:00
|
|
|
FileName androidDir = FileName::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);
|
2016-04-20 12:49:25 +02:00
|
|
|
reportRunResult(fi, false);
|
2014-09-22 16:20:51 +03:00
|
|
|
return;
|
|
|
|
}
|
2013-10-10 16:30:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
AbstractProcessStep::run(fi);
|
|
|
|
}
|
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
BuildStepConfigWidget *AndroidPackageInstallationStep::createConfigWidget()
|
2013-10-10 16:12:16 +02:00
|
|
|
{
|
|
|
|
return new AndroidPackageInstallationStepWidget(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool AndroidPackageInstallationStep::immutable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// AndroidPackageInstallationStepWidget
|
|
|
|
//
|
|
|
|
|
2017-12-07 15:30:16 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
2013-10-10 16:12:16 +02:00
|
|
|
AndroidPackageInstallationStepWidget::AndroidPackageInstallationStepWidget(AndroidPackageInstallationStep *step)
|
2018-09-20 11:19:41 +02:00
|
|
|
: BuildStepConfigWidget(step, false)
|
2013-10-10 16:12:16 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AndroidPackageInstallationStepWidget::summaryText() const
|
|
|
|
{
|
2018-02-08 20:51:43 +01:00
|
|
|
return "<b>" + tr("Make install") + "</b>";
|
2013-10-10 16:12:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString AndroidPackageInstallationStepWidget::displayName() const
|
|
|
|
{
|
|
|
|
return tr("Make install");
|
|
|
|
}
|
|
|
|
|
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
|