Commit e8b4e180 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

RunConfiguration: Introduce buildSystemTarget()



Introduce a method that maps a RunConfiguration to the build system target
that created the executable.

Implement the method in all RunConfigurations where that makes sense (e.g.
no CustomExecutables).

Change-Id: Ifaac859c2cd9b2806a0d7c185b2239312a67752a
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 83625299
......@@ -155,6 +155,15 @@ QString BareMetalRunConfiguration::projectFilePath() const
return m_projectFilePath;
}
QString BareMetalRunConfiguration::buildSystemTarget() const
{
const BuildTargetInfoList targets = target()->applicationTargets();
const Utils::FileName projectFilePath = Utils::FileName::fromString(m_projectFilePath);
auto bst = std::find_if(targets.list.constBegin(), targets.list.constEnd(),
[&projectFilePath](const BuildTargetInfo &bti) { return bti.projectFilePath == projectFilePath; });
return (bst == targets.list.constEnd()) ? QString() : bst->targetName;
}
void BareMetalRunConfiguration::setDisabledReason(const QString &reason) const
{
m_disabledReason = reason;
......
......@@ -58,6 +58,8 @@ public:
QString projectFilePath() const;
QString buildSystemTarget() const final;
static const char *IdPrefix;
signals:
......
......@@ -56,6 +56,8 @@ public:
bool isEnabled() const override;
QString disabledReason() const override;
QString buildSystemTarget() const final { return m_buildTarget; }
protected:
CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source);
bool fromMap(const QVariantMap &map) override;
......
......@@ -274,6 +274,11 @@ QVariantMap IosRunConfiguration::toMap() const
return res;
}
QString IosRunConfiguration::buildSystemTarget() const
{
return static_cast<QmakeProject *>(target()->project())->mapProFilePathToTarget(m_profilePath);
}
bool IosRunConfiguration::isEnabled() const
{
if (m_parseInProgress || !m_parseSuccess)
......
......@@ -68,6 +68,8 @@ public:
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
QString buildSystemTarget() const final;
protected:
IosRunConfiguration(ProjectExplorer::Target *parent, IosRunConfiguration *source);
......
......@@ -266,6 +266,10 @@ public:
virtual Runnable runnable() const;
virtual Abi abi() const;
// Return the name of the build system target that created this run configuration.
// May return an empty string if no target built the executable!
virtual QString buildSystemTarget() const { return QString(); }
void addExtraAspect(IRunConfigurationAspect *aspect);
signals:
......
......@@ -665,7 +665,7 @@ QList<ProjectExplorer::RunConfiguration *> QbsProductNode::runConfigurations() c
QbsRunConfiguration *qbsRc = qobject_cast<QbsRunConfiguration *>(rc);
if (!qbsRc)
continue;
if (qbsRc->uniqueProductName() == QbsProject::uniqueProductName(qbsProductData()))
if (qbsRc->buildSystemTarget() == QbsProject::uniqueProductName(qbsProductData()))
result << qbsRc;
}
......
......@@ -297,7 +297,7 @@ void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
}
QString QbsRunConfiguration::uniqueProductName() const
QString QbsRunConfiguration::buildSystemTarget() const
{
return m_uniqueProductName;
}
......
......@@ -75,7 +75,7 @@ public:
void addToBaseEnvironment(Utils::Environment &env) const;
QString uniqueProductName() const;
QString buildSystemTarget() const final;
bool isConsoleApplication() const;
signals:
......
......@@ -136,6 +136,11 @@ QString QmakeAndroidRunConfiguration::disabledReason() const
return QString();
}
QString QmakeAndroidRunConfiguration::buildSystemTarget() const
{
return qmakeProject()->mapProFilePathToTarget(m_proFilePath);
}
void QmakeAndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress)
{
QmakeProject *project = qmakeProject();
......
......@@ -51,6 +51,8 @@ public:
bool isEnabled() const override;
QString disabledReason() const override;
QString buildSystemTarget() const final;
protected:
QmakeAndroidRunConfiguration(ProjectExplorer::Target *parent, QmakeAndroidRunConfiguration *source);
......
......@@ -422,6 +422,11 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
}
QString DesktopQmakeRunConfiguration::buildSystemTarget() const
{
return qmakeProject()->mapProFilePathToTarget(m_proFilePath);
}
Utils::FileName DesktopQmakeRunConfiguration::proFilePath() const
{
return m_proFilePath;
......
......@@ -78,6 +78,8 @@ public:
void addToBaseEnvironment(Utils::Environment &env) const;
QString buildSystemTarget() const final;
signals:
void baseWorkingDirectoryChanged(const QString&);
void usingDyldImageSuffixChanged(bool);
......
......@@ -1546,6 +1546,13 @@ QmakeProject::AsyncUpdateState QmakeProject::asyncUpdateState() const
return m_asyncUpdateState;
}
QString QmakeProject::mapProFilePathToTarget(const FileName &proFilePath)
{
const QmakeProjectManager::QmakeProFileNode *root = rootProjectNode();
const QmakeProjectManager::QmakeProFileNode *node = root ? root->findProFileFor(proFilePath) : nullptr;
return node ? node->targetInformation().target : QString();
}
} // namespace QmakeProjectManager
#include "qmakeproject.moc"
......@@ -136,6 +136,8 @@ public:
enum AsyncUpdateState { Base, AsyncFullUpdatePending, AsyncPartialUpdatePending, AsyncUpdateInProgress, ShuttingDown };
AsyncUpdateState asyncUpdateState() const;
QString mapProFilePathToTarget(const Utils::FileName &proFilePath);
signals:
void proFileUpdated(QmakeProjectManager::QmakeProFileNode *node, bool, bool);
void buildDirectoryInitialized();
......
......@@ -151,6 +151,11 @@ QVariantMap RemoteLinuxRunConfiguration::toMap() const
return map;
}
QString RemoteLinuxRunConfiguration::buildSystemTarget() const
{
return d->targetName;
}
bool RemoteLinuxRunConfiguration::fromMap(const QVariantMap &map)
{
if (!RunConfiguration::fromMap(map))
......
......@@ -77,6 +77,8 @@ public:
QVariantMap toMap() const override;
QString buildSystemTarget() const final;
static const char *IdPrefix;
signals:
......
......@@ -32,6 +32,7 @@
#include <projectexplorer/target.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <qmakeprojectmanager/qmakeproject.h>
namespace WinRt {
namespace Internal {
......@@ -84,5 +85,11 @@ void WinRtRunConfiguration::setUninstallAfterStop(bool b)
emit uninstallAfterStopChanged(m_uninstallAfterStop);
}
QString WinRtRunConfiguration::buildSystemTarget() const
{
return static_cast<QmakeProjectManager::QmakeProject *>(target()->project())
->mapProFilePathToTarget(Utils::FileName::fromString(m_proFilePath));
}
} // namespace Internal
} // namespace WinRt
......@@ -47,6 +47,8 @@ public:
bool uninstallAfterStop() const { return m_uninstallAfterStop; }
void setUninstallAfterStop(bool b);
QString buildSystemTarget() const final;
signals:
void argumentsChanged(QString);
void uninstallAfterStopChanged(bool);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment