ProjectExplorer: Introduce and use a Target::buildSystemUpdated signal

Change-Id: I497d46866146600a1ed9162bd720c574ee4d4769
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-11-15 15:44:45 +01:00
parent 738bbf1a87
commit c2127c9ec4
21 changed files with 52 additions and 38 deletions

View File

@@ -31,6 +31,7 @@
#include "androidmanager.h" #include "androidmanager.h"
#include "adbcommandswidget.h" #include "adbcommandswidget.h"
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -132,7 +133,7 @@ AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id)
postStartShellCmdAspect->setSettingsKey("Android.PostStartShellCmdListKey"); postStartShellCmdAspect->setSettingsKey("Android.PostStartShellCmdListKey");
postStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device after application quits.")); postStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device after application quits."));
connect(target, &Target::parsingFinished, this, [this] { connect(target, &Target::buildSystemUpdated, this, [this] {
updateTargetInformation(); updateTargetInformation();
AndroidManager::updateGradleProperties(this->target(), buildKey()); AndroidManager::updateGradleProperties(this->target(), buildKey());
}); });

View File

@@ -153,6 +153,8 @@ void AutotoolsBuildSystem::makefileParsingFinished()
m_makefileParserThread->deleteLater(); m_makefileParserThread->deleteLater();
m_makefileParserThread = nullptr; m_makefileParserThread = nullptr;
emitBuildSystemUpdated();
} }
static QStringList filterIncludes(const QString &absSrc, const QString &absBuild, static QStringList filterIncludes(const QString &absSrc, const QString &absBuild,

View File

@@ -26,6 +26,7 @@
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "baremetalrunconfiguration.h" #include "baremetalrunconfiguration.h"
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
@@ -49,13 +50,9 @@ BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target, Core::Id id
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>();
connect(target, &Target::deploymentDataChanged,
this, &BareMetalRunConfiguration::updateTargetInformation);
connect(target, &Target::applicationTargetsChanged,
this, &BareMetalRunConfiguration::updateTargetInformation);
connect(target, &Target::kitChanged, connect(target, &Target::kitChanged,
this, &BareMetalRunConfiguration::updateTargetInformation); // Handles device changes, etc. this, &BareMetalRunConfiguration::updateTargetInformation); // Handles device changes, etc.
connect(target, &Target::parsingFinished, connect(target, &Target::buildSystemUpdated,
this, &BareMetalRunConfiguration::updateTargetInformation); this, &BareMetalRunConfiguration::updateTargetInformation);
} }

View File

@@ -27,6 +27,7 @@
#include "qdbconstants.h" #include "qdbconstants.h"
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/deploymentdata.h> #include <projectexplorer/deploymentdata.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -85,13 +86,9 @@ QdbRunConfiguration::QdbRunConfiguration(Target *target, Core::Id id)
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>();
addAspect<FullCommandLineAspect>(this); addAspect<FullCommandLineAspect>(this);
connect(target, &Target::deploymentDataChanged,
this, &QdbRunConfiguration::updateTargetInformation);
connect(target, &Target::applicationTargetsChanged,
this, &QdbRunConfiguration::updateTargetInformation);
connect(target, &Target::kitChanged, connect(target, &Target::kitChanged,
this, &QdbRunConfiguration::updateTargetInformation); this, &QdbRunConfiguration::updateTargetInformation);
connect(target, &Target::parsingFinished, connect(target, &Target::buildSystemUpdated,
this, &QdbRunConfiguration::updateTargetInformation); this, &QdbRunConfiguration::updateTargetInformation);
setDefaultDisplayName(tr("Run on Boot2Qt Device")); setDefaultDisplayName(tr("Run on Boot2Qt Device"));

View File

@@ -362,6 +362,8 @@ void CMakeBuildSystem::combineScanAndParse()
} }
m_currentGuard = {}; m_currentGuard = {};
emitBuildSystemUpdated();
} }
void CMakeBuildSystem::checkAndReportError(QString &errorMessage) void CMakeBuildSystem::checkAndReportError(QString &errorMessage)

View File

@@ -502,6 +502,8 @@ void CompilationDatabaseBuildSystem::updateDeploymentData()
m_deployFileWatcher->addFile(deploymentFilePath.toString(), m_deployFileWatcher->addFile(deploymentFilePath.toString(),
FileSystemWatcher::WatchModifiedDate); FileSystemWatcher::WatchModifiedDate);
} }
emitBuildSystemUpdated();
} }
static TextEditor::TextDocument *createCompilationDatabaseDocument() static TextEditor::TextDocument *createCompilationDatabaseDocument()

View File

@@ -498,6 +498,8 @@ void GenericBuildSystem::refresh(RefreshOptions options)
refreshCppCodeModel(); refreshCppCodeModel();
updateDeploymentData(); updateDeploymentData();
guard.markAsSuccess(); guard.markAsSuccess();
emitBuildSystemUpdated();
} }
/** /**

View File

@@ -179,7 +179,8 @@ void NimbleBuildSystem::setTasks(std::vector<NimbleTask> tasks)
return; return;
m_tasks = std::move(tasks); m_tasks = std::move(tasks);
emit tasksChanged(); emit tasksChanged();
emit target()->targetPropertiesChanged();
emitBuildSystemUpdated();
} }
void NimbleBuildSystem::setMetadata(NimbleMetadata metadata) void NimbleBuildSystem::setMetadata(NimbleMetadata metadata)

View File

@@ -49,9 +49,7 @@ NimbleRunConfiguration::NimbleRunConfiguration(ProjectExplorer::Target *target,
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>();
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
connect(target, &Target::parsingFinished, connect(target, &Target::buildSystemUpdated,
this, &NimbleRunConfiguration::updateTargetInformation);
connect(target, &Target::targetPropertiesChanged,
this, &NimbleRunConfiguration::updateTargetInformation); this, &NimbleRunConfiguration::updateTargetInformation);
updateTargetInformation(); updateTargetInformation();

View File

@@ -160,6 +160,8 @@ void NimBuildSystem::updateProject()
// Complete scan // Complete scan
m_guard.markAsSuccess(); m_guard.markAsSuccess();
m_guard = {}; // Trigger destructor of previous object, emitting parsingFinished() m_guard = {}; // Trigger destructor of previous object, emitting parsingFinished()
emitBuildSystemUpdated();
} }
bool NimBuildSystem::supportsAction(Node *context, ProjectAction action, const Node *node) const bool NimBuildSystem::supportsAction(Node *context, ProjectAction action, const Node *node) const

View File

@@ -274,7 +274,6 @@ void BuildSystem::setDeploymentData(const DeploymentData &deploymentData)
emit deploymentDataChanged(); emit deploymentDataChanged();
emit applicationTargetsChanged(); emit applicationTargetsChanged();
emit target()->deploymentDataChanged(); emit target()->deploymentDataChanged();
emit target()->applicationTargetsChanged();
} }
} }
@@ -288,7 +287,6 @@ void BuildSystem::setApplicationTargets(const QList<BuildTargetInfo> &appTargets
if (Utils::toSet(appTargets) != Utils::toSet(d->m_appTargets)) { if (Utils::toSet(appTargets) != Utils::toSet(d->m_appTargets)) {
d->m_appTargets = appTargets; d->m_appTargets = appTargets;
emit applicationTargetsChanged(); emit applicationTargetsChanged();
emit target()->applicationTargetsChanged();
} }
} }
@@ -309,6 +307,11 @@ void BuildSystem::setRootProjectNode(std::unique_ptr<ProjectNode> &&root)
d->m_target->project()->setRootProjectNode(std::move(root)); d->m_target->project()->setRootProjectNode(std::move(root));
} }
void BuildSystem::emitBuildSystemUpdated()
{
target()->buildSystemUpdated(this);
}
QString BuildSystem::disabledReason(const QString &buildKey) const QString BuildSystem::disabledReason(const QString &buildKey) const
{ {
if (hasParsingData()) { if (hasParsingData()) {

View File

@@ -114,6 +114,8 @@ public:
mutable bool m_success = false; mutable bool m_success = false;
}; };
void emitBuildSystemUpdated();
public: public:
// FIXME: Make this private and the BuildSystem a friend // FIXME: Make this private and the BuildSystem a friend
ParseGuard guardParsingRun() { return ParseGuard(this); } ParseGuard guardParsingRun() { return ParseGuard(this); }

View File

@@ -25,6 +25,7 @@
#include "desktoprunconfiguration.h" #include "desktoprunconfiguration.h"
#include "buildsystem.h"
#include "localenvironmentaspect.h" #include "localenvironmentaspect.h"
#include "project.h" #include "project.h"
#include "runconfigurationaspects.h" #include "runconfigurationaspects.h"
@@ -78,13 +79,6 @@ DesktopRunConfiguration::DesktopRunConfiguration(Target *target, Core::Id id, Ki
if (kind == Qbs) { if (kind == Qbs) {
connect(target, &Target::parsingFinished,
envAspect, &EnvironmentAspect::environmentChanged);
connect(target, &Target::deploymentDataChanged,
this, &DesktopRunConfiguration::updateTargetInformation);
connect(target, &Target::applicationTargetsChanged,
this, &DesktopRunConfiguration::updateTargetInformation);
// Handles device changes, etc. // Handles device changes, etc.
connect(target, &Target::kitChanged, connect(target, &Target::kitChanged,
this, &DesktopRunConfiguration::updateTargetInformation); this, &DesktopRunConfiguration::updateTargetInformation);
@@ -95,7 +89,7 @@ DesktopRunConfiguration::DesktopRunConfiguration(Target *target, Core::Id id, Ki
} }
connect(target, &Target::parsingFinished, connect(target, &Target::buildSystemUpdated,
this, &DesktopRunConfiguration::updateTargetInformation); this, &DesktopRunConfiguration::updateTargetInformation);
} }

View File

@@ -27,6 +27,7 @@
#include "appoutputpane.h" #include "appoutputpane.h"
#include "buildsteplist.h" #include "buildsteplist.h"
#include "buildsystem.h"
#include "compileoutputwindow.h" #include "compileoutputwindow.h"
#include "configtaskhandler.h" #include "configtaskhandler.h"
#include "customexecutablerunconfiguration.h" #include "customexecutablerunconfiguration.h"
@@ -653,6 +654,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd = new ProjectExplorerPluginPrivate; dd = new ProjectExplorerPluginPrivate;
qRegisterMetaType<ProjectExplorer::BuildSystem *>();
qRegisterMetaType<ProjectExplorer::RunControl *>(); qRegisterMetaType<ProjectExplorer::RunControl *>();
qRegisterMetaType<ProjectExplorer::DeployableFile>("ProjectExplorer::DeployableFile"); qRegisterMetaType<ProjectExplorer::DeployableFile>("ProjectExplorer::DeployableFile");

View File

@@ -124,8 +124,10 @@ signals:
void overlayIconChanged(); void overlayIconChanged();
void kitChanged(); void kitChanged();
void parsingStarted(); void parsingStarted();
void parsingFinished(bool); void parsingFinished(bool);
void buildSystemUpdated(ProjectExplorer::BuildSystem *bs);
// TODO clean up signal names // TODO clean up signal names
// might be better to also have aboutToRemove signals // might be better to also have aboutToRemove signals
@@ -143,8 +145,6 @@ signals:
void activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration *dc); void activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration *dc);
void deploymentDataChanged(); void deploymentDataChanged();
void applicationTargetsChanged();
void targetPropertiesChanged();
private: private:
bool fromMap(const QVariantMap &map); bool fromMap(const QVariantMap &map);

View File

@@ -227,6 +227,8 @@ void PythonBuildSystem::triggerParsing()
setApplicationTargets(appTargets); setApplicationTargets(appTargets);
guard.markAsSuccess(); guard.markAsSuccess();
emitBuildSystemUpdated();
} }
bool PythonBuildSystem::saveRawFileList(const QStringList &rawFileList) bool PythonBuildSystem::saveRawFileList(const QStringList &rawFileList)

View File

@@ -35,6 +35,7 @@
#include <languageclient/languageclientmanager.h> #include <languageclient/languageclientmanager.h>
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/localenvironmentaspect.h> #include <projectexplorer/localenvironmentaspect.h>
#include <projectexplorer/projectconfigurationaspects.h> #include <projectexplorer/projectconfigurationaspects.h>
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
@@ -277,9 +278,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id)
return cmd; return cmd;
}); });
connect(target, &Target::applicationTargetsChanged, connect(target, &Target::buildSystemUpdated,
this, &PythonRunConfiguration::updateTargetInformation);
connect(target, &Target::parsingFinished,
this, &PythonRunConfiguration::updateTargetInformation); this, &PythonRunConfiguration::updateTargetInformation);
} }

View File

@@ -620,6 +620,7 @@ void QbsBuildSystem::updateAfterParse()
updateQmlJsCodeModel(); updateQmlJsCodeModel();
emit project()->fileListChanged(); emit project()->fileListChanged();
m_envCache.clear(); m_envCache.clear();
emitBuildSystemUpdated();
} }
void QbsBuildSystem::delayedUpdateAfterParse() void QbsBuildSystem::delayedUpdateAfterParse()
@@ -688,6 +689,11 @@ void QbsBuildSystem::handleQbsParsingDone(bool success)
updateCppCodeModel(); updateCppCodeModel();
m_guard.markAsSuccess(); m_guard.markAsSuccess();
m_guard = {}; m_guard = {};
// This one used to change the executable path of a Qbs desktop run configuration
// in case the "install" check box in the build step is unchecked and then build
// is triggered (which is otherwise a no-op).
emitBuildSystemUpdated();
} }
void QbsBuildSystem::rebuildProjectTree() void QbsBuildSystem::rebuildProjectTree()
@@ -800,6 +806,7 @@ void QbsBuildSystem::updateAfterBuild()
DeploymentData deploymentDataTmp = deploymentData(); DeploymentData deploymentDataTmp = deploymentData();
deploymentDataTmp.setLocalInstallRoot(installRoot()); deploymentDataTmp.setLocalInstallRoot(installRoot());
setDeploymentData(deploymentDataTmp); setDeploymentData(deploymentDataTmp);
emitBuildSystemUpdated();
return; return;
} }
qCDebug(qbsPmLog) << "Updating data after build"; qCDebug(qbsPmLog) << "Updating data after build";
@@ -1274,6 +1281,9 @@ void QbsBuildSystem::updateBuildTargetData()
OpTimer optimer("updateBuildTargetData"); OpTimer optimer("updateBuildTargetData");
updateApplicationTargets(); updateApplicationTargets();
updateDeploymentInfo(); updateDeploymentInfo();
// This one used after a normal build.
emitBuildSystemUpdated();
} }
} // namespace Internal } // namespace Internal

View File

@@ -512,6 +512,8 @@ void QmakeBuildSystem::decrementPendingEvaluateFutures()
target()->updateDefaultDeployConfigurations(); target()->updateDefaultDeployConfigurations();
m_guard.markAsSuccess(); // Qmake always returns (some) data, even when it failed:-) m_guard.markAsSuccess(); // Qmake always returns (some) data, even when it failed:-)
m_guard = {}; // This triggers emitParsingFinished by destroying the previous guard. m_guard = {}; // This triggers emitParsingFinished by destroying the previous guard.
emitBuildSystemUpdated();
} }
} }
} }

View File

@@ -27,6 +27,7 @@
#include "qnxconstants.h" #include "qnxconstants.h"
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/deployablefile.h> #include <projectexplorer/deployablefile.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/runcontrol.h> #include <projectexplorer/runcontrol.h>
@@ -80,9 +81,7 @@ QnxRunConfiguration::QnxRunConfiguration(Target *target, Core::Id id)
emit enabledChanged(); emit enabledChanged();
}; };
connect(target, &Target::deploymentDataChanged, this, updateTargetInformation); connect(target, &Target::buildSystemUpdated, this, updateTargetInformation);
connect(target, &Target::applicationTargetsChanged, this, updateTargetInformation);
connect(target, &Target::parsingFinished, this, updateTargetInformation);
connect(target, &Target::kitChanged, this, updateTargetInformation); connect(target, &Target::kitChanged, this, updateTargetInformation);
} }

View File

@@ -29,6 +29,7 @@
#include "remotelinuxx11forwardingaspect.h" #include "remotelinuxx11forwardingaspect.h"
#include "remotelinuxenvironmentaspect.h" #include "remotelinuxenvironmentaspect.h"
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/deploymentdata.h> #include <projectexplorer/deploymentdata.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
@@ -68,11 +69,7 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Core::I
if (HostOsInfo::isAnyUnixHost()) if (HostOsInfo::isAnyUnixHost())
addAspect<X11ForwardingAspect>(); addAspect<X11ForwardingAspect>();
connect(target, &Target::deploymentDataChanged, connect(target, &Target::buildSystemUpdated,
this, &RemoteLinuxRunConfiguration::updateTargetInformation);
connect(target, &Target::applicationTargetsChanged,
this, &RemoteLinuxRunConfiguration::updateTargetInformation);
connect(target, &Target::parsingFinished,
this, &RemoteLinuxRunConfiguration::updateTargetInformation); this, &RemoteLinuxRunConfiguration::updateTargetInformation);
connect(target, &Target::kitChanged, connect(target, &Target::kitChanged,
this, &RemoteLinuxRunConfiguration::updateTargetInformation); this, &RemoteLinuxRunConfiguration::updateTargetInformation);