| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Copyright (C) 2018 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and The Qt Company. For licensing terms | 
					
						
							|  |  |  | ** and conditions see https://www.qt.io/terms-conditions. For further
 | 
					
						
							|  |  |  | ** information use the contact form at https://www.qt.io/contact-us.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** GNU General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU | 
					
						
							|  |  |  | ** General Public License version 3 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
					
						
							|  |  |  | ** included in the packaging of this file. Please review the following | 
					
						
							|  |  |  | ** information to ensure the GNU General Public License requirements will | 
					
						
							|  |  |  | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #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
										 |  |  | 
 | 
					
						
							|  |  |  | #include <coreplugin/icontext.h>
 | 
					
						
							| 
									
										
										
										
											2019-01-08 12:33:18 +01:00
										 |  |  | #include <cpptools/cppkitinfo.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | #include <cpptools/cppprojectupdater.h>
 | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | #include <cpptools/projectinfo.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | #include <projectexplorer/buildinfo.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/buildsteplist.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/buildtargetinfo.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>
 | 
					
						
							|  |  |  | #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-08-13 11:15:27 +02:00
										 |  |  | #include <projectexplorer/toolchainconfigwidget.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>
 | 
					
						
							|  |  |  | #include <utils/qtcassert.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | #include <utils/runextensions.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  | #include <QTimer>
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | #ifdef Q_OS_WIN
 | 
					
						
							|  |  |  | #include <Windows.h>
 | 
					
						
							|  |  |  | #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"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | Core::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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | ToolChain *toolchainFromCompilerId(const Core::Id &compilerId, const Core::Id &language) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | ToolChain *toolchainFromFlags(const Kit *kit, const QStringList &flags, const Core::Id &language) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     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.
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |     const Utils::FilePath compiler = Utils::FilePath::fromString(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; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Core::Id compilerId = getCompilerId(compiler.fileName()); | 
					
						
							|  |  |  |     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-05-28 13:49:26 +02:00
										 |  |  | CppTools::RawProjectPart makeRawProjectPart(const Utils::FilePath &projectFile, | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |                                             Kit *kit, | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |                                             CppTools::KitInfo &kitInfo, | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |                                             const QString &workingDir, | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |                                             const Utils::FilePath &fileName, | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |                                             QStringList flags) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     HeaderPaths headerPaths; | 
					
						
							|  |  |  |     Macros macros; | 
					
						
							|  |  |  |     CppTools::ProjectFile::Kind fileKind = CppTools::ProjectFile::Unclassified; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const QStringList originalFlags = flags; | 
					
						
							|  |  |  |     filteredFlags(fileName.fileName(), | 
					
						
							|  |  |  |                   workingDir, | 
					
						
							|  |  |  |                   flags, | 
					
						
							|  |  |  |                   headerPaths, | 
					
						
							|  |  |  |                   macros, | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |                   fileKind, | 
					
						
							|  |  |  |                   kitInfo.sysRootPath); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     CppTools::RawProjectPart rpp; | 
					
						
							|  |  |  |     rpp.setProjectFileLocation(projectFile.toString()); | 
					
						
							|  |  |  |     rpp.setBuildSystemTarget(workingDir); | 
					
						
							|  |  |  |     rpp.setDisplayName(fileName.fileName()); | 
					
						
							|  |  |  |     rpp.setFiles({fileName.toString()}); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     rpp.setHeaderPaths(headerPaths); | 
					
						
							|  |  |  |     rpp.setMacros(macros); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (fileKind == CppTools::ProjectFile::Kind::CHeader | 
					
						
							|  |  |  |             || fileKind == CppTools::ProjectFile::Kind::CSource) { | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         if (!kitInfo.cToolChain) { | 
					
						
							|  |  |  |             kitInfo.cToolChain = toolchainFromFlags(kit, | 
					
						
							|  |  |  |                                                     originalFlags, | 
					
						
							|  |  |  |                                                     ProjectExplorer::Constants::C_LANGUAGE_ID); | 
					
						
							|  |  |  |             ToolChainKitAspect::setToolChain(kit, kitInfo.cToolChain); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         addDriverModeFlagIfNeeded(kitInfo.cToolChain, flags, originalFlags); | 
					
						
							|  |  |  |         rpp.setFlagsForC({kitInfo.cToolChain, flags}); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  |             ToolChainKitAspect::setToolChain(kit, kitInfo.cxxToolChain); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |         addDriverModeFlagIfNeeded(kitInfo.cxxToolChain, flags, originalFlags); | 
					
						
							|  |  |  |         rpp.setFlagsForCxx({kitInfo.cxxToolChain, flags}); | 
					
						
							| 
									
										
										
										
											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
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  |     CppTools::ProjectFile::Kind fileKind = CppTools::ProjectFile::classify(fileName); | 
					
						
							|  |  |  |     if (CppTools::ProjectFile::isHeader(fileKind)) | 
					
						
							|  |  |  |         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-03-14 15:34:14 +01:00
										 |  |  |                 const CppTools::RawProjectParts &rpps, | 
					
						
							|  |  |  |                 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  |     for (const CppTools::RawProjectPart &rpp : rpps) { | 
					
						
							|  |  |  |         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-05-16 15:36:55 +02:00
										 |  |  | void CompilationDatabaseProject::buildTreeAndProjectParts() | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-01-08 12:33:18 +01:00
										 |  |  |     CppTools::KitInfo kitInfo(this); | 
					
						
							|  |  |  |     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; | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     CppTools::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-05-16 15:36:55 +02:00
										 |  |  |         CppTools::RawProjectPart rpp = makeRawProjectPart(projectFilePath(), | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |                                                           m_kit.get(), | 
					
						
							| 
									
										
										
										
											2019-04-25 16:06:39 +02:00
										 |  |  |                                                           kitInfo, | 
					
						
							| 
									
										
										
										
											2018-11-02 16:07:42 +01:00
										 |  |  |                                                           entry.workingDir, | 
					
						
							|  |  |  |                                                           entry.fileName, | 
					
						
							|  |  |  |                                                           entry.flags); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         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
										 |  |  | 
 | 
					
						
							|  |  |  |         CppTools::RawProjectPart rppExtra; | 
					
						
							|  |  |  |         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()); | 
					
						
							|  |  |  |     createTree(root, 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)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     setRootProjectNode(std::move(root)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-05 16:58:07 +02:00
										 |  |  |     m_cppCodeModelUpdater->update({this, kitInfo, activeBuildEnvironment(), rpps}); | 
					
						
							| 
									
										
										
										
											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) | 
					
						
							| 
									
										
										
										
											2018-12-11 15:37:59 +01:00
										 |  |  |     , m_cppCodeModelUpdater(std::make_unique<CppTools::CppProjectUpdater>()) | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     , m_parseDelay(new QTimer(this)) | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     setId(Constants::COMPILATIONDATABASEPROJECT_ID); | 
					
						
							|  |  |  |     setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID)); | 
					
						
							|  |  |  |     setDisplayName(projectDirectory().fileName()); | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     setRequiredKitPredicate([](const Kit *) { return false; }); | 
					
						
							|  |  |  |     setPreferredKitPredicate([](const Kit *) { return false; }); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-30 10:31:34 +01:00
										 |  |  |     m_kit.reset(KitManager::defaultKit()->clone()); | 
					
						
							| 
									
										
										
										
											2019-08-01 14:58:00 +02:00
										 |  |  |     addTargetForKit(m_kit.get()); | 
					
						
							| 
									
										
										
										
											2018-11-02 10:00:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-15 12:23:35 +02:00
										 |  |  |     connect(this, | 
					
						
							|  |  |  |             &CompilationDatabaseProject::rootProjectDirectoryChanged, | 
					
						
							|  |  |  |             m_parseDelay, | 
					
						
							|  |  |  |             QOverload<>::of(&QTimer::start)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setExtraProjectFiles( | 
					
						
							|  |  |  |         {projectFile.stringAppended(Constants::COMPILATIONDATABASEPROJECT_FILES_SUFFIX)}); | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     connect(m_parseDelay, &QTimer::timeout, this, &CompilationDatabaseProject::reparseProject); | 
					
						
							| 
									
										
										
										
											2019-08-15 12:23:35 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     m_parseDelay->setSingleShot(true); | 
					
						
							|  |  |  |     m_parseDelay->setInterval(1000); | 
					
						
							| 
									
										
										
										
											2019-08-15 12:23:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(this, &Project::projectFileIsDirty, this, &CompilationDatabaseProject::reparseProject); | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  | Utils::FilePath CompilationDatabaseProject::rootPathFromSettings() const | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  | { | 
					
						
							|  |  |  | #ifdef WITH_TESTS
 | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |     return Utils::FilePath::fromString(projectDirectory().fileName()); | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2019-07-24 11:01:47 +02:00
										 |  |  |     return Utils::FilePath::fromString( | 
					
						
							| 
									
										
										
										
											2019-04-11 12:42:13 +02:00
										 |  |  |         namedSettings(ProjectExplorer::Constants::PROJECT_ROOT_PATH_KEY).toString()); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | Project::RestoreResult CompilationDatabaseProject::fromMap(const QVariantMap &map, | 
					
						
							|  |  |  |                                                            QString *errorMessage) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Project::RestoreResult result = Project::fromMap(map, errorMessage); | 
					
						
							|  |  |  |     if (result == Project::RestoreResult::Ok) { | 
					
						
							| 
									
										
										
										
											2019-05-28 13:49:26 +02:00
										 |  |  |         const Utils::FilePath rootPath = rootPathFromSettings(); | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  |         if (rootPath.isEmpty()) | 
					
						
							|  |  |  |             changeRootProjectDirectory(); // This triggers reparse itself.
 | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             reparseProject(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return result; | 
					
						
							| 
									
										
										
										
											2019-03-14 11:09:36 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 15:34:14 +01:00
										 |  |  | void CompilationDatabaseProject::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
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-06 14:46:37 +02:00
										 |  |  |     m_parser = new CompilationDbParser(displayName(), | 
					
						
							|  |  |  |                                        projectFilePath(), | 
					
						
							|  |  |  |                                        rootPathFromSettings(), | 
					
						
							|  |  |  |                                        m_mimeBinaryCache, | 
					
						
							|  |  |  |                                        guardParsingRun(), | 
					
						
							|  |  |  |                                        this); | 
					
						
							| 
									
										
										
										
											2019-05-16 15:36:55 +02:00
										 |  |  |     connect(m_parser, &CompilationDbParser::finished, this, [this](bool success) { | 
					
						
							|  |  |  |         if (success) | 
					
						
							|  |  |  |             buildTreeAndProjectParts(); | 
					
						
							|  |  |  |         m_parser = nullptr; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     m_parser->start(); | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CompilationDatabaseProject::~CompilationDatabaseProject() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_parserWatcher.cancel(); | 
					
						
							|  |  |  |     m_parserWatcher.waitForFinished(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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); | 
					
						
							|  |  |  |     setDisplayName("Compilation Database"); | 
					
						
							|  |  |  |     addMimeType(Constants::COMPILATIONDATABASEMIMETYPE); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setEditorCreator([]() { return new TextEditor::BaseTextEditor; }); | 
					
						
							|  |  |  |     setEditorWidgetCreator([]() { return new TextEditor::TextEditorWidget; }); | 
					
						
							|  |  |  |     setDocumentCreator(createCompilationDatabaseDocument); | 
					
						
							|  |  |  |     setUseGenericHighlighter(true); | 
					
						
							|  |  |  |     setCommentDefinition(Utils::CommentDefinition::HashStyle); | 
					
						
							|  |  |  |     setCodeFoldingSupported(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | CompilationDatabaseBuildConfiguration::CompilationDatabaseBuildConfiguration( | 
					
						
							|  |  |  |     ProjectExplorer::Target *target, Core::Id id) | 
					
						
							|  |  |  |     : ProjectExplorer::BuildConfiguration(target, id) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-03 17:26:49 +02:00
										 |  |  |     target->setApplicationTargets({BuildTargetInfo()}); | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-02 18:06:29 +02:00
										 |  |  | void CompilationDatabaseBuildConfiguration::initialize() | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-08-02 18:06:29 +02:00
										 |  |  |     ProjectExplorer::BuildConfiguration::initialize(); | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  |     BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); | 
					
						
							| 
									
										
										
										
											2019-06-26 13:23:44 +02:00
										 |  |  |     buildSteps->appendStep(ProjectExplorer::Constants::PROCESS_STEP_ID); | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ProjectExplorer::NamedWidget *CompilationDatabaseBuildConfiguration::createConfigWidget() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return new ProjectExplorer::NamedWidget(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CompilationDatabaseBuildConfigurationFactory::CompilationDatabaseBuildConfigurationFactory() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     registerBuildConfiguration<CompilationDatabaseBuildConfiguration>( | 
					
						
							|  |  |  |         "CompilationDatabase.CompilationDatabaseBuildConfiguration"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setSupportedProjectType(Constants::COMPILATIONDATABASEPROJECT_ID); | 
					
						
							|  |  |  |     setSupportedProjectMimeTypeName(Constants::COMPILATIONDATABASEMIMETYPE); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-27 10:22:13 +02:00
										 |  |  | QList<BuildInfo> CompilationDatabaseBuildConfigurationFactory::availableBuilds | 
					
						
							| 
									
										
										
										
											2019-08-22 13:05:42 +02:00
										 |  |  |     (const Kit *kit, const FilePath &, bool) const | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-06-27 10:22:13 +02:00
										 |  |  |     const QString name = tr("Release"); | 
					
						
							|  |  |  |     ProjectExplorer::BuildInfo info(this); | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  |     info.typeName = name; | 
					
						
							|  |  |  |     info.displayName = name; | 
					
						
							|  |  |  |     info.buildType = BuildConfiguration::Release; | 
					
						
							| 
									
										
										
										
											2019-08-22 13:05:42 +02:00
										 |  |  |     info.kitId = kit->id(); | 
					
						
							| 
									
										
										
										
											2019-06-27 10:22:13 +02:00
										 |  |  |     return {info}; | 
					
						
							| 
									
										
										
										
											2019-04-18 10:18:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 11:15:27 +02:00
										 |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace CompilationDatabaseProjectManager
 |