forked from qt-creator/qt-creator
RemoteLinux: Create run configs by target name, not by project file.
The current approach fails for all build systems where one project file can define more than one executable. Change-Id: Ieda413975709fbd6e7ea87b185aa962f63cb7c1f Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -709,7 +709,9 @@ void CMakeProject::updateApplicationAndDeploymentTargets()
|
||||
deploymentData.addFile(ct.executable, deploymentPrefix + buildDir.relativeFilePath(QFileInfo(ct.executable).dir().path()), DeployableFile::TypeExecutable);
|
||||
if (!ct.library) {
|
||||
// TODO: Put a path to corresponding .cbp file into projectFilePath?
|
||||
appTargetList.list << BuildTargetInfo(ct.executable, ct.executable);
|
||||
appTargetList.list << BuildTargetInfo(ct.title,
|
||||
Utils::FileName::fromString(ct.executable),
|
||||
Utils::FileName::fromString(ct.executable));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "projectexplorer_export.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QList>
|
||||
@@ -42,26 +43,24 @@ class PROJECTEXPLORER_EXPORT BuildTargetInfo
|
||||
{
|
||||
public:
|
||||
BuildTargetInfo() {}
|
||||
BuildTargetInfo(const Utils::FileName &targetFilePath, const Utils::FileName &projectFilePath)
|
||||
: targetFilePath(targetFilePath), projectFilePath(projectFilePath)
|
||||
{
|
||||
}
|
||||
|
||||
BuildTargetInfo(const QString &targetFilePath, const QString &projectFilePath)
|
||||
: targetFilePath(Utils::FileName::fromUserInput(targetFilePath)),
|
||||
projectFilePath(Utils::FileName::fromUserInput(projectFilePath))
|
||||
BuildTargetInfo(const QString &targetName, const Utils::FileName &targetFilePath,
|
||||
const Utils::FileName &projectFilePath)
|
||||
: targetName(targetName)
|
||||
, targetFilePath(targetFilePath)
|
||||
, projectFilePath(projectFilePath)
|
||||
{
|
||||
}
|
||||
|
||||
QString targetName;
|
||||
Utils::FileName targetFilePath;
|
||||
Utils::FileName projectFilePath;
|
||||
|
||||
bool isValid() const { return !targetFilePath.isEmpty(); }
|
||||
bool isValid() const { return !targetName.isEmpty(); }
|
||||
};
|
||||
|
||||
inline bool operator==(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2)
|
||||
{
|
||||
return ti1.targetFilePath == ti2.targetFilePath;
|
||||
return ti1.targetName == ti2.targetName;
|
||||
}
|
||||
|
||||
inline bool operator!=(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2)
|
||||
@@ -71,7 +70,7 @@ inline bool operator!=(const BuildTargetInfo &ti1, const BuildTargetInfo &ti2)
|
||||
|
||||
inline uint qHash(const BuildTargetInfo &ti)
|
||||
{
|
||||
return qHash(ti.targetFilePath);
|
||||
return qHash(ti.targetName);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +91,18 @@ public:
|
||||
return Utils::FileName();
|
||||
}
|
||||
|
||||
bool hasTarget(const QString &targetName) {
|
||||
return Utils::anyOf(list, [&targetName](const BuildTargetInfo &ti) {
|
||||
return ti.targetName == targetName;
|
||||
});
|
||||
}
|
||||
|
||||
Utils::FileName targetFilePath(const QString &targetName) {
|
||||
return Utils::findOrDefault(list, [&targetName](const BuildTargetInfo &ti) {
|
||||
return ti.targetName == targetName;
|
||||
}).targetFilePath;
|
||||
}
|
||||
|
||||
QList<BuildTargetInfo> list;
|
||||
};
|
||||
|
||||
|
||||
@@ -769,7 +769,8 @@ void QbsProject::updateApplicationTargets(const qbs::ProjectData &projectData)
|
||||
if (!productData.isEnabled() || !productData.isRunnable())
|
||||
continue;
|
||||
if (productData.targetArtifacts().isEmpty()) { // No build yet.
|
||||
applications.list << ProjectExplorer::BuildTargetInfo(Utils::FileName(),
|
||||
applications.list << ProjectExplorer::BuildTargetInfo(productData.name(),
|
||||
Utils::FileName(),
|
||||
Utils::FileName::fromString(productData.location().fileName()));
|
||||
continue;
|
||||
}
|
||||
@@ -777,7 +778,8 @@ void QbsProject::updateApplicationTargets(const qbs::ProjectData &projectData)
|
||||
QTC_ASSERT(ta.isValid(), continue);
|
||||
if (!ta.isExecutable())
|
||||
continue;
|
||||
applications.list << ProjectExplorer::BuildTargetInfo(Utils::FileName::fromString(ta.filePath()),
|
||||
applications.list << ProjectExplorer::BuildTargetInfo(productData.name(),
|
||||
Utils::FileName::fromString(ta.filePath()),
|
||||
Utils::FileName::fromString(productData.location().fileName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1497,8 +1497,11 @@ void QmakeProject::updateBuildSystemData()
|
||||
target->setDeploymentData(deploymentData);
|
||||
|
||||
BuildTargetInfoList appTargetList;
|
||||
foreach (const QmakeProFileNode * const node, applicationProFiles())
|
||||
appTargetList.list << BuildTargetInfo(executableFor(node), node->path());
|
||||
foreach (const QmakeProFileNode * const node, applicationProFiles()) {
|
||||
appTargetList.list << BuildTargetInfo(node->targetInformation().target,
|
||||
Utils::FileName::fromString(executableFor(node)),
|
||||
Utils::FileName::fromString(node->path()));
|
||||
}
|
||||
target->setApplicationTargets(appTargetList);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace {
|
||||
const char QtLibPathKey[] = "Qt4ProjectManager.QnxRunConfiguration.QtLibPath";
|
||||
}
|
||||
|
||||
QnxRunConfiguration::QnxRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &proFilePath)
|
||||
: RemoteLinux::RemoteLinuxRunConfiguration(parent, id, proFilePath)
|
||||
QnxRunConfiguration::QnxRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &targetName)
|
||||
: RemoteLinux::RemoteLinuxRunConfiguration(parent, id, targetName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class QnxRunConfiguration : public RemoteLinux::RemoteLinuxRunConfiguration
|
||||
Q_OBJECT
|
||||
public:
|
||||
QnxRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
|
||||
const QString &projectFilePath);
|
||||
const QString &targetName);
|
||||
|
||||
Utils::Environment environment() const;
|
||||
|
||||
|
||||
@@ -97,7 +97,17 @@ bool QnxRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, Core
|
||||
|
||||
ProjectExplorer::RunConfiguration *QnxRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, Core::Id id)
|
||||
{
|
||||
return new QnxRunConfiguration(parent, id, pathFromId(id));
|
||||
const QString projectFilePath = pathFromId(id);
|
||||
const QmakeProjectManager::QmakeProject * const qt4Project
|
||||
= qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project());
|
||||
QTC_ASSERT(qt4Project, return 0);
|
||||
foreach (const QmakeProjectManager::QmakeProFileNode * const node,
|
||||
qt4Project->applicationProFiles()) {
|
||||
if (node->path() == projectFilePath)
|
||||
return new QnxRunConfiguration(parent, id, node->targetInformation().target);
|
||||
}
|
||||
QTC_CHECK(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool QnxRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
namespace {
|
||||
const char ArgumentsKey[] = "Qt4ProjectManager.MaemoRunConfiguration.Arguments";
|
||||
const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile";
|
||||
const char TargetNameKey[] = "Qt4ProjectManager.MaemoRunConfiguration.TargetName";
|
||||
const char UseAlternateExeKey[] = "RemoteLinux.RunConfig.UseAlternateRemoteExecutable";
|
||||
const char AlternateExeKey[] = "RemoteLinux.RunConfig.AlternateRemoteExecutable";
|
||||
const char WorkingDirectoryKey[] = "RemoteLinux.RunConfig.WorkingDirectory";
|
||||
@@ -55,14 +55,14 @@ const char WorkingDirectoryKey[] = "RemoteLinux.RunConfig.WorkingDirectory";
|
||||
|
||||
class RemoteLinuxRunConfigurationPrivate {
|
||||
public:
|
||||
RemoteLinuxRunConfigurationPrivate(const QString &projectFilePath)
|
||||
: projectFilePath(projectFilePath),
|
||||
RemoteLinuxRunConfigurationPrivate(const QString &targetName)
|
||||
: targetName(targetName),
|
||||
useAlternateRemoteExecutable(false)
|
||||
{
|
||||
}
|
||||
|
||||
RemoteLinuxRunConfigurationPrivate(const RemoteLinuxRunConfigurationPrivate *other)
|
||||
: projectFilePath(other->projectFilePath),
|
||||
: targetName(other->targetName),
|
||||
arguments(other->arguments),
|
||||
useAlternateRemoteExecutable(other->useAlternateRemoteExecutable),
|
||||
alternateRemoteExecutable(other->alternateRemoteExecutable),
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
QString projectFilePath;
|
||||
QString targetName;
|
||||
QStringList arguments;
|
||||
bool useAlternateRemoteExecutable;
|
||||
QString alternateRemoteExecutable;
|
||||
@@ -82,9 +82,9 @@ public:
|
||||
using namespace Internal;
|
||||
|
||||
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *parent, Core::Id id,
|
||||
const QString &proFilePath)
|
||||
const QString &targetName)
|
||||
: AbstractRemoteLinuxRunConfiguration(parent, id),
|
||||
d(new RemoteLinuxRunConfigurationPrivate(proFilePath))
|
||||
d(new RemoteLinuxRunConfigurationPrivate(targetName))
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -135,7 +135,7 @@ QVariantMap RemoteLinuxRunConfiguration::toMap() const
|
||||
QVariantMap map(RunConfiguration::toMap());
|
||||
map.insert(QLatin1String(ArgumentsKey), d->arguments);
|
||||
const QDir dir = QDir(target()->project()->projectDirectory().toString());
|
||||
map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(d->projectFilePath));
|
||||
map.insert(QLatin1String(TargetNameKey), d->targetName);
|
||||
map.insert(QLatin1String(UseAlternateExeKey), d->useAlternateRemoteExecutable);
|
||||
map.insert(QLatin1String(AlternateExeKey), d->alternateRemoteExecutable);
|
||||
map.insert(QLatin1String(WorkingDirectoryKey), d->workingDirectory);
|
||||
@@ -149,8 +149,8 @@ bool RemoteLinuxRunConfiguration::fromMap(const QVariantMap &map)
|
||||
|
||||
d->arguments = map.value(QLatin1String(ArgumentsKey)).toStringList();
|
||||
const QDir dir = QDir(target()->project()->projectDirectory().toString());
|
||||
d->projectFilePath
|
||||
= QDir::cleanPath(dir.filePath(map.value(QLatin1String(ProFileKey)).toString()));
|
||||
d->targetName
|
||||
= QDir::cleanPath(dir.filePath(map.value(QLatin1String(TargetNameKey)).toString()));
|
||||
d->useAlternateRemoteExecutable = map.value(QLatin1String(UseAlternateExeKey), false).toBool();
|
||||
d->alternateRemoteExecutable = map.value(QLatin1String(AlternateExeKey)).toString();
|
||||
d->workingDirectory = map.value(QLatin1String(WorkingDirectoryKey)).toString();
|
||||
@@ -162,9 +162,9 @@ bool RemoteLinuxRunConfiguration::fromMap(const QVariantMap &map)
|
||||
|
||||
QString RemoteLinuxRunConfiguration::defaultDisplayName()
|
||||
{
|
||||
if (!d->projectFilePath.isEmpty())
|
||||
if (!d->targetName.isEmpty())
|
||||
//: %1 is the name of a project which is being run on remote Linux
|
||||
return tr("%1 (on Remote Device)").arg(QFileInfo(d->projectFilePath).completeBaseName());
|
||||
return tr("%1 (on Remote Device)").arg(d->targetName);
|
||||
//: Remote Linux run configuration default display name
|
||||
return tr("Run on Remote Device");
|
||||
}
|
||||
@@ -183,8 +183,7 @@ Environment RemoteLinuxRunConfiguration::environment() const
|
||||
|
||||
QString RemoteLinuxRunConfiguration::localExecutableFilePath() const
|
||||
{
|
||||
return target()->applicationTargets()
|
||||
.targetForProject(Utils::FileName::fromString(d->projectFilePath)).toString();
|
||||
return target()->applicationTargets().targetFilePath(d->targetName).toString();
|
||||
}
|
||||
|
||||
QString RemoteLinuxRunConfiguration::defaultRemoteExecutableFilePath() const
|
||||
@@ -241,11 +240,6 @@ void RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated()
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
QString RemoteLinuxRunConfiguration::projectFilePath() const
|
||||
{
|
||||
return d->projectFilePath;
|
||||
}
|
||||
|
||||
const char *RemoteLinuxRunConfiguration::IdPrefix = "RemoteLinuxRunConfiguration:";
|
||||
|
||||
} // namespace RemoteLinux
|
||||
|
||||
@@ -60,7 +60,7 @@ class REMOTELINUX_EXPORT RemoteLinuxRunConfiguration : public AbstractRemoteLinu
|
||||
|
||||
public:
|
||||
RemoteLinuxRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
|
||||
const QString &projectFilePath);
|
||||
const QString &targetName);
|
||||
~RemoteLinuxRunConfiguration();
|
||||
|
||||
bool isEnabled() const;
|
||||
@@ -83,8 +83,6 @@ public:
|
||||
|
||||
QVariantMap toMap() const;
|
||||
|
||||
QString projectFilePath() const;
|
||||
|
||||
static const char *IdPrefix;
|
||||
|
||||
signals:
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <projectexplorer/target.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
@@ -47,7 +46,7 @@ namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
|
||||
namespace {
|
||||
QString pathFromId(Core::Id id)
|
||||
QString stringFromId(Core::Id id)
|
||||
{
|
||||
QByteArray idStr = id.name();
|
||||
if (!idStr.startsWith(RemoteLinuxRunConfiguration::IdPrefix))
|
||||
@@ -72,7 +71,7 @@ bool RemoteLinuxRunConfigurationFactory::canCreate(Target *parent, Core::Id id)
|
||||
if (!canHandle(parent))
|
||||
return false;
|
||||
return id == RemoteLinuxCustomRunConfiguration::runConfigId()
|
||||
|| !parent->applicationTargets().targetForProject(pathFromId(id)).isEmpty();
|
||||
|| parent->applicationTargets().hasTarget(stringFromId(id));
|
||||
}
|
||||
|
||||
bool RemoteLinuxRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
||||
@@ -100,7 +99,7 @@ QList<Core::Id> RemoteLinuxRunConfigurationFactory::availableCreationIds(Target
|
||||
|
||||
const Core::Id base = Core::Id(RemoteLinuxRunConfiguration::IdPrefix);
|
||||
foreach (const BuildTargetInfo &bti, parent->applicationTargets().list)
|
||||
result << base.withSuffix(bti.projectFilePath.toString());
|
||||
result << base.withSuffix(bti.targetName);
|
||||
result << RemoteLinuxCustomRunConfiguration::runConfigId();
|
||||
return result;
|
||||
}
|
||||
@@ -109,15 +108,14 @@ QString RemoteLinuxRunConfigurationFactory::displayNameForId(Core::Id id) const
|
||||
{
|
||||
if (id == RemoteLinuxCustomRunConfiguration::runConfigId())
|
||||
return RemoteLinuxCustomRunConfiguration::runConfigDefaultDisplayName();
|
||||
return QFileInfo(pathFromId(id)).completeBaseName()
|
||||
+ QLatin1Char(' ') + tr("(on Remote Generic Linux Host)");
|
||||
return stringFromId(id) + QLatin1Char(' ') + tr("(on Remote Generic Linux Host)");
|
||||
}
|
||||
|
||||
RunConfiguration *RemoteLinuxRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
|
||||
{
|
||||
if (id == RemoteLinuxCustomRunConfiguration::runConfigId())
|
||||
return new RemoteLinuxCustomRunConfiguration(parent);
|
||||
return new RemoteLinuxRunConfiguration(parent, id, pathFromId(id));
|
||||
return new RemoteLinuxRunConfiguration(parent, id, stringFromId(id));
|
||||
}
|
||||
|
||||
RunConfiguration *RemoteLinuxRunConfigurationFactory::doRestore(Target *parent,
|
||||
|
||||
Reference in New Issue
Block a user