forked from qt-creator/qt-creator
CMake: Add logging category for generic cmake stuff
Use the category in CMakeProject. Change-Id: Idb19a92080884f1feff082d8e9db3ca5336b9249 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -66,6 +66,8 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(cmakeProjectLog, "qtc.cmake.project", QtWarningMsg);
|
||||||
|
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
static CMakeBuildConfiguration *activeBc(const CMakeProject *p)
|
static CMakeBuildConfiguration *activeBc(const CMakeProject *p)
|
||||||
@@ -267,6 +269,7 @@ CMakeProject::~CMakeProject()
|
|||||||
|
|
||||||
void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
||||||
{
|
{
|
||||||
|
qCDebug(cmakeProjectLog) << "Updating CMake project data";
|
||||||
const CMakeBuildConfiguration *aBc = activeBc(this);
|
const CMakeBuildConfiguration *aBc = activeBc(this);
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
|
|
||||||
@@ -277,9 +280,11 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
const QList<CMakeBuildTarget> buildTargets = m_buildDirManager.takeBuildTargets(errorMessage);
|
const QList<CMakeBuildTarget> buildTargets = m_buildDirManager.takeBuildTargets(errorMessage);
|
||||||
checkAndReportError(errorMessage);
|
checkAndReportError(errorMessage);
|
||||||
bc->setBuildTargets(buildTargets);
|
bc->setBuildTargets(buildTargets);
|
||||||
|
qCDebug(cmakeProjectLog) << "Build target data set.";
|
||||||
const CMakeConfig cmakeConfig = m_buildDirManager.takeCMakeConfiguration(errorMessage);
|
const CMakeConfig cmakeConfig = m_buildDirManager.takeCMakeConfiguration(errorMessage);
|
||||||
checkAndReportError(errorMessage);
|
checkAndReportError(errorMessage);
|
||||||
bc->setConfigurationFromCMake(cmakeConfig);
|
bc->setConfigurationFromCMake(cmakeConfig);
|
||||||
|
qCDebug(cmakeProjectLog) << "CMake configuration data set.";
|
||||||
|
|
||||||
CMakeConfig patchedConfig = cmakeConfig;
|
CMakeConfig patchedConfig = cmakeConfig;
|
||||||
{
|
{
|
||||||
@@ -313,7 +318,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
appsPaths.values = apps;
|
appsPaths.values = apps;
|
||||||
patchedConfig.append(appsPaths);
|
patchedConfig.append(appsPaths);
|
||||||
}
|
}
|
||||||
|
qCDebug(cmakeProjectLog) << "Application data regenerated.";
|
||||||
|
|
||||||
auto newRoot = generateProjectTree(m_allFiles);
|
auto newRoot = generateProjectTree(m_allFiles);
|
||||||
if (newRoot) {
|
if (newRoot) {
|
||||||
@@ -329,6 +334,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qCDebug(cmakeProjectLog) << "Project tree updated.";
|
||||||
|
|
||||||
Target *t = bc->target();
|
Target *t = bc->target();
|
||||||
t->setApplicationTargets(bc->appTargets());
|
t->setApplicationTargets(bc->appTargets());
|
||||||
@@ -339,12 +345,14 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
qDeleteAll(m_extraCompilers);
|
qDeleteAll(m_extraCompilers);
|
||||||
m_extraCompilers = findExtraCompilers();
|
m_extraCompilers = findExtraCompilers();
|
||||||
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
||||||
|
qCDebug(cmakeProjectLog) << "Extra compilers updated.";
|
||||||
|
|
||||||
QtSupport::CppKitInfo kitInfo(this);
|
QtSupport::CppKitInfo kitInfo(this);
|
||||||
QTC_ASSERT(kitInfo.isValid(), return);
|
QTC_ASSERT(kitInfo.isValid(), return);
|
||||||
|
|
||||||
CppTools::RawProjectParts rpps = m_buildDirManager.createRawProjectParts(errorMessage);
|
CppTools::RawProjectParts rpps = m_buildDirManager.createRawProjectParts(errorMessage);
|
||||||
checkAndReportError(errorMessage);
|
checkAndReportError(errorMessage);
|
||||||
|
qCDebug(cmakeProjectLog) << "Raw project parts created.";
|
||||||
|
|
||||||
for (CppTools::RawProjectPart &rpp : rpps) {
|
for (CppTools::RawProjectPart &rpp : rpps) {
|
||||||
rpp.setQtVersion(kitInfo.projectPartQtVersion); // TODO: Check if project actually uses Qt.
|
rpp.setQtVersion(kitInfo.projectPartQtVersion); // TODO: Check if project actually uses Qt.
|
||||||
@@ -355,14 +363,18 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_cppCodeModelUpdater->update({this, kitInfo, rpps});
|
m_cppCodeModelUpdater->update({this, kitInfo, rpps});
|
||||||
|
qCDebug(cmakeProjectLog) << "C++ codemodel updated.";
|
||||||
|
|
||||||
updateQmlJSCodeModel();
|
updateQmlJSCodeModel();
|
||||||
|
qCDebug(cmakeProjectLog) << "QML codemodel updated.";
|
||||||
|
|
||||||
m_buildDirManager.resetData();
|
m_buildDirManager.resetData();
|
||||||
|
qCDebug(cmakeProjectLog) << "CMake specific data was reset.";
|
||||||
|
|
||||||
emit fileListChanged();
|
emit fileListChanged();
|
||||||
|
|
||||||
bc->emitBuildTypeChanged();
|
bc->emitBuildTypeChanged();
|
||||||
|
qCDebug(cmakeProjectLog) << "All CMake project data up to date.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeProject::updateQmlJSCodeModel()
|
void CMakeProject::updateQmlJSCodeModel()
|
||||||
@@ -673,12 +685,17 @@ void CMakeProject::checkAndReportError(QString &errorMessage) const
|
|||||||
|
|
||||||
QList<ProjectExplorer::ExtraCompiler *> CMakeProject::findExtraCompilers() const
|
QList<ProjectExplorer::ExtraCompiler *> CMakeProject::findExtraCompilers() const
|
||||||
{
|
{
|
||||||
QList<ProjectExplorer::ExtraCompiler *> extraCompilers;
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: start.";
|
||||||
const QList<ExtraCompilerFactory *> factories =
|
|
||||||
ExtraCompilerFactory::extraCompilerFactories();
|
|
||||||
|
|
||||||
const QSet<QString> fileExtensions
|
QList<ProjectExplorer::ExtraCompiler *> extraCompilers;
|
||||||
= Utils::transform<QSet>(factories, &ExtraCompilerFactory::sourceTag);
|
const QList<ExtraCompilerFactory *> factories = ExtraCompilerFactory::extraCompilerFactories();
|
||||||
|
|
||||||
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got factories.";
|
||||||
|
|
||||||
|
const QSet<QString> fileExtensions = Utils::transform<QSet>(factories,
|
||||||
|
&ExtraCompilerFactory::sourceTag);
|
||||||
|
|
||||||
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got file extensions:" << fileExtensions;
|
||||||
|
|
||||||
// Find all files generated by any of the extra compilers, in a rather crude way.
|
// Find all files generated by any of the extra compilers, in a rather crude way.
|
||||||
const FilePathList fileList = files([&fileExtensions](const Node *n) {
|
const FilePathList fileList = files([&fileExtensions](const Node *n) {
|
||||||
@@ -689,14 +706,20 @@ QList<ProjectExplorer::ExtraCompiler *> CMakeProject::findExtraCompilers() const
|
|||||||
return pos >= 0 && fileExtensions.contains(fp.mid(pos + 1));
|
return pos >= 0 && fileExtensions.contains(fp.mid(pos + 1));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got list of files to check.";
|
||||||
|
|
||||||
// Generate the necessary information:
|
// Generate the necessary information:
|
||||||
for (const FilePath &file : fileList) {
|
for (const FilePath &file : fileList) {
|
||||||
ExtraCompilerFactory *factory = Utils::findOrDefault(factories, [&file](const ExtraCompilerFactory *f) {
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Processing" << file.toUserOutput();
|
||||||
return file.endsWith('.' + f->sourceTag());
|
ExtraCompilerFactory *factory = Utils::findOrDefault(factories,
|
||||||
});
|
[&file](const ExtraCompilerFactory *f) {
|
||||||
|
return file.endsWith(
|
||||||
|
'.' + f->sourceTag());
|
||||||
|
});
|
||||||
QTC_ASSERT(factory, continue);
|
QTC_ASSERT(factory, continue);
|
||||||
|
|
||||||
QStringList generated = filesGeneratedFrom(file.toString());
|
QStringList generated = filesGeneratedFrom(file.toString());
|
||||||
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: generated files:" << generated;
|
||||||
if (generated.isEmpty())
|
if (generated.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -704,8 +727,11 @@ QList<ProjectExplorer::ExtraCompiler *> CMakeProject::findExtraCompilers() const
|
|||||||
= transform(generated,
|
= transform(generated,
|
||||||
[](const QString &s) { return FilePath::fromString(s); });
|
[](const QString &s) { return FilePath::fromString(s); });
|
||||||
extraCompilers.append(factory->create(this, file, fileNames));
|
extraCompilers.append(factory->create(this, file, fileNames));
|
||||||
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: done with" << file.toUserOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qCDebug(cmakeProjectLog) << "Finding Extra Compilers: done.";
|
||||||
|
|
||||||
return extraCompilers;
|
return extraCompilers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user