forked from qt-creator/qt-creator
Qbs run config: Run executable from installed location, if possible
It's been like that for a long time, but the behavior was inadvertantly changed in a recent refactoring. Change-Id: I2f301c995c1f9bb235718e02326c4c64dea91694 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -40,6 +40,12 @@ class PROJECTEXPLORER_EXPORT DeploymentData
|
|||||||
public:
|
public:
|
||||||
void setFileList(const QList<DeployableFile> &files) { m_files = files; }
|
void setFileList(const QList<DeployableFile> &files) { m_files = files; }
|
||||||
|
|
||||||
|
void setLocalInstallRoot(const Utils::FileName &installRoot)
|
||||||
|
{
|
||||||
|
m_localInstallRoot = installRoot;
|
||||||
|
}
|
||||||
|
Utils::FileName localInstallRoot() const { return m_localInstallRoot; }
|
||||||
|
|
||||||
void addFile(const DeployableFile &file)
|
void addFile(const DeployableFile &file)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_files.size(); ++i) {
|
for (int i = 0; i < m_files.size(); ++i) {
|
||||||
@@ -70,11 +76,13 @@ public:
|
|||||||
|
|
||||||
bool operator==(const DeploymentData &other) const
|
bool operator==(const DeploymentData &other) const
|
||||||
{
|
{
|
||||||
return m_files.toSet() == other.m_files.toSet();
|
return m_files.toSet() == other.m_files.toSet()
|
||||||
|
&& m_localInstallRoot == other.m_localInstallRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<DeployableFile> m_files;
|
QList<DeployableFile> m_files;
|
||||||
|
Utils::FileName m_localInstallRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator!=(const DeploymentData &d1, const DeploymentData &d2)
|
inline bool operator!=(const DeploymentData &d1, const DeploymentData &d2)
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "qbsproject.h"
|
#include "qbsproject.h"
|
||||||
|
|
||||||
#include "qbsbuildconfiguration.h"
|
#include "qbsbuildconfiguration.h"
|
||||||
|
#include "qbsbuildstep.h"
|
||||||
#include "qbslogsink.h"
|
#include "qbslogsink.h"
|
||||||
#include "qbspmlogging.h"
|
#include "qbspmlogging.h"
|
||||||
#include "qbsprojectimporter.h"
|
#include "qbsprojectimporter.h"
|
||||||
@@ -474,6 +475,18 @@ void QbsProject::updateProjectNodes()
|
|||||||
rebuildProjectTree();
|
rebuildProjectTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileName QbsProject::installRoot()
|
||||||
|
{
|
||||||
|
if (!activeTarget())
|
||||||
|
return FileName();
|
||||||
|
const auto * const bc
|
||||||
|
= qobject_cast<QbsBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
|
||||||
|
if (!bc)
|
||||||
|
return FileName();
|
||||||
|
const QbsBuildStep * const buildStep = bc->qbsStep();
|
||||||
|
return buildStep && buildStep->install() ? buildStep->installRoot() : FileName();
|
||||||
|
}
|
||||||
|
|
||||||
void QbsProject::handleQbsParsingDone(bool success)
|
void QbsProject::handleQbsParsingDone(bool success)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_qbsProjectParser, return);
|
QTC_ASSERT(m_qbsProjectParser, return);
|
||||||
@@ -607,8 +620,14 @@ void QbsProject::updateAfterBuild()
|
|||||||
OpTimer opTimer("updateAfterBuild");
|
OpTimer opTimer("updateAfterBuild");
|
||||||
QTC_ASSERT(m_qbsProject.isValid(), return);
|
QTC_ASSERT(m_qbsProject.isValid(), return);
|
||||||
const qbs::ProjectData &projectData = m_qbsProject.projectData();
|
const qbs::ProjectData &projectData = m_qbsProject.projectData();
|
||||||
if (projectData == m_projectData)
|
if (projectData == m_projectData) {
|
||||||
|
if (activeTarget()) {
|
||||||
|
DeploymentData deploymentData = activeTarget()->deploymentData();
|
||||||
|
deploymentData.setLocalInstallRoot(installRoot());
|
||||||
|
activeTarget()->setDeploymentData(deploymentData);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
qCDebug(qbsPmLog) << "Updating data after build";
|
qCDebug(qbsPmLog) << "Updating data after build";
|
||||||
m_projectData = projectData;
|
m_projectData = projectData;
|
||||||
updateProjectNodes();
|
updateProjectNodes();
|
||||||
@@ -1077,6 +1096,7 @@ void QbsProject::updateApplicationTargets()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildTargetInfo bti;
|
BuildTargetInfo bti;
|
||||||
bti.buildKey = QbsProject::uniqueProductName(productData);
|
bti.buildKey = QbsProject::uniqueProductName(productData);
|
||||||
bti.targetFilePath = FileName::fromString(targetFile);
|
bti.targetFilePath = FileName::fromString(targetFile);
|
||||||
@@ -1120,6 +1140,7 @@ void QbsProject::updateDeploymentInfo()
|
|||||||
f.isExecutable() ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal);
|
f.isExecutable() ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
deploymentData.setLocalInstallRoot(installRoot());
|
||||||
if (activeTarget())
|
if (activeTarget())
|
||||||
activeTarget()->setDeploymentData(deploymentData);
|
activeTarget()->setDeploymentData(deploymentData);
|
||||||
}
|
}
|
||||||
|
@@ -131,6 +131,7 @@ private:
|
|||||||
void updateAfterParse();
|
void updateAfterParse();
|
||||||
void delayedUpdateAfterParse();
|
void delayedUpdateAfterParse();
|
||||||
void updateProjectNodes();
|
void updateProjectNodes();
|
||||||
|
Utils::FileName installRoot();
|
||||||
|
|
||||||
void projectLoaded() override;
|
void projectLoaded() override;
|
||||||
ProjectExplorer::ProjectImporter *projectImporter() const override;
|
ProjectExplorer::ProjectImporter *projectImporter() const override;
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/variablechooser.h>
|
#include <coreplugin/variablechooser.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/deploymentdata.h>
|
||||||
#include <projectexplorer/localenvironmentaspect.h>
|
#include <projectexplorer/localenvironmentaspect.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
@@ -165,11 +166,22 @@ void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
|||||||
m_envCache.insert(key, env);
|
m_envCache.insert(key, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::FileName QbsRunConfiguration::executableToRun(const BuildTargetInfo &targetInfo) const
|
||||||
|
{
|
||||||
|
const FileName appInBuildDir = targetInfo.targetFilePath;
|
||||||
|
if (target()->deploymentData().localInstallRoot().isEmpty())
|
||||||
|
return appInBuildDir;
|
||||||
|
const QString deployedAppFilePath = target()->deploymentData()
|
||||||
|
.deployableForLocalFile(appInBuildDir.toString()).remoteFilePath();
|
||||||
|
const FileName appInLocalInstallDir = target()->deploymentData().localInstallRoot()
|
||||||
|
+ deployedAppFilePath;
|
||||||
|
return appInLocalInstallDir.exists() ? appInLocalInstallDir : appInBuildDir;
|
||||||
|
}
|
||||||
|
|
||||||
void QbsRunConfiguration::updateTargetInformation()
|
void QbsRunConfiguration::updateTargetInformation()
|
||||||
{
|
{
|
||||||
BuildTargetInfo bti = target()->applicationTargets().buildTargetInfo(buildKey());
|
BuildTargetInfo bti = target()->applicationTargets().buildTargetInfo(buildKey());
|
||||||
FileName executable = bti.targetFilePath;
|
const FileName executable = executableToRun(bti);
|
||||||
|
|
||||||
auto terminalAspect = extraAspect<TerminalAspect>();
|
auto terminalAspect = extraAspect<TerminalAspect>();
|
||||||
if (!terminalAspect->isUserSet())
|
if (!terminalAspect->isUserSet())
|
||||||
terminalAspect->setUseTerminal(bti.usesTerminal);
|
terminalAspect->setUseTerminal(bti.usesTerminal);
|
||||||
|
@@ -53,6 +53,7 @@ public:
|
|||||||
void addToBaseEnvironment(Utils::Environment &env) const;
|
void addToBaseEnvironment(Utils::Environment &env) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Utils::FileName executableToRun(const ProjectExplorer::BuildTargetInfo &targetInfo) const;
|
||||||
QVariantMap toMap() const final;
|
QVariantMap toMap() const final;
|
||||||
bool fromMap(const QVariantMap &map) final;
|
bool fromMap(const QVariantMap &map) final;
|
||||||
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &rci) final;
|
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &rci) final;
|
||||||
|
Reference in New Issue
Block a user