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
|
|
|
|
2013-03-12 12:03:44 +01:00
|
|
|
#include "androiddeployconfiguration.h"
|
2012-07-03 16:57:44 +03:00
|
|
|
#include "androidconstants.h"
|
2013-09-17 18:24:57 +02:00
|
|
|
#include "androiddeployqtstep.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "androidmanager.h"
|
2014-06-25 15:42:11 +02:00
|
|
|
#include "androidqtsupport.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2014-06-25 15:42:11 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2016-12-16 00:43:14 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <projectexplorer/target.h>
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
using namespace ProjectExplorer;
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
namespace Android {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-11-13 11:51:49 +01:00
|
|
|
// Qt 5.2 has a new form of deployment
|
|
|
|
|
const char ANDROID_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.AndroidDeployConfiguration2";
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
AndroidDeployConfiguration::AndroidDeployConfiguration(Target *parent, Core::Id id)
|
|
|
|
|
: DeployConfiguration(parent, id)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
|
|
|
|
setDisplayName(tr("Deploy to Android device"));
|
|
|
|
|
setDefaultDisplayName(displayName());
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
AndroidDeployConfiguration::AndroidDeployConfiguration(Target *parent, DeployConfiguration *source)
|
|
|
|
|
: DeployConfiguration(parent, source)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-09-12 17:38:08 +02:00
|
|
|
cloneSteps(source);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
AndroidDeployConfigurationFactory::AndroidDeployConfigurationFactory(QObject *parent)
|
|
|
|
|
: DeployConfigurationFactory(parent)
|
2012-07-03 16:57:44 +03:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("AndroidDeployConfigurationFactory"));
|
|
|
|
|
}
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
bool AndroidDeployConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
return availableCreationIds(parent).contains(id);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
DeployConfiguration *AndroidDeployConfigurationFactory::create(Target *parent, Core::Id id)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-06-23 12:24:44 +03:00
|
|
|
AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent, id);
|
2014-06-25 15:42:11 +02:00
|
|
|
dc->stepList()->insertStep(0, new AndroidDeployQtStep(dc->stepList()));
|
2012-04-18 20:30:57 +03:00
|
|
|
return dc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
bool AndroidDeployConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-08-09 01:56:51 +02:00
|
|
|
return canCreate(parent, idFromMap(map));
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
DeployConfiguration *AndroidDeployConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
2012-07-03 16:57:44 +03:00
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent, idFromMap(map));
|
2012-04-18 20:30:57 +03:00
|
|
|
if (dc->fromMap(map))
|
|
|
|
|
return dc;
|
|
|
|
|
|
|
|
|
|
delete dc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
bool AndroidDeployConfigurationFactory::canClone(Target *parent, DeployConfiguration *source) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!AndroidManager::supportsAndroid(parent))
|
2012-04-18 20:30:57 +03:00
|
|
|
return false;
|
2013-09-17 18:24:57 +02:00
|
|
|
return canCreate(parent, source->id());
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
DeployConfiguration *AndroidDeployConfigurationFactory::clone(Target *parent, DeployConfiguration *source)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
2012-04-24 15:49:09 +02:00
|
|
|
return new AndroidDeployConfiguration(parent, source);
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
QList<Core::Id> AndroidDeployConfigurationFactory::availableCreationIds(Target *parent) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2012-07-03 16:57:44 +03:00
|
|
|
QList<Core::Id> ids;
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!parent->project()->supportsKit(parent->kit()))
|
2012-07-03 16:57:44 +03:00
|
|
|
return ids;
|
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(parent->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2012-07-03 16:57:44 +03:00
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
if (!tc || tc->targetAbi().osFlavor() != Abi::AndroidLinuxFlavor)
|
2012-07-03 16:57:44 +03:00
|
|
|
return ids;
|
|
|
|
|
|
2013-09-17 18:24:57 +02:00
|
|
|
QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(parent->kit());
|
2015-06-16 15:25:54 +02:00
|
|
|
if (!qt || qt->type() != QLatin1String(Constants::ANDROIDQT))
|
2012-07-03 16:57:44 +03:00
|
|
|
return ids;
|
2014-05-07 15:03:43 +03:00
|
|
|
ids << Core::Id(ANDROID_DEPLOYCONFIGURATION_ID);
|
2012-07-03 16:57:44 +03:00
|
|
|
return ids;
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
QString AndroidDeployConfigurationFactory::displayNameForId(Core::Id id) const
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2014-09-01 16:35:18 +02:00
|
|
|
if (id == Core::Id(ANDROID_DEPLOYCONFIGURATION_ID))
|
2012-04-24 15:49:09 +02:00
|
|
|
return tr("Deploy on Android");
|
|
|
|
|
return QString();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
2012-06-23 12:24:44 +03:00
|
|
|
|
2012-08-09 01:56:51 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Android
|