From 67186c761f93858e10589ad1a7baa4f2cde27c7b Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 17 Jun 2019 12:30:33 +0200 Subject: [PATCH] CMake: Add logging category for generic cmake stuff Use the category in CMakeProject. Change-Id: Idb19a92080884f1feff082d8e9db3ca5336b9249 Reviewed-by: Eike Ziller Reviewed-by: Cristian Adam --- .../cmakeprojectmanager/cmakeproject.cpp | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index b19ac2dfbe8..cebd0dac42e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -66,6 +66,8 @@ using namespace Utils; namespace CMakeProjectManager { +Q_LOGGING_CATEGORY(cmakeProjectLog, "qtc.cmake.project", QtWarningMsg); + using namespace Internal; static CMakeBuildConfiguration *activeBc(const CMakeProject *p) @@ -267,6 +269,7 @@ CMakeProject::~CMakeProject() void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc) { + qCDebug(cmakeProjectLog) << "Updating CMake project data"; const CMakeBuildConfiguration *aBc = activeBc(this); QString errorMessage; @@ -277,9 +280,11 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc) const QList buildTargets = m_buildDirManager.takeBuildTargets(errorMessage); checkAndReportError(errorMessage); bc->setBuildTargets(buildTargets); + qCDebug(cmakeProjectLog) << "Build target data set."; const CMakeConfig cmakeConfig = m_buildDirManager.takeCMakeConfiguration(errorMessage); checkAndReportError(errorMessage); bc->setConfigurationFromCMake(cmakeConfig); + qCDebug(cmakeProjectLog) << "CMake configuration data set."; CMakeConfig patchedConfig = cmakeConfig; { @@ -313,7 +318,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc) appsPaths.values = apps; patchedConfig.append(appsPaths); } - + qCDebug(cmakeProjectLog) << "Application data regenerated."; auto newRoot = generateProjectTree(m_allFiles); if (newRoot) { @@ -329,6 +334,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc) } } } + qCDebug(cmakeProjectLog) << "Project tree updated."; Target *t = bc->target(); t->setApplicationTargets(bc->appTargets()); @@ -339,12 +345,14 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc) qDeleteAll(m_extraCompilers); m_extraCompilers = findExtraCompilers(); CppTools::GeneratedCodeModelSupport::update(m_extraCompilers); + qCDebug(cmakeProjectLog) << "Extra compilers updated."; QtSupport::CppKitInfo kitInfo(this); QTC_ASSERT(kitInfo.isValid(), return); CppTools::RawProjectParts rpps = m_buildDirManager.createRawProjectParts(errorMessage); checkAndReportError(errorMessage); + qCDebug(cmakeProjectLog) << "Raw project parts created."; for (CppTools::RawProjectPart &rpp : rpps) { 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}); + qCDebug(cmakeProjectLog) << "C++ codemodel updated."; updateQmlJSCodeModel(); + qCDebug(cmakeProjectLog) << "QML codemodel updated."; m_buildDirManager.resetData(); + qCDebug(cmakeProjectLog) << "CMake specific data was reset."; emit fileListChanged(); bc->emitBuildTypeChanged(); + qCDebug(cmakeProjectLog) << "All CMake project data up to date."; } void CMakeProject::updateQmlJSCodeModel() @@ -673,12 +685,17 @@ void CMakeProject::checkAndReportError(QString &errorMessage) const QList CMakeProject::findExtraCompilers() const { - QList extraCompilers; - const QList factories = - ExtraCompilerFactory::extraCompilerFactories(); + qCDebug(cmakeProjectLog) << "Finding Extra Compilers: start."; - const QSet fileExtensions - = Utils::transform(factories, &ExtraCompilerFactory::sourceTag); + QList extraCompilers; + const QList factories = ExtraCompilerFactory::extraCompilerFactories(); + + qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got factories."; + + const QSet fileExtensions = Utils::transform(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. const FilePathList fileList = files([&fileExtensions](const Node *n) { @@ -689,14 +706,20 @@ QList CMakeProject::findExtraCompilers() const return pos >= 0 && fileExtensions.contains(fp.mid(pos + 1)); }); + qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Got list of files to check."; + // Generate the necessary information: for (const FilePath &file : fileList) { - ExtraCompilerFactory *factory = Utils::findOrDefault(factories, [&file](const ExtraCompilerFactory *f) { - return file.endsWith('.' + f->sourceTag()); - }); + qCDebug(cmakeProjectLog) << "Finding Extra Compilers: Processing" << file.toUserOutput(); + ExtraCompilerFactory *factory = Utils::findOrDefault(factories, + [&file](const ExtraCompilerFactory *f) { + return file.endsWith( + '.' + f->sourceTag()); + }); QTC_ASSERT(factory, continue); QStringList generated = filesGeneratedFrom(file.toString()); + qCDebug(cmakeProjectLog) << "Finding Extra Compilers: generated files:" << generated; if (generated.isEmpty()) continue; @@ -704,8 +727,11 @@ QList CMakeProject::findExtraCompilers() const = transform(generated, [](const QString &s) { return FilePath::fromString(s); }); extraCompilers.append(factory->create(this, file, fileNames)); + qCDebug(cmakeProjectLog) << "Finding Extra Compilers: done with" << file.toUserOutput(); } + qCDebug(cmakeProjectLog) << "Finding Extra Compilers: done."; + return extraCompilers; }