| 
									
										
										
										
											2022-08-19 15:59:36 +02:00
										 |  |  | // Copyright (C) 2018 The Qt Company Ltd.
 | 
					
						
							| 
									
										
										
										
											2022-12-21 10:12:09 +01:00
										 |  |  | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "compilationdatabaseproject.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "compilationdatabaseconstants.h"
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  | #include "compilationdbparser.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-17 23:21:31 +01:00
										 |  |  | #include <coreplugin/coreplugintr.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | #include <coreplugin/icontext.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-30 10:58:08 +02:00
										 |  |  | #include <cppeditor/cppprojectupdater.h>
 | 
					
						
							|  |  |  | #include <cppeditor/projectinfo.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | #include <projectexplorer/buildinfo.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/buildsteplist.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/buildtargetinfo.h>
 | 
					
						
							| 
									
										
										
										
											2019-10-28 17:15:38 +01:00
										 |  |  | #include <projectexplorer/deploymentdata.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | #include <projectexplorer/gcctoolchain.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | #include <projectexplorer/headerpath.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | #include <projectexplorer/kitinformation.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-04 13:43:38 +01:00
										 |  |  | #include <projectexplorer/kitmanager.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | #include <projectexplorer/namedwidget.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | #include <projectexplorer/projectexplorerconstants.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/projectnodes.h>
 | 
					
						
							| 
									
										
										
										
											2018-11-01 15:10:52 +01:00
										 |  |  | #include <projectexplorer/target.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | #include <projectexplorer/toolchainmanager.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | #include <texteditor/textdocument.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <utils/algorithm.h>
 | 
					
						
							| 
									
										
										
										
											2019-10-28 17:15:38 +01:00
										 |  |  | #include <utils/filesystemwatcher.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | #include <utils/qtcassert.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | #ifdef Q_OS_WIN
 | 
					
						
							| 
									
										
										
										
											2021-09-24 17:07:56 +03:00
										 |  |  | #include <windows.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using namespace ProjectExplorer; | 
					
						
							| 
									
										
										
										
											2019-06-27 10:22:13 +02:00
										 |  |  | using namespace Utils; | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace CompilationDatabaseProjectManager { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | namespace { | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | bool isGccCompiler(const QString &compilerName) | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  |     return compilerName.contains("gcc") | 
					
						
							|  |  |  |            || (compilerName.contains("g++") && !compilerName.contains("clang")); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  | bool isClCompatibleCompiler(const QString &compilerName) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return compilerName.endsWith("cl"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 13:59:38 +02:00
										 |  |  | Utils::Id getCompilerId(QString compilerName) | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     if (Utils::HostOsInfo::isWindowsHost()) { | 
					
						
							|  |  |  |         if (compilerName.endsWith(".exe")) | 
					
						
							|  |  |  |             compilerName.chop(4); | 
					
						
							|  |  |  |         if (isGccCompiler(compilerName)) | 
					
						
							|  |  |  |             return ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID; | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         if (isClCompatibleCompiler(compilerName)) | 
					
						
							|  |  |  |             return ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID; | 
					
						
							|  |  |  |         return ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID; | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (isGccCompiler(compilerName)) | 
					
						
							|  |  |  |         return ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID; | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     // Default is clang
 | 
					
						
							|  |  |  |     return ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 13:59:38 +02:00
										 |  |  | ToolChain *toolchainFromCompilerId(const Utils::Id &compilerId, const Utils::Id &language) | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return ToolChainManager::toolChain([&compilerId, &language](const ToolChain *tc) { | 
					
						
							|  |  |  |         if (!tc->isValid() || tc->language() != language) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         return tc->typeId() == compilerId; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | QString compilerPath(QString pathFlag) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (pathFlag.isEmpty()) | 
					
						
							|  |  |  |         return pathFlag; | 
					
						
							|  |  |  | #ifdef Q_OS_WIN
 | 
					
						
							|  |  |  |     // Handle short DOS style file names (cmake can generate them).
 | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  |     const DWORD pathLength = GetLongPathNameW(reinterpret_cast<LPCWSTR>(pathFlag.utf16()), | 
					
						
							|  |  |  |                                               nullptr, | 
					
						
							|  |  |  |                                               0); | 
					
						
							|  |  |  |     if (pathLength > 0) { | 
					
						
							|  |  |  |         // Works only with existing paths.
 | 
					
						
							|  |  |  |         wchar_t *buffer = new wchar_t[pathLength]; | 
					
						
							|  |  |  |         GetLongPathNameW(reinterpret_cast<LPCWSTR>(pathFlag.utf16()), buffer, pathLength); | 
					
						
							|  |  |  |         pathFlag = QString::fromUtf16(reinterpret_cast<ushort *>(buffer), | 
					
						
							|  |  |  |                                       static_cast<int>(pathLength - 1)); | 
					
						
							|  |  |  |         delete[] buffer; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  |     return QDir::fromNativeSeparators(pathFlag); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 13:59:38 +02:00
										 |  |  | ToolChain *toolchainFromFlags(const Kit *kit, const QStringList &flags, const Utils::Id &language) | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (flags.empty()) | 
					
						
							| 
									
										
										
										
											2019-02-06 12:50:51 +01:00
										 |  |  |         return ToolChainKitAspect::toolChain(kit, language); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     // Try exact compiler match.
 | 
					
						
							| 
									
										
										
										
											2023-01-26 13:52:11 +01:00
										 |  |  |     const Utils::FilePath compiler = Utils::FilePath::fromUserInput(compilerPath(flags.front())); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     ToolChain *toolchain = ToolChainManager::toolChain([&compiler, &language](const ToolChain *tc) { | 
					
						
							|  |  |  |         return tc->isValid() && tc->language() == language && tc->compilerCommand() == compiler; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     if (toolchain) | 
					
						
							|  |  |  |         return toolchain; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 13:59:38 +02:00
										 |  |  |     Utils::Id compilerId = getCompilerId(compiler.fileName()); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     if ((toolchain = toolchainFromCompilerId(compilerId, language))) | 
					
						
							|  |  |  |         return toolchain; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (compilerId != ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID && | 
					
						
							|  |  |  |             compilerId != ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID) { | 
					
						
							|  |  |  |         compilerId = Utils::HostOsInfo::isWindowsHost() | 
					
						
							|  |  |  |                 ? ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID | 
					
						
							|  |  |  |                 : ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID; | 
					
						
							|  |  |  |         if ((toolchain = toolchainFromCompilerId(compilerId, language))) | 
					
						
							|  |  |  |             return toolchain; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 12:50:51 +01:00
										 |  |  |     toolchain = ToolChainKitAspect::toolChain(kit, language); | 
					
						
							| 
									
										
										
										
											2018-11-14 12:11:33 +01:00
										 |  |  |     qWarning() << "No matching toolchain found, use the default."; | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     return toolchain; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  | void addDriverModeFlagIfNeeded(const ToolChain *toolchain, | 
					
						
							|  |  |  |                                QStringList &flags, | 
					
						
							|  |  |  |                                const QStringList &originalFlags) | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     if (toolchain->typeId() == ProjectExplorer::Constants::CLANG_CL_TOOLCHAIN_TYPEID | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  |         && !originalFlags.empty() && !originalFlags.front().endsWith("cl") | 
					
						
							|  |  |  |         && !originalFlags.front().endsWith("cl.exe")) { | 
					
						
							| 
									
										
										
										
											2018-11-01 09:22:52 +01:00
										 |  |  |         flags.prepend("--driver-mode=g++"); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  | RawProjectPart makeRawProjectPart(const Utils::FilePath &projectFile, | 
					
						
							|  |  |  |                                   Kit *kit, | 
					
						
							| 
									
										
										
										
											2019-08-29 09:59:45 +02:00
										 |  |  |                                   ProjectExplorer::KitInfo &kitInfo, | 
					
						
							| 
									
										
										
										
											2022-11-25 14:06:47 +01:00
										 |  |  |                                   const FilePath &workingDir, | 
					
						
							|  |  |  |                                   const FilePath &filePath, | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |                                   QStringList flags) | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     HeaderPaths headerPaths; | 
					
						
							|  |  |  |     Macros macros; | 
					
						
							| 
									
										
										
										
											2021-08-30 10:58:08 +02:00
										 |  |  |     CppEditor::ProjectFile::Kind fileKind = CppEditor::ProjectFile::Unclassified; | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const QStringList originalFlags = flags; | 
					
						
							| 
									
										
										
										
											2022-11-25 14:06:47 +01:00
										 |  |  |     filteredFlags(filePath, | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |                   workingDir, | 
					
						
							|  |  |  |                   flags, | 
					
						
							|  |  |  |                   headerPaths, | 
					
						
							|  |  |  |                   macros, | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |                   fileKind, | 
					
						
							|  |  |  |                   kitInfo.sysRootPath); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |     RawProjectPart rpp; | 
					
						
							| 
									
										
										
										
											2022-11-25 14:06:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  |     rpp.setProjectFileLocation(projectFile.toString()); | 
					
						
							| 
									
										
										
										
											2022-11-25 14:06:47 +01:00
										 |  |  |     rpp.setBuildSystemTarget(workingDir.path()); | 
					
						
							|  |  |  |     rpp.setDisplayName(filePath.fileName()); | 
					
						
							|  |  |  |     rpp.setFiles({filePath.toFSPathString()}); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     rpp.setHeaderPaths(headerPaths); | 
					
						
							|  |  |  |     rpp.setMacros(macros); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-30 10:58:08 +02:00
										 |  |  |     if (fileKind == CppEditor::ProjectFile::Kind::CHeader | 
					
						
							|  |  |  |             || fileKind == CppEditor::ProjectFile::Kind::CSource) { | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         if (!kitInfo.cToolChain) { | 
					
						
							|  |  |  |             kitInfo.cToolChain = toolchainFromFlags(kit, | 
					
						
							|  |  |  |                                                     originalFlags, | 
					
						
							|  |  |  |                                                     ProjectExplorer::Constants::C_LANGUAGE_ID); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         addDriverModeFlagIfNeeded(kitInfo.cToolChain, flags, originalFlags); | 
					
						
							| 
									
										
										
										
											2018-06-11 12:52:04 +02:00
										 |  |  |         rpp.setFlagsForC({kitInfo.cToolChain, flags, workingDir}); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         if (!kitInfo.cxxToolChain) { | 
					
						
							|  |  |  |             kitInfo.cxxToolChain = toolchainFromFlags(kit, | 
					
						
							|  |  |  |                                                       originalFlags, | 
					
						
							|  |  |  |                                                       ProjectExplorer::Constants::CXX_LANGUAGE_ID); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         addDriverModeFlagIfNeeded(kitInfo.cxxToolChain, flags, originalFlags); | 
					
						
							| 
									
										
										
										
											2018-06-11 12:52:04 +02:00
										 |  |  |         rpp.setFlagsForCxx({kitInfo.cxxToolChain, flags, workingDir}); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return rpp; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  | QStringList relativeDirsList(Utils::FilePath currentPath, const Utils::FilePath &rootPath) | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QStringList dirsList; | 
					
						
							|  |  |  |     while (!currentPath.isEmpty() && currentPath != rootPath) { | 
					
						
							|  |  |  |         QString dirName = currentPath.fileName(); | 
					
						
							|  |  |  |         if (dirName.isEmpty()) | 
					
						
							|  |  |  |             dirName = currentPath.toString(); | 
					
						
							|  |  |  |         dirsList.prepend(dirName); | 
					
						
							|  |  |  |         currentPath = currentPath.parentDir(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return dirsList; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | FolderNode *addChildFolderNode(FolderNode *parent, const QString &childName) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |     const Utils::FilePath path = parent->filePath().pathAppended(childName); | 
					
						
							| 
									
										
										
										
											2019-05-16 14:49:56 +02:00
										 |  |  |     auto node = std::make_unique<FolderNode>(path); | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  |     FolderNode *childNode = node.get(); | 
					
						
							| 
									
										
										
										
											2019-02-25 18:08:36 +01:00
										 |  |  |     childNode->setDisplayName(childName); | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  |     parent->addNode(std::move(node)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return childNode; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | FolderNode *addOrGetChildFolderNode(FolderNode *parent, const QString &childName) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-14 12:56:57 +01:00
										 |  |  |     for (FolderNode *folder : parent->folderNodes()) { | 
					
						
							|  |  |  |         if (folder->filePath().fileName() == childName) { | 
					
						
							|  |  |  |             return folder; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return addChildFolderNode(parent, childName); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Return the node for folderPath.
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  | FolderNode *createFoldersIfNeeded(FolderNode *root, const Utils::FilePath &folderPath) | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const QStringList dirsList = relativeDirsList(folderPath, root->filePath()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     FolderNode *parent = root; | 
					
						
							|  |  |  |     for (const QString &dir : dirsList) | 
					
						
							|  |  |  |         parent = addOrGetChildFolderNode(parent, dir); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return parent; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  | FileType fileTypeForName(const QString &fileName) | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-08-30 10:58:08 +02:00
										 |  |  |     CppEditor::ProjectFile::Kind fileKind = CppEditor::ProjectFile::classify(fileName); | 
					
						
							|  |  |  |     if (CppEditor::ProjectFile::isHeader(fileKind)) | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  |         return FileType::Header; | 
					
						
							|  |  |  |     return FileType::Source; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  | void addChild(FolderNode *root, const Utils::FilePath &fileName) | 
					
						
							| 
									
										
										
										
											2019-04-26 11:41:49 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     FolderNode *parentNode = createFoldersIfNeeded(root, fileName.parentDir()); | 
					
						
							|  |  |  |     if (!parentNode->fileNode(fileName)) { | 
					
						
							|  |  |  |         parentNode->addNode( | 
					
						
							|  |  |  |             std::make_unique<FileNode>(fileName, fileTypeForName(fileName.fileName()))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void createTree(std::unique_ptr<ProjectNode> &root, | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |                 const Utils::FilePath &rootPath, | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |                 const RawProjectParts &rpps, | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  |                 const QList<FileNode *> &scannedFiles = QList<FileNode *>()) | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     root->setAbsoluteFilePathAndLine(rootPath, -1); | 
					
						
							| 
									
										
										
										
											2019-04-26 11:41:49 +02:00
										 |  |  |     std::unique_ptr<FolderNode> secondRoot; | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |     for (const RawProjectPart &rpp : rpps) { | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  |         for (const QString &filePath : rpp.files) { | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |             Utils::FilePath fileName = Utils::FilePath::fromString(filePath); | 
					
						
							| 
									
										
										
										
											2019-04-26 11:41:49 +02:00
										 |  |  |             if (!fileName.isChildOf(rootPath)) { | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |                 if (fileName.isChildOf(Utils::FilePath::fromString(rpp.buildSystemTarget))) { | 
					
						
							| 
									
										
										
										
											2019-04-26 11:41:49 +02:00
										 |  |  |                     if (!secondRoot) | 
					
						
							|  |  |  |                         secondRoot = std::make_unique<ProjectNode>( | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |                             Utils::FilePath::fromString(rpp.buildSystemTarget)); | 
					
						
							| 
									
										
										
										
											2019-04-26 11:41:49 +02:00
										 |  |  |                     addChild(secondRoot.get(), fileName); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 addChild(root.get(), fileName); | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (FileNode *node : scannedFiles) { | 
					
						
							|  |  |  |         if (node->fileType() != FileType::Header) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |         const Utils::FilePath fileName = node->filePath(); | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  |         if (!fileName.isChildOf(rootPath)) | 
					
						
							|  |  |  |             continue; | 
					
						
							| 
									
										
										
										
											2019-04-26 11:41:49 +02:00
										 |  |  |         FolderNode *parentNode = createFoldersIfNeeded(root.get(), fileName.parentDir()); | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  |         if (!parentNode->fileNode(fileName)) { | 
					
						
							|  |  |  |             std::unique_ptr<FileNode> headerNode(node->clone()); | 
					
						
							|  |  |  |             headerNode->setEnabled(false); | 
					
						
							|  |  |  |             parentNode->addNode(std::move(headerNode)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     qDeleteAll(scannedFiles); | 
					
						
							| 
									
										
										
										
											2019-04-26 11:41:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (secondRoot) { | 
					
						
							|  |  |  |         std::unique_ptr<ProjectNode> firstRoot = std::move(root); | 
					
						
							|  |  |  |         root = std::make_unique<ProjectNode>(firstRoot->filePath()); | 
					
						
							|  |  |  |         firstRoot->setDisplayName(rootPath.fileName()); | 
					
						
							|  |  |  |         root->addNode(std::move(firstRoot)); | 
					
						
							|  |  |  |         root->addNode(std::move(secondRoot)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-01 16:59:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | } // anonymous namespace
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  | CompilationDatabaseBuildSystem::CompilationDatabaseBuildSystem(Target *target) | 
					
						
							|  |  |  |     : BuildSystem(target) | 
					
						
							| 
									
										
										
										
											2021-08-30 10:58:08 +02:00
										 |  |  |     , m_cppCodeModelUpdater(std::make_unique<CppEditor::CppProjectUpdater>()) | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |     , m_deployFileWatcher(new FileSystemWatcher(this)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     connect(target->project(), &CompilationDatabaseProject::rootProjectDirectoryChanged, | 
					
						
							|  |  |  |             this, [this] { | 
					
						
							|  |  |  |         m_projectFileHash.clear(); | 
					
						
							| 
									
										
										
										
											2020-03-12 12:09:54 +01:00
										 |  |  |         requestDelayedParse(); | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-12 12:09:54 +01:00
										 |  |  |     requestDelayedParse(); | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(project(), &Project::projectFileIsDirty, this, &CompilationDatabaseBuildSystem::reparseProject); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_deployFileWatcher, &FileSystemWatcher::fileChanged, | 
					
						
							|  |  |  |             this, &CompilationDatabaseBuildSystem::updateDeploymentData); | 
					
						
							|  |  |  |     connect(target->project(), &Project::activeTargetChanged, | 
					
						
							|  |  |  |             this, &CompilationDatabaseBuildSystem::updateDeploymentData); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CompilationDatabaseBuildSystem::~CompilationDatabaseBuildSystem() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_parserWatcher.cancel(); | 
					
						
							|  |  |  |     m_parserWatcher.waitForFinished(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CompilationDatabaseBuildSystem::triggerParsing() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     reparseProject(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CompilationDatabaseBuildSystem::buildTreeAndProjectParts() | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-19 18:24:23 +01:00
										 |  |  |     Kit *k = kit(); | 
					
						
							|  |  |  |     ProjectExplorer::KitInfo kitInfo(k); | 
					
						
							| 
									
										
										
										
											2019-01-08 12:33:18 +01:00
										 |  |  |     QTC_ASSERT(kitInfo.isValid(), return); | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  |     // Reset toolchains to pick them based on the database entries.
 | 
					
						
							|  |  |  |     kitInfo.cToolChain = nullptr; | 
					
						
							|  |  |  |     kitInfo.cxxToolChain = nullptr; | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |     RawProjectParts rpps; | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     QTC_ASSERT(m_parser, return); | 
					
						
							|  |  |  |     const DbContents dbContents = m_parser->dbContents(); | 
					
						
							|  |  |  |     const DbEntry *prevEntry = nullptr; | 
					
						
							|  |  |  |     for (const DbEntry &entry : dbContents.entries) { | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  |         if (prevEntry && prevEntry->flags == entry.flags) { | 
					
						
							|  |  |  |             rpps.back().files.append(entry.fileName.toString()); | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         prevEntry = &entry; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |         RawProjectPart rpp = makeRawProjectPart(projectFilePath(), | 
					
						
							| 
									
										
										
										
											2020-03-19 18:24:23 +01:00
										 |  |  |                                                 k, | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |                                                 kitInfo, | 
					
						
							|  |  |  |                                                 entry.workingDir, | 
					
						
							|  |  |  |                                                 entry.fileName, | 
					
						
							|  |  |  |                                                 entry.flags); | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         rpps.append(rpp); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     if (!dbContents.extras.empty()) { | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |         const Utils::FilePath baseDir = projectFilePath().parentDir(); | 
					
						
							| 
									
										
										
										
											2019-05-01 16:59:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         QStringList extraFiles; | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |         for (const QString &extra : dbContents.extras) | 
					
						
							| 
									
										
										
										
											2019-05-17 12:32:05 +02:00
										 |  |  |             extraFiles.append(baseDir.pathAppended(extra).toString()); | 
					
						
							| 
									
										
										
										
											2019-05-01 16:59:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-28 18:22:45 +02:00
										 |  |  |         RawProjectPart rppExtra; | 
					
						
							| 
									
										
										
										
											2019-05-01 16:59:52 +02:00
										 |  |  |         rppExtra.setFiles(extraFiles); | 
					
						
							|  |  |  |         rpps.append(rppExtra); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     auto root = std::make_unique<ProjectNode>(projectDirectory()); | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |     createTree(root, project()->rootProjectDirectory(), rpps, m_parser->scannedFiles()); | 
					
						
							| 
									
										
										
										
											2018-10-30 14:21:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     root->addNode(std::make_unique<FileNode>(projectFilePath(), FileType::Project)); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     if (QFile::exists(dbContents.extraFileName)) | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |         root->addNode(std::make_unique<FileNode>(Utils::FilePath::fromString(dbContents.extraFileName), | 
					
						
							| 
									
										
										
										
											2019-05-01 16:59:52 +02:00
										 |  |  |                                                  FileType::Project)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 15:21:54 +01:00
										 |  |  |     setRootProjectNode(std::move(root)); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |     m_cppCodeModelUpdater->update({project(), kitInfo, activeParseEnvironment(), rpps}); | 
					
						
							| 
									
										
										
										
											2019-10-28 17:15:38 +01:00
										 |  |  |     updateDeploymentData(); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  | CompilationDatabaseProject::CompilationDatabaseProject(const Utils::FilePath &projectFile) | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  |     : Project(Constants::COMPILATIONDATABASEMIMETYPE, projectFile) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setId(Constants::COMPILATIONDATABASEPROJECT_ID); | 
					
						
							|  |  |  |     setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID)); | 
					
						
							|  |  |  |     setDisplayName(projectDirectory().fileName()); | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |     setBuildSystemCreator([](Target *t) { return new CompilationDatabaseBuildSystem(t); }); | 
					
						
							| 
									
										
										
										
											2019-08-15 12:23:35 +02:00
										 |  |  |     setExtraProjectFiles( | 
					
						
							|  |  |  |         {projectFile.stringAppended(Constants::COMPILATIONDATABASEPROJECT_FILES_SUFFIX)}); | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-07 16:25:09 +01:00
										 |  |  | Utils::FilePath CompilationDatabaseProject::rootPathFromSettings() const | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-10-21 14:05:40 +02:00
										 |  |  |     Utils::FilePath rootPath; | 
					
						
							|  |  |  | #ifndef WITH_TESTS
 | 
					
						
							|  |  |  |     rootPath = Utils::FilePath::fromString( | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  |         namedSettings(ProjectExplorer::Constants::PROJECT_ROOT_PATH_KEY).toString()); | 
					
						
							| 
									
										
										
										
											2021-10-21 14:05:40 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2021-09-01 14:59:17 +02:00
										 |  |  |     if (rootPath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2021-10-21 14:05:40 +02:00
										 |  |  |         rootPath = projectDirectory(); | 
					
						
							| 
									
										
										
										
											2021-09-01 14:59:17 +02:00
										 |  |  |     return rootPath; | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-16 13:11:10 +02:00
										 |  |  | void CompilationDatabaseProject::configureAsExampleProject(Kit *kit) | 
					
						
							| 
									
										
										
										
											2020-03-04 13:43:38 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-06-16 13:11:10 +02:00
										 |  |  |     if (kit) | 
					
						
							|  |  |  |         addTargetForKit(kit); | 
					
						
							|  |  |  |     else if (KitManager::defaultKit()) | 
					
						
							| 
									
										
										
										
											2020-03-04 13:43:38 +01:00
										 |  |  |         addTargetForKit(KitManager::defaultKit()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  | void CompilationDatabaseBuildSystem::reparseProject() | 
					
						
							| 
									
										
										
										
											2019-03-14 11:09:36 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     if (m_parser) { | 
					
						
							|  |  |  |         QTC_CHECK(isParsing()); | 
					
						
							|  |  |  |         m_parser->stop(); | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-01-07 16:25:09 +01:00
										 |  |  |     const FilePath rootPath = static_cast<CompilationDatabaseProject *>(project())->rootPathFromSettings(); | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |     m_parser = new CompilationDbParser(project()->displayName(), | 
					
						
							| 
									
										
										
										
											2019-08-06 14:46:37 +02:00
										 |  |  |                                        projectFilePath(), | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |                                        rootPath, | 
					
						
							| 
									
										
										
										
											2019-08-06 14:46:37 +02:00
										 |  |  |                                        m_mimeBinaryCache, | 
					
						
							|  |  |  |                                        guardParsingRun(), | 
					
						
							|  |  |  |                                        this); | 
					
						
							| 
									
										
										
										
											2019-10-22 09:43:24 +02:00
										 |  |  |     connect(m_parser, &CompilationDbParser::finished, this, [this](ParseResult result) { | 
					
						
							|  |  |  |         m_projectFileHash = m_parser->projectFileHash(); | 
					
						
							|  |  |  |         if (result == ParseResult::Success) | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |             buildTreeAndProjectParts(); | 
					
						
							|  |  |  |         m_parser = nullptr; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2019-10-22 09:43:24 +02:00
										 |  |  |     m_parser->setPreviousProjectFileHash(m_projectFileHash); | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     m_parser->start(); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  | void CompilationDatabaseBuildSystem::updateDeploymentData() | 
					
						
							| 
									
										
										
										
											2019-10-28 17:15:38 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     const Utils::FilePath deploymentFilePath = projectDirectory() | 
					
						
							|  |  |  |             .pathAppended("QtCreatorDeployment.txt"); | 
					
						
							|  |  |  |     DeploymentData deploymentData; | 
					
						
							| 
									
										
										
										
											2023-02-08 08:21:41 +01:00
										 |  |  |     deploymentData.addFilesFromDeploymentFile(deploymentFilePath, projectDirectory()); | 
					
						
							| 
									
										
										
										
											2019-10-25 09:55:32 +02:00
										 |  |  |     setDeploymentData(deploymentData); | 
					
						
							| 
									
										
										
										
											2019-10-28 17:15:38 +01:00
										 |  |  |     if (m_deployFileWatcher->files() != QStringList(deploymentFilePath.toString())) { | 
					
						
							| 
									
										
										
										
											2021-09-14 14:36:46 +02:00
										 |  |  |         m_deployFileWatcher->clear(); | 
					
						
							| 
									
										
										
										
											2019-10-28 17:15:38 +01:00
										 |  |  |         m_deployFileWatcher->addFile(deploymentFilePath.toString(), | 
					
						
							|  |  |  |                                      FileSystemWatcher::WatchModifiedDate); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-11-15 15:44:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emitBuildSystemUpdated(); | 
					
						
							| 
									
										
										
										
											2019-10-28 17:15:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | static TextEditor::TextDocument *createCompilationDatabaseDocument() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto doc = new TextEditor::TextDocument; | 
					
						
							|  |  |  |     doc->setId(Constants::COMPILATIONDATABASEPROJECT_ID); | 
					
						
							|  |  |  |     doc->setMimeType(Constants::COMPILATIONDATABASEMIMETYPE); | 
					
						
							|  |  |  |     return doc; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CompilationDatabaseEditorFactory::CompilationDatabaseEditorFactory() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setId(Constants::COMPILATIONDATABASEPROJECT_ID); | 
					
						
							| 
									
										
										
										
											2023-02-17 23:21:31 +01:00
										 |  |  |     setDisplayName(::Core::Tr::tr("Compilation Database")); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  |     addMimeType(Constants::COMPILATIONDATABASEMIMETYPE); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setEditorCreator([]() { return new TextEditor::BaseTextEditor; }); | 
					
						
							|  |  |  |     setEditorWidgetCreator([]() { return new TextEditor::TextEditorWidget; }); | 
					
						
							|  |  |  |     setDocumentCreator(createCompilationDatabaseDocument); | 
					
						
							|  |  |  |     setUseGenericHighlighter(true); | 
					
						
							|  |  |  |     setCommentDefinition(Utils::CommentDefinition::HashStyle); | 
					
						
							|  |  |  |     setCodeFoldingSupported(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-09 12:59:38 +01:00
										 |  |  | class CompilationDatabaseBuildConfiguration : public BuildConfiguration | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-09 12:59:38 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-06-26 13:59:38 +02:00
										 |  |  |     CompilationDatabaseBuildConfiguration(Target *target, Utils::Id id) | 
					
						
							| 
									
										
										
										
											2019-12-09 12:59:38 +01:00
										 |  |  |         : BuildConfiguration(target, id) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | CompilationDatabaseBuildConfigurationFactory::CompilationDatabaseBuildConfigurationFactory() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     registerBuildConfiguration<CompilationDatabaseBuildConfiguration>( | 
					
						
							|  |  |  |         "CompilationDatabase.CompilationDatabaseBuildConfiguration"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setSupportedProjectType(Constants::COMPILATIONDATABASEPROJECT_ID); | 
					
						
							|  |  |  |     setSupportedProjectMimeTypeName(Constants::COMPILATIONDATABASEMIMETYPE); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-09 18:42:28 +01:00
										 |  |  |     setBuildGenerator([](const Kit *, const FilePath &projectPath, bool) { | 
					
						
							| 
									
										
										
										
											2023-02-10 16:15:49 +01:00
										 |  |  |         const QString name = QCoreApplication::translate("QtC::ProjectExplorer", "Release"); | 
					
						
							| 
									
										
										
										
											2020-01-09 18:42:28 +01:00
										 |  |  |         ProjectExplorer::BuildInfo info; | 
					
						
							| 
									
										
										
										
											2020-01-09 15:06:30 +01:00
										 |  |  |         info.typeName = name; | 
					
						
							|  |  |  |         info.displayName = name; | 
					
						
							|  |  |  |         info.buildType = BuildConfiguration::Release; | 
					
						
							|  |  |  |         info.buildDirectory = projectPath.parentDir(); | 
					
						
							|  |  |  |         return QList<BuildInfo>{info}; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace CompilationDatabaseProjectManager
 |