forked from qt-creator/qt-creator
Android: Merge run configuration into base class
The base AndroidRunConfiguration as such is buildsystem agnostic now, it is, however not usable with other buildsystems as the apk build step relies on qmake specific information, so the run configuration factory stays on the buildsystem specific side for now. Change-Id: I00538846028cc060aceea15ffd2e63068450f1e8 Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
@@ -30,7 +30,9 @@
|
||||
#include "androidrunconfigurationwidget.h"
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
@@ -49,6 +51,9 @@ AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
||||
connect(target->project(), &Project::parsingFinished, this, [this] {
|
||||
updateTargetInformation();
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::setPreStartShellCommands(const QStringList &cmdList)
|
||||
@@ -115,4 +120,29 @@ const QStringList &AndroidRunConfiguration::postFinishShellCommands() const
|
||||
return m_postFinishShellCommands;
|
||||
}
|
||||
|
||||
void AndroidRunConfiguration::updateTargetInformation()
|
||||
{
|
||||
const BuildTargetInfo bti = buildTargetInfo();
|
||||
setDisplayName(bti.displayName);
|
||||
setDefaultDisplayName(bti.displayName);
|
||||
}
|
||||
|
||||
QString AndroidRunConfiguration::disabledReason() const
|
||||
{
|
||||
const BuildTargetInfo bti = buildTargetInfo();
|
||||
const QString projectFileName = bti.projectFilePath.toString();
|
||||
|
||||
if (project()->isParsing())
|
||||
return tr("The project file \"%1\" is currently being parsed.").arg(projectFileName);
|
||||
|
||||
if (!project()->hasParsingData()) {
|
||||
if (!bti.projectFilePath.exists())
|
||||
return tr("The project file \"%1\" does not exist.").arg(projectFileName);
|
||||
|
||||
return tr("The project file \"%1\" could not be parsed.").arg(projectFileName);
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
} // namespace Android
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
QVariantMap toMap() const override;
|
||||
QString disabledReason() const override;
|
||||
|
||||
const QStringList &amStartExtraArgs() const;
|
||||
const QStringList &preStartShellCommands() const;
|
||||
@@ -51,6 +52,7 @@ private:
|
||||
void setPreStartShellCommands(const QStringList &cmdList);
|
||||
void setPostFinishShellCommands(const QStringList &cmdList);
|
||||
void setAmStartExtraArgs(const QStringList &args);
|
||||
void updateTargetInformation();
|
||||
|
||||
QStringList m_amStartExtraArgs;
|
||||
QStringList m_preStartShellCommands;
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "androidextralibrarylistmodel.h"
|
||||
#include "qmakeandroidrunconfiguration.h"
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
|
||||
#include <proparser/prowriter.h>
|
||||
|
||||
|
||||
@@ -114,11 +115,10 @@ void AndroidExtraLibraryListModel::activeRunConfigurationChanged()
|
||||
QmakeProjectManager::QmakeProFile *AndroidExtraLibraryListModel::activeProFile() const
|
||||
{
|
||||
ProjectExplorer::RunConfiguration *rc = m_target->activeRunConfiguration();
|
||||
QmakeAndroidRunConfiguration *qarc = qobject_cast<QmakeAndroidRunConfiguration *>(rc);
|
||||
if (!qarc)
|
||||
return 0;
|
||||
if (!rc)
|
||||
return nullptr;
|
||||
auto project = static_cast<QmakeProject *>(m_target->project());
|
||||
return project->rootProFile()->findProFile(qarc->proFilePath());
|
||||
return project->rootProFile()->findProFile(Utils::FileName::fromString(rc->buildKey()));
|
||||
}
|
||||
|
||||
void AndroidExtraLibraryListModel::proFileUpdated(QmakeProjectManager::QmakeProFile *pro)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "createandroidmanifestwizard.h"
|
||||
#include "qmakeandroidrunconfiguration.h"
|
||||
|
||||
#include <android/androidconfigurations.h>
|
||||
#include <android/androidmanager.h>
|
||||
@@ -32,6 +31,7 @@
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
@@ -206,9 +206,8 @@ CreateAndroidManifestWizard::CreateAndroidManifestWizard(ProjectExplorer::Target
|
||||
m_copyGradle = version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0);
|
||||
|
||||
const QmakeProFile *currentRunNode = nullptr;
|
||||
ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration();
|
||||
if (auto qrc = qobject_cast<QmakeAndroidRunConfiguration *>(rc))
|
||||
currentRunNode = project->rootProFile()->findProFile(qrc->proFilePath());
|
||||
if (ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration())
|
||||
currentRunNode = project->rootProFile()->findProFile(FileName::fromString(rc->buildKey()));
|
||||
|
||||
if (files.isEmpty()) {
|
||||
// oh uhm can't create anything
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include "qmakeandroidbuildapkstep.h"
|
||||
#include "qmakeandroidbuildapkwidget.h"
|
||||
#include "qmakeandroidrunconfiguration.h"
|
||||
|
||||
#include <android/androidconfigurations.h>
|
||||
#include <android/androidconstants.h>
|
||||
@@ -46,8 +45,6 @@
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
using namespace Android;
|
||||
using QmakeProjectManager::QmakeProject;
|
||||
using QmakeProjectManager::QmakeProFileNode;
|
||||
@@ -80,8 +77,8 @@ QmakeAndroidBuildApkStep::QmakeAndroidBuildApkStep(ProjectExplorer::BuildStepLis
|
||||
Utils::FileName QmakeAndroidBuildApkStep::proFilePathForInputFile() const
|
||||
{
|
||||
ProjectExplorer::RunConfiguration *rc = target()->activeRunConfiguration();
|
||||
if (auto *arc = qobject_cast<QmakeAndroidRunConfiguration *>(rc))
|
||||
return arc->proFilePath();
|
||||
if (rc)
|
||||
return Utils::FileName::fromString(rc->buildKey());
|
||||
return Utils::FileName();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmakeandroidrunconfiguration.h"
|
||||
|
||||
#include <android/androidconstants.h>
|
||||
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qtsupport/qtoutputformatter.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
||||
#include <qmakeprojectmanager/qmakenodes.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace {
|
||||
QLatin1String PRO_FILE_KEY("QMakeProjectManager.QmakeAndroidRunConfiguration.ProFile");
|
||||
}
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using QmakeProjectManager::QmakeProject;
|
||||
|
||||
namespace QmakeAndroidSupport {
|
||||
namespace Internal {
|
||||
|
||||
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *target, Core::Id id)
|
||||
: AndroidRunConfiguration(target, id)
|
||||
{
|
||||
connect(target->project(), &Project::parsingFinished, this, [this]() {
|
||||
updateDisplayName();
|
||||
});
|
||||
}
|
||||
|
||||
void QmakeAndroidRunConfiguration::updateDisplayName()
|
||||
{
|
||||
QmakeProject *project = qmakeProject();
|
||||
const QmakeProjectManager::QmakeProFileNode *root = project->rootProjectNode();
|
||||
if (root) {
|
||||
const QmakeProjectManager::QmakeProFileNode *node = root->findProFileFor(proFilePath());
|
||||
if (node) { // should always be found
|
||||
setDisplayName(node->displayName());
|
||||
setDefaultDisplayName(node->displayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString QmakeAndroidRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (qmakeProject()->isParsing())
|
||||
return tr("The .pro file \"%1\" is currently being parsed.")
|
||||
.arg(proFilePath().fileName());
|
||||
|
||||
if (!qmakeProject()->hasParsingData()) {
|
||||
if (!proFilePath().exists())
|
||||
return tr("The .pro file \"%1\" does not exist.")
|
||||
.arg(proFilePath().fileName());
|
||||
|
||||
QmakeProjectManager::QmakeProFileNode *rootProjectNode = qmakeProject()->rootProjectNode();
|
||||
if (!rootProjectNode) // Shutting down
|
||||
return QString();
|
||||
|
||||
if (!rootProjectNode->findProFileFor(proFilePath()))
|
||||
return tr("The .pro file \"%1\" is not part of the project.")
|
||||
.arg(proFilePath().fileName());
|
||||
|
||||
return tr("The .pro file \"%1\" could not be parsed.")
|
||||
.arg(proFilePath().fileName());
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QmakeProject *QmakeAndroidRunConfiguration::qmakeProject() const
|
||||
{
|
||||
Target *t = target();
|
||||
QTC_ASSERT(t, return nullptr);
|
||||
return static_cast<QmakeProject *>(t->project());
|
||||
}
|
||||
|
||||
Utils::FileName QmakeAndroidRunConfiguration::proFilePath() const
|
||||
{
|
||||
return Utils::FileName::fromString(buildKey());
|
||||
}
|
||||
|
||||
|
||||
// QmakeAndroidRunConfigurationFactory
|
||||
|
||||
QmakeAndroidRunConfigurationFactory::QmakeAndroidRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<QmakeAndroidRunConfiguration>
|
||||
("Qt4ProjectManager.AndroidRunConfiguration:");
|
||||
addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
|
||||
addSupportedTargetDeviceType(Android::Constants::ANDROID_DEVICE_TYPE);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Android
|
||||
@@ -1,60 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/androidrunconfiguration.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace QmakeProjectManager { class QmakeProject; }
|
||||
|
||||
namespace QmakeAndroidSupport {
|
||||
namespace Internal {
|
||||
|
||||
class QmakeAndroidRunConfiguration : public Android::AndroidRunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmakeAndroidRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||
|
||||
Utils::FileName proFilePath() const;
|
||||
|
||||
private:
|
||||
QString disabledReason() const override;
|
||||
void updateDisplayName();
|
||||
|
||||
QmakeProjectManager::QmakeProject *qmakeProject() const;
|
||||
};
|
||||
|
||||
class QmakeAndroidRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
QmakeAndroidRunConfigurationFactory();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmakeAndroidSupport
|
||||
@@ -26,11 +26,13 @@
|
||||
#include "qmakeandroidbuildapkstep.h"
|
||||
#include "qmakeandroidsupport.h"
|
||||
#include "androidqmakebuildconfigurationfactory.h"
|
||||
#include "qmakeandroidrunconfiguration.h"
|
||||
|
||||
#include <android/androidconstants.h>
|
||||
#include <android/androidglobal.h>
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qmakeprojectmanager/qmakeproject.h>
|
||||
|
||||
@@ -85,11 +87,11 @@ QStringList QmakeAndroidSupport::soLibSearchPath(const ProjectExplorer::Target *
|
||||
QStringList QmakeAndroidSupport::androidExtraLibs(const ProjectExplorer::Target *target) const
|
||||
{
|
||||
ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration();
|
||||
QmakeAndroidRunConfiguration *qarc = qobject_cast<QmakeAndroidRunConfiguration *>(rc);
|
||||
if (!qarc)
|
||||
if (!rc)
|
||||
return QStringList();
|
||||
auto project = static_cast<QmakeProject *>(target->project());
|
||||
QmakeProFileNode *node = project->rootProjectNode()->findProFileFor(qarc->proFilePath());
|
||||
QmakeProFileNode *node =
|
||||
project->rootProjectNode()->findProFileFor(Utils::FileName::fromString(rc->buildKey()));
|
||||
return node->variableValue(QmakeProjectManager::Variable::AndroidExtraLibs);
|
||||
}
|
||||
|
||||
@@ -155,12 +157,11 @@ void QmakeAndroidSupport::manifestSaved(const ProjectExplorer::Target *target)
|
||||
|
||||
Utils::FileName QmakeAndroidSupport::manifestSourcePath(const ProjectExplorer::Target *target)
|
||||
{
|
||||
ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration();
|
||||
if (auto qrc = qobject_cast<QmakeAndroidRunConfiguration *>(rc)) {
|
||||
if (ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration()) {
|
||||
const auto project = static_cast<QmakeProjectManager::QmakeProject *>(target->project());
|
||||
if (project->rootProjectNode()) {
|
||||
const QmakeProFileNode *node =
|
||||
project->rootProjectNode()->findProFileFor(qrc->proFilePath());
|
||||
project->rootProjectNode()->findProFileFor(Utils::FileName::fromString(rc->buildKey()));
|
||||
if (node) {
|
||||
QString packageSource = node->singleVariableValue(Variable::AndroidPackageSourceDir);
|
||||
if (!packageSource.isEmpty()) {
|
||||
|
||||
@@ -8,7 +8,6 @@ HEADERS += \
|
||||
androidextralibrarylistmodel.h \
|
||||
createandroidmanifestwizard.h \
|
||||
qmakeandroidsupport.h \
|
||||
qmakeandroidrunconfiguration.h \
|
||||
qmakeandroidbuildapkstep.h \
|
||||
qmakeandroidbuildapkwidget.h \
|
||||
androidqmakebuildconfigurationfactory.h \
|
||||
@@ -18,7 +17,6 @@ SOURCES += \
|
||||
androidextralibrarylistmodel.cpp \
|
||||
createandroidmanifestwizard.cpp \
|
||||
qmakeandroidsupport.cpp \
|
||||
qmakeandroidrunconfiguration.cpp \
|
||||
qmakeandroidbuildapkstep.cpp \
|
||||
qmakeandroidbuildapkwidget.cpp \
|
||||
androidqmakebuildconfigurationfactory.cpp \
|
||||
|
||||
@@ -27,8 +27,6 @@ QtcPlugin {
|
||||
"qmakeandroidbuildapkwidget.ui",
|
||||
"androidqmakebuildconfigurationfactory.cpp",
|
||||
"androidqmakebuildconfigurationfactory.h",
|
||||
"qmakeandroidrunconfiguration.cpp",
|
||||
"qmakeandroidrunconfiguration.h",
|
||||
"qmakeandroidsupport.cpp",
|
||||
"qmakeandroidsupport.h",
|
||||
"qmakeandroidsupportplugin.h",
|
||||
|
||||
@@ -27,12 +27,32 @@
|
||||
|
||||
#include "androidqmakebuildconfigurationfactory.h"
|
||||
#include "qmakeandroidbuildapkstep.h"
|
||||
#include "qmakeandroidrunconfiguration.h"
|
||||
#include "qmakeandroidsupport.h"
|
||||
|
||||
#include <android/androidconstants.h>
|
||||
#include <android/androidrunconfiguration.h>
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace QmakeAndroidSupport {
|
||||
namespace Internal {
|
||||
|
||||
class QmakeAndroidRunConfigurationFactory : public RunConfigurationFactory
|
||||
{
|
||||
public:
|
||||
QmakeAndroidRunConfigurationFactory()
|
||||
{
|
||||
registerRunConfiguration<Android::AndroidRunConfiguration>
|
||||
("Qt4ProjectManager.AndroidRunConfiguration:");
|
||||
addSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
|
||||
addSupportedTargetDeviceType(Android::Constants::ANDROID_DEVICE_TYPE);
|
||||
}
|
||||
};
|
||||
|
||||
class QmakeAndroidSupportPluginPrivate
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user