forked from qt-creator/qt-creator
CMake: Move CMakeProjectManager::findCbpFile to tealeafreader.cpp
That's the the only user of that code. Change-Id: Iabc6a1fa9a4ad05c467e8ed64386d3185de25f02 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -173,23 +173,3 @@ QString CMakeManager::mimeType() const
|
|||||||
{
|
{
|
||||||
return QLatin1String(Constants::CMAKEPROJECTMIMETYPE);
|
return QLatin1String(Constants::CMAKEPROJECTMIMETYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeManager::findCbpFile(const QDir &directory)
|
|
||||||
{
|
|
||||||
// Find the cbp file
|
|
||||||
// the cbp file is named like the project() command in the CMakeList.txt file
|
|
||||||
// so this function below could find the wrong cbp file, if the user changes the project()
|
|
||||||
// 2name
|
|
||||||
QDateTime t;
|
|
||||||
QString file;
|
|
||||||
foreach (const QString &cbpFile , directory.entryList()) {
|
|
||||||
if (cbpFile.endsWith(QLatin1String(".cbp"))) {
|
|
||||||
QFileInfo fi(directory.path() + QLatin1Char('/') + cbpFile);
|
|
||||||
if (t.isNull() || fi.lastModified() > t) {
|
|
||||||
file = directory.path() + QLatin1Char('/') + cbpFile;
|
|
||||||
t = fi.lastModified();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
class QAction;
|
||||||
class QDir;
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
@@ -46,8 +45,6 @@ public:
|
|||||||
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString) override;
|
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString) override;
|
||||||
QString mimeType() const override;
|
QString mimeType() const override;
|
||||||
|
|
||||||
static QString findCbpFile(const QDir &);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateCmakeActions();
|
void updateCmakeActions();
|
||||||
void clearCMakeCache(ProjectExplorer::Project *project);
|
void clearCMakeCache(ProjectExplorer::Project *project);
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
#include "cmakekitinformation.h"
|
#include "cmakekitinformation.h"
|
||||||
#include "cmakeparser.h"
|
#include "cmakeparser.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectmanager.h"
|
|
||||||
#include "cmakeprojectnodes.h"
|
#include "cmakeprojectnodes.h"
|
||||||
|
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
@@ -169,9 +168,29 @@ void TeaLeafReader::resetData()
|
|||||||
m_files.clear();
|
m_files.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString findCbpFile(const QDir &directory)
|
||||||
|
{
|
||||||
|
// Find the cbp file
|
||||||
|
// the cbp file is named like the project() command in the CMakeList.txt file
|
||||||
|
// so this function below could find the wrong cbp file, if the user changes the project()
|
||||||
|
// 2name
|
||||||
|
QDateTime t;
|
||||||
|
QString file;
|
||||||
|
foreach (const QString &cbpFile , directory.entryList()) {
|
||||||
|
if (cbpFile.endsWith(QLatin1String(".cbp"))) {
|
||||||
|
QFileInfo fi(directory.path() + QLatin1Char('/') + cbpFile);
|
||||||
|
if (t.isNull() || fi.lastModified() > t) {
|
||||||
|
file = directory.path() + QLatin1Char('/') + cbpFile;
|
||||||
|
t = fi.lastModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
void TeaLeafReader::parse(bool force)
|
void TeaLeafReader::parse(bool force)
|
||||||
{
|
{
|
||||||
const QString cbpFile = CMakeManager::findCbpFile(QDir(m_parameters.buildDirectory.toString()));
|
const QString cbpFile = findCbpFile(QDir(m_parameters.buildDirectory.toString()));
|
||||||
const QFileInfo cbpFileFi = cbpFile.isEmpty() ? QFileInfo() : QFileInfo(cbpFile);
|
const QFileInfo cbpFileFi = cbpFile.isEmpty() ? QFileInfo() : QFileInfo(cbpFile);
|
||||||
if (!cbpFileFi.exists()) {
|
if (!cbpFileFi.exists()) {
|
||||||
// Initial create:
|
// Initial create:
|
||||||
@@ -385,7 +404,7 @@ void TeaLeafReader::extractData()
|
|||||||
// Do not insert topCMake into m_cmakeFiles: The project already watches that!
|
// Do not insert topCMake into m_cmakeFiles: The project already watches that!
|
||||||
|
|
||||||
// Find cbp file
|
// Find cbp file
|
||||||
FileName cbpFile = FileName::fromString(CMakeManager::findCbpFile(bldDir.toString()));
|
FileName cbpFile = FileName::fromString(findCbpFile(bldDir.toString()));
|
||||||
if (cbpFile.isEmpty())
|
if (cbpFile.isEmpty())
|
||||||
return;
|
return;
|
||||||
m_cmakeFiles.insert(cbpFile);
|
m_cmakeFiles.insert(cbpFile);
|
||||||
|
Reference in New Issue
Block a user