forked from qt-creator/qt-creator
CMake: Reimplement CMakeCache.txt parsing in BuildDirManager
The CMakeProjectImporter will need that in addition to the tealeafreader. Change-Id: I453a7a124b5303e163e9c85bc3fc215215617119 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -337,6 +337,19 @@ CMakeConfig BuildDirManager::parsedConfiguration() const
|
|||||||
return m_cmakeCache;
|
return m_cmakeCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMakeConfig BuildDirManager::parseConfiguration(const Utils::FileName &cacheFile, QString *errorMessage)
|
||||||
|
{
|
||||||
|
if (!cacheFile.exists()) {
|
||||||
|
if (errorMessage)
|
||||||
|
*errorMessage = tr("CMakeCache.txt file not found.");
|
||||||
|
return { };
|
||||||
|
}
|
||||||
|
CMakeConfig result = CMakeConfigItem::itemsFromFile(cacheFile, errorMessage);
|
||||||
|
if (!errorMessage->isEmpty())
|
||||||
|
return { };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void BuildDirManager::checkConfiguration()
|
void BuildDirManager::checkConfiguration()
|
||||||
{
|
{
|
||||||
if (m_tempDir) // always throw away changes in the tmpdir!
|
if (m_tempDir) // always throw away changes in the tmpdir!
|
||||||
|
@@ -78,15 +78,15 @@ public:
|
|||||||
QList<CMakeBuildTarget> buildTargets() const;
|
QList<CMakeBuildTarget> buildTargets() const;
|
||||||
CMakeConfig parsedConfiguration() const;
|
CMakeConfig parsedConfiguration() const;
|
||||||
|
|
||||||
|
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
|
||||||
|
QString *errorMessage);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void configurationStarted() const;
|
void configurationStarted() const;
|
||||||
void dataAvailable() const;
|
void dataAvailable() const;
|
||||||
void errorOccured(const QString &err) const;
|
void errorOccured(const QString &err) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static CMakeConfig parseConfiguration(const Utils::FileName &cacheFile,
|
|
||||||
QString *errorMessage);
|
|
||||||
|
|
||||||
const Utils::FileName workDirectory() const;
|
const Utils::FileName workDirectory() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "tealeafreader.h"
|
#include "tealeafreader.h"
|
||||||
|
|
||||||
|
#include "builddirmanager.h"
|
||||||
#include "cmakebuildconfiguration.h"
|
#include "cmakebuildconfiguration.h"
|
||||||
#include "cmakecbpparser.h"
|
#include "cmakecbpparser.h"
|
||||||
#include "cmakekitinformation.h"
|
#include "cmakekitinformation.h"
|
||||||
@@ -222,15 +223,16 @@ QList<CMakeBuildTarget> TeaLeafReader::buildTargets() const
|
|||||||
|
|
||||||
CMakeConfig TeaLeafReader::takeParsedConfiguration()
|
CMakeConfig TeaLeafReader::takeParsedConfiguration()
|
||||||
{
|
{
|
||||||
CMakeConfig result;
|
|
||||||
FileName cacheFile = m_parameters.buildDirectory;
|
FileName cacheFile = m_parameters.buildDirectory;
|
||||||
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
|
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
|
||||||
if (!cacheFile.exists())
|
|
||||||
return result;
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
result = CMakeConfigItem::itemsFromFile(cacheFile, &errorMessage);
|
CMakeConfig result = BuildDirManager::parseConfiguration(cacheFile, &errorMessage);
|
||||||
if (!errorMessage.isEmpty())
|
|
||||||
|
if (!errorMessage.isEmpty()) {
|
||||||
emit errorOccured(errorMessage);
|
emit errorOccured(errorMessage);
|
||||||
|
return { };
|
||||||
|
}
|
||||||
|
|
||||||
const FileName sourceOfBuildDir
|
const FileName sourceOfBuildDir
|
||||||
= FileName::fromUtf8(CMakeConfigItem::valueOf("CMAKE_HOME_DIRECTORY", result));
|
= FileName::fromUtf8(CMakeConfigItem::valueOf("CMAKE_HOME_DIRECTORY", result));
|
||||||
const FileName canonicalSourceOfBuildDir = FileUtils::canonicalPath(sourceOfBuildDir);
|
const FileName canonicalSourceOfBuildDir = FileUtils::canonicalPath(sourceOfBuildDir);
|
||||||
@@ -239,6 +241,7 @@ CMakeConfig TeaLeafReader::takeParsedConfiguration()
|
|||||||
emit errorOccured(tr("The build directory is not for %1 but for %2")
|
emit errorOccured(tr("The build directory is not for %1 but for %2")
|
||||||
.arg(canonicalSourceOfBuildDir.toUserOutput(),
|
.arg(canonicalSourceOfBuildDir.toUserOutput(),
|
||||||
canonicalSourceDirectory.toUserOutput()));
|
canonicalSourceDirectory.toUserOutput()));
|
||||||
|
return { };
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user