forked from qt-creator/qt-creator
ProjectExplorer: Refactor BuildSystem::extraCompilerForSource
Factor out backend into more generic function to easily support new accessors. No functional changes. Change-Id: I715ce2842d2c63574bdf6ada0d0e32fbfd5d08fb Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1401,11 +1401,9 @@ void CMakeBuildSystem::runGenerator(Id id)
|
|||||||
proc->start();
|
proc->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtraCompiler *CMakeBuildSystem::extraCompilerForSource(const Utils::FilePath &source)
|
ExtraCompiler *CMakeBuildSystem::findExtraCompiler(const ExtraCompilerFilter &filter) const
|
||||||
{
|
{
|
||||||
return Utils::findOrDefault(m_extraCompilers, [source](ExtraCompiler *ec) {
|
return Utils::findOrDefault(m_extraCompilers, filter);
|
||||||
return ec->source() == source;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
@@ -122,7 +122,8 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QList<QPair<Utils::Id, QString>> generators() const override;
|
QList<QPair<Utils::Id, QString>> generators() const override;
|
||||||
void runGenerator(Utils::Id id) override;
|
void runGenerator(Utils::Id id) override;
|
||||||
ProjectExplorer::ExtraCompiler *extraCompilerForSource(const Utils::FilePath &source) override;
|
ProjectExplorer::ExtraCompiler *findExtraCompiler(
|
||||||
|
const ExtraCompilerFilter &filter) const override;
|
||||||
|
|
||||||
enum ForceEnabledChanged { False, True };
|
enum ForceEnabledChanged { False, True };
|
||||||
void clearError(ForceEnabledChanged fec = ForceEnabledChanged::False);
|
void clearError(ForceEnabledChanged fec = ForceEnabledChanged::False);
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include "buildsystem.h"
|
#include "buildsystem.h"
|
||||||
|
|
||||||
#include "buildconfiguration.h"
|
#include "buildconfiguration.h"
|
||||||
|
#include "extracompiler.h"
|
||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
#include "projectexplorertr.h"
|
#include "projectexplorertr.h"
|
||||||
#include "runconfiguration.h"
|
#include "runconfiguration.h"
|
||||||
@@ -190,6 +191,12 @@ void BuildSystem::requestParseHelper(int delay)
|
|||||||
d->m_delayedParsingTimer.start();
|
d->m_delayedParsingTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtraCompiler *BuildSystem::findExtraCompiler(
|
||||||
|
const std::function<bool (const ExtraCompiler *)> &) const
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool BuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *notAdded)
|
bool BuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *notAdded)
|
||||||
{
|
{
|
||||||
Q_UNUSED(filePaths)
|
Q_UNUSED(filePaths)
|
||||||
@@ -236,10 +243,9 @@ bool BuildSystem::supportsAction(Node *, ProjectAction, const Node *) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtraCompiler *BuildSystem::extraCompilerForSource(const Utils::FilePath &source)
|
ExtraCompiler *BuildSystem::extraCompilerForSource(const Utils::FilePath &source) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(source);
|
return findExtraCompiler([source](const ExtraCompiler *ec) { return ec->source() == source; });
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeInstallCommand BuildSystem::makeInstallCommand(const FilePath &installRoot) const
|
MakeInstallCommand BuildSystem::makeInstallCommand(const FilePath &installRoot) const
|
||||||
|
@@ -84,7 +84,7 @@ public:
|
|||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
|
|
||||||
// Owned by the build system. Use only in main thread. Can go away at any time.
|
// Owned by the build system. Use only in main thread. Can go away at any time.
|
||||||
virtual ExtraCompiler *extraCompilerForSource(const Utils::FilePath &source);
|
ExtraCompiler *extraCompilerForSource(const Utils::FilePath &source) const;
|
||||||
|
|
||||||
virtual MakeInstallCommand makeInstallCommand(const Utils::FilePath &installRoot) const;
|
virtual MakeInstallCommand makeInstallCommand(const Utils::FilePath &installRoot) const;
|
||||||
|
|
||||||
@@ -161,9 +161,12 @@ protected:
|
|||||||
// Call in GUI thread right after the actual parsing is done
|
// Call in GUI thread right after the actual parsing is done
|
||||||
void emitParsingFinished(bool success);
|
void emitParsingFinished(bool success);
|
||||||
|
|
||||||
|
using ExtraCompilerFilter = std::function<bool(const ExtraCompiler *)>;
|
||||||
private:
|
private:
|
||||||
void requestParseHelper(int delay); // request a (delayed!) parser run.
|
void requestParseHelper(int delay); // request a (delayed!) parser run.
|
||||||
|
|
||||||
|
virtual ExtraCompiler *findExtraCompiler(const ExtraCompilerFilter &filter) const;
|
||||||
|
|
||||||
class BuildSystemPrivate *d = nullptr;
|
class BuildSystemPrivate *d = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -586,11 +586,9 @@ void QbsBuildSystem::delayParsing()
|
|||||||
requestDelayedParse();
|
requestDelayedParse();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtraCompiler *QbsBuildSystem::extraCompilerForSource(const Utils::FilePath &source)
|
ExtraCompiler *QbsBuildSystem::findExtraCompiler(const ExtraCompilerFilter &filter) const
|
||||||
{
|
{
|
||||||
return Utils::findOrDefault(m_extraCompilers, [source](ExtraCompiler *ec) {
|
return Utils::findOrDefault(m_extraCompilers, filter);
|
||||||
return ec->source() == source;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsBuildSystem::parseCurrentBuildConfiguration()
|
void QbsBuildSystem::parseCurrentBuildConfiguration()
|
||||||
|
@@ -105,7 +105,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
friend class QbsProject;
|
friend class QbsProject;
|
||||||
|
|
||||||
ProjectExplorer::ExtraCompiler *extraCompilerForSource(const Utils::FilePath &source) override;
|
ProjectExplorer::ExtraCompiler *findExtraCompiler(
|
||||||
|
const ExtraCompilerFilter &filter) const override;
|
||||||
|
|
||||||
void handleQbsParsingDone(bool success);
|
void handleQbsParsingDone(bool success);
|
||||||
void changeActiveTarget(ProjectExplorer::Target *t);
|
void changeActiveTarget(ProjectExplorer::Target *t);
|
||||||
|
@@ -2080,15 +2080,16 @@ QList<ExtraCompiler *> QmakeProFile::extraCompilers() const
|
|||||||
return m_extraCompilers;
|
return m_extraCompilers;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtraCompiler *QmakeProFile::extraCompilerForSource(const Utils::FilePath &sourceFile)
|
ExtraCompiler *QmakeProFile::findExtraCompiler(
|
||||||
|
const std::function<bool(ProjectExplorer::ExtraCompiler *)> &filter)
|
||||||
{
|
{
|
||||||
for (ExtraCompiler * const ec : std::as_const(m_extraCompilers)) {
|
for (ExtraCompiler * const ec : std::as_const(m_extraCompilers)) {
|
||||||
if (ec->source() == sourceFile)
|
if (filter(ec))
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
for (QmakePriFile * const priFile : std::as_const(m_children)) {
|
for (QmakePriFile * const priFile : std::as_const(m_children)) {
|
||||||
if (const auto proFile = dynamic_cast<QmakeProFile *>(priFile)) {
|
if (const auto proFile = dynamic_cast<QmakeProFile *>(priFile)) {
|
||||||
if (ExtraCompiler * const ec = proFile->extraCompilerForSource(sourceFile))
|
if (ExtraCompiler * const ec = proFile->findExtraCompiler(filter))
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -301,7 +301,8 @@ public:
|
|||||||
const Utils::FilePath &sourceFile,
|
const Utils::FilePath &sourceFile,
|
||||||
const ProjectExplorer::FileType &sourceFileType) const;
|
const ProjectExplorer::FileType &sourceFileType) const;
|
||||||
QList<ProjectExplorer::ExtraCompiler *> extraCompilers() const;
|
QList<ProjectExplorer::ExtraCompiler *> extraCompilers() const;
|
||||||
ProjectExplorer::ExtraCompiler *extraCompilerForSource(const Utils::FilePath &sourceFile);
|
ProjectExplorer::ExtraCompiler *findExtraCompiler(
|
||||||
|
const std::function<bool(ProjectExplorer::ExtraCompiler *)> &filter);
|
||||||
|
|
||||||
TargetInformation targetInformation() const;
|
TargetInformation targetInformation() const;
|
||||||
InstallsList installsList() const;
|
InstallsList installsList() const;
|
||||||
|
@@ -532,9 +532,9 @@ void QmakeBuildSystem::scheduleUpdateAllNowOrLater()
|
|||||||
scheduleUpdateAll(QmakeProFile::ParseLater);
|
scheduleUpdateAll(QmakeProFile::ParseLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtraCompiler *QmakeBuildSystem::extraCompilerForSource(const Utils::FilePath &source)
|
ExtraCompiler *QmakeBuildSystem::findExtraCompiler(const ExtraCompilerFilter &filter) const
|
||||||
{
|
{
|
||||||
return m_rootProFile->extraCompilerForSource(source);
|
return m_rootProFile->findExtraCompiler(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeBuildConfiguration *QmakeBuildSystem::qmakeBuildConfiguration() const
|
QmakeBuildConfiguration *QmakeBuildSystem::qmakeBuildConfiguration() const
|
||||||
|
@@ -163,7 +163,8 @@ public:
|
|||||||
void scheduleUpdateAllNowOrLater();
|
void scheduleUpdateAllNowOrLater();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectExplorer::ExtraCompiler *extraCompilerForSource(const Utils::FilePath &source) override;
|
ProjectExplorer::ExtraCompiler *findExtraCompiler(
|
||||||
|
const ExtraCompilerFilter &filter) const override;
|
||||||
|
|
||||||
void scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay);
|
void scheduleUpdateAll(QmakeProFile::AsyncUpdateDelay delay);
|
||||||
void scheduleUpdateAllLater() { scheduleUpdateAll(QmakeProFile::ParseLater); }
|
void scheduleUpdateAllLater() { scheduleUpdateAll(QmakeProFile::ParseLater); }
|
||||||
|
Reference in New Issue
Block a user