forked from qt-creator/qt-creator
CMake: Disable switching between different readers
Remove the code that switches between different types of readers based on what the different CMake binaries support. This is no longer needed since only file-api is supported now. Change-Id: Ia86d143f5e2cecc2bcd68ab7d62503915a32d223 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -5,7 +5,6 @@ add_qtc_plugin(CMakeProjectManager
|
||||
SOURCES
|
||||
builddirmanager.cpp builddirmanager.h
|
||||
builddirparameters.cpp builddirparameters.h
|
||||
builddirreader.cpp builddirreader.h
|
||||
cmake_global.h
|
||||
cmakeautocompleter.cpp cmakeautocompleter.h
|
||||
cmakebuildconfiguration.cpp cmakebuildconfiguration.h
|
||||
|
@@ -131,46 +131,6 @@ void BuildDirManager::emitReparseRequest() const
|
||||
}
|
||||
}
|
||||
|
||||
void BuildDirManager::updateReaderType(const BuildDirParameters &p,
|
||||
std::function<void()> todo)
|
||||
{
|
||||
if (!m_reader || !m_reader->isCompatible(p)) {
|
||||
if (m_reader) {
|
||||
stopParsingAndClearState();
|
||||
qCDebug(cmakeBuildDirManagerLog) << "Creating new reader do to incompatible parameters";
|
||||
} else {
|
||||
qCDebug(cmakeBuildDirManagerLog) << "Creating first reader";
|
||||
}
|
||||
m_reader = BuildDirReader::createReader(p);
|
||||
|
||||
if (!m_reader) {
|
||||
TaskHub::addTask(BuildSystemTask(
|
||||
Task::Error,
|
||||
tr("The kit does not define a valid CMake tool to parse this project with.")));
|
||||
return;
|
||||
}
|
||||
|
||||
connect(m_reader.get(),
|
||||
&BuildDirReader::configurationStarted,
|
||||
this,
|
||||
&BuildDirManager::parsingStarted);
|
||||
connect(m_reader.get(),
|
||||
&BuildDirReader::dataAvailable,
|
||||
this,
|
||||
&BuildDirManager::emitDataAvailable);
|
||||
connect(m_reader.get(),
|
||||
&BuildDirReader::errorOccurred,
|
||||
this,
|
||||
&BuildDirManager::emitErrorOccurred);
|
||||
connect(m_reader.get(), &BuildDirReader::dirty, this, &BuildDirManager::becameDirty);
|
||||
connect(m_reader.get(), &BuildDirReader::isReadyNow, this, todo);
|
||||
}
|
||||
|
||||
QTC_ASSERT(m_reader, return );
|
||||
|
||||
m_reader->setParameters(p);
|
||||
}
|
||||
|
||||
bool BuildDirManager::hasConfigChanged()
|
||||
{
|
||||
checkConfiguration();
|
||||
@@ -265,14 +225,7 @@ bool BuildDirManager::isParsing() const
|
||||
void BuildDirManager::stopParsingAndClearState()
|
||||
{
|
||||
qCDebug(cmakeBuildDirManagerLog) << "stopping parsing run!";
|
||||
if (m_reader) {
|
||||
if (m_reader->isParsing())
|
||||
m_reader->errorOccurred(tr("Parsing has been canceled."));
|
||||
disconnect(m_reader.get(), nullptr, this, nullptr);
|
||||
m_reader->stop();
|
||||
}
|
||||
m_reader.reset();
|
||||
resetData();
|
||||
}
|
||||
|
||||
void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters ¶meters,
|
||||
@@ -290,7 +243,25 @@ void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters &par
|
||||
m_parameters.workDirectory = workDirectory(parameters);
|
||||
updateReparseParameters(reparseParameters);
|
||||
|
||||
updateReaderType(m_parameters, [this]() { emitReparseRequest(); });
|
||||
QTC_CHECK(!m_reader); // The parsing should have stopped at this time already!
|
||||
m_reader = std::make_unique<FileApiReader>();
|
||||
|
||||
connect(m_reader.get(),
|
||||
&FileApiReader::configurationStarted,
|
||||
this,
|
||||
&BuildDirManager::parsingStarted);
|
||||
connect(m_reader.get(),
|
||||
&FileApiReader::dataAvailable,
|
||||
this,
|
||||
&BuildDirManager::emitDataAvailable);
|
||||
connect(m_reader.get(),
|
||||
&FileApiReader::errorOccurred,
|
||||
this,
|
||||
&BuildDirManager::emitErrorOccurred);
|
||||
connect(m_reader.get(), &FileApiReader::dirty, this, &BuildDirManager::becameDirty);
|
||||
|
||||
m_reader->setParameters(m_parameters);
|
||||
emitReparseRequest();
|
||||
}
|
||||
|
||||
CMakeBuildSystem *BuildDirManager::buildSystem() const
|
||||
@@ -319,8 +290,7 @@ void BuildDirManager::becameDirty()
|
||||
|
||||
void BuildDirManager::resetData()
|
||||
{
|
||||
if (m_reader)
|
||||
m_reader->resetData();
|
||||
m_reader.reset();
|
||||
}
|
||||
|
||||
bool BuildDirManager::persistCMakeState()
|
||||
|
@@ -26,8 +26,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "builddirparameters.h"
|
||||
#include "builddirreader.h"
|
||||
#include "cmakebuildtarget.h"
|
||||
#include "fileapireader.h"
|
||||
|
||||
#include <projectexplorer/rawprojectpart.h>
|
||||
|
||||
@@ -116,8 +116,6 @@ private:
|
||||
|
||||
Utils::FilePath workDirectory(const BuildDirParameters ¶meters) const;
|
||||
|
||||
void updateReaderType(const BuildDirParameters &p, std::function<void()> todo);
|
||||
|
||||
bool hasConfigChanged();
|
||||
|
||||
void writeConfigurationIntoBuildDirectory(const Utils::MacroExpander *expander);
|
||||
@@ -128,7 +126,7 @@ private:
|
||||
int m_reparseParameters;
|
||||
CMakeBuildSystem *m_buildSystem = nullptr;
|
||||
mutable std::unordered_map<Utils::FilePath, std::unique_ptr<Utils::TemporaryDirectory>> m_buildDirToTempDir;
|
||||
mutable std::unique_ptr<BuildDirReader> m_reader;
|
||||
mutable std::unique_ptr<FileApiReader> m_reader;
|
||||
mutable bool m_isHandlingError = false;
|
||||
};
|
||||
|
||||
|
@@ -1,56 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "builddirreader.h"
|
||||
|
||||
#include "fileapireader.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// BuildDirReader:
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
std::unique_ptr<BuildDirReader> BuildDirReader::createReader(const BuildDirParameters &p)
|
||||
{
|
||||
CMakeTool *cmake = p.cmakeTool();
|
||||
QTC_ASSERT(p.isValid() && cmake, return {});
|
||||
|
||||
auto type = cmake->readerType();
|
||||
if (!type)
|
||||
return {};
|
||||
switch (type.value()) {
|
||||
case CMakeTool::FileApi:
|
||||
return std::make_unique<FileApiReader>();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CMakeProjectManager
|
@@ -1,80 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "builddirparameters.h"
|
||||
#include "cmakebuildtarget.h"
|
||||
|
||||
#include <projectexplorer/rawprojectpart.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ProjectExplorer { class FileNode; }
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeBuildConfiguration;
|
||||
class CMakeProjectNode;
|
||||
|
||||
class BuildDirReader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static std::unique_ptr<BuildDirReader> createReader(const BuildDirParameters &p);
|
||||
virtual void setParameters(const BuildDirParameters &p) = 0;
|
||||
|
||||
virtual bool isCompatible(const BuildDirParameters &p) = 0;
|
||||
virtual void resetData() = 0;
|
||||
virtual void parse(bool forceCMakeRun, bool forceConfiguration) = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
virtual bool isParsing() const = 0;
|
||||
|
||||
virtual QSet<Utils::FilePath> projectFilesToWatch() const = 0;
|
||||
virtual QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) = 0;
|
||||
virtual CMakeConfig takeParsedConfiguration(QString &errorMessage) = 0;
|
||||
virtual std::unique_ptr<CMakeProjectNode> generateProjectTree(
|
||||
const QList<const ProjectExplorer::FileNode *> &allFiles, QString &errorMessage)
|
||||
= 0;
|
||||
virtual ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage) = 0;
|
||||
|
||||
signals:
|
||||
void isReadyNow() const;
|
||||
void configurationStarted() const;
|
||||
void dataAvailable() const;
|
||||
void dirty() const;
|
||||
void errorOccurred(const QString &message) const;
|
||||
|
||||
protected:
|
||||
BuildDirParameters m_parameters;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CMakeProjectManager
|
@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
|
||||
|
||||
HEADERS = builddirmanager.h \
|
||||
builddirparameters.h \
|
||||
builddirreader.h \
|
||||
cmakebuildstep.h \
|
||||
cmakebuildsystem.h \
|
||||
cmakebuildtarget.h \
|
||||
@@ -40,7 +39,6 @@ HEADERS = builddirmanager.h \
|
||||
|
||||
SOURCES = builddirmanager.cpp \
|
||||
builddirparameters.cpp \
|
||||
builddirreader.cpp \
|
||||
cmakebuildstep.cpp \
|
||||
cmakebuildsystem.cpp \
|
||||
cmakeconfigitem.cpp \
|
||||
|
@@ -23,8 +23,6 @@ QtcPlugin {
|
||||
"builddirparameters.h",
|
||||
"builddirmanager.cpp",
|
||||
"builddirmanager.h",
|
||||
"builddirreader.cpp",
|
||||
"builddirreader.h",
|
||||
"cmake_global.h",
|
||||
"cmakebuildconfiguration.cpp",
|
||||
"cmakebuildconfiguration.h",
|
||||
|
@@ -54,6 +54,8 @@ FileApiReader::FileApiReader() {}
|
||||
|
||||
FileApiReader::~FileApiReader()
|
||||
{
|
||||
if (isParsing())
|
||||
emit errorOccurred(tr("Parsing has been canceled."));
|
||||
stop();
|
||||
resetData();
|
||||
}
|
||||
@@ -74,15 +76,6 @@ void FileApiReader::setParameters(const BuildDirParameters &p)
|
||||
if (!m_isParsing)
|
||||
emit dirty();
|
||||
});
|
||||
|
||||
qCDebug(cmakeFileApiMode) << "FileApiReader: IS READY NOW SIGNAL";
|
||||
emit isReadyNow();
|
||||
}
|
||||
|
||||
bool FileApiReader::isCompatible(const BuildDirParameters &p)
|
||||
{
|
||||
const CMakeTool *cmakeTool = p.cmakeTool();
|
||||
return cmakeTool && cmakeTool->readerType() == CMakeTool::FileApi;
|
||||
}
|
||||
|
||||
void FileApiReader::resetData()
|
||||
|
@@ -25,13 +25,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "builddirreader.h"
|
||||
#include "fileapiparser.h"
|
||||
#include "cmakebuildtarget.h"
|
||||
#include "cmakeprocess.h"
|
||||
#include "cmakeprojectnodes.h"
|
||||
#include "fileapiparser.h"
|
||||
|
||||
#include <projectexplorer/rawprojectpart.h>
|
||||
|
||||
#include <utils/optional.h>
|
||||
|
||||
#include <QFuture>
|
||||
#include <QObject>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -44,29 +48,34 @@ namespace Internal {
|
||||
|
||||
class FileApiQtcData;
|
||||
|
||||
class FileApiReader final : public BuildDirReader
|
||||
class FileApiReader final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileApiReader();
|
||||
~FileApiReader() final;
|
||||
~FileApiReader();
|
||||
|
||||
void setParameters(const BuildDirParameters &p) final;
|
||||
void setParameters(const BuildDirParameters &p);
|
||||
|
||||
bool isCompatible(const BuildDirParameters &p) final;
|
||||
void resetData() final;
|
||||
void parse(bool forceCMakeRun, bool forceConfiguration) final;
|
||||
void stop() final;
|
||||
void resetData();
|
||||
void parse(bool forceCMakeRun, bool forceConfiguration);
|
||||
void stop();
|
||||
|
||||
bool isParsing() const final;
|
||||
bool isParsing() const;
|
||||
|
||||
QSet<Utils::FilePath> projectFilesToWatch() const final;
|
||||
QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) final;
|
||||
CMakeConfig takeParsedConfiguration(QString &errorMessage) final;
|
||||
QSet<Utils::FilePath> projectFilesToWatch() const;
|
||||
QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage);
|
||||
CMakeConfig takeParsedConfiguration(QString &errorMessage);
|
||||
std::unique_ptr<CMakeProjectNode> generateProjectTree(
|
||||
const QList<const ProjectExplorer::FileNode *> &allFiles, QString &errorMessage) final;
|
||||
ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage) final;
|
||||
const QList<const ProjectExplorer::FileNode *> &allFiles, QString &errorMessage);
|
||||
ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage);
|
||||
|
||||
signals:
|
||||
void configurationStarted() const;
|
||||
void dataAvailable() const;
|
||||
void dirty() const;
|
||||
void errorOccurred(const QString &message) const;
|
||||
|
||||
private:
|
||||
void startState();
|
||||
@@ -90,6 +99,8 @@ private:
|
||||
bool m_isParsing = false;
|
||||
|
||||
std::unique_ptr<FileApiParser> m_fileApi;
|
||||
|
||||
BuildDirParameters m_parameters;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user