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 "androidplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "androidconfigurations.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
#include "androidconstants.h"
|
|
|
|
|
#include "androiddebugsupport.h"
|
2013-09-17 18:24:57 +02:00
|
|
|
#include "androiddeployqtstep.h"
|
2012-07-03 16:57:44 +03:00
|
|
|
#include "androiddevice.h"
|
2013-01-25 16:49:22 +01:00
|
|
|
#include "androidgdbserverkitinformation.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
#include "androidmanager.h"
|
2013-05-08 17:52:01 +02:00
|
|
|
#include "androidmanifesteditorfactory.h"
|
2017-12-07 15:30:16 +01:00
|
|
|
#include "androidpackageinstallationstep.h"
|
2013-09-30 15:24:18 +02:00
|
|
|
#include "androidpotentialkit.h"
|
2017-12-07 15:30:16 +01:00
|
|
|
#include "androidqmltoolingsupport.h"
|
2019-02-14 12:29:00 +01:00
|
|
|
#include "androidqtversion.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
#include "androidrunconfiguration.h"
|
|
|
|
|
#include "androidruncontrol.h"
|
|
|
|
|
#include "androidsettingspage.h"
|
|
|
|
|
#include "androidtoolchain.h"
|
2014-08-20 16:29:26 +02:00
|
|
|
#include "javaeditor.h"
|
2017-06-20 12:41:19 +02:00
|
|
|
|
2013-08-21 13:28:03 +02:00
|
|
|
#ifdef HAVE_QBS
|
|
|
|
|
# include "androidqbspropertyprovider.h"
|
|
|
|
|
#endif
|
2013-05-08 17:52:01 +02:00
|
|
|
|
2016-04-29 23:06:26 +02:00
|
|
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
2018-12-05 13:00:36 +01:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2019-01-24 17:27:50 +01:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
2018-01-30 18:41:56 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2013-02-25 13:25:32 +01:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2018-12-05 13:00:36 +01:00
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
2018-01-30 18:41:56 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2016-04-29 23:06:26 +02:00
|
|
|
|
2013-02-14 15:51:59 +01:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2016-04-29 23:06:26 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2017-06-20 12:41:19 +02:00
|
|
|
using namespace ProjectExplorer::Constants;
|
2012-07-03 16:57:44 +03:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
namespace Android {
|
2018-02-09 16:16:38 +01:00
|
|
|
namespace Internal {
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2019-01-24 17:27:50 +01:00
|
|
|
class AndroidDeployConfigurationFactory : public DeployConfigurationFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AndroidDeployConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
setConfigBaseId("Qt4ProjectManager.AndroidDeployConfiguration2");
|
|
|
|
|
addSupportedTargetDeviceType(Constants::ANDROID_DEVICE_TYPE);
|
|
|
|
|
setDefaultDisplayName(QCoreApplication::translate("Android::Internal",
|
|
|
|
|
"Deploy to Android device"));
|
|
|
|
|
addInitialStep(AndroidDeployQtStep::stepId());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-16 09:34:54 +02:00
|
|
|
class AndroidRunConfigurationFactory : public RunConfigurationFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
AndroidRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
registerRunConfiguration<Android::AndroidRunConfiguration>
|
|
|
|
|
("Qt4ProjectManager.AndroidRunConfiguration:");
|
|
|
|
|
addSupportedTargetDeviceType(Android::Constants::ANDROID_DEVICE_TYPE);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-20 11:40:53 +01:00
|
|
|
class QmlPreviewRunWorkerFactory : public RunWorkerFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QmlPreviewRunWorkerFactory()
|
|
|
|
|
{
|
|
|
|
|
addSupportedRunMode(QML_PREVIEW_RUN_MODE);
|
|
|
|
|
setProducer([](RunControl *runControl) -> RunWorker * {
|
|
|
|
|
const Runnable runnable = runControl->runConfiguration()->runnable();
|
|
|
|
|
return new AndroidQmlToolingSupport(runControl, runnable.executable);
|
|
|
|
|
});
|
|
|
|
|
addConstraint([](RunConfiguration *runConfig) {
|
|
|
|
|
return runConfig->isEnabled()
|
|
|
|
|
&& runConfig->id().name().startsWith("QmlProjectManager.QmlRunConfiguration")
|
|
|
|
|
&& DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit())
|
|
|
|
|
== Android::Constants::ANDROID_DEVICE_TYPE;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-12-05 13:00:36 +01:00
|
|
|
class AndroidPluginPrivate : public QObject
|
2018-01-26 14:57:01 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2018-12-05 13:00:36 +01:00
|
|
|
AndroidPluginPrivate()
|
|
|
|
|
{
|
|
|
|
|
connect(SessionManager::instance(), &SessionManager::projectAdded, this, [=](Project *project) {
|
|
|
|
|
for (Target *target : project->targets())
|
|
|
|
|
handleNewTarget(target);
|
|
|
|
|
connect(project, &Project::addedTarget, this, &AndroidPluginPrivate::handleNewTarget);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleNewTarget(Target *target)
|
|
|
|
|
{
|
2019-02-06 12:50:51 +01:00
|
|
|
if (DeviceTypeKitAspect::deviceTypeId(target->kit()) != Android::Constants::ANDROID_DEVICE_TYPE)
|
2018-12-05 13:00:36 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (BuildConfiguration *bc : target->buildConfigurations())
|
|
|
|
|
handleNewBuildConfiguration(bc);
|
|
|
|
|
|
|
|
|
|
connect(target, &Target::addedBuildConfiguration,
|
|
|
|
|
this, &AndroidPluginPrivate::handleNewBuildConfiguration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleNewBuildConfiguration(BuildConfiguration *bc)
|
|
|
|
|
{
|
|
|
|
|
connect(bc->target()->project(), &Project::parsingFinished, bc, [bc] {
|
|
|
|
|
AndroidManager::updateGradleProperties(bc->target());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-26 14:57:01 +01:00
|
|
|
AndroidConfigurations androidConfiguration;
|
|
|
|
|
AndroidSettingsPage settingsPage;
|
|
|
|
|
AndroidDeployQtStepFactory deployQtStepFactory;
|
|
|
|
|
AndroidQtVersionFactory qtVersionFactory;
|
|
|
|
|
AndroidToolChainFactory toolChainFactory;
|
|
|
|
|
AndroidDeployConfigurationFactory deployConfigurationFactory;
|
|
|
|
|
AndroidDeviceFactory deviceFactory;
|
|
|
|
|
AndroidPotentialKit potentialKit;
|
|
|
|
|
JavaEditorFactory javaEditorFactory;
|
|
|
|
|
AndroidPackageInstallationFactory packackeInstallationFactory;
|
|
|
|
|
AndroidManifestEditorFactory manifestEditorFactory;
|
2018-05-16 09:34:54 +02:00
|
|
|
AndroidRunConfigurationFactory runConfigFactory;
|
2019-03-20 11:40:53 +01:00
|
|
|
|
2019-03-13 12:22:44 +01:00
|
|
|
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidRunSupport> runWorkerFactory;
|
|
|
|
|
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidDebugSupport>
|
|
|
|
|
debugWorkerFactory{DEBUG_RUN_MODE};
|
|
|
|
|
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidQmlToolingSupport>
|
|
|
|
|
profilerWorkerFactory{QML_PROFILER_RUN_MODE};
|
|
|
|
|
SimpleRunWorkerFactory<AndroidRunConfiguration, AndroidQmlToolingSupport>
|
|
|
|
|
qmlPreviewWorkerFactory{QML_PREVIEW_RUN_MODE};
|
2019-03-20 11:40:53 +01:00
|
|
|
QmlPreviewRunWorkerFactory qmlPreviewWorkerFactory2;
|
|
|
|
|
|
2018-07-02 18:40:29 +02:00
|
|
|
AndroidBuildApkStepFactory buildApkStepFactory;
|
2019-03-14 09:17:59 +01:00
|
|
|
AndroidGdbServerKitAspect gdbServerKitAspect;
|
2018-01-26 14:57:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AndroidPlugin::~AndroidPlugin()
|
|
|
|
|
{
|
2018-02-09 16:16:38 +01:00
|
|
|
delete d;
|
2018-01-26 14:57:01 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
Q_UNUSED(arguments);
|
2012-08-09 01:56:51 +02:00
|
|
|
Q_UNUSED(errorMessage);
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2018-02-09 16:16:38 +01:00
|
|
|
d = new AndroidPluginPrivate;
|
2013-02-28 14:06:17 +01:00
|
|
|
|
2016-04-29 23:06:26 +02:00
|
|
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
|
|
|
|
this, &AndroidPlugin::kitsRestored);
|
2013-02-28 15:07:01 +01:00
|
|
|
|
|
|
|
|
return true;
|
2013-02-25 13:25:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidPlugin::kitsRestored()
|
|
|
|
|
{
|
2014-06-25 15:42:11 +02:00
|
|
|
AndroidConfigurations::updateAutomaticKitList();
|
2016-04-29 23:06:26 +02:00
|
|
|
connect(QtSupport::QtVersionManager::instance(), &QtSupport::QtVersionManager::qtVersionsChanged,
|
|
|
|
|
AndroidConfigurations::instance(), &AndroidConfigurations::updateAutomaticKitList);
|
2018-05-24 14:01:19 +02:00
|
|
|
disconnect(KitManager::instance(), &KitManager::kitsLoaded,
|
2016-04-29 23:06:26 +02:00
|
|
|
this, &AndroidPlugin::kitsRestored);
|
2012-09-06 12:07:29 +02:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2018-02-09 16:16:38 +01:00
|
|
|
} // namespace Internal
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace Android
|