diff options
Diffstat (limited to 'src/tools')
105 files changed, 1776 insertions, 956 deletions
diff --git a/src/tools/3rdparty/CMakeLists.txt b/src/tools/3rdparty/CMakeLists.txt new file mode 100644 index 0000000000..b82a82ceb0 --- /dev/null +++ b/src/tools/3rdparty/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(cplusplus-keywordgen) diff --git a/src/tools/3rdparty/cplusplus-keywordgen/CMakeLists.txt b/src/tools/3rdparty/cplusplus-keywordgen/CMakeLists.txt new file mode 100644 index 0000000000..0ab12f5bf2 --- /dev/null +++ b/src/tools/3rdparty/cplusplus-keywordgen/CMakeLists.txt @@ -0,0 +1,5 @@ +add_qtc_executable(cplusplus-keywordgen + DEPENDS CPlusPlus Utils + SOURCES cplusplus-keywordgen.cpp +) + diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt new file mode 100644 index 0000000000..4ec3202b0b --- /dev/null +++ b/src/tools/CMakeLists.txt @@ -0,0 +1,48 @@ +add_subdirectory(3rdparty) +add_subdirectory(buildoutputparser) +if (NOT Clang_FOUND) + message(WARNING "Could not find Clang installation - disabling clangbackend.") +else () + add_subdirectory(clangbackend) + add_subdirectory(clangrefactoringbackend) + add_subdirectory(clangpchmanagerbackend) +endif () + +option(BUILD_CPLUSPLUS_TOOLS "Build CPlusPlus tools" OFF) + +function(add_qtc_cpp_tool name) + add_qtc_executable(${name} + DEFINES + PATH_PREPROCESSOR_CONFIG=\"${CMAKE_CURRENT_SOURCE_DIR}/pp-configuration.inc\" + ${ARGN} + DEPENDS CPlusPlus Utils Qt5::Widgets + INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/cplusplus-shared" + "${CMAKE_CURRENT_SOURCE_DIR}/${name}" + SOURCES + cplusplus-shared/utils.cpp + "${name}/${name}.cpp" + ) +endfunction() + +if (BUILD_CPLUSPLUS_TOOLS) + add_qtc_cpp_tool(cplusplus-ast2png "") + add_qtc_cpp_tool(cplusplus-frontend "") + add_qtc_cpp_tool(cplusplus-mkvisitor PATH_AST_H=\"${CMAKE_CURRENT_SOURCE_DIR}/../../libs/3rdparty/cplusplus/AST.h\") + add_qtc_cpp_tool(cplusplus-update-frontend PATH_CPP_FRONTEND=\"${CMAKE_CURRENT_SOURCE_DIR}/../../libs/3rdparty/cplusplus\" PATH_DUMPERS_FILE=\"${CMAKE_CURRENT_SOURCE_DIR}/../cplusplus-ast2png/dumpers.inc\") +endif() + +if (APPLE) + add_subdirectory(iostool) +endif() + +add_subdirectory(qml2puppet) +# add_subdirectory(qtcdebugger) ## windows only +# add_subdirectory(qtcrashhandler) +add_subdirectory(qtcreatorcrashhandler) +# add_subdirectory(qtcreatorwidgets) ## qbs does not build this either +add_subdirectory(qtpromaker) +# add_subdirectory(screenshotcropper) ## qbs does not build this either +add_subdirectory(sdktool) +add_subdirectory(valgrindfake) +# add_subdirectory(wininterrupt) ## windows only +# add_subdirectory(winrtdebughelper) ## windows only diff --git a/src/tools/buildoutputparser/CMakeLists.txt b/src/tools/buildoutputparser/CMakeLists.txt new file mode 100644 index 0000000000..ff55e888a3 --- /dev/null +++ b/src/tools/buildoutputparser/CMakeLists.txt @@ -0,0 +1,6 @@ +add_qtc_executable(buildoutputparser + DEPENDS Utils ProjectExplorer QtSupport QmakeProjectManager + SOURCES + main.cpp + outputprocessor.cpp outputprocessor.h +) diff --git a/src/tools/clangbackend/CMakeLists.txt b/src/tools/clangbackend/CMakeLists.txt new file mode 100644 index 0000000000..c0ad4e864d --- /dev/null +++ b/src/tools/clangbackend/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(source) + +add_qtc_executable(clangbackend + DEPENDS Qt5::Core Qt5::Network clangbackend_lib Sqlite ClangSupport libclang + SOURCES + ../qtcreatorcrashhandler/crashhandlersetup.cpp ../qtcreatorcrashhandler/crashhandlersetup.h + clangbackendmain.cpp +) diff --git a/src/tools/clangbackend/source/CMakeLists.txt b/src/tools/clangbackend/source/CMakeLists.txt new file mode 100644 index 0000000000..fe0ab54deb --- /dev/null +++ b/src/tools/clangbackend/source/CMakeLists.txt @@ -0,0 +1,66 @@ +add_qtc_library(clangbackend_lib STATIC + DEPENDS libclang Sqlite ClangSupport + PUBLIC_DEFINES CLANGSUPPORT_BUILD_LIB + PUBLIC_INCLUDES + ${CLANG_INCLUDE_DIRS} + SOURCES + clangasyncjob.h + clangbackend_global.h + clangclock.h + clangcodecompleteresults.cpp clangcodecompleteresults.h + clangcodemodelserver.cpp clangcodemodelserver.h + clangcompletecodejob.cpp clangcompletecodejob.h + clangdocument.cpp clangdocument.h + clangdocumentjob.h + clangdocumentprocessor.cpp clangdocumentprocessor.h + clangdocumentprocessors.cpp clangdocumentprocessors.h + clangdocuments.cpp clangdocuments.h + clangdocumentsuspenderresumer.cpp clangdocumentsuspenderresumer.h + clangexceptions.cpp clangexceptions.h + clangfilepath.cpp clangfilepath.h + clangfilesystemwatcher.cpp clangfilesystemwatcher.h + clangfollowsymbol.cpp clangfollowsymbol.h + clangfollowsymboljob.cpp clangfollowsymboljob.h + clangiasyncjob.cpp clangiasyncjob.h + clangjobcontext.cpp clangjobcontext.h + clangjobqueue.cpp clangjobqueue.h + clangjobrequest.cpp clangjobrequest.h + clangjobs.cpp clangjobs.h + clangparsesupportivetranslationunitjob.cpp clangparsesupportivetranslationunitjob.h + clangreferencescollector.cpp clangreferencescollector.h + clangrequestannotationsjob.cpp clangrequestannotationsjob.h + clangrequestreferencesjob.cpp clangrequestreferencesjob.h + clangrequesttooltipjob.cpp clangrequesttooltipjob.h + clangresumedocumentjob.cpp clangresumedocumentjob.h + clangstring.h + clangsupportivetranslationunitinitializer.cpp clangsupportivetranslationunitinitializer.h + clangsuspenddocumentjob.cpp clangsuspenddocumentjob.h + clangtooltipinfocollector.cpp clangtooltipinfocollector.h + clangtranslationunit.cpp clangtranslationunit.h + clangtranslationunits.cpp clangtranslationunits.h + clangtranslationunitupdater.cpp clangtranslationunitupdater.h + clangtype.cpp clangtype.h + clangunsavedfilesshallowarguments.cpp clangunsavedfilesshallowarguments.h + clangupdateannotationsjob.cpp clangupdateannotationsjob.h + clangupdateextraannotationsjob.cpp clangupdateextraannotationsjob.h + codecompleter.cpp codecompleter.h + codecompletionchunkconverter.cpp codecompletionchunkconverter.h + codecompletionsextractor.cpp codecompletionsextractor.h + commandlinearguments.cpp commandlinearguments.h + cursor.cpp cursor.h + diagnostic.cpp diagnostic.h + diagnosticset.cpp diagnosticset.h + diagnosticsetiterator.h + fixit.cpp fixit.h + fulltokeninfo.cpp fulltokeninfo.h + skippedsourceranges.cpp skippedsourceranges.h + sourcelocation.cpp sourcelocation.h + sourcerange.cpp sourcerange.h + token.cpp token.h + tokeninfo.cpp tokeninfo.h + tokenprocessor.h + tokenprocessoriterator.h + unsavedfile.cpp unsavedfile.h + unsavedfiles.cpp unsavedfiles.h + utf8positionfromlinecolumn.cpp utf8positionfromlinecolumn.h +) diff --git a/src/tools/clangbackend/source/clangbackend_global.h b/src/tools/clangbackend/source/clangbackend_global.h index bca0937d59..0e89673b96 100644 --- a/src/tools/clangbackend/source/clangbackend_global.h +++ b/src/tools/clangbackend/source/clangbackend_global.h @@ -36,29 +36,9 @@ enum class PreferredTranslationUnit LastUninitialized, }; -// CLANG-UPGRADE-CHECK: Remove IS_PRETTY_DECL_SUPPORTED once we require clang >= 7.0 -#if defined(CINDEX_VERSION_HAS_PRETTYDECL_BACKPORTED) || CINDEX_VERSION_MINOR >= 46 -# define IS_PRETTY_DECL_SUPPORTED -#endif - -// CLANG-UPGRADE-CHECK: Remove IS_INVALIDDECL_SUPPORTED once we require clang >= 7.0 -#if defined(CINDEX_VERSION_HAS_ISINVALIDECL_BACKPORTED) || CINDEX_VERSION_MINOR >= 46 -# define IS_INVALIDDECL_SUPPORTED -#endif - -// CLANG-UPGRADE-CHECK: Remove IS_LIMITSKIPFUNCTIONBODIESTOPREAMBLE_SUPPORTED once we require clang >= 7.0 -#if defined(CINDEX_VERSION_HAS_LIMITSKIPFUNCTIONBODIESTOPREAMBLE_BACKPORTED) || CINDEX_VERSION_MINOR >= 46 -# define IS_LIMITSKIPFUNCTIONBODIESTOPREAMBLE_SUPPORTED -#endif - // CLANG-UPGRADE-CHECK: Remove IS_SKIPWARNINGSFROMINCLUDEDFILES_SUPPORTED #if defined(CINDEX_VERSION_HAS_SKIPWARNINGSFROMINCLUDEDFILES_BACKPORTED) # define IS_SKIPWARNINGSFROMINCLUDEDFILES_SUPPORTED #endif -// CLANG-UPGRADE-CHECK: Remove IS_COMPLETION_FIXITS_BACKPORTED once we require clang >= 7.0 -#if defined(CINDEX_VERSION_HAS_COMPLETION_FIXITS_BACKPORTED) || CINDEX_VERSION_MINOR >= 49 -# define IS_COMPLETION_FIXITS_BACKPORTED -#endif - } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/source/clangtooltipinfocollector.cpp b/src/tools/clangbackend/source/clangtooltipinfocollector.cpp index beecf63bb6..0d001ca3d4 100644 --- a/src/tools/clangbackend/source/clangtooltipinfocollector.cpp +++ b/src/tools/clangbackend/source/clangtooltipinfocollector.cpp @@ -87,7 +87,6 @@ Utf8String displayName(const Cursor &cursor) Utf8String textForFunctionLike(const Cursor &cursor) { -#ifdef IS_PRETTY_DECL_SUPPORTED CXPrintingPolicy policy = clang_getCursorPrintingPolicy(cursor.cx()); clang_PrintingPolicy_setProperty(policy, CXPrintingPolicy_FullyQualifiedName, 1); clang_PrintingPolicy_setProperty(policy, CXPrintingPolicy_TerseOutput, 1); @@ -98,17 +97,6 @@ Utf8String textForFunctionLike(const Cursor &cursor) clang_getCursorPrettyPrinted(cursor.cx(), policy)); clang_PrintingPolicy_dispose(policy); return prettyPrinted; -#else - // Printing function declarations with displayName() is quite limited: - // * result type is not included - // * parameter names are not included - // * templates in the result type are not included - // * no full qualification of the function name - return Utf8String(cursor.resultType().spelling()) - + Utf8StringLiteral(" ") - + qualificationPrefix(cursor) - + Utf8String(cursor.displayName()); -#endif } Utf8String textForEnumConstantDecl(const Cursor &cursor) diff --git a/src/tools/clangbackend/source/clangtranslationunitupdater.cpp b/src/tools/clangbackend/source/clangtranslationunitupdater.cpp index a45a898738..fdad057089 100644 --- a/src/tools/clangbackend/source/clangtranslationunitupdater.cpp +++ b/src/tools/clangbackend/source/clangtranslationunitupdater.cpp @@ -177,10 +177,8 @@ uint TranslationUnitUpdater::defaultParseOptions() return CXTranslationUnit_CacheCompletionResults | CXTranslationUnit_PrecompiledPreamble | CXTranslationUnit_CreatePreambleOnFirstParse -#ifdef IS_LIMITSKIPFUNCTIONBODIESTOPREAMBLE_SUPPORTED | CXTranslationUnit_SkipFunctionBodies | CXTranslationUnit_LimitSkipFunctionBodiesToPreamble -#endif #ifdef IS_SKIPWARNINGSFROMINCLUDEDFILES_SUPPORTED | CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles #endif diff --git a/src/tools/clangbackend/source/codecompleter.cpp b/src/tools/clangbackend/source/codecompleter.cpp index 0613adf146..2db3fbe0f1 100644 --- a/src/tools/clangbackend/source/codecompleter.cpp +++ b/src/tools/clangbackend/source/codecompleter.cpp @@ -130,7 +130,7 @@ static QString tweakName(const Utf8String &oldName) if (!oldName.contains('>')) return QString(); - QString fullName = QString(oldName).trimmed(); + QString fullName = oldName.toString().trimmed(); if (!fullName.endsWith('>')) { // This is the class<type>::method case - remove ::method part if (!fullName.endsWith("create") || !fullName.contains("QSharedPointer")) @@ -197,9 +197,7 @@ ClangCodeCompleteResults CodeCompleter::completeHelper(uint line, uint column) uint CodeCompleter::defaultOptions() const { uint options = CXCodeComplete_IncludeMacros - #ifdef IS_COMPLETION_FIXITS_BACKPORTED | CXCodeComplete_IncludeCompletionsWithFixIts - #endif | CXCodeComplete_IncludeCodePatterns; if (TranslationUnitUpdater::defaultParseOptions() diff --git a/src/tools/clangbackend/source/codecompleter.h b/src/tools/clangbackend/source/codecompleter.h index 6bfe77c09d..473404f03e 100644 --- a/src/tools/clangbackend/source/codecompleter.h +++ b/src/tools/clangbackend/source/codecompleter.h @@ -39,7 +39,6 @@ class ClangCodeCompleteResults; class CodeCompleter { public: - CodeCompleter() = default; CodeCompleter(const TranslationUnit &translationUnit, const UnsavedFiles &unsavedFiles); diff --git a/src/tools/clangbackend/source/codecompletionsextractor.cpp b/src/tools/clangbackend/source/codecompletionsextractor.cpp index 065a589539..be36cae088 100644 --- a/src/tools/clangbackend/source/codecompletionsextractor.cpp +++ b/src/tools/clangbackend/source/codecompletionsextractor.cpp @@ -361,8 +361,8 @@ SourceRangeContainer toRangeContainer(const UnsavedFile &file, CXSourceRange cxS QTC_ASSERT(startLine == endLine, return SourceRangeContainer();); const Utf8String lineText = file.lineRange(startLine, endLine); - startColumn = QString(lineText.mid(0, startColumn - 1)).size() + 1; - endColumn = QString(lineText.mid(0, endColumn - 1)).size() + 1; + startColumn = lineText.mid(0, startColumn - 1).toString().size() + 1; + endColumn = lineText.mid(0, endColumn - 1).toString().size() + 1; return SourceRangeContainer(SourceLocationContainer(file.filePath(), startLine, startColumn), SourceLocationContainer(file.filePath(), endLine, endColumn)); @@ -370,7 +370,6 @@ SourceRangeContainer toRangeContainer(const UnsavedFile &file, CXSourceRange cxS void CodeCompletionsExtractor::extractRequiredFixIts() { -#ifdef IS_COMPLETION_FIXITS_BACKPORTED unsigned fixItsNumber = clang_getCompletionNumFixIts(cxCodeCompleteResults, cxCodeCompleteResultIndex); @@ -386,7 +385,6 @@ void CodeCompletionsExtractor::extractRequiredFixIts() currentCodeCompletion_.requiredFixIts.push_back( FixItContainer(Utf8String(fixIt), toRangeContainer(unsavedFile, range))); } -#endif } void CodeCompletionsExtractor::adaptPriority() diff --git a/src/tools/clangbackend/source/cursor.cpp b/src/tools/clangbackend/source/cursor.cpp index e76091a661..00fde42cc8 100644 --- a/src/tools/clangbackend/source/cursor.cpp +++ b/src/tools/clangbackend/source/cursor.cpp @@ -107,11 +107,7 @@ bool Cursor::isDeclaration() const bool Cursor::isInvalidDeclaration() const { -#ifdef IS_INVALIDDECL_SUPPORTED return clang_isInvalidDeclaration(m_cxCursor); -#else - return false; -#endif } bool Cursor::isLocalVariable() const diff --git a/src/tools/clangpchmanagerbackend/CMakeLists.txt b/src/tools/clangpchmanagerbackend/CMakeLists.txt new file mode 100644 index 0000000000..513fd4a7a5 --- /dev/null +++ b/src/tools/clangpchmanagerbackend/CMakeLists.txt @@ -0,0 +1,9 @@ +add_subdirectory(source) + +add_qtc_executable(clangpchmanagerbackend + DEPENDS + clangrefactoringbackend_lib clangpchmanagerbackend_lib + clangTooling libclang Sqlite ClangSupport clangToolingRefactor clangQuery clangIndex + SOURCES + clangpchmanagerbackendmain.cpp +) diff --git a/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp b/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp index b2a58b0d66..0ce49e829d 100644 --- a/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp +++ b/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp @@ -95,23 +95,22 @@ public: class ApplicationEnvironment final : public ClangBackEnd::Environment { public: - ApplicationEnvironment(const QString &pchsPath) - : m_pchBuildDirectoryPath(pchsPath) + ApplicationEnvironment(const QString &pchsPath, const QString &preIncludeSearchPath) + : m_pchBuildDirectoryPath(pchsPath.toStdString()) + , m_preIncludeSearchPath(ClangBackEnd::FilePath{preIncludeSearchPath}) { } - QString pchBuildDirectory() const override + Utils::PathString pchBuildDirectory() const override { return m_pchBuildDirectoryPath; } + uint hardwareConcurrency() const override { return std::thread::hardware_concurrency(); } + ClangBackEnd::NativeFilePathView preIncludeSearchPath() const override { - return m_pchBuildDirectoryPath; - } - - uint hardwareConcurrency() const override - { - return std::thread::hardware_concurrency(); + return m_preIncludeSearchPath; } private: - QString m_pchBuildDirectoryPath; + Utils::PathString m_pchBuildDirectoryPath; + ClangBackEnd::NativeFilePath m_preIncludeSearchPath; }; QStringList processArguments(QCoreApplication &application) @@ -123,6 +122,7 @@ QStringList processArguments(QCoreApplication &application) parser.addPositionalArgument(QStringLiteral("connection"), QStringLiteral("Connection")); parser.addPositionalArgument(QStringLiteral("databasepath"), QStringLiteral("Database path")); parser.addPositionalArgument(QStringLiteral("pchspath"), QStringLiteral("PCHs path")); + parser.addPositionalArgument(QStringLiteral("resourcepath"), QStringLiteral("Resource path")); parser.process(application); @@ -172,9 +172,9 @@ struct Data // because we have a cycle dependency { using TaskScheduler = ClangBackEnd::TaskScheduler<PchCreatorManager, ClangBackEnd::PchTaskQueue::Task>; - Data(const QString &databasePath, const QString &pchsPath) + Data(const QString &databasePath, const QString &pchsPath, const QString &preIncludeSearchPath) : database{Utils::PathString{databasePath}, 100000ms} - , environment{pchsPath} + , environment{pchsPath, preIncludeSearchPath} {} Sqlite::Database database; ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database}; @@ -182,7 +182,8 @@ struct Data // because we have a cycle dependency ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher{filePathCache}; ApplicationEnvironment environment; ProjectPartsStorage<> projectPartsStorage{database}; - ProjectPartsManager projectParts{projectPartsStorage}; + PrecompiledHeaderStorage<> preCompiledHeaderStorage{database}; + ProjectPartsManager projectParts{projectPartsStorage, preCompiledHeaderStorage}; GeneratedFiles generatedFiles; PchCreatorManager pchCreatorManager{generatedFiles, environment, @@ -190,7 +191,6 @@ struct Data // because we have a cycle dependency clangPchManagerServer, includeWatcher, buildDependencyStorage}; - PrecompiledHeaderStorage<> preCompiledHeaderStorage{database}; ClangBackEnd::ProgressCounter pchCreationProgressCounter{[&](int progress, int total) { executeInLoop([&] { clangPchManagerServer.setPchCreationProgress(progress, total); @@ -205,7 +205,8 @@ struct Data // because we have a cycle dependency projectTaskScheduler, pchCreationProgressCounter, preCompiledHeaderStorage, - database}; + database, + environment}; ClangBackEnd::PchTasksMerger pchTaskMerger{pchTaskQueue}; ClangBackEnd::BuildDependenciesStorage<> buildDependencyStorage{database}; ClangBackEnd::BuildDependencyCollector buildDependencyCollector{filePathCache, @@ -215,7 +216,8 @@ struct Data // because we have a cycle dependency [&](ClangBackEnd::FilePathView path) -> TimeStamp { return QFileInfo(QString(path)).lastModified().toSecsSinceEpoch(); }}; - ClangBackEnd::ModifiedTimeChecker modifiedTimeChecker{getModifiedTime, filePathCache}; + ClangBackEnd::ModifiedTimeChecker<ClangBackEnd::SourceEntries> modifiedTimeChecker{getModifiedTime, + filePathCache}; ClangBackEnd::BuildDependenciesProvider buildDependencyProvider{buildDependencyStorage, modifiedTimeChecker, buildDependencyCollector, @@ -265,13 +267,16 @@ int main(int argc, char *argv[]) const QString connectionName = arguments[0]; const QString databasePath = arguments[1]; const QString pchsPath = arguments[2]; + const QString preIncludeSearchPath = arguments[3] + "/indexer_preincludes"; - Data data{databasePath, pchsPath}; + Data data{databasePath, pchsPath, preIncludeSearchPath}; data.includeWatcher.setNotifier(&data.clangPchManagerServer); ConnectionServer<PchManagerServer, PchManagerClientProxy> connectionServer; connectionServer.setServer(&data.clangPchManagerServer); + data.buildDependencyProvider.setEnsureAliveMessageIsSentCallback( + [&] { connectionServer.ensureAliveMessageIsSent(); }); connectionServer.start(connectionName); return application.exec(); diff --git a/src/tools/clangpchmanagerbackend/source/CMakeLists.txt b/src/tools/clangpchmanagerbackend/source/CMakeLists.txt new file mode 100644 index 0000000000..76973c6a21 --- /dev/null +++ b/src/tools/clangpchmanagerbackend/source/CMakeLists.txt @@ -0,0 +1,49 @@ +add_qtc_library(clangpchmanagerbackend_lib STATIC + DEPENDS clangrefactoringbackend_lib ClangSupport + PUBLIC_DEPENDS libclang + PUBLIC_DEFINES CLANGSUPPORT_BUILD_LIB + PUBLIC_INCLUDES + ${CLANG_INCLUDE_DIRS} + SOURCES + builddependenciesprovider.cpp builddependenciesprovider.h + builddependenciesproviderinterface.h + builddependenciesstorage.h + builddependenciesstorageinterface.h + builddependency.h + builddependencycollector.cpp builddependencycollector.h + builddependencygeneratorinterface.h + clangpchmanagerbackend_global.h + collectbuilddependencyaction.h + collectbuilddependencypreprocessorcallbacks.h + collectbuilddependencytoolaction.h + collectusedmacroactionfactory.h + collectusedmacrosaction.h + collectusedmacrosandsourcespreprocessorcallbacks.h + generatepchactionfactory.h + pchcreator.cpp pchcreator.h + pchcreatorinterface.h + pchmanagerserver.cpp pchmanagerserver.h + pchnotcreatederror.h + pchtask.h + pchtaskgenerator.cpp pchtaskgenerator.h + pchtaskgeneratorinterface.h + pchtaskqueue.cpp + pchtaskqueue.h + pchtaskqueueinterface.h + pchtasksmerger.cpp + pchtasksmerger.h + pchtasksmergerinterface.h + precompiledheaderstorage.h + precompiledheaderstorageinterface.h + processorinterface.h + processormanager.h + processormanagerinterface.h + projectpartsmanager.cpp projectpartsmanager.h + projectpartsmanagerinterface.h + queueinterface.h + taskscheduler.h + taskschedulerinterface.h + toolchainargumentscache.h + usedmacrofilter.h + usedmacrosandsourcescollector.cpp usedmacrosandsourcescollector.h +) diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp index bf00f39098..c2e3b4a5f9 100644 --- a/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp +++ b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp @@ -55,8 +55,10 @@ OutputContainer setUnion(InputContainer1 &&input1, BuildDependency BuildDependenciesProvider::create(const ProjectPartContainer &projectPart) { - auto sourcesAndProjectPart = createSourceEntriesFromStorage( - projectPart.sourcePathIds, projectPart.projectPartId); + m_ensureAliveMessageIsSentCallback(); + + auto sourcesAndProjectPart = createSourceEntriesFromStorage(projectPart.sourcePathIds, + projectPart.projectPartId); if (!m_modifiedTimeChecker.isUpToDate(sourcesAndProjectPart.first)) { BuildDependency buildDependency = m_generator.create(projectPart); diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h index 9700b83aa3..924e3e4f45 100644 --- a/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h +++ b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h @@ -27,6 +27,8 @@ #include "builddependenciesproviderinterface.h" +#include <modifiedtimecheckerinterface.h> + namespace Sqlite { class TransactionInterface; } @@ -34,14 +36,13 @@ class TransactionInterface; namespace ClangBackEnd { class BuildDependenciesStorageInterface; -class ModifiedTimeCheckerInterface; class BuildDependencyGeneratorInterface; class BuildDependenciesProvider : public BuildDependenciesProviderInterface { public: BuildDependenciesProvider(BuildDependenciesStorageInterface &buildDependenciesStorage, - ModifiedTimeCheckerInterface &modifiedTimeChecker, + ModifiedTimeCheckerInterface<> &modifiedTimeChecker, BuildDependencyGeneratorInterface &buildDependenciesGenerator, Sqlite::TransactionInterface &transactionBackend) : m_storage(buildDependenciesStorage) @@ -52,6 +53,11 @@ public: BuildDependency create(const ProjectPartContainer &projectPart) override; + void setEnsureAliveMessageIsSentCallback(std::function<void()> &&callback) + { + m_ensureAliveMessageIsSentCallback = std::move(callback); + } + private: BuildDependency createBuildDependencyFromStorage(SourceEntries &&includes) const; UsedMacros createUsedMacrosFromStorage(const SourceEntries &includes) const; @@ -61,9 +67,10 @@ private: private: BuildDependenciesStorageInterface &m_storage; - ModifiedTimeCheckerInterface &m_modifiedTimeChecker; + ModifiedTimeCheckerInterface<> &m_modifiedTimeChecker; BuildDependencyGeneratorInterface &m_generator; Sqlite::TransactionInterface &m_transactionBackend; + std::function<void()> m_ensureAliveMessageIsSentCallback; }; } // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesstorage.h b/src/tools/clangpchmanagerbackend/source/builddependenciesstorage.h index e7269dd0f9..8c8c51a6cd 100644 --- a/src/tools/clangpchmanagerbackend/source/builddependenciesstorage.h +++ b/src/tools/clangpchmanagerbackend/source/builddependenciesstorage.h @@ -66,6 +66,12 @@ public: } } + FilePathIds fetchSources(ProjectPartId projectPartId) const override + { + return fetchProjectPartsFilesStatement.template values<FilePathId>(1024, + projectPartId.projectPathId); + } + void insertOrUpdateFileStatuses(const FileStatuses &fileStatuses) override { WriteStatement &statement = insertOrUpdateFileStatusesStatement; @@ -246,6 +252,8 @@ public: "CONFLICT(sourceId, projectPartId) DO UPDATE SET sourceType = ?003, " "hasMissingIncludes = ?004", database}; + mutable ReadStatement fetchProjectPartsFilesStatement{ + "SELECT sourceId FROM projectPartsFiles WHERE projectPartId = ? ORDER BY sourceId", database}; mutable ReadStatement fetchSourceDependenciesStatement{ "WITH RECURSIVE collectedDependencies(sourceId) AS (VALUES(?) UNION " "SELECT dependencySourceId FROM sourceDependencies, " diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h b/src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h index a56e88b1f2..1166564b32 100644 --- a/src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h +++ b/src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h @@ -56,6 +56,7 @@ public: virtual UsedMacros fetchUsedMacros(FilePathId sourceId) const = 0; virtual ProjectPartId fetchProjectPartId(Utils::SmallStringView projectPartName) = 0; virtual void updatePchCreationTimeStamp(long long pchCreationTimeStamp, ProjectPartId projectPartId) = 0; + virtual FilePathIds fetchSources(ProjectPartId projectPartId) const = 0; protected: ~BuildDependenciesStorageInterface() = default; diff --git a/src/tools/clangpchmanagerbackend/source/builddependencycollector.cpp b/src/tools/clangpchmanagerbackend/source/builddependencycollector.cpp index 1d08442c51..b2c6cf8f86 100644 --- a/src/tools/clangpchmanagerbackend/source/builddependencycollector.cpp +++ b/src/tools/clangpchmanagerbackend/source/builddependencycollector.cpp @@ -33,7 +33,7 @@ #include <utils/smallstring.h> #include <algorithm> -#include <iostream> + namespace ClangBackEnd { namespace { @@ -68,18 +68,26 @@ FilePaths generatedFilePaths(const V2::FileContainers &containers) { BuildDependency BuildDependencyCollector::create(const ProjectPartContainer &projectPart) { - CommandLineBuilder<ProjectPartContainer, Utils::SmallStringVector> - builder{projectPart, projectPart.toolChainArguments, InputFileType::Source}; + if (projectPart.sourcePathIds.size()) { + CommandLineBuilder<ProjectPartContainer, Utils::SmallStringVector> builder{ + projectPart, + projectPart.toolChainArguments, + InputFileType::Source, + {}, + {}, + {}, + m_environment.preIncludeSearchPath()}; - addFiles(projectPart.sourcePathIds, std::move(builder.commandLine)); + addFiles(projectPart.sourcePathIds, std::move(builder.commandLine)); - setExcludedFilePaths(m_filePathCache.filePaths(projectPart.headerPathIds + - projectPart.sourcePathIds) + - generatedFilePaths(m_generatedFiles.fileContainers())); + setExcludedFilePaths( + m_filePathCache.filePaths(projectPart.headerPathIds + projectPart.sourcePathIds) + + generatedFilePaths(m_generatedFiles.fileContainers())); - addUnsavedFiles(m_generatedFiles.fileContainers()); + addUnsavedFiles(m_generatedFiles.fileContainers()); - collect(); + collect(); + } auto buildDependency = std::move(m_buildDependency); @@ -121,8 +129,7 @@ void BuildDependencyCollector::collect() auto action = std::make_unique<CollectBuildDependencyToolAction>(m_buildDependency, m_filePathCache, - m_excludedFilePaths, - m_sourcesManager); + m_excludedFilePaths); tool.run(action.get()); } @@ -147,7 +154,7 @@ void BuildDependencyCollector::setExcludedFilePaths(ClangBackEnd::FilePaths &&ex void BuildDependencyCollector::addFiles(const FilePathIds &filePathIds, Utils::SmallStringVector &&arguments) { - m_clangTool.addFile(FilePath{m_environment.pchBuildDirectory().toStdString(), "dummy.cpp"}, + m_clangTool.addFile(FilePath{m_environment.pchBuildDirectory(), "dummy.cpp"}, generateFakeFileContent(filePathIds), std::move(arguments)); m_buildDependency.sourceFiles.insert(m_buildDependency.sourceFiles.end(), diff --git a/src/tools/clangpchmanagerbackend/source/builddependencycollector.h b/src/tools/clangpchmanagerbackend/source/builddependencycollector.h index f8aaa8f07c..084024c821 100644 --- a/src/tools/clangpchmanagerbackend/source/builddependencycollector.h +++ b/src/tools/clangpchmanagerbackend/source/builddependencycollector.h @@ -95,7 +95,6 @@ private: BuildDependency m_buildDependency; ClangBackEnd::FilePaths m_excludedFilePaths; Utils::SmallStringVector m_directories; - SourcesManager m_sourcesManager; const FilePathCachingInterface &m_filePathCache; const GeneratedFilesInterface &m_generatedFiles; const Environment &m_environment; diff --git a/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri b/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri index 61bcedc262..6b79e2e71f 100644 --- a/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri +++ b/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri @@ -12,7 +12,6 @@ HEADERS += \ $$PWD/pchmanagerserver.h \ $$PWD/clangpchmanagerbackend_global.h \ $$PWD/pchnotcreatederror.h \ - $$PWD/environment.h \ $$PWD/pchcreatorinterface.h \ $$PWD/projectpartsmanager.h \ $$PWD/projectpartsmanagerinterface.h \ @@ -29,8 +28,6 @@ HEADERS += \ $$PWD/builddependenciesprovider.h \ $$PWD/builddependenciesstorageinterface.h \ $$PWD/builddependency.h \ - $$PWD/modifiedtimecheckerinterface.h \ - $$PWD/sourceentry.h \ $$PWD/builddependenciesstorage.h \ $$PWD/builddependencygeneratorinterface.h \ $$PWD/usedmacrofilter.h \ @@ -40,8 +37,7 @@ HEADERS += \ $$PWD/pchtaskqueue.h \ $$PWD/generatepchactionfactory.h \ $$PWD/pchtaskgeneratorinterface.h \ - $$PWD/toolchainargumentscache.h \ - $$PWD/modifiedtimechecker.h + $$PWD/toolchainargumentscache.h !isEmpty(LIBTOOLING_LIBS) { SOURCES += \ diff --git a/src/tools/clangpchmanagerbackend/source/collectbuilddependencyaction.h b/src/tools/clangpchmanagerbackend/source/collectbuilddependencyaction.h index fa1a10e79c..3e98dc2483 100644 --- a/src/tools/clangpchmanagerbackend/source/collectbuilddependencyaction.h +++ b/src/tools/clangpchmanagerbackend/source/collectbuilddependencyaction.h @@ -40,15 +40,13 @@ class CollectBuildDependencyAction final : public clang::PreprocessOnlyAction { public: CollectBuildDependencyAction(BuildDependency &buildDependency, - const FilePathCachingInterface &filePathCache, - std::vector<uint> &excludedIncludeUID, - std::vector<uint> &alreadyIncludedFileUIDs, - SourcesManager &sourcesManager) - : m_buildDependency(buildDependency), - m_filePathCache(filePathCache), - m_excludedIncludeUID(excludedIncludeUID), - m_alreadyIncludedFileUIDs(alreadyIncludedFileUIDs), - m_sourcesManager(sourcesManager) + const FilePathCachingInterface &filePathCache, + std::vector<uint> &excludedIncludeUID, + std::vector<uint> &alreadyIncludedFileUIDs) + : m_buildDependency(buildDependency) + , m_filePathCache(filePathCache) + , m_excludedIncludeUID(excludedIncludeUID) + , m_alreadyIncludedFileUIDs(alreadyIncludedFileUIDs) { } @@ -66,7 +64,6 @@ public: m_excludedIncludeUID, m_alreadyIncludedFileUIDs, compilerInstance.getSourceManager(), - m_sourcesManager, compilerInstance.getPreprocessorPtr()); preprocessor.addPPCallbacks( @@ -88,7 +85,6 @@ private: const FilePathCachingInterface &m_filePathCache; std::vector<uint> &m_excludedIncludeUID; std::vector<uint> &m_alreadyIncludedFileUIDs; - SourcesManager &m_sourcesManager; }; } // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h b/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h index f3b365d8d5..8583ff7a15 100644 --- a/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h +++ b/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h @@ -54,12 +54,10 @@ public: const std::vector<uint> &excludedIncludeUID, std::vector<uint> &alreadyIncludedFileUIDs, clang::SourceManager &sourceManager, - SourcesManager &sourcesManager, std::shared_ptr<clang::Preprocessor> preprocessor) : CollectUsedMacrosAndSourcesPreprocessorCallbacksBase(buildDependency.usedMacros, filePathCache, sourceManager, - sourcesManager, preprocessor, buildDependency.sourceDependencies, buildDependency.sourceFiles, @@ -189,7 +187,6 @@ public: { filterOutHeaderGuards(); mergeUsedMacros(); - m_sourcesManager.updateModifiedTimeStamps(); filterOutIncludesWithMissingIncludes(); } @@ -293,7 +290,7 @@ public: entry.get().hasMissingIncludes = HasMissingIncludes::Yes; } - SourceDependencies sourceDependenciesSortedByDependendFilePathId() const + SourceDependencies sourceDependenciesSortedByDependentFilePathId() const { auto sourceDependencies = m_buildDependency.sourceDependencies; std::sort(sourceDependencies.begin(), sourceDependencies.end(), [](auto first, auto second) { @@ -309,7 +306,7 @@ public: sortAndMakeUnique(m_containsMissingIncludes); collectSourceWithMissingIncludes(m_containsMissingIncludes, - sourceDependenciesSortedByDependendFilePathId()); + sourceDependenciesSortedByDependentFilePathId()); removeSourceWithMissingIncludesFromSources(); } diff --git a/src/tools/clangpchmanagerbackend/source/collectbuilddependencytoolaction.h b/src/tools/clangpchmanagerbackend/source/collectbuilddependencytoolaction.h index 4f28d0f7c8..471291ee90 100644 --- a/src/tools/clangpchmanagerbackend/source/collectbuilddependencytoolaction.h +++ b/src/tools/clangpchmanagerbackend/source/collectbuilddependencytoolaction.h @@ -38,13 +38,11 @@ class CollectBuildDependencyToolAction final : public clang::tooling::FrontendAc { public: CollectBuildDependencyToolAction(BuildDependency &buildDependency, - const FilePathCachingInterface &filePathCache, - const ClangBackEnd::FilePaths &excludedIncludes, - SourcesManager &sourcesManager) - : m_buildDependency(buildDependency), - m_filePathCache(filePathCache), - m_excludedFilePaths(excludedIncludes), - m_sourcesManager(sourcesManager) + const FilePathCachingInterface &filePathCache, + const ClangBackEnd::FilePaths &excludedIncludes) + : m_buildDependency(buildDependency) + , m_filePathCache(filePathCache) + , m_excludedFilePaths(excludedIncludes) {} @@ -67,8 +65,7 @@ public: return new CollectBuildDependencyAction(m_buildDependency, m_filePathCache, m_excludedIncludeUIDs, - m_alreadyIncludedFileUIDs, - m_sourcesManager); + m_alreadyIncludedFileUIDs); } std::vector<uint> generateExcludedIncludeFileUIDs(clang::FileManager &fileManager) const @@ -95,7 +92,6 @@ private: BuildDependency &m_buildDependency; const FilePathCachingInterface &m_filePathCache; const ClangBackEnd::FilePaths &m_excludedFilePaths; - SourcesManager &m_sourcesManager; }; } // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/collectusedmacroactionfactory.h b/src/tools/clangpchmanagerbackend/source/collectusedmacroactionfactory.h index b3f1cc0029..423d5f8876 100644 --- a/src/tools/clangpchmanagerbackend/source/collectusedmacroactionfactory.h +++ b/src/tools/clangpchmanagerbackend/source/collectusedmacroactionfactory.h @@ -39,13 +39,11 @@ class CollectUsedMacrosToolActionFactory final : public clang::tooling::Frontend public: CollectUsedMacrosToolActionFactory(UsedMacros &usedMacros, FilePathCachingInterface &filePathCache, - SourcesManager &sourcesManager, SourceDependencies &sourceDependencies, FilePathIds &sourceFiles, FileStatuses &fileStatuses) : m_usedMacros(usedMacros), m_filePathCache(filePathCache), - m_sourcesManager(sourcesManager), m_sourceDependencies(sourceDependencies), m_sourceFiles(sourceFiles), m_fileStatuses(fileStatuses) @@ -67,7 +65,6 @@ public: { return new CollectUsedMacrosAction(m_usedMacros, m_filePathCache, - m_sourcesManager, m_sourceDependencies, m_sourceFiles, m_fileStatuses); @@ -76,7 +73,6 @@ public: private: UsedMacros &m_usedMacros; FilePathCachingInterface &m_filePathCache; - SourcesManager &m_sourcesManager; SourceDependencies &m_sourceDependencies; FilePathIds &m_sourceFiles; FileStatuses &m_fileStatuses; diff --git a/src/tools/clangpchmanagerbackend/source/collectusedmacrosaction.h b/src/tools/clangpchmanagerbackend/source/collectusedmacrosaction.h index 4134d41d41..8f50e5a230 100644 --- a/src/tools/clangpchmanagerbackend/source/collectusedmacrosaction.h +++ b/src/tools/clangpchmanagerbackend/source/collectusedmacrosaction.h @@ -41,13 +41,11 @@ class CollectUsedMacrosAction final : public clang::PreprocessOnlyAction public: CollectUsedMacrosAction(UsedMacros &usedMacros, FilePathCachingInterface &filePathCache, - SourcesManager &sourcesManager, SourceDependencies &sourceDependencies, FilePathIds &sourceFiles, FileStatuses &fileStatuses) : m_usedMacros(usedMacros), m_filePathCache(filePathCache), - m_sourcesManager(sourcesManager), m_sourceDependencies(sourceDependencies), m_sourceFiles(sourceFiles), m_fileStatuses(fileStatuses) @@ -65,7 +63,6 @@ public: m_usedMacros, m_filePathCache, compilerInstance.getSourceManager(), - m_sourcesManager, compilerInstance.getPreprocessorPtr(), m_sourceDependencies, m_sourceFiles, @@ -87,7 +84,6 @@ public: private: UsedMacros &m_usedMacros; FilePathCachingInterface &m_filePathCache; - SourcesManager &m_sourcesManager; SourceDependencies &m_sourceDependencies; FilePathIds &m_sourceFiles; FileStatuses &m_fileStatuses; diff --git a/src/tools/clangpchmanagerbackend/source/collectusedmacrosandsourcespreprocessorcallbacks.h b/src/tools/clangpchmanagerbackend/source/collectusedmacrosandsourcespreprocessorcallbacks.h index b8ea406df0..5dc630de18 100644 --- a/src/tools/clangpchmanagerbackend/source/collectusedmacrosandsourcespreprocessorcallbacks.h +++ b/src/tools/clangpchmanagerbackend/source/collectusedmacrosandsourcespreprocessorcallbacks.h @@ -54,17 +54,16 @@ public: CollectUsedMacrosAndSourcesPreprocessorCallbacksBase(UsedMacros &usedMacros, const FilePathCachingInterface &filePathCache, const clang::SourceManager &sourceManager, - SourcesManager &sourcesManager, std::shared_ptr<clang::Preprocessor> preprocessor, SourceDependencies &sourceDependencies, FilePathIds &sourceFiles, FileStatuses &fileStatuses) - : SymbolsVisitorBase(filePathCache, &sourceManager, sourcesManager), - m_usedMacros(usedMacros), - m_preprocessor(preprocessor), - m_sourceDependencies(sourceDependencies), - m_sourceFiles(sourceFiles), - m_fileStatuses(fileStatuses) + : SymbolsVisitorBase(filePathCache, &sourceManager, m_filePathIndices) + , m_usedMacros(usedMacros) + , m_preprocessor(preprocessor) + , m_sourceDependencies(sourceDependencies) + , m_sourceFiles(sourceFiles) + , m_fileStatuses(fileStatuses) {} void addSourceFile(const clang::FileEntry *fileEntry) @@ -166,6 +165,7 @@ public: private: UsedMacros m_maybeUsedMacros; + FilePathIds m_filePathIndices; UsedMacros &m_usedMacros; std::shared_ptr<clang::Preprocessor> m_preprocessor; SourceDependencies &m_sourceDependencies; @@ -248,7 +248,6 @@ public: { filterOutHeaderGuards(); mergeUsedMacros(); - m_sourcesManager.updateModifiedTimeStamps(); } private: diff --git a/src/tools/clangpchmanagerbackend/source/environment.h b/src/tools/clangpchmanagerbackend/source/environment.h deleted file mode 100644 index 7f575fe169..0000000000 --- a/src/tools/clangpchmanagerbackend/source/environment.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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. -** -****************************************************************************/ - -#pragma once - -#include <QString> - -namespace ClangBackEnd { - -class Environment -{ -public: - Environment() = default; - Environment(const Environment &) = delete; - Environment &operator=(const Environment &) = delete; - - virtual QString pchBuildDirectory() const = 0; - virtual uint hardwareConcurrency() const = 0; - -protected: - ~Environment() = default; -}; - -} // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h b/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h index 2b1f4d036d..c4a8cae028 100644 --- a/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h +++ b/src/tools/clangpchmanagerbackend/source/generatepchactionfactory.h @@ -46,8 +46,9 @@ public: { compilerInstance.getPreprocessorOpts().DisablePCHValidation = true; compilerInstance.getPreprocessorOpts().AllowPCHWithCompilerErrors = true; - compilerInstance.getLangOpts().DelayedTemplateParsing = true; compilerInstance.getDiagnosticOpts().ErrorLimit = 0; + compilerInstance.getFrontendOpts().SkipFunctionBodies = true; + compilerInstance.getFrontendOpts().IncludeTimestamps = true; std::unique_ptr<llvm::MemoryBuffer> Input = llvm::MemoryBuffer::getMemBuffer(m_fileContent); compilerInstance.getPreprocessorOpts().addRemappedFile(m_filePath, Input.release()); diff --git a/src/tools/clangpchmanagerbackend/source/modifiedtimechecker.h b/src/tools/clangpchmanagerbackend/source/modifiedtimechecker.h deleted file mode 100644 index d641de054c..0000000000 --- a/src/tools/clangpchmanagerbackend/source/modifiedtimechecker.h +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** 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. -** -****************************************************************************/ - -#pragma once - -#include "modifiedtimecheckerinterface.h" - -#include <filepathcachinginterface.h> - -#include <algorithm> -#include <iterator> - -namespace ClangBackEnd { - -class ModifiedTimeChecker final : public ModifiedTimeCheckerInterface -{ -public: - using GetModifiedTime = std::function<ClangBackEnd::TimeStamp(ClangBackEnd::FilePathView filePath)>; - ModifiedTimeChecker(GetModifiedTime &getModifiedTime, FilePathCachingInterface &filePathCache) - : m_getModifiedTime(getModifiedTime) - , m_filePathCache(filePathCache) - {} - - bool isUpToDate(const SourceEntries &sourceEntries) const - { - if (sourceEntries.empty()) - return false; - - updateCurrentSourceTimeStamps(sourceEntries); - - return compareEntries(sourceEntries); - } - - void pathsChanged(const FilePathIds &filePathIds) - { - using SourceTimeStampReferences = std::vector<std::reference_wrapper<SourceTimeStamp>>; - - SourceTimeStampReferences timeStampsToUpdate; - timeStampsToUpdate.reserve(filePathIds.size()); - - std::set_intersection(m_currentSourceTimeStamps.begin(), - m_currentSourceTimeStamps.end(), - filePathIds.begin(), - filePathIds.end(), - std::back_inserter(timeStampsToUpdate)); - - for (SourceTimeStamp &sourceTimeStamp : timeStampsToUpdate) { - sourceTimeStamp.lastModified = m_getModifiedTime( - m_filePathCache.filePath(sourceTimeStamp.sourceId)); - } - } - -private: - bool compareEntries(const SourceEntries &sourceEntries) const - { - class CompareSourceId - { - public: - bool operator()(SourceTimeStamp first, SourceTimeStamp second) { - return first.sourceId < second.sourceId; - } - - bool operator()(SourceEntry first, SourceEntry second) - { - return first.sourceId < second.sourceId; - } - - bool operator()(SourceTimeStamp first, SourceEntry second) - { - return first.sourceId < second.sourceId; - } - - bool operator()(SourceEntry first, SourceTimeStamp second) - { - return first.sourceId < second.sourceId; - } - }; - - SourceTimeStamps currentSourceTimeStamp; - currentSourceTimeStamp.reserve(sourceEntries.size()); - std::set_intersection(m_currentSourceTimeStamps.begin(), - m_currentSourceTimeStamps.end(), - sourceEntries.begin(), - sourceEntries.end(), - std::back_inserter(currentSourceTimeStamp), - CompareSourceId{}); - - class CompareTime - { - public: - bool operator()(SourceTimeStamp first, SourceTimeStamp second) - { - return first.lastModified <= second.lastModified; - } - - bool operator()(SourceEntry first, SourceEntry second) - { - return first.pchCreationTimeStamp <= - second.pchCreationTimeStamp; - } - - bool operator()(SourceTimeStamp first, SourceEntry second) - { - return first.lastModified <= second.pchCreationTimeStamp; - } - - bool operator()(SourceEntry first, SourceTimeStamp second) - { - return first.pchCreationTimeStamp <= second.lastModified; - } - }; - - return std::lexicographical_compare(currentSourceTimeStamp.begin(), - currentSourceTimeStamp.end(), - sourceEntries.begin(), - sourceEntries.end(), - CompareTime{}); - } - - void updateCurrentSourceTimeStamps(const SourceEntries &sourceEntries) const - { - SourceTimeStamps sourceTimeStamps = newSourceTimeStamps(sourceEntries); - - for (SourceTimeStamp &newSourceTimeStamp : sourceTimeStamps) { - newSourceTimeStamp.lastModified = m_getModifiedTime( - m_filePathCache.filePath(newSourceTimeStamp.sourceId)); - } - - auto split = sourceTimeStamps.insert(sourceTimeStamps.end(), - m_currentSourceTimeStamps.begin(), - m_currentSourceTimeStamps.end()); - std::inplace_merge(sourceTimeStamps.begin(), split, sourceTimeStamps.end()); - - m_currentSourceTimeStamps = sourceTimeStamps; - } - - SourceTimeStamps newSourceTimeStamps(const SourceEntries &sourceEntries) const - { - SourceEntries newSourceEntries; - newSourceEntries.reserve(sourceEntries.size()); - - class CompareSourceId - { - public: - bool operator()(SourceTimeStamp first, SourceTimeStamp second) - { - return first.sourceId < second.sourceId; - } - - bool operator()(SourceEntry first, SourceEntry second) - { - return first.sourceId < second.sourceId; - } - - bool operator()(SourceTimeStamp first, SourceEntry second) - { - return first.sourceId < second.sourceId; - } - - bool operator()(SourceEntry first, SourceTimeStamp second) - { - return first.sourceId < second.sourceId; - } - }; - - std::set_difference(sourceEntries.begin(), - sourceEntries.end(), - m_currentSourceTimeStamps.begin(), - m_currentSourceTimeStamps.end(), - std::back_inserter(newSourceEntries), - CompareSourceId{}); - - SourceTimeStamps newTimeStamps; - newTimeStamps.reserve(newSourceEntries.size()); - - std::transform(newSourceEntries.begin(), - newSourceEntries.end(), - std::back_inserter(newTimeStamps), - [](SourceEntry entry) { - return SourceTimeStamp{entry.sourceId, {}}; - }); - - return newTimeStamps; - } - -private: - mutable SourceTimeStamps m_currentSourceTimeStamps; - GetModifiedTime &m_getModifiedTime; - FilePathCachingInterface &m_filePathCache; -}; - -} // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/pchcreator.cpp b/src/tools/clangpchmanagerbackend/source/pchcreator.cpp index 3f858b50ee..cd7b492868 100644 --- a/src/tools/clangpchmanagerbackend/source/pchcreator.cpp +++ b/src/tools/clangpchmanagerbackend/source/pchcreator.cpp @@ -104,25 +104,29 @@ Utils::SmallStringVector PchCreator::generateClangCompilerArguments(const PchTas InputFileType::Header, {}, pchOutputPath, - pchTask.systemPchPath}; + pchTask.systemPchPath, + pchTask.preIncludeSearchPath}; return builder.commandLine; } void PchCreator::generatePch(PchTask &&pchTask) { + m_projectPartPch.projectPartId = pchTask.projectPartId(); m_projectPartPch.lastModified = QDateTime::currentSecsSinceEpoch(); + + if (pchTask.includes.empty()) + return; + auto content = generatePchIncludeFileContent(pchTask.includes); auto pchOutputPath = generatePchFilePath(); - FilePath headerFilePath{m_environment.pchBuildDirectory().toStdString(), "dummy.h"}; + FilePath headerFilePath{m_environment.pchBuildDirectory(), "dummy.h"}; Utils::SmallStringVector commandLine = generateClangCompilerArguments(pchTask, pchOutputPath); m_clangTool.addFile(std::move(headerFilePath), content.clone(), std::move(commandLine)); bool success = generatePch(NativeFilePath{headerFilePath}, content); - m_projectPartPch.projectPartId = pchTask.projectPartId(); - if (success) { m_sources = pchTask.sources; m_projectPartPch.pchPath = std::move(pchOutputPath); @@ -168,17 +172,19 @@ void PchCreator::clear() void PchCreator::doInMainThreadAfterFinished() { - FilePathIds existingSources; - existingSources.reserve(m_sources.size()); - std::set_difference(m_sources.begin(), - m_sources.end(), - m_generatedFilePathIds.begin(), - m_generatedFilePathIds.end(), - std::back_inserter(existingSources)); - m_buildDependenciesStorage.updatePchCreationTimeStamp(m_projectPartPch.lastModified, - m_projectPartPch.projectPartId); - m_clangPathwatcher.updateIdPaths({{m_projectPartPch.projectPartId, existingSources}}); - m_pchManagerClient.precompiledHeadersUpdated(ProjectPartPchs{m_projectPartPch}); + if (m_projectPartPch.projectPartId.isValid()) { + FilePathIds existingSources; + existingSources.reserve(m_sources.size()); + std::set_difference(m_sources.begin(), + m_sources.end(), + m_generatedFilePathIds.begin(), + m_generatedFilePathIds.end(), + std::back_inserter(existingSources)); + m_buildDependenciesStorage.updatePchCreationTimeStamp(m_projectPartPch.lastModified, + m_projectPartPch.projectPartId); + m_clangPathwatcher.updateIdPaths({{m_projectPartPch.projectPartId, existingSources}}); + m_pchManagerClient.precompiledHeadersUpdated({m_projectPartPch.projectPartId}); + } } const FilePathCaching &PchCreator::filePathCache() diff --git a/src/tools/clangpchmanagerbackend/source/pchmanagerserver.cpp b/src/tools/clangpchmanagerbackend/source/pchmanagerserver.cpp index c1c12121aa..9cce6ef469 100644 --- a/src/tools/clangpchmanagerbackend/source/pchmanagerserver.cpp +++ b/src/tools/clangpchmanagerbackend/source/pchmanagerserver.cpp @@ -34,6 +34,7 @@ #include <updategeneratedfilesmessage.h> #include <updateprojectpartsmessage.h> +#include <utils/algorithm.h> #include <utils/smallstring.h> #include <QApplication> @@ -57,18 +58,29 @@ void PchManagerServer::end() QCoreApplication::exit(); } +namespace { +ProjectPartIds toProjectPartIds(const ProjectPartContainers &projectParts) +{ + return Utils::transform<ProjectPartIds>(projectParts, [](const auto &projectPart) { + return projectPart.projectPartId; + }); +} +} // namespace + void PchManagerServer::updateProjectParts(UpdateProjectPartsMessage &&message) { m_toolChainsArgumentsCache.update(message.projectsParts, message.toolChainArguments); - ProjectPartContainers newProjectParts = m_projectPartsManager.update(message.takeProjectsParts()); + auto upToDateProjectParts = m_projectPartsManager.update(message.takeProjectsParts()); if (m_generatedFiles.isValid()) { - m_pchTaskGenerator.addProjectParts(std::move(newProjectParts), + m_pchTaskGenerator.addProjectParts(std::move(upToDateProjectParts.notUpToDate), std::move(message.toolChainArguments)); } else { - m_projectPartsManager.updateDeferred(newProjectParts); + m_projectPartsManager.updateDeferred(upToDateProjectParts.notUpToDate); } + + client()->precompiledHeadersUpdated(toProjectPartIds(upToDateProjectParts.upToDate)); } void PchManagerServer::removeProjectParts(RemoveProjectPartsMessage &&message) diff --git a/src/tools/clangpchmanagerbackend/source/pchtask.h b/src/tools/clangpchmanagerbackend/source/pchtask.h index 7d8879fcbd..74b410831e 100644 --- a/src/tools/clangpchmanagerbackend/source/pchtask.h +++ b/src/tools/clangpchmanagerbackend/source/pchtask.h @@ -94,8 +94,8 @@ public: && first.systemIncludeSearchPaths == second.systemIncludeSearchPaths && first.projectIncludeSearchPaths == second.projectIncludeSearchPaths && first.toolChainArguments == second.toolChainArguments - && first.language == second.language - && first.languageVersion == second.languageVersion + && first.preIncludeSearchPath == second.preIncludeSearchPath + && first.language == second.language && first.languageVersion == second.languageVersion && first.languageExtension == second.languageExtension; } @@ -110,6 +110,7 @@ public: IncludeSearchPaths systemIncludeSearchPaths; IncludeSearchPaths projectIncludeSearchPaths; Utils::SmallStringVector toolChainArguments; + NativeFilePathView preIncludeSearchPath; Utils::Language language = Utils::Language::Cxx; Utils::LanguageVersion languageVersion = Utils::LanguageVersion::CXX98; Utils::LanguageExtension languageExtension = Utils::LanguageExtension::None; diff --git a/src/tools/clangpchmanagerbackend/source/pchtaskqueue.cpp b/src/tools/clangpchmanagerbackend/source/pchtaskqueue.cpp index 2abe3fa394..b9d6a48fe3 100644 --- a/src/tools/clangpchmanagerbackend/source/pchtaskqueue.cpp +++ b/src/tools/clangpchmanagerbackend/source/pchtaskqueue.cpp @@ -25,11 +25,16 @@ #include "pchtaskqueue.h" +#include <environment.h> #include <pchcreatorinterface.h> #include <precompiledheaderstorageinterface.h> #include <progresscounter.h> #include <sqlitetransaction.h> +#include <utils/algorithm.h> + +#include <iostream> + namespace ClangBackEnd { void PchTaskQueue::addPchTasks(PchTasks &&newPchTasks, PchTasks &destination) @@ -42,12 +47,12 @@ void PchTaskQueue::addPchTasks(PchTasks &&newPchTasks, PchTasks &destination) PchTasks mergedPchTasks; mergedPchTasks.reserve(destination.size() + newPchTasks.size()); - std::set_union(std::make_move_iterator(newPchTasks.begin()), - std::make_move_iterator(newPchTasks.end()), - std::make_move_iterator(destination.begin()), - std::make_move_iterator(destination.end()), - std::back_inserter(mergedPchTasks), - compare); + Utils::set_union(std::make_move_iterator(newPchTasks.begin()), + std::make_move_iterator(newPchTasks.end()), + std::make_move_iterator(destination.begin()), + std::make_move_iterator(destination.end()), + std::back_inserter(mergedPchTasks), + compare); destination = std::move(mergedPchTasks); @@ -142,16 +147,17 @@ std::vector<PchTaskQueue::Task> PchTaskQueue::createProjectTasks(PchTasks &&pchT auto convert = [this](auto &&pchTask) { return [pchTask = std::move(pchTask), this](PchCreatorInterface &pchCreator) mutable { const auto projectPartId = pchTask.projectPartId(); - pchTask.systemPchPath = m_precompiledHeaderStorage.fetchSystemPrecompiledHeaderPath( - projectPartId); - pchCreator.generatePch(std::move(pchTask)); - const auto &projectPartPch = pchCreator.projectPartPch(); - if (projectPartPch.pchPath.empty()) { - m_precompiledHeaderStorage.deleteProjectPrecompiledHeader(projectPartId); - } else { - m_precompiledHeaderStorage.insertProjectPrecompiledHeader( - projectPartId, projectPartPch.pchPath, projectPartPch.lastModified); - } + pchTask.systemPchPath = m_precompiledHeaderStorage.fetchSystemPrecompiledHeaderPath( + projectPartId); + pchTask.preIncludeSearchPath = m_environment.preIncludeSearchPath(); + pchCreator.generatePch(std::move(pchTask)); + const auto &projectPartPch = pchCreator.projectPartPch(); + if (projectPartPch.pchPath.empty()) { + m_precompiledHeaderStorage.deleteProjectPrecompiledHeader(projectPartId); + } else { + m_precompiledHeaderStorage.insertProjectPrecompiledHeader( + projectPartId, projectPartPch.pchPath, projectPartPch.lastModified); + } }; }; @@ -171,15 +177,15 @@ std::vector<PchTaskQueue::Task> PchTaskQueue::createSystemTasks(PchTasks &&pchTa auto convert = [this](auto &&pchTask) { return [pchTask = std::move(pchTask), this](PchCreatorInterface &pchCreator) mutable { const auto projectPartIds = pchTask.projectPartIds; - pchCreator.generatePch(std::move(pchTask)); - const auto &projectPartPch = pchCreator.projectPartPch(); - if (projectPartPch.pchPath.empty()) { - m_precompiledHeaderStorage.deleteSystemPrecompiledHeaders(projectPartIds); - } else { - m_precompiledHeaderStorage.insertSystemPrecompiledHeaders(projectPartIds, - projectPartPch.pchPath, - projectPartPch.lastModified); - } + pchTask.preIncludeSearchPath = m_environment.preIncludeSearchPath(); + pchCreator.generatePch(std::move(pchTask)); + const auto &projectPartPch = pchCreator.projectPartPch(); + if (projectPartPch.pchPath.empty()) { + m_precompiledHeaderStorage.deleteSystemPrecompiledHeaders(projectPartIds); + } else { + m_precompiledHeaderStorage.insertSystemPrecompiledHeaders( + projectPartIds, projectPartPch.pchPath, projectPartPch.lastModified); + } }; }; diff --git a/src/tools/clangpchmanagerbackend/source/pchtaskqueue.h b/src/tools/clangpchmanagerbackend/source/pchtaskqueue.h index 2d6d76ee58..80d96b8e85 100644 --- a/src/tools/clangpchmanagerbackend/source/pchtaskqueue.h +++ b/src/tools/clangpchmanagerbackend/source/pchtaskqueue.h @@ -36,6 +36,7 @@ namespace ClangBackEnd { class PchCreatorInterface; class PrecompiledHeaderStorageInterface; class ProgressCounter; +class Environment; class PchTaskQueue final : public PchTaskQueueInterface { @@ -46,12 +47,14 @@ public: TaskSchedulerInterface<Task> &projectPchTaskScheduler, ProgressCounter &progressCounter, PrecompiledHeaderStorageInterface &precompiledHeaderStorage, - Sqlite::TransactionInterface &transactionsInterface) + Sqlite::TransactionInterface &transactionsInterface, + const Environment &environment) : m_systemPchTaskScheduler(systemPchTaskScheduler) , m_projectPchTaskScheduler(projectPchTaskScheduler) , m_precompiledHeaderStorage(precompiledHeaderStorage) , m_transactionsInterface(transactionsInterface) , m_progressCounter(progressCounter) + , m_environment(environment) {} void addSystemPchTasks(PchTasks &&pchTasks) override; @@ -80,6 +83,7 @@ private: PrecompiledHeaderStorageInterface &m_precompiledHeaderStorage; Sqlite::TransactionInterface &m_transactionsInterface; ProgressCounter &m_progressCounter; + const Environment &m_environment; }; } // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/pchtasksmerger.cpp b/src/tools/clangpchmanagerbackend/source/pchtasksmerger.cpp index 7e850b8947..68a8e4a642 100644 --- a/src/tools/clangpchmanagerbackend/source/pchtasksmerger.cpp +++ b/src/tools/clangpchmanagerbackend/source/pchtasksmerger.cpp @@ -27,6 +27,8 @@ #include "pchtaskqueueinterface.h" +#include <utils/algorithm.h> + namespace ClangBackEnd { void PchTasksMerger::mergeTasks(PchTaskSets &&taskSets, @@ -48,11 +50,11 @@ Result merge(Container &&first, Container &&second) Result result; result.reserve(first.size() + second.size()); - std::set_union(std::make_move_iterator(first.begin()), - std::make_move_iterator(first.end()), - std::make_move_iterator(second.begin()), - std::make_move_iterator(second.end()), - std::back_inserter(result)); + Utils::set_union(std::make_move_iterator(first.begin()), + std::make_move_iterator(first.end()), + std::make_move_iterator(second.begin()), + std::make_move_iterator(second.end()), + std::back_inserter(result)); return result; } diff --git a/src/tools/clangpchmanagerbackend/source/precompiledheaderstorage.h b/src/tools/clangpchmanagerbackend/source/precompiledheaderstorage.h index e1b2f8aa2e..5510376fd5 100644 --- a/src/tools/clangpchmanagerbackend/source/precompiledheaderstorage.h +++ b/src/tools/clangpchmanagerbackend/source/precompiledheaderstorage.h @@ -25,6 +25,7 @@ #pragma once +#include "pchpaths.h" #include "precompiledheaderstorageinterface.h" #include <sqlitetransaction.h> @@ -77,6 +78,20 @@ public: } } + void deleteProjectPrecompiledHeaders(const ProjectPartIds &projectPartIds) override + { + try { + Sqlite::ImmediateTransaction transaction{database}; + + for (ProjectPartId projectPartId : projectPartIds) + deleteProjectPrecompiledHeaderStatement.write(projectPartId.projectPathId); + + transaction.commit(); + } catch (const Sqlite::StatementIsBusy) { + deleteProjectPrecompiledHeaders(projectPartIds); + } + } + void insertSystemPrecompiledHeaders(const ProjectPartIds &projectPartIds, Utils::SmallStringView pchPath, long long pchBuildTime) override @@ -128,9 +143,42 @@ public: return FilePath(""); } - Utils::optional<ProjectPartPch> fetchPrecompiledHeader(ProjectPartId projectPartId) const + FilePath fetchPrecompiledHeader(ProjectPartId projectPartId) const override { - return getPrecompiledHeader.template value<ProjectPartPch, 3>(projectPartId.projectPathId); + try { + Sqlite::DeferredTransaction transaction{database}; + + auto value = fetchPrecompiledHeaderStatement.template value<FilePath>( + projectPartId.projectPathId); + + if (value) + return *value; + + transaction.commit(); + } catch (const Sqlite::StatementIsBusy) { + return fetchPrecompiledHeader(projectPartId); + } + + return FilePath(""); + } + + PchPaths fetchPrecompiledHeaders(ProjectPartId projectPartId) const override + { + try { + Sqlite::DeferredTransaction transaction{database}; + + auto value = fetchPrecompiledHeadersStatement.template value<PchPaths, 2>( + projectPartId.projectPathId); + + if (value) + return *value; + + transaction.commit(); + } catch (const Sqlite::StatementIsBusy) { + return fetchPrecompiledHeaders(projectPartId); + } + + return {}; } public: @@ -138,7 +186,7 @@ public: Database &database; WriteStatement insertProjectPrecompiledHeaderStatement{ "INSERT INTO precompiledHeaders(projectPartId, projectPchPath, projectPchBuildTime) " - "VALUES((SELECT projectPartId FROM projectParts WHERE projectPartName = ?001),?002,?003) " + "VALUES(?001,?002,?003) " "ON CONFLICT (projectPartId) DO UPDATE SET projectPchPath=?002,projectPchBuildTime=?003", database}; WriteStatement insertSystemPrecompiledHeaderStatement{ @@ -156,9 +204,12 @@ public: database}; ReadStatement fetchSystemPrecompiledHeaderPathStatement{ "SELECT systemPchPath FROM precompiledHeaders WHERE projectPartId = ?", database}; - mutable ReadStatement getPrecompiledHeader{ - "SELECT projectPartId, ifnull(nullif(projectPchPath, ''), systemPchPath), " - "projectPchBuildTime FROM precompiledHeaders WHERE projectPartId = ?", + mutable ReadStatement fetchPrecompiledHeaderStatement{ + "SELECT ifnull(nullif(projectPchPath, ''), systemPchPath) " + "FROM precompiledHeaders WHERE projectPartId = ?", + database}; + mutable ReadStatement fetchPrecompiledHeadersStatement{ + "SELECT projectPchPath, systemPchPath FROM precompiledHeaders WHERE projectPartId = ?", database}; }; diff --git a/src/tools/clangpchmanagerbackend/source/precompiledheaderstorageinterface.h b/src/tools/clangpchmanagerbackend/source/precompiledheaderstorageinterface.h index e2a2b4a3b6..2ce880cd6a 100644 --- a/src/tools/clangpchmanagerbackend/source/precompiledheaderstorageinterface.h +++ b/src/tools/clangpchmanagerbackend/source/precompiledheaderstorageinterface.h @@ -27,7 +27,7 @@ #include "projectpartpch.h" -#include <filepath.h> +#include <pchpaths.h> #include <projectpartid.h> #include <utils/smallstringvector.h> @@ -47,14 +47,16 @@ public: Utils::SmallStringView pchPath, long long pchBuildTime) = 0; - virtual void deleteProjectPrecompiledHeader(ProjectPartId projectPartName) = 0; + virtual void deleteProjectPrecompiledHeader(ProjectPartId projectPartId) = 0; + virtual void deleteProjectPrecompiledHeaders(const ProjectPartIds &projectPartIds) = 0; virtual void insertSystemPrecompiledHeaders(const ProjectPartIds &projectPartIds, Utils::SmallStringView pchPath, long long pchBuildTime) = 0; virtual void deleteSystemPrecompiledHeaders(const ProjectPartIds &projectPartIds) = 0; virtual FilePath fetchSystemPrecompiledHeaderPath(ProjectPartId projectPartId) = 0; - virtual Utils::optional<ProjectPartPch> fetchPrecompiledHeader(ProjectPartId projectPartId) const = 0; + virtual FilePath fetchPrecompiledHeader(ProjectPartId projectPartId) const = 0; + virtual PchPaths fetchPrecompiledHeaders(ProjectPartId projectPartId) const = 0; protected: ~PrecompiledHeaderStorageInterface() = default; diff --git a/src/tools/clangpchmanagerbackend/source/projectpartsmanager.cpp b/src/tools/clangpchmanagerbackend/source/projectpartsmanager.cpp index ada99f44cd..191a13e16b 100644 --- a/src/tools/clangpchmanagerbackend/source/projectpartsmanager.cpp +++ b/src/tools/clangpchmanagerbackend/source/projectpartsmanager.cpp @@ -44,31 +44,35 @@ ProjectPartIds toProjectPartIds(const ProjectPartContainers &projectsParts) return ids; } -ProjectPartContainers ProjectPartsManager::update(ProjectPartContainers &&projectsParts) +ProjectPartsManager::UpToDataProjectParts ProjectPartsManager::update(ProjectPartContainers &&projectsParts) { - auto updatedProjectParts = filterNewProjectParts(std::move(projectsParts), m_projectParts); + auto notUpToDateProjectParts = filterProjectParts(projectsParts, m_projectParts); - if (updatedProjectParts.empty()) - return {}; + if (notUpToDateProjectParts.empty()) + return {std::move(projectsParts), {}}; auto persistentProjectParts = m_projectPartsStorage.fetchProjectParts( - toProjectPartIds(updatedProjectParts)); + toProjectPartIds(notUpToDateProjectParts)); if (persistentProjectParts.size() > 0) { mergeProjectParts(persistentProjectParts); - updatedProjectParts = filterNewProjectParts(std::move(updatedProjectParts), - persistentProjectParts); + notUpToDateProjectParts = filterProjectParts(notUpToDateProjectParts, persistentProjectParts); - if (updatedProjectParts.empty()) + if (notUpToDateProjectParts.empty()) return {}; } - m_projectPartsStorage.updateProjectParts(updatedProjectParts); + m_projectPartsStorage.updateProjectParts(notUpToDateProjectParts); + m_projectPartsStorage.resetIndexingTimeStamps(notUpToDateProjectParts); + m_precompiledHeaderStorage.deleteProjectPrecompiledHeaders( + toProjectPartIds(notUpToDateProjectParts)); - mergeProjectParts(updatedProjectParts); + mergeProjectParts(notUpToDateProjectParts); - return updatedProjectParts; + auto upToDateProjectParts = filterProjectParts(projectsParts, notUpToDateProjectParts); + + return {upToDateProjectParts, notUpToDateProjectParts}; } void ProjectPartsManager::remove(const ProjectPartIds &projectPartIds) @@ -173,8 +177,8 @@ ProjectPartContainers ProjectPartsManager::deferredUpdates() return deferredProjectParts; } -ProjectPartContainers ProjectPartsManager::filterNewProjectParts( - ProjectPartContainers &&projectsParts, const ProjectPartContainers &oldProjectParts) +ProjectPartContainers ProjectPartsManager::filterProjectParts( + const ProjectPartContainers &projectsParts, const ProjectPartContainers &oldProjectParts) { ProjectPartContainers updatedProjectPartContainers; updatedProjectPartContainers.reserve(projectsParts.size()); diff --git a/src/tools/clangpchmanagerbackend/source/projectpartsmanager.h b/src/tools/clangpchmanagerbackend/source/projectpartsmanager.h index 6583db25c6..35d9e41c1c 100644 --- a/src/tools/clangpchmanagerbackend/source/projectpartsmanager.h +++ b/src/tools/clangpchmanagerbackend/source/projectpartsmanager.h @@ -27,6 +27,7 @@ #include "clangpchmanagerbackend_global.h" +#include <precompiledheaderstorageinterface.h> #include <projectpartsmanagerinterface.h> #include <projectpartsstorageinterface.h> @@ -35,27 +36,31 @@ namespace ClangBackEnd { inline namespace Pch { + class ProjectPartsManager final : public ProjectPartsManagerInterface { public: - ProjectPartsManager(ProjectPartsStorageInterface &projectPartsStorage) + ProjectPartsManager(ProjectPartsStorageInterface &projectPartsStorage, + PrecompiledHeaderStorageInterface &precompiledHeaderStorage) : m_projectPartsStorage(projectPartsStorage) + , m_precompiledHeaderStorage(precompiledHeaderStorage) {} - ProjectPartContainers update(ProjectPartContainers &&projectsParts) override; + UpToDataProjectParts update(ProjectPartContainers &&projectsParts) override; void remove(const ProjectPartIds &projectPartIds) override; ProjectPartContainers projects(const ProjectPartIds &projectPartIds) const override; void updateDeferred(const ProjectPartContainers &projectsParts) override; ProjectPartContainers deferredUpdates() override; - static ProjectPartContainers filterNewProjectParts(ProjectPartContainers &&newProjectsParts, - const ProjectPartContainers &oldProjectParts); + static ProjectPartContainers filterProjectParts(const ProjectPartContainers &newProjectsParts, + const ProjectPartContainers &oldProjectParts); void mergeProjectParts(const ProjectPartContainers &projectsParts); const ProjectPartContainers &projectParts() const; private: ProjectPartContainers m_projectParts; ProjectPartsStorageInterface &m_projectPartsStorage; + PrecompiledHeaderStorageInterface &m_precompiledHeaderStorage; }; } // namespace Pch diff --git a/src/tools/clangpchmanagerbackend/source/projectpartsmanagerinterface.h b/src/tools/clangpchmanagerbackend/source/projectpartsmanagerinterface.h index ee80173f8a..54bae58c1a 100644 --- a/src/tools/clangpchmanagerbackend/source/projectpartsmanagerinterface.h +++ b/src/tools/clangpchmanagerbackend/source/projectpartsmanagerinterface.h @@ -32,11 +32,18 @@ namespace ClangBackEnd { class ProjectPartsManagerInterface { public: + class UpToDataProjectParts + { + public: + ProjectPartContainers upToDate; + ProjectPartContainers notUpToDate; + }; + ProjectPartsManagerInterface() = default; ProjectPartsManagerInterface(const ProjectPartsManagerInterface &) = delete; ProjectPartsManagerInterface &operator=(const ProjectPartsManagerInterface &) = delete; - virtual ProjectPartContainers update(ProjectPartContainers &&projectsParts) = 0; + virtual UpToDataProjectParts update(ProjectPartContainers &&projectsParts) = 0; virtual void remove(const ProjectPartIds &projectPartIds) = 0; virtual ProjectPartContainers projects(const ProjectPartIds &projectPartIds) const = 0; virtual void updateDeferred(const ProjectPartContainers &projectsParts) = 0; diff --git a/src/tools/clangpchmanagerbackend/source/sourceentry.h b/src/tools/clangpchmanagerbackend/source/sourceentry.h deleted file mode 100644 index 5c45db6bde..0000000000 --- a/src/tools/clangpchmanagerbackend/source/sourceentry.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** 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. -** -****************************************************************************/ - -#pragma once - -#include <filepathid.h> - -#include <vector> - -namespace ClangBackEnd { - -enum class SourceType : unsigned char { - TopProjectInclude, - TopSystemInclude, - UserInclude, - ProjectInclude, - SystemInclude, - Source -}; - -enum class HasMissingIncludes : unsigned char { No, Yes }; - -class TimeStamp -{ - using int64 = long long; -public: - TimeStamp() = default; - TimeStamp(int64 value) - : value(value) - {} - - operator int64() const - { - return value; - } - - int64 value = -1; -}; - -class SourceTimeStamp -{ - using int64 = long long; -public: - SourceTimeStamp(int sourceId, int64 lastModified) - : lastModified(lastModified) - , sourceId(sourceId) - {} - - SourceTimeStamp(FilePathId sourceId, TimeStamp lastModified) - : lastModified(lastModified) - , sourceId(sourceId) - {} - - friend bool operator<(SourceTimeStamp first, SourceTimeStamp second) - { - return first.sourceId < second.sourceId; - } - - friend bool operator<(SourceTimeStamp first, FilePathId second) - { - return first.sourceId < second; - } - - friend bool operator<(FilePathId first, SourceTimeStamp second) - { - return first < second.sourceId; - } - - friend bool operator==(SourceTimeStamp first, SourceTimeStamp second) - { - return first.sourceId == second.sourceId && first.lastModified == second.lastModified; - } - - friend bool operator!=(SourceTimeStamp first, SourceTimeStamp second) - { - return !(first == second); - } - -public: - TimeStamp lastModified; - FilePathId sourceId; -}; - -using SourceTimeStamps = std::vector<SourceTimeStamp>; - -class SourceEntry -{ - using int64 = long long; - -public: - SourceEntry(int sourceId, - int64 pchCreationTimeStamp, - int sourceType, - int hasMissingIncludes) - : pchCreationTimeStamp(pchCreationTimeStamp), sourceId(sourceId), - sourceType(static_cast<SourceType>(sourceType)), - hasMissingIncludes( - static_cast<HasMissingIncludes>(hasMissingIncludes)) {} - - SourceEntry(FilePathId sourceId, - SourceType sourceType, - TimeStamp pchCreationTimeStamp, - HasMissingIncludes hasMissingIncludes = HasMissingIncludes::No) - : pchCreationTimeStamp(pchCreationTimeStamp), sourceId(sourceId), - sourceType(sourceType), hasMissingIncludes(hasMissingIncludes) {} - - friend bool operator<(SourceEntry first, SourceEntry second) { - return first.sourceId < second.sourceId; - } - - friend bool operator==(SourceEntry first, SourceEntry second) - { - return first.sourceId == second.sourceId && first.sourceType == second.sourceType - && first.pchCreationTimeStamp == second.pchCreationTimeStamp; - } - - friend bool operator!=(SourceEntry first, SourceEntry second) { return !(first == second); } - -public: - TimeStamp pchCreationTimeStamp; - FilePathId sourceId; - SourceType sourceType = SourceType::UserInclude; - HasMissingIncludes hasMissingIncludes = HasMissingIncludes::No; -}; - -using SourceEntries = std::vector<SourceEntry>; -using SourceEntryReference = std::reference_wrapper<SourceEntry>; -using SourceEntryReferences = std::vector<SourceEntryReference>; -} // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/toolchainargumentscache.h b/src/tools/clangpchmanagerbackend/source/toolchainargumentscache.h index ed5ab3b1fd..d4d8a6479f 100644 --- a/src/tools/clangpchmanagerbackend/source/toolchainargumentscache.h +++ b/src/tools/clangpchmanagerbackend/source/toolchainargumentscache.h @@ -27,6 +27,8 @@ #include <projectpartcontainer.h> +#include <utils/algorithm.h> + #include <functional> namespace ClangBackEnd { @@ -48,11 +50,11 @@ struct ArgumentsEntry ProjectPartIds mergedIds; mergedIds.reserve(ids.size() + newIds.size()); - std::set_union(std::make_move_iterator(ids.begin()), - std::make_move_iterator(ids.end()), - std::make_move_iterator(newIds.begin()), - std::make_move_iterator(newIds.end()), - std::back_inserter(mergedIds)); + Utils::set_union(std::make_move_iterator(ids.begin()), + std::make_move_iterator(ids.end()), + std::make_move_iterator(newIds.begin()), + std::make_move_iterator(newIds.end()), + std::back_inserter(mergedIds)); ids = std::move(mergedIds); } diff --git a/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.cpp b/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.cpp index b26b2b801c..770d46f5e1 100644 --- a/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.cpp +++ b/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.cpp @@ -48,7 +48,6 @@ void UsedMacroAndSourcesCollector::collect() auto action = std::make_unique<CollectUsedMacrosToolActionFactory>( m_usedMacros, m_filePathCache, - m_sourcesManager, m_sourceDependencies, m_sourceFiles, m_fileStatuses); diff --git a/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.h b/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.h index a5b5749c12..9b72201fbb 100644 --- a/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.h +++ b/src/tools/clangpchmanagerbackend/source/usedmacrosandsourcescollector.h @@ -74,7 +74,6 @@ public: private: ClangTool m_clangTool; - SourcesManager m_sourcesManager; UsedMacros m_usedMacros; FilePathCachingInterface &m_filePathCache; FilePathIds m_sourceFiles; diff --git a/src/tools/clangrefactoringbackend/CMakeLists.txt b/src/tools/clangrefactoringbackend/CMakeLists.txt new file mode 100644 index 0000000000..d161659e82 --- /dev/null +++ b/src/tools/clangrefactoringbackend/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(source) + +add_qtc_executable(clangrefactoringbackend + DEPENDS + clangrefactoringbackend_lib Sqlite + SOURCES + clangrefactoringbackendmain.cpp +) diff --git a/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp b/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp index 9579f760c9..aaef21b608 100644 --- a/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp +++ b/src/tools/clangrefactoringbackend/clangrefactoringbackendmain.cpp @@ -30,11 +30,12 @@ #include <QDir> #include <connectionserver.h> +#include <environment.h> #include <executeinloop.h> #include <filepathcaching.h> #include <generatedfiles.h> -#include <refactoringserver.h> #include <refactoringclientproxy.h> +#include <refactoringserver.h> #include <symbolindexing.h> #include <sqliteexception.h> @@ -59,6 +60,8 @@ QStringList processArguments(QCoreApplication &application) parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument(QStringLiteral("connection"), QStringLiteral("Connection")); + parser.addPositionalArgument(QStringLiteral("databasepath"), QStringLiteral("Database path")); + parser.addPositionalArgument(QStringLiteral("resourcepath"), QStringLiteral("Resource path")); parser.process(application); @@ -85,12 +88,32 @@ public: } }; +class ApplicationEnvironment final : public ClangBackEnd::Environment +{ +public: + ApplicationEnvironment(const QString &preIncludeSearchPath) + : m_preIncludeSearchPath(ClangBackEnd::FilePath{preIncludeSearchPath}) + {} + + Utils::PathString pchBuildDirectory() const override { return {}; } + uint hardwareConcurrency() const override { return std::thread::hardware_concurrency(); } + ClangBackEnd::NativeFilePathView preIncludeSearchPath() const override + { + return m_preIncludeSearchPath; + } + +private: + ClangBackEnd::NativeFilePath m_preIncludeSearchPath; +}; + struct Data // because we have a cycle dependency { - Data(const QString &databasePath) - : database{Utils::PathString{databasePath}, 100000ms} + Data(const QString &databasePath, const QString &preIncludeSearchPath) + : environment{preIncludeSearchPath} + , database{Utils::PathString{databasePath}, 100000ms} {} + ApplicationEnvironment environment; Sqlite::Database database; RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database}; FilePathCaching filePathCache{database}; @@ -103,7 +126,8 @@ struct Data // because we have a cycle dependency executeInLoop([&] { clangCodeModelServer.setProgress(progress, total); }); - }}; + }, + environment}; }; #ifdef Q_OS_WIN @@ -131,8 +155,9 @@ int main(int argc, char *argv[]) const QStringList arguments = processArguments(application); const QString connectionName = arguments[0]; const QString databasePath = arguments[1]; + const QString preIncludeSearchPath = arguments[2] + "/indexer_preincludes"; - Data data{databasePath}; + Data data{databasePath, preIncludeSearchPath}; ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer; connectionServer.setServer(&data.clangCodeModelServer); diff --git a/src/tools/clangrefactoringbackend/source/CMakeLists.txt b/src/tools/clangrefactoringbackend/source/CMakeLists.txt new file mode 100644 index 0000000000..d43472fd60 --- /dev/null +++ b/src/tools/clangrefactoringbackend/source/CMakeLists.txt @@ -0,0 +1,54 @@ +add_qtc_library(clangrefactoringbackend_lib STATIC + PUBLIC_DEPENDS + Threads::Threads + LLVMCore libclang + clangAST clangASTMatchers clangBasic clangDynamicASTMatchers clangFrontend + clangHandleCXX clangIndex clangLex + clangSerialization clangTooling clangQuery + ClangSupport + PUBLIC_DEFINES CLANGSUPPORT_BUILD_LIB + PUBLIC_INCLUDES + ${CLANG_INCLUDE_DIRS} + "../../clangpchmanagerbackend/source" + SOURCES + clangquery.cpp clangquery.h + clangquerygatherer.cpp clangquerygatherer.h + clangrefactoringbackend_global.h + clangtool.cpp clangtool.h + collectmacrospreprocessorcallbacks.h + collectmacrossourcefilecallbacks.cpp collectmacrossourcefilecallbacks.h + collectsymbolsaction.cpp collectsymbolsaction.h + filestatus.h + filestatuscache.cpp filestatuscache.h + filestatuspreprocessorcallbacks.cpp filestatuspreprocessorcallbacks.h + findcursorusr.h + findlocationsofusrs.h + findusrforcursoraction.cpp findusrforcursoraction.h + indexdataconsumer.cpp indexdataconsumer.h + locationsourcefilecallbacks.cpp locationsourcefilecallbacks.h + macropreprocessorcallbacks.cpp macropreprocessorcallbacks.h + projectpartentry.h + refactoringcompilationdatabase.cpp refactoringcompilationdatabase.h + refactoringserver.cpp refactoringserver.h + sourcedependency.h + sourcelocationentry.h + sourcelocationsutils.h + sourcerangeextractor.cpp sourcerangeextractor.h + sourcerangefilter.cpp sourcerangefilter.h + sourcesmanager.h + symbolentry.h + symbolfinder.cpp symbolfinder.h + symbolindexer.cpp symbolindexer.h + symbolindexertask.h + symbolindexertaskqueue.h + symbolindexertaskqueueinterface.h + symbolindexing.cpp symbolindexing.h + symbolindexinginterface.h + symbollocationfinderaction.cpp symbollocationfinderaction.h + symbolscollector.cpp symbolscollector.h + symbolscollectorinterface.h + symbolstorage.h + symbolstorageinterface.h + symbolsvisitorbase.h + usedmacro.h +) diff --git a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri index fcac51f226..e7e83da788 100644 --- a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri +++ b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri @@ -2,6 +2,7 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/clangrefactoringbackend_global.h \ + $$PWD/filestatuspreprocessorcallbacks.h \ $$PWD/sourcerangefilter.h \ $$PWD/symbolindexer.h \ $$PWD/symbolentry.h \ @@ -64,6 +65,7 @@ HEADERS += \ } SOURCES += \ + $$PWD/filestatuspreprocessorcallbacks.cpp \ $$PWD/sourcerangefilter.cpp \ $$PWD/symbolindexer.cpp \ $$PWD/filestatuscache.cpp diff --git a/src/tools/clangrefactoringbackend/source/collectmacrospreprocessorcallbacks.h b/src/tools/clangrefactoringbackend/source/collectmacrospreprocessorcallbacks.h index 1d16b0f5e1..b0d59607e2 100644 --- a/src/tools/clangrefactoringbackend/source/collectmacrospreprocessorcallbacks.h +++ b/src/tools/clangrefactoringbackend/source/collectmacrospreprocessorcallbacks.h @@ -56,18 +56,16 @@ public: SourceDependencies &sourceDependencies, FilePathCachingInterface &filePathCache, const clang::SourceManager &sourceManager, - std::shared_ptr<clang::Preprocessor> &&preprocessor, - SourcesManager &sourcesManager) + std::shared_ptr<clang::Preprocessor> &&preprocessor) : CollectUsedMacrosAndSourcesPreprocessorCallbacksBase(usedMacros, filePathCache, sourceManager, - sourcesManager, std::move(preprocessor), sourceDependencies, sourceFiles, - fileStatuses), - m_symbolEntries(symbolEntries), - m_sourceLocationEntries(sourceLocationEntries) + fileStatuses) + , m_symbolEntries(symbolEntries) + , m_sourceLocationEntries(sourceLocationEntries) { } @@ -88,17 +86,15 @@ public: } void InclusionDirective(clang::SourceLocation hashLocation, - const clang::Token &/*includeToken*/, + const clang::Token & /*includeToken*/, llvm::StringRef /*fileName*/, bool /*isAngled*/, clang::CharSourceRange /*fileNameRange*/, const clang::FileEntry *file, llvm::StringRef /*searchPath*/, llvm::StringRef /*relativePath*/, - const clang::Module * /*imported*/ -#if LLVM_VERSION_MAJOR >= 7 - , clang::SrcMgr::CharacteristicKind /*fileType*/ -#endif + const clang::Module * /*imported*/, + clang::SrcMgr::CharacteristicKind /*fileType*/ ) override { if (!m_skipInclude && file) @@ -174,7 +170,6 @@ public: { filterOutHeaderGuards(); mergeUsedMacros(); - m_sourcesManager.updateModifiedTimeStamps(); } static const clang::MacroInfo *firstMacroInfo(const clang::MacroDirective *macroDirective) diff --git a/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.cpp b/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.cpp index d96fb05026..d360b727c4 100644 --- a/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.cpp +++ b/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.cpp @@ -34,16 +34,15 @@ namespace ClangBackEnd { bool CollectMacrosSourceFileCallbacks::handleBeginSource(clang::CompilerInstance &compilerInstance) { auto callbacks = std::make_unique<CollectMacrosPreprocessorCallbacks>( - m_symbolEntries, - m_sourceLocationEntries, - m_sourceFiles, - m_usedMacros, - m_fileStatuses, - m_sourceDependencies, - m_filePathCache, - compilerInstance.getSourceManager(), - compilerInstance.getPreprocessorPtr(), - m_sourcesManager); + m_symbolEntries, + m_sourceLocationEntries, + m_sourceFiles, + m_usedMacros, + m_fileStatuses, + m_sourceDependencies, + m_filePathCache, + compilerInstance.getSourceManager(), + compilerInstance.getPreprocessorPtr()); compilerInstance.getPreprocessorPtr()->addPPCallbacks(std::move(callbacks)); diff --git a/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.h b/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.h index 2392238106..16ba5a4f53 100644 --- a/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.h +++ b/src/tools/clangrefactoringbackend/source/collectmacrossourcefilecallbacks.h @@ -44,12 +44,10 @@ class CollectMacrosSourceFileCallbacks : public clang::tooling::SourceFileCallba public: CollectMacrosSourceFileCallbacks(SymbolEntries &symbolEntries, SourceLocationEntries &sourceLocationEntries, - FilePathCachingInterface &filePathCache, - SourcesManager &sourcesManager) - : m_symbolEntries(symbolEntries), - m_sourceLocationEntries(sourceLocationEntries), - m_filePathCache(filePathCache), - m_sourcesManager(sourcesManager) + FilePathCachingInterface &filePathCache) + : m_symbolEntries(symbolEntries) + , m_sourceLocationEntries(sourceLocationEntries) + , m_filePathCache(filePathCache) { } @@ -96,7 +94,6 @@ private: SymbolEntries &m_symbolEntries; SourceLocationEntries &m_sourceLocationEntries; FilePathCachingInterface &m_filePathCache; - SourcesManager &m_sourcesManager; }; } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/collectsymbolsaction.cpp b/src/tools/clangrefactoringbackend/source/collectsymbolsaction.cpp index 91c0dd28d8..301f50beae 100644 --- a/src/tools/clangrefactoringbackend/source/collectsymbolsaction.cpp +++ b/src/tools/clangrefactoringbackend/source/collectsymbolsaction.cpp @@ -33,8 +33,7 @@ std::unique_ptr<clang::ASTConsumer> CollectSymbolsAction::newASTConsumer( clang::CompilerInstance &compilerInstance, llvm::StringRef inFile) { - m_indexDataConsumer->setSourceManager(&compilerInstance.getSourceManager()); - return m_action.CreateASTConsumer(compilerInstance, inFile); + return clang::WrapperFrontendAction::CreateASTConsumer(compilerInstance, inFile); } } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/collectsymbolsaction.h b/src/tools/clangrefactoringbackend/source/collectsymbolsaction.h index 2074a25a6e..a38f1c4f87 100644 --- a/src/tools/clangrefactoringbackend/source/collectsymbolsaction.h +++ b/src/tools/clangrefactoringbackend/source/collectsymbolsaction.h @@ -26,8 +26,8 @@ #pragma once #include "clangrefactoringbackend_global.h" -#include "sourcelocationentry.h" #include "indexdataconsumer.h" +#include "sourcelocationentry.h" #include "symbolentry.h" #include <utils/smallstring.h> @@ -37,53 +37,68 @@ #include <clang/Frontend/CompilerInstance.h> #include <clang/Frontend/FrontendAction.h> #include <clang/Index/IndexingAction.h> +#include <clang/Lex/PreprocessorOptions.h> #include <mutex> namespace ClangBackEnd { -class CollectSymbolsAction +class CollectSymbolsAction : public clang::WrapperFrontendAction { public: CollectSymbolsAction(std::shared_ptr<IndexDataConsumer> indexDataConsumer) - : m_action(indexDataConsumer, createIndexingOptions()), - m_indexDataConsumer(indexDataConsumer.get()) + : clang::WrapperFrontendAction( + clang::index::createIndexingAction(indexDataConsumer, createIndexingOptions(), nullptr)) + , m_indexDataConsumer(indexDataConsumer) {} std::unique_ptr<clang::ASTConsumer> newASTConsumer(clang::CompilerInstance &compilerInstance, llvm::StringRef inFile); -private: - class WrappedIndexAction final : public clang::WrapperFrontendAction - { - public: - WrappedIndexAction(std::shared_ptr<clang::index::IndexDataConsumer> indexDataConsumer, - clang::index::IndexingOptions indexingOptions) - : clang::WrapperFrontendAction( - clang::index::createIndexingAction(indexDataConsumer, indexingOptions, nullptr)) - {} - - std::unique_ptr<clang::ASTConsumer> - CreateASTConsumer(clang::CompilerInstance &compilerInstance, - llvm::StringRef inFile) override - { - return WrapperFrontendAction::CreateASTConsumer(compilerInstance, inFile); - } - }; - - static - clang::index::IndexingOptions createIndexingOptions() + + static clang::index::IndexingOptions createIndexingOptions() { clang::index::IndexingOptions options; options.SystemSymbolFilter = clang::index::IndexingOptions::SystemSymbolFilterKind::None; options.IndexFunctionLocals = true; + options.IndexMacrosInPreprocessor = true; return options; } + bool BeginInvocation(clang::CompilerInstance &compilerInstance) override + { + m_indexDataConsumer->setSourceManager(&compilerInstance.getSourceManager()); + compilerInstance.getPreprocessorOpts().AllowPCHWithCompilerErrors = true; + compilerInstance.getDiagnosticOpts().ErrorLimit = 1; + + return clang::WrapperFrontendAction::BeginInvocation(compilerInstance); + } + + bool BeginSourceFileAction(clang::CompilerInstance &compilerInstance) override + { + compilerInstance.getPreprocessor().SetSuppressIncludeNotFoundError(true); + + return clang::WrapperFrontendAction::BeginSourceFileAction(compilerInstance); + } + + void EndSourceFileAction() override { clang::WrapperFrontendAction::EndSourceFileAction(); } + + bool PrepareToExecuteAction(clang::CompilerInstance &instance) override + { + return clang::WrapperFrontendAction::PrepareToExecuteAction(instance); + } + + void ExecuteAction() override { clang::WrapperFrontendAction::ExecuteAction(); } + + std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &compilerInstance, + llvm::StringRef inFile) override + { + return WrapperFrontendAction::CreateASTConsumer(compilerInstance, inFile); + } + private: - WrappedIndexAction m_action; - IndexDataConsumer *m_indexDataConsumer; + std::shared_ptr<IndexDataConsumer> m_indexDataConsumer; }; } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/filestatuspreprocessorcallbacks.cpp b/src/tools/clangrefactoringbackend/source/filestatuspreprocessorcallbacks.cpp new file mode 100644 index 0000000000..28efe39f9b --- /dev/null +++ b/src/tools/clangrefactoringbackend/source/filestatuspreprocessorcallbacks.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "filestatuspreprocessorcallbacks.h" + +namespace ClangBackEnd { + +void FileStatusPreprocessorCallbacks::FileChanged(clang::SourceLocation sourceLocation, + clang::PPCallbacks::FileChangeReason reason, + clang::SrcMgr::CharacteristicKind, + clang::FileID) +{ + if (reason == clang::PPCallbacks::EnterFile) { + const clang::FileEntry *fileEntry = m_sourceManager->getFileEntryForID( + m_sourceManager->getFileID(sourceLocation)); + if (fileEntry) + addFileStatus(fileEntry); + } +} + +void FileStatusPreprocessorCallbacks::addFileStatus(const clang::FileEntry *fileEntry) +{ + auto id = filePathId(fileEntry); + + auto found = std::lower_bound(m_fileStatuses.begin(), + m_fileStatuses.end(), + id, + [](const auto &first, const auto &second) { + return first.filePathId < second; + }); + + if (found == m_fileStatuses.end() || found->filePathId != id) { + m_fileStatuses.emplace(found, id, fileEntry->getSize(), fileEntry->getModificationTime()); + } +} + +} // namespace ClangBackEnd diff --git a/src/tools/clangpchmanagerbackend/source/modifiedtimecheckerinterface.h b/src/tools/clangrefactoringbackend/source/filestatuspreprocessorcallbacks.h index c0cae1cf4b..ad7bc4f4d6 100644 --- a/src/tools/clangpchmanagerbackend/source/modifiedtimecheckerinterface.h +++ b/src/tools/clangrefactoringbackend/source/filestatuspreprocessorcallbacks.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. @@ -25,22 +25,35 @@ #pragma once -#include "sourceentry.h" +#include "filestatus.h" +#include "symbolsvisitorbase.h" + +#include <filepathid.h> + +#include <clang/Lex/PPCallbacks.h> namespace ClangBackEnd { -class ModifiedTimeCheckerInterface +class FileStatusPreprocessorCallbacks final : public clang::PPCallbacks, public SymbolsVisitorBase { public: - ModifiedTimeCheckerInterface() = default; - ModifiedTimeCheckerInterface(const ModifiedTimeCheckerInterface &) = delete; - ModifiedTimeCheckerInterface &operator=(const ModifiedTimeCheckerInterface &) = delete; - - virtual bool isUpToDate(const SourceEntries &sourceEntries) const = 0; - -protected: - ~ModifiedTimeCheckerInterface() = default; + FileStatusPreprocessorCallbacks(FileStatuses &fileStatuses, + const FilePathCachingInterface &filePathCache, + const clang::SourceManager *sourceManager, + FilePathIds &filePathIndices) + : SymbolsVisitorBase(filePathCache, sourceManager, filePathIndices) + , m_fileStatuses(fileStatuses) + {} + + void FileChanged(clang::SourceLocation sourceLocation, + clang::PPCallbacks::FileChangeReason reason, + clang::SrcMgr::CharacteristicKind, + clang::FileID) override; + + void addFileStatus(const clang::FileEntry *fileEntry); + +private: + FileStatuses &m_fileStatuses; }; } // namespace ClangBackEnd - diff --git a/src/tools/clangrefactoringbackend/source/findcursorusr.h b/src/tools/clangrefactoringbackend/source/findcursorusr.h index 549086cd3a..06777d8611 100644 --- a/src/tools/clangrefactoringbackend/source/findcursorusr.h +++ b/src/tools/clangrefactoringbackend/source/findcursorusr.h @@ -25,6 +25,8 @@ #pragma once +#include "clangrefactoringbackend_global.h" + #include <clang/AST/AST.h> #include <clang/AST/ASTContext.h> #include <clang/AST/RecursiveASTVisitor.h> @@ -161,7 +163,7 @@ std::vector<const clang::NamedDecl *> namedDeclarationsAt(const clang::ASTContex auto declarations = Context.getTranslationUnitDecl()->decls(); for (auto ¤tDeclation : declarations) { - const auto &fileLocation = currentDeclation->getLocStart(); + const auto &fileLocation = currentDeclation->getBeginLoc(); const auto &fileName = sourceManager.getFilename(fileLocation); if (fileName == currentFile) { visitor.TraverseDecl(currentDeclation); diff --git a/src/tools/clangrefactoringbackend/source/indexdataconsumer.cpp b/src/tools/clangrefactoringbackend/source/indexdataconsumer.cpp index 86e5fb597c..1fa6043461 100644 --- a/src/tools/clangrefactoringbackend/source/indexdataconsumer.cpp +++ b/src/tools/clangrefactoringbackend/source/indexdataconsumer.cpp @@ -24,14 +24,18 @@ ****************************************************************************/ #include "indexdataconsumer.h" +#include "collectsymbolsaction.h" +#include "filestatuspreprocessorcallbacks.h" +#include <clang/AST/DeclVisitor.h> #include <clang/Basic/SourceLocation.h> #include <clang/Index/IndexSymbol.h> -#include <clang/AST/Decl.h> -#include <clang/AST/DeclVisitor.h> +#include <clang/Index/IndexingAction.h> #include <llvm/ADT/ArrayRef.h> +#include <iostream> + namespace ClangBackEnd { namespace { @@ -113,23 +117,33 @@ bool isReference(clang::index::SymbolRoleSet symbolRoles) return symbolRoles & (uint(SymbolRole::Reference) | uint(SymbolRole::Call)); } -} +} // namespace bool IndexDataConsumer::skipSymbol(clang::FileID fileId, clang::index::SymbolRoleSet symbolRoles) { - bool alreadyParsed = isAlreadyParsed(fileId); - bool isParsedDeclaration = alreadyParsed && isDeclaration(symbolRoles); - bool isParsedReference = alreadyParsed && !dependentFilesAreModified() && isReference(symbolRoles); + return isAlreadyParsed(fileId, m_symbolSourcesManager) + && !m_symbolSourcesManager.dependentFilesModified(); +} + +bool IndexDataConsumer::isAlreadyParsed(clang::FileID fileId, SourcesManager &sourcesManager) +{ + const clang::FileEntry *fileEntry = m_sourceManager->getFileEntryForID(fileId); + if (!fileEntry) + return false; + return sourcesManager.alreadyParsed(filePathId(fileEntry), fileEntry->getModificationTime()); +} - return isParsedDeclaration || isParsedReference; +void IndexDataConsumer::setPreprocessor(std::shared_ptr<clang::Preprocessor> preprocessor) +{ + preprocessor->addPPCallbacks(std::make_unique<FileStatusPreprocessorCallbacks>( + m_fileStatuses, m_filePathCache, m_sourceManager, m_filePathIndices)); } -bool IndexDataConsumer::handleDeclOccurence( - const clang::Decl *declaration, - clang::index::SymbolRoleSet symbolRoles, - llvm::ArrayRef<clang::index::SymbolRelation> /*symbolRelations*/, - clang::SourceLocation sourceLocation, - IndexDataConsumer::ASTNodeInfo /*astNodeInfo*/) +bool IndexDataConsumer::handleDeclOccurence(const clang::Decl *declaration, + clang::index::SymbolRoleSet symbolRoles, + llvm::ArrayRef<clang::index::SymbolRelation> /*symbolRelations*/, + clang::SourceLocation sourceLocation, + IndexDataConsumer::ASTNodeInfo /*astNodeInfo*/) { const auto *namedDeclaration = clang::dyn_cast<clang::NamedDecl>(declaration); if (namedDeclaration) { @@ -137,7 +151,6 @@ bool IndexDataConsumer::handleDeclOccurence( return true; if (skipSymbol(m_sourceManager->getFileID(sourceLocation), symbolRoles)) - return true; SymbolIndex globalId = toSymbolIndex(declaration->getCanonicalDecl()); @@ -165,4 +178,64 @@ bool IndexDataConsumer::handleDeclOccurence( return true; } +namespace { + +SourceLocationKind macroSymbolType(clang::index::SymbolRoleSet roles) +{ + if (roles & static_cast<clang::index::SymbolRoleSet>(clang::index::SymbolRole::Definition)) + return SourceLocationKind::MacroDefinition; + + if (roles & static_cast<clang::index::SymbolRoleSet>(clang::index::SymbolRole::Undefinition)) + return SourceLocationKind::MacroUndefinition; + + if (roles & static_cast<clang::index::SymbolRoleSet>(clang::index::SymbolRole::Reference)) + return SourceLocationKind::MacroUsage; + + return SourceLocationKind::None; +} + +} // namespace + +bool IndexDataConsumer::handleMacroOccurence(const clang::IdentifierInfo *identifierInfo, + const clang::MacroInfo *macroInfo, + clang::index::SymbolRoleSet roles, + clang::SourceLocation sourceLocation) +{ + if (macroInfo && sourceLocation.isFileID() + && !isAlreadyParsed(m_sourceManager->getFileID(sourceLocation), m_macroSourcesManager) + && !isInSystemHeader(sourceLocation)) { + FilePathId fileId = filePathId(sourceLocation); + if (fileId.isValid()) { + auto macroName = identifierInfo->getName(); + SymbolIndex globalId = toSymbolIndex(macroInfo); + + auto found = m_symbolEntries.find(globalId); + if (found == m_symbolEntries.end()) { + Utils::optional<Utils::PathString> usr = generateUSR(macroName, sourceLocation); + if (usr) { + m_symbolEntries.emplace(std::piecewise_construct, + std::forward_as_tuple(globalId), + std::forward_as_tuple(std::move(*usr), + macroName, + SymbolKind::Macro)); + } + } + + m_sourceLocationEntries.emplace_back(globalId, + fileId, + lineColum(sourceLocation), + macroSymbolType(roles)); + } + } + + return true; +} + +void IndexDataConsumer::finish() +{ + m_macroSourcesManager.updateModifiedTimeStamps(); + m_symbolSourcesManager.updateModifiedTimeStamps(); + m_filePathIndices.clear(); +} + } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/indexdataconsumer.h b/src/tools/clangrefactoringbackend/source/indexdataconsumer.h index 6db595391c..730ca12b23 100644 --- a/src/tools/clangrefactoringbackend/source/indexdataconsumer.h +++ b/src/tools/clangrefactoringbackend/source/indexdataconsumer.h @@ -26,6 +26,7 @@ #pragma once #include "clangrefactoringbackend_global.h" +#include "filestatus.h" #include "sourcelocationentry.h" #include "symbolentry.h" #include "symbolsvisitorbase.h" @@ -42,28 +43,48 @@ class IndexDataConsumer : public clang::index::IndexDataConsumer, public: IndexDataConsumer(SymbolEntries &symbolEntries, SourceLocationEntries &sourceLocationEntries, + FileStatuses &fileStatuses, FilePathCachingInterface &filePathCache, - SourcesManager &sourcesManager) - : SymbolsVisitorBase(filePathCache, nullptr, sourcesManager), - m_symbolEntries(symbolEntries), - m_sourceLocationEntries(sourceLocationEntries) + SourcesManager &symbolSourcesManager, + SourcesManager ¯oSourcesManager) + : SymbolsVisitorBase(filePathCache, nullptr, m_filePathIndices) + , m_symbolEntries(symbolEntries) + , m_sourceLocationEntries(sourceLocationEntries) + , m_fileStatuses(fileStatuses) + , m_symbolSourcesManager(symbolSourcesManager) + , m_macroSourcesManager(macroSourcesManager) + {} IndexDataConsumer(const IndexDataConsumer &) = delete; IndexDataConsumer &operator=(const IndexDataConsumer &) = delete; + void setPreprocessor(std::shared_ptr<clang::Preprocessor> preprocessor) override; + bool handleDeclOccurence(const clang::Decl *declaration, clang::index::SymbolRoleSet symbolRoles, llvm::ArrayRef<clang::index::SymbolRelation> symbolRelations, clang::SourceLocation sourceLocation, ASTNodeInfo astNodeInfo) override; + bool handleMacroOccurence(const clang::IdentifierInfo *identifierInfo, + const clang::MacroInfo *macroInfo, + clang::index::SymbolRoleSet roles, + clang::SourceLocation sourceLocation) override; + + void finish() override; + private: bool skipSymbol(clang::FileID fileId, clang::index::SymbolRoleSet symbolRoles); + bool isAlreadyParsed(clang::FileID fileId, SourcesManager &sourcesManager); private: + FilePathIds m_filePathIndices; SymbolEntries &m_symbolEntries; SourceLocationEntries &m_sourceLocationEntries; + FileStatuses &m_fileStatuses; + SourcesManager &m_symbolSourcesManager; + SourcesManager &m_macroSourcesManager; }; } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h index b25e43e483..ad37c8a3e9 100644 --- a/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h +++ b/src/tools/clangrefactoringbackend/source/refactoringcompilationdatabase.h @@ -31,7 +31,6 @@ namespace ClangBackEnd { - class RefactoringCompilationDatabase : public clang::tooling::CompilationDatabase { public: diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index e0315c6626..1ee61eb67c 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -29,6 +29,7 @@ #include "symbolindexertaskqueue.h" #include <commandlinebuilder.h> +#include <environment.h> #include <chrono> #include <iostream> @@ -66,7 +67,9 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ FilePathCachingInterface &filePathCache, FileStatusCache &fileStatusCache, Sqlite::TransactionInterface &transactionInterface, - ProjectPartsStorageInterface &projectPartsStorage) + ProjectPartsStorageInterface &projectPartsStorage, + ModifiedTimeCheckerInterface<SourceTimeStamps> &modifiedTimeChecker, + const Environment &environment) : m_symbolIndexerTaskQueue(symbolIndexerTaskQueue) , m_symbolStorage(symbolStorage) , m_buildDependencyStorage(buildDependenciesStorage) @@ -76,6 +79,8 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ , m_fileStatusCache(fileStatusCache) , m_transactionInterface(transactionInterface) , m_projectPartsStorage(projectPartsStorage) + , m_modifiedTimeChecker(modifiedTimeChecker) + , m_environment(environment) { pathWatcher.setNotifier(this); } @@ -88,45 +93,59 @@ void SymbolIndexer::updateProjectParts(ProjectPartContainers &&projectParts) void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) { - Sqlite::DeferredTransaction transaction{m_transactionInterface}; - ProjectPartId projectPartId = projectPart.projectPartId; - const Utils::optional<ProjectPartPch> optionalProjectPartPch - = m_precompiledHeaderStorage.fetchPrecompiledHeader(projectPartId); - - transaction.commit(); - - using Builder = CommandLineBuilder<ProjectPartContainer, Utils::SmallStringVector>; - Builder commandLineBuilder{projectPart, - projectPart.toolChainArguments, - InputFileType::Source, - {}, - {}, - optionalProjectPartPch ? FilePathView{optionalProjectPartPch->pchPath} - : FilePathView{}}; std::vector<SymbolIndexerTask> symbolIndexerTask; symbolIndexerTask.reserve(projectPart.sourcePathIds.size()); for (FilePathId sourcePathId : projectPart.sourcePathIds) { - auto indexing = [arguments = commandLineBuilder.commandLine, - sourcePathId, - this](SymbolsCollectorInterface &symbolsCollector) { - symbolsCollector.setFile(sourcePathId, arguments); - - bool success = symbolsCollector.collectSymbols(); - - if (success) { - Sqlite::ImmediateTransaction transaction{m_transactionInterface}; - - m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), - symbolsCollector.sourceLocations()); - transaction.commit(); - } - }; - - symbolIndexerTask.emplace_back(sourcePathId, projectPartId, std::move(indexing)); + SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps( + sourcePathId); + + if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) { + auto indexing = [projectPart, + sourcePathId, + preIncludeSearchPath = m_environment.preIncludeSearchPath(), + this](SymbolsCollectorInterface &symbolsCollector) { + auto collect = [&](const FilePath &pchPath) { + using Builder = CommandLineBuilder<ProjectPartContainer, Utils::SmallStringVector>; + Builder commandLineBuilder{projectPart, + projectPart.toolChainArguments, + InputFileType::Source, + {}, + {}, + pchPath, + preIncludeSearchPath}; + symbolsCollector.setFile(sourcePathId, commandLineBuilder.commandLine); + + return symbolsCollector.collectSymbols(); + }; + + auto store = [&] { + Sqlite::ImmediateTransaction transaction{m_transactionInterface}; + m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses()); + m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), + symbolsCollector.sourceLocations()); + transaction.commit(); + }; + + const PchPaths pchPaths = m_precompiledHeaderStorage.fetchPrecompiledHeaders( + projectPart.projectPartId); + + if (pchPaths.projectPchPath.size() && collect(pchPaths.projectPchPath)) { + store(); + } else if (pchPaths.systemPchPath.size() && collect(pchPaths.systemPchPath)) { + store(); + } else if (collect({})) { + store(); + } + }; + + symbolIndexerTask.emplace_back(sourcePathId, projectPartId, std::move(indexing)); + } } + m_pathWatcher.updateIdPaths( + {{projectPartId, m_buildDependencyStorage.fetchSources(projectPartId)}}); m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask)); m_symbolIndexerTaskQueue.processEntries(); } @@ -135,11 +154,13 @@ void SymbolIndexer::pathsWithIdsChanged(const ProjectPartIds &) {} void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds) { + FilePathIds dependentSourcePathIds = m_symbolStorage.fetchDependentSourceIds(filePathIds); + std::vector<SymbolIndexerTask> symbolIndexerTask; - symbolIndexerTask.reserve(filePathIds.size()); + symbolIndexerTask.reserve(dependentSourcePathIds.size()); - for (FilePathId filePathId : filePathIds) - updateChangedPath(filePathId, symbolIndexerTask); + for (FilePathId dependentSourcePathId : dependentSourcePathIds) + updateChangedPath(dependentSourcePathId, symbolIndexerTask); m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask)); m_symbolIndexerTaskQueue.processEntries(); @@ -155,35 +176,54 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId, optionalArtefact = m_projectPartsStorage.fetchProjectPartArtefact(filePathId); if (!optionalArtefact) return; - - const Utils::optional<ProjectPartPch> optionalProjectPartPch - = m_precompiledHeaderStorage.fetchPrecompiledHeader(optionalArtefact->projectPartId); transaction.commit(); - const ProjectPartArtefact &artefact = *optionalArtefact; + ProjectPartId projectPartId = optionalArtefact->projectPartId; - auto pchPath = optionalProjectPartPch ? optionalProjectPartPch->pchPath : FilePath{}; + SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps(filePathId); - CommandLineBuilder<ProjectPartArtefact, Utils::SmallStringVector> - builder{artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath}; + auto indexing = [optionalArtefact = std::move(optionalArtefact), + filePathId, + preIncludeSearchPath = m_environment.preIncludeSearchPath(), + this](SymbolsCollectorInterface &symbolsCollector) { + auto collect = [&](const FilePath &pchPath) { + const ProjectPartArtefact &artefact = *optionalArtefact; - auto indexing = [arguments = builder.commandLine, filePathId, this]( - SymbolsCollectorInterface &symbolsCollector) { - symbolsCollector.setFile(filePathId, arguments); + using Builder = CommandLineBuilder<ProjectPartArtefact, Utils::SmallStringVector>; + Builder builder{artefact, + artefact.toolChainArguments, + InputFileType::Source, + {}, + {}, + pchPath, + preIncludeSearchPath}; - bool success = symbolsCollector.collectSymbols(); + symbolsCollector.setFile(filePathId, builder.commandLine); - if (success) { - Sqlite::ImmediateTransaction transaction{m_transactionInterface}; + return symbolsCollector.collectSymbols(); + }; + auto store = [&] { + Sqlite::ImmediateTransaction transaction{m_transactionInterface}; + m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses()); m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(), symbolsCollector.sourceLocations()); - transaction.commit(); + }; + + const PchPaths pchPaths = m_precompiledHeaderStorage.fetchPrecompiledHeaders( + optionalArtefact->projectPartId); + + if (pchPaths.projectPchPath.size() && collect(pchPaths.projectPchPath)) { + store(); + } else if (pchPaths.systemPchPath.size() && collect(pchPaths.systemPchPath)) { + store(); + } else if (collect({})) { + store(); } }; - symbolIndexerTask.emplace_back(filePathId, optionalArtefact->projectPartId, std::move(indexing)); + symbolIndexerTask.emplace_back(filePathId, projectPartId, std::move(indexing)); } bool SymbolIndexer::compilerMacrosOrIncludeSearchPathsAreDifferent( diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.h b/src/tools/clangrefactoringbackend/source/symbolindexer.h index c398c0f2bf..64b442bf33 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.h +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.h @@ -32,6 +32,7 @@ #include "clangpathwatcher.h" #include <filecontainerv2.h> +#include <modifiedtimecheckerinterface.h> #include <precompiledheaderstorageinterface.h> #include <projectpartcontainer.h> #include <projectpartsstorageinterface.h> @@ -39,6 +40,7 @@ namespace ClangBackEnd { class SymbolsCollectorInterface; +class Environment; class SymbolIndexer final : public ClangPathWatcherNotifier { @@ -51,7 +53,9 @@ public: FilePathCachingInterface &filePathCache, FileStatusCache &fileStatusCache, Sqlite::TransactionInterface &transactionInterface, - ProjectPartsStorageInterface &projectPartsStorage); + ProjectPartsStorageInterface &projectPartsStorage, + ModifiedTimeCheckerInterface<SourceTimeStamps> &modifiedTimeChecker, + const Environment &environment); void updateProjectParts(ProjectPartContainers &&projectParts); void updateProjectPart(ProjectPartContainer &&projectPart); @@ -81,6 +85,8 @@ private: FileStatusCache &m_fileStatusCache; Sqlite::TransactionInterface &m_transactionInterface; ProjectPartsStorageInterface &m_projectPartsStorage; + ModifiedTimeCheckerInterface<SourceTimeStamps> &m_modifiedTimeChecker; + const Environment &m_environment; }; } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h b/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h index 7ca3513284..1f15f2ffaa 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h +++ b/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h @@ -30,6 +30,7 @@ #include <filepathid.h> #include <progresscounter.h> +#include <sqlitedatabase.h> #include <taskschedulerinterface.h> #include <utils/algorithm.h> @@ -38,10 +39,6 @@ #include <functional> #include <vector> -namespace Sqlite { -class TransactionInterface; -} - namespace ClangBackEnd { class SymbolsCollectorInterface; @@ -53,9 +50,11 @@ public: using Task = SymbolIndexerTask::Callable; SymbolIndexerTaskQueue(TaskSchedulerInterface<Task> &symbolIndexerTaskScheduler, - ProgressCounter &progressCounter) - : m_symbolIndexerScheduler(symbolIndexerTaskScheduler), - m_progressCounter(progressCounter) + ProgressCounter &progressCounter, + Sqlite::DatabaseInterface &database) + : m_symbolIndexerScheduler(symbolIndexerTaskScheduler) + , m_progressCounter(progressCounter) + , m_database(database) {} void addOrUpdateTasks(std::vector<SymbolIndexerTask> &&tasks) @@ -94,12 +93,21 @@ public: void processEntries() { - uint taskCount = m_symbolIndexerScheduler.slotUsage().free; + auto slotUsage = m_symbolIndexerScheduler.slotUsage(); + uint taskCount = slotUsage.free; auto newEnd = std::prev(m_tasks.end(), std::min<int>(int(taskCount), int(m_tasks.size()))); m_symbolIndexerScheduler.addTasks({std::make_move_iterator(newEnd), std::make_move_iterator(m_tasks.end())}); m_tasks.erase(newEnd, m_tasks.end()); + + if (m_tasks.empty() && slotUsage.used == 0) { + try { + m_database.walCheckpointFull(); + } catch (Sqlite::Exception &exception) { + exception.printWarning(); + } + } } void syncTasks(); @@ -108,6 +116,7 @@ private: std::vector<SymbolIndexerTask> m_tasks; TaskSchedulerInterface<Task> &m_symbolIndexerScheduler; ProgressCounter &m_progressCounter; + Sqlite::DatabaseInterface &m_database; }; } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbolindexing.h b/src/tools/clangrefactoringbackend/source/symbolindexing.h index c942059bad..5c391503bf 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexing.h +++ b/src/tools/clangrefactoringbackend/source/symbolindexing.h @@ -38,13 +38,16 @@ #include <precompiledheaderstorage.h> #include <projectpartsstorage.h> -#include <refactoringdatabaseinitializer.h> #include <filepathcachingfwd.h> +#include <modifiedtimechecker.h> +#include <refactoringdatabaseinitializer.h> #include <sqlitedatabase.h> #include <sqlitereadstatement.h> #include <sqlitewritestatement.h> +#include <QDateTime> +#include <QFileInfo> #include <QFileSystemWatcher> #include <thread> @@ -82,7 +85,8 @@ public: SymbolIndexing(Sqlite::Database &database, FilePathCachingInterface &filePathCache, const GeneratedFiles &generatedFiles, - ProgressCounter::SetProgressCallback &&setProgressCallback) + ProgressCounter::SetProgressCallback &&setProgressCallback, + const Environment &environment) : m_filePathCache(filePathCache) , m_buildDependencyStorage(database) , m_precompiledHeaderStorage(database) @@ -90,6 +94,18 @@ public: , m_symbolStorage(database) , m_collectorManger(generatedFiles, database) , m_progressCounter(std::move(setProgressCallback)) + , m_indexer(m_indexerQueue, + m_symbolStorage, + m_buildDependencyStorage, + m_precompiledHeaderStorage, + m_sourceWatcher, + m_filePathCache, + m_fileStatusCache, + m_symbolStorage.database, + m_projectPartsStorage, + m_modifiedTimeChecker, + environment) + , m_indexerQueue(m_indexerScheduler, m_progressCounter, database) , m_indexerScheduler(m_collectorManger, m_indexerQueue, m_progressCounter, @@ -130,16 +146,14 @@ private: FileStatusCache m_fileStatusCache{m_filePathCache}; SymbolsCollectorManager m_collectorManger; ProgressCounter m_progressCounter; - SymbolIndexer m_indexer{m_indexerQueue, - m_symbolStorage, - m_buildDependencyStorage, - m_precompiledHeaderStorage, - m_sourceWatcher, - m_filePathCache, - m_fileStatusCache, - m_symbolStorage.database, - m_projectPartsStorage}; - SymbolIndexerTaskQueue m_indexerQueue{m_indexerScheduler, m_progressCounter}; + std::function<TimeStamp(FilePathView filePath)> getModifiedTime{ + [&](ClangBackEnd::FilePathView path) -> TimeStamp { + return QFileInfo(QString(path)).lastModified().toSecsSinceEpoch(); + }}; + ModifiedTimeChecker<ClangBackEnd::SourceTimeStamps> m_modifiedTimeChecker{getModifiedTime, + m_filePathCache}; + SymbolIndexer m_indexer; + SymbolIndexerTaskQueue m_indexerQueue; SymbolIndexerTaskScheduler m_indexerScheduler; }; diff --git a/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.cpp b/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.cpp index f8782b405b..eddcf683c7 100644 --- a/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.cpp +++ b/src/tools/clangrefactoringbackend/source/symbollocationfinderaction.cpp @@ -93,7 +93,7 @@ std::unique_ptr<clang::ASTConsumer> SymbolLocationFinderAction::newASTConsumer() consumer->setSourceLocations(&m_sourceLocations); - return std::move(consumer); + return consumer; } } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbolscollector.cpp b/src/tools/clangrefactoringbackend/source/symbolscollector.cpp index 188d6fd207..071837ac52 100644 --- a/src/tools/clangrefactoringbackend/source/symbolscollector.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolscollector.cpp @@ -32,10 +32,14 @@ namespace ClangBackEnd { SymbolsCollector::SymbolsCollector(Sqlite::Database &database) - : m_filePathCache(database), - m_indexDataConsumer(std::make_shared<IndexDataConsumer>(m_symbolEntries, m_sourceLocationEntries, m_filePathCache, m_sourcesManager)), - m_collectSymbolsAction(m_indexDataConsumer), - m_collectMacrosSourceFileCallbacks(m_symbolEntries, m_sourceLocationEntries, m_filePathCache, m_sourcesManager) + : m_filePathCache(database) + , m_indexDataConsumer(std::make_shared<IndexDataConsumer>(m_symbolEntries, + m_sourceLocationEntries, + m_fileStatuses, + m_filePathCache, + m_symbolSourcesManager, + m_macroSourcesManager)) + , m_collectSymbolsAction(m_indexDataConsumer) { } @@ -43,7 +47,6 @@ void SymbolsCollector::addFiles(const FilePathIds &filePathIds, const Utils::SmallStringVector &arguments) { m_clangTool.addFiles(m_filePathCache.filePaths(filePathIds), arguments); - m_collectMacrosSourceFileCallbacks.addSourceFiles(filePathIds); } void SymbolsCollector::setFile(FilePathId filePathId, const Utils::SmallStringVector &arguments) @@ -58,90 +61,73 @@ void SymbolsCollector::setUnsavedFiles(const V2::FileContainers &unsavedFiles) void SymbolsCollector::clear() { - m_indexDataConsumer->clear(); - m_collectMacrosSourceFileCallbacks.clear(); m_symbolEntries.clear(); m_sourceLocationEntries.clear(); + m_fileStatuses.clear(); m_clangTool = ClangTool(); } -template <typename Factory> -std::unique_ptr<clang::tooling::FrontendActionFactory> -newFrontendActionFactory(Factory *consumerFactory, - clang::tooling::SourceFileCallbacks *sourceFileCallbacks) +std::unique_ptr<clang::tooling::FrontendActionFactory> newFrontendActionFactory(CollectSymbolsAction *action) { class FrontendActionFactoryAdapter : public clang::tooling::FrontendActionFactory { public: - explicit FrontendActionFactoryAdapter(Factory *consumerFactory, - clang::tooling::SourceFileCallbacks *sourceFileCallbacks) - : m_consumerFactory(consumerFactory), - m_sourceFileCallbacks(sourceFileCallbacks) + explicit FrontendActionFactoryAdapter(CollectSymbolsAction *consumerFactory) + : m_action(consumerFactory) {} - clang::FrontendAction *create() override { - return new ConsumerFactoryAdaptor(m_consumerFactory, m_sourceFileCallbacks); - } + clang::FrontendAction *create() override { return new AdaptorAction(m_action); } private: - class ConsumerFactoryAdaptor : public clang::ASTFrontendAction { + class AdaptorAction : public clang::ASTFrontendAction + { public: - ConsumerFactoryAdaptor(Factory *consumerFactory, - clang::tooling::SourceFileCallbacks *sourceFileCallbacks) - : m_consumerFactory(consumerFactory), - m_sourceFileCallbacks(sourceFileCallbacks) + AdaptorAction(CollectSymbolsAction *action) + : m_action(action) {} - std::unique_ptr<clang::ASTConsumer> - CreateASTConsumer(clang::CompilerInstance &instance, StringRef inFile) override { - return m_consumerFactory->newASTConsumer(instance, inFile); + std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &instance, + llvm::StringRef inFile) override + { + return m_action->newASTConsumer(instance, inFile); } - protected: - bool BeginInvocation(clang::CompilerInstance &compilerInstance) override + bool BeginInvocation(clang::CompilerInstance &instance) override { - compilerInstance.getLangOpts().DelayedTemplateParsing = false; - compilerInstance.getPreprocessorOpts().AllowPCHWithCompilerErrors = true; - - return clang::ASTFrontendAction::BeginInvocation(compilerInstance); + return m_action->BeginInvocation(instance); } - - bool BeginSourceFileAction(clang::CompilerInstance &compilerInstance) override + bool BeginSourceFileAction(clang::CompilerInstance &instance) override { - compilerInstance.getPreprocessor().SetSuppressIncludeNotFoundError(true); - - if (!clang::ASTFrontendAction::BeginSourceFileAction(compilerInstance)) - return false; - if (m_sourceFileCallbacks) - return m_sourceFileCallbacks->handleBeginSource(compilerInstance); - return true; + return m_action->BeginSourceFileAction(instance); } - void EndSourceFileAction() override + bool PrepareToExecuteAction(clang::CompilerInstance &instance) override { - if (m_sourceFileCallbacks) - m_sourceFileCallbacks->handleEndSource(); - clang::ASTFrontendAction::EndSourceFileAction(); + return m_action->PrepareToExecuteAction(instance); } + void ExecuteAction() override { m_action->ExecuteAction(); } + void EndSourceFileAction() override { m_action->EndSourceFileAction(); } + + bool hasPCHSupport() const override { return m_action->hasPCHSupport(); } + bool hasASTFileSupport() const override { return m_action->hasASTFileSupport(); } + bool hasIRSupport() const override { return false; } + bool hasCodeCompletionSupport() const override { return false; } private: - Factory *m_consumerFactory; - clang::tooling::SourceFileCallbacks *m_sourceFileCallbacks; + CollectSymbolsAction *m_action; }; - Factory *m_consumerFactory; - clang::tooling::SourceFileCallbacks *m_sourceFileCallbacks; + CollectSymbolsAction *m_action; }; - return std::unique_ptr<clang::tooling::FrontendActionFactory>( - new FrontendActionFactoryAdapter(consumerFactory, sourceFileCallbacks)); + return std::unique_ptr<clang::tooling::FrontendActionFactory>( + new FrontendActionFactoryAdapter(action)); } bool SymbolsCollector::collectSymbols() { auto tool = m_clangTool.createTool(); - auto actionFactory = ClangBackEnd::newFrontendActionFactory(&m_collectSymbolsAction, - &m_collectMacrosSourceFileCallbacks); + auto actionFactory = ClangBackEnd::newFrontendActionFactory(&m_collectSymbolsAction); return tool.run(actionFactory.get()) != 1; } @@ -160,24 +146,9 @@ const SourceLocationEntries &SymbolsCollector::sourceLocations() const return m_sourceLocationEntries; } -const FilePathIds &SymbolsCollector::sourceFiles() const -{ - return m_collectMacrosSourceFileCallbacks.sourceFiles(); -} - -const UsedMacros &SymbolsCollector::usedMacros() const -{ - return m_collectMacrosSourceFileCallbacks.usedMacros(); -} - const FileStatuses &SymbolsCollector::fileStatuses() const { - return m_collectMacrosSourceFileCallbacks.fileStatuses(); -} - -const SourceDependencies &SymbolsCollector::sourceDependencies() const -{ - return m_collectMacrosSourceFileCallbacks.sourceDependencies(); + return m_fileStatuses; } bool SymbolsCollector::isUsed() const diff --git a/src/tools/clangrefactoringbackend/source/symbolscollector.h b/src/tools/clangrefactoringbackend/source/symbolscollector.h index b37647e969..cc7ca4396c 100644 --- a/src/tools/clangrefactoringbackend/source/symbolscollector.h +++ b/src/tools/clangrefactoringbackend/source/symbolscollector.h @@ -58,10 +58,7 @@ public: const SymbolEntries &symbols() const override; const SourceLocationEntries &sourceLocations() const override; - const FilePathIds &sourceFiles() const override; - const UsedMacros &usedMacros() const override; const FileStatuses &fileStatuses() const override; - const SourceDependencies &sourceDependencies() const override; bool isUsed() const override; void setIsUsed(bool isUsed) override; @@ -71,10 +68,11 @@ private: ClangTool m_clangTool; SymbolEntries m_symbolEntries; SourceLocationEntries m_sourceLocationEntries; + FileStatuses m_fileStatuses; std::shared_ptr<IndexDataConsumer> m_indexDataConsumer; CollectSymbolsAction m_collectSymbolsAction; - CollectMacrosSourceFileCallbacks m_collectMacrosSourceFileCallbacks; - SourcesManager m_sourcesManager; + SourcesManager m_symbolSourcesManager; + SourcesManager m_macroSourcesManager; bool m_isUsed = false; }; diff --git a/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h b/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h index 94b3142371..07b5de223c 100644 --- a/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h +++ b/src/tools/clangrefactoringbackend/source/symbolscollectorinterface.h @@ -48,10 +48,7 @@ public: virtual const SymbolEntries &symbols() const = 0; virtual const SourceLocationEntries &sourceLocations() const = 0; - virtual const FilePathIds &sourceFiles() const = 0; - virtual const UsedMacros &usedMacros() const = 0; virtual const FileStatuses &fileStatuses() const = 0; - virtual const SourceDependencies &sourceDependencies() const = 0; }; } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbolstorage.h b/src/tools/clangrefactoringbackend/source/symbolstorage.h index 9dffe48c96..3d7d4c9784 100644 --- a/src/tools/clangrefactoringbackend/source/symbolstorage.h +++ b/src/tools/clangrefactoringbackend/source/symbolstorage.h @@ -41,7 +41,7 @@ namespace ClangBackEnd { -template <typename DatabaseType> +template<typename DatabaseType = Sqlite::Database> class SymbolStorage final : public SymbolStorageInterface { using Database = DatabaseType; @@ -70,6 +70,93 @@ public: deleteNewLocationsTable(); } + void insertOrUpdateIndexingTimeStamps(const FilePathIds &filePathIds, TimeStamp indexingTimeStamp) override + { + try { + Sqlite::ImmediateTransaction transaction{database}; + + for (FilePathId filePathId : filePathIds) { + inserOrUpdateIndexingTimesStampStatement.write(filePathId.filePathId, + indexingTimeStamp.value); + } + + transaction.commit(); + } catch (const Sqlite::StatementIsBusy &) { + insertOrUpdateIndexingTimeStamps(filePathIds, indexingTimeStamp); + } + } + + void insertOrUpdateIndexingTimeStamps(const FileStatuses &fileStatuses) override + { + for (FileStatus fileStatus : fileStatuses) { + inserOrUpdateIndexingTimesStampStatement.write(fileStatus.filePathId.filePathId, + fileStatus.lastModified); + } + } + + SourceTimeStamps fetchIndexingTimeStamps() const override + { + try { + Sqlite::DeferredTransaction transaction{database}; + + auto timeStamps = fetchIndexingTimeStampsStatement.template values<SourceTimeStamp, 2>( + 1024); + + transaction.commit(); + + return timeStamps; + } catch (const Sqlite::StatementIsBusy &) { + return fetchIndexingTimeStamps(); + } + } + + SourceTimeStamps fetchIncludedIndexingTimeStamps(FilePathId sourcePathId) const override + { + try { + Sqlite::DeferredTransaction transaction{database}; + + auto timeStamps = fetchIncludedIndexingTimeStampsStatement + .template values<SourceTimeStamp, 2>(1024, sourcePathId.filePathId); + + transaction.commit(); + + return timeStamps; + } catch (const Sqlite::StatementIsBusy &) { + return fetchIncludedIndexingTimeStamps(sourcePathId); + } + } + + FilePathIds fetchDependentSourceIds(const FilePathIds &sourcePathIds) const override + { + try { + FilePathIds dependentSourceIds; + + Sqlite::DeferredTransaction transaction{database}; + + for (FilePathId sourcePathId : sourcePathIds) { + FilePathIds newDependentSourceIds; + newDependentSourceIds.reserve(dependentSourceIds.size() + 1024); + + auto newIds = fetchDependentSourceIdsStatement + .template values<FilePathId>(1024, sourcePathId.filePathId); + + std::set_union(dependentSourceIds.begin(), + dependentSourceIds.end(), + newIds.begin(), + newIds.end(), + std::back_inserter(newDependentSourceIds)); + + dependentSourceIds = std::move(newDependentSourceIds); + } + + transaction.commit(); + + return dependentSourceIds; + } catch (const Sqlite::StatementIsBusy &) { + return fetchDependentSourceIds(sourcePathIds); + } + } + void fillTemporarySymbolsTable(const SymbolEntries &symbolEntries) { WriteStatement &statement = insertSymbolsToNewSymbolsStatement; @@ -191,6 +278,25 @@ public: database}; WriteStatement deleteNewSymbolsTableStatement{"DELETE FROM newSymbols", database}; WriteStatement deleteNewLocationsTableStatement{"DELETE FROM newLocations", database}; + WriteStatement inserOrUpdateIndexingTimesStampStatement{ + "INSERT INTO fileStatuses(sourceId, indexingTimeStamp) VALUES (?001, ?002) ON " + "CONFLICT(sourceId) DO UPDATE SET indexingTimeStamp = ?002", + database}; + mutable ReadStatement fetchIncludedIndexingTimeStampsStatement{ + "WITH RECURSIVE collectedDependencies(sourceId) AS (VALUES(?) UNION SELECT " + "dependencySourceId FROM sourceDependencies, collectedDependencies WHERE " + "sourceDependencies.sourceId == collectedDependencies.sourceId) SELECT DISTINCT sourceId, " + "indexingTimeStamp FROM collectedDependencies NATURAL JOIN fileStatuses ORDER BY sourceId", + database}; + mutable ReadStatement fetchIndexingTimeStampsStatement{ + "SELECT sourceId, indexingTimeStamp FROM fileStatuses", database}; + mutable ReadStatement fetchDependentSourceIdsStatement{ + "WITH RECURSIVE collectedDependencies(sourceId) AS (VALUES(?) UNION SELECT " + "sourceDependencies.sourceId FROM sourceDependencies, collectedDependencies WHERE " + "sourceDependencies.dependencySourceId == collectedDependencies.sourceId) SELECT sourceId " + "FROM collectedDependencies WHERE sourceId NOT IN (SELECT dependencySourceId FROM " + "sourceDependencies) ORDER BY sourceId", + database}; }; } // namespace ClangBackEnd diff --git a/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h b/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h index 1d04c4d168..d3c8035e8c 100644 --- a/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h +++ b/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h @@ -28,6 +28,9 @@ #include "sourcelocationentry.h" #include "symbolentry.h" +#include <filestatus.h> +#include <sourceentry.h> + #include <compilermacro.h> #include <sqlitetransaction.h> @@ -45,6 +48,11 @@ public: virtual void addSymbolsAndSourceLocations(const SymbolEntries &symbolEntries, const SourceLocationEntries &sourceLocations) = 0; + virtual void insertOrUpdateIndexingTimeStamps(const FilePathIds &filePathIds, TimeStamp indexingTimeStamp) = 0; + virtual void insertOrUpdateIndexingTimeStamps(const FileStatuses &fileStatuses) = 0; + virtual SourceTimeStamps fetchIndexingTimeStamps() const = 0; + virtual SourceTimeStamps fetchIncludedIndexingTimeStamps(FilePathId sourcePathId) const = 0; + virtual FilePathIds fetchDependentSourceIds(const FilePathIds &sourcePathIds) const = 0; protected: ~SymbolStorageInterface() = default; diff --git a/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h b/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h index ff2142f40e..7b63cb223e 100644 --- a/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h +++ b/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h @@ -46,10 +46,10 @@ class SymbolsVisitorBase public: SymbolsVisitorBase(const FilePathCachingInterface &filePathCache, const clang::SourceManager *sourceManager, - SourcesManager &sourcesManager) - : m_filePathCache(filePathCache), - m_sourceManager(sourceManager), - m_sourcesManager(sourcesManager) + FilePathIds &filePathIndices) + : m_filePathCache(filePathCache) + , m_sourceManager(sourceManager) + , m_filePathIndices(filePathIndices) {} FilePathId filePathId(clang::SourceLocation sourceLocation) @@ -60,25 +60,6 @@ public: return filePathId(fileEntry); } - bool dependentFilesAreModified() - { - return m_sourcesManager.dependentFilesModified(); - } - - bool isAlreadyParsed(clang::FileID fileId) - { - const clang::FileEntry *fileEntry = m_sourceManager->getFileEntryForID(fileId); - if (!fileEntry) - return false; - return m_sourcesManager.alreadyParsed(filePathId(fileEntry), - fileEntry->getModificationTime()); - } - - bool alreadyParsed(clang::SourceLocation sourceLocation) - { - return isAlreadyParsed(m_sourceManager->getFileID(sourceLocation)); - } - FilePathId filePathId(const clang::FileEntry *fileEntry) { if (fileEntry) { @@ -156,22 +137,26 @@ public: return isSystem(m_sourceManager->getSLocEntry(fileId).getFile().getFileCharacteristic()); } + bool isInSystemHeader(clang::SourceLocation sourceLocation) const + { + return m_sourceManager->isInSystemHeader(sourceLocation); + } + static bool isSystem(clang::SrcMgr::CharacteristicKind kind) { return clang::SrcMgr::isSystem(kind); } - void clear() - { - m_filePathIndices.clear(); - } + const FilePathCachingInterface &filePathCache() const { return m_filePathCache; } + const clang::SourceManager *sourceManager() const { return m_sourceManager; } protected: - std::vector<FilePathId> m_filePathIndices; const FilePathCachingInterface &m_filePathCache; const clang::SourceManager *m_sourceManager = nullptr; - SourcesManager &m_sourcesManager; + +private: + FilePathIds &m_filePathIndices; }; } // namespace ClangBackend diff --git a/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp b/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp index 59aab237ec..ad69adae56 100644 --- a/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp +++ b/src/tools/cplusplus-ast2png/cplusplus-ast2png.cpp @@ -423,12 +423,11 @@ public: static const char *const pretty[] = {"warning", "error", "fatal"}; - QString str; - str.sprintf("%s:%d:%d: When parsing as %s: %s: ", fileName->chars(), line, column, + QString str = QString::asprintf("%s:%d:%d: When parsing as %s: %s: ", fileName->chars(), line, column, parseModeToString(m_parseMode).toUtf8().constData(), pretty[level]); m_errorString->append(str.toUtf8()); - str.vsprintf(format, ap); + str += QString::vasprintf(format, ap); m_errorString->append(str.toUtf8()); m_errorString->append('\n'); } diff --git a/src/tools/cplusplus-shared/utils.cpp b/src/tools/cplusplus-shared/utils.cpp index 48178d7cf9..1373d5f6f9 100644 --- a/src/tools/cplusplus-shared/utils.cpp +++ b/src/tools/cplusplus-shared/utils.cpp @@ -94,7 +94,7 @@ SystemPreprocessor::SystemPreprocessor(bool verbose) QMapIterator<QString, QString> i(m_knownCompilers); while (i.hasNext()) { i.next(); - const Utils::FileName executablePath + const Utils::FilePath executablePath = Utils::Environment::systemEnvironment().searchInPath(i.key()); if (!executablePath.isEmpty()) { m_compiler = i.key(); diff --git a/src/tools/iconlister/iconlister.cpp b/src/tools/iconlister/iconlister.cpp index 509214cc25..522cd1891b 100644 --- a/src/tools/iconlister/iconlister.cpp +++ b/src/tools/iconlister/iconlister.cpp @@ -327,6 +327,8 @@ void IconLister::addProjectExplorerIcons() ""}, {QIcon(":/projectexplorer/images/fileoverlay_h.png"), "fileoverlay_h.png", prefix, ""}, + {QIcon(":/projectexplorer/images/fileoverlay_py.png"), "fileoverlay_py.png", prefix, + ""}, {QIcon(":/projectexplorer/images/fileoverlay_unknown.png"), "fileoverlay_unknown.png", prefix, ""}, diff --git a/src/tools/icons/qtcreatoricons.svg b/src/tools/icons/qtcreatoricons.svg index 86fcbb48d0..cb6e4836af 100644 --- a/src/tools/icons/qtcreatoricons.svg +++ b/src/tools/icons/qtcreatoricons.svg @@ -14,7 +14,7 @@ height="600" id="svg2" version="1.1" - inkscape:version="0.92.1 r15371" + inkscape:version="0.92.4 5da689c313, 2019-01-14" sodipodi:docname="qtcreatoricons.svg"> <defs id="defs4"> @@ -561,19 +561,11 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="4" - inkscape:cx="407.31417" - inkscape:cy="170.08332" inkscape:document-units="px" - inkscape:current-layer="g4718" showgrid="true" showguides="true" inkscape:guide-bbox="true" - inkscape:window-width="2880" - inkscape:window-height="1503" - inkscape:window-x="-13" - inkscape:window-y="527" - inkscape:window-maximized="1" + inkscape:window-maximized="0" inkscape:snap-grids="true"> <inkscape:grid type="xygrid" @@ -612,7 +604,7 @@ inkscape:locked="false" /> <sodipodi:guide orientation="0,1" - position="0,80" + position="232,80" id="guide4545" inkscape:locked="false" /> <sodipodi:guide @@ -3453,6 +3445,207 @@ width="100%" height="100%" /> </g> + <g + transform="translate(128)" + id="src/libs/utils/images/settings"> + <use + transform="translate(1740,132)" + height="100%" + width="100%" + id="use4105" + xlink:href="#backgroundRect" + y="0" + x="0" /> + <circle + style="fill:none;stroke:#000000;stroke-width:1.75" + id="path4133" + cx="1732" + cy="576" + r="3.5" /> + <path + style="fill:#000000" + d="m 1733.25,579.5 -0.5,2.5 h -1.5 l -0.5,-2.5 z" + id="path4135" + inkscape:connector-curvature="0" + inkscape:transform-center-y="5.25" + sodipodi:nodetypes="ccccc" /> + <use + x="0" + y="0" + xlink:href="#path4135" + inkscape:transform-center-y="3.5355339" + id="use4137" + transform="rotate(45,1732,576)" + width="100%" + height="100%" + inkscape:transform-center-x="3.5355339" /> + <use + x="0" + y="0" + xlink:href="#path4135" + id="use4139" + transform="rotate(90,1732,576)" + width="100%" + height="100%" + inkscape:transform-center-x="5.25" /> + <use + x="0" + y="0" + xlink:href="#path4135" + inkscape:transform-center-y="-3.5355339" + id="use4141" + transform="rotate(135,1732,576)" + width="100%" + height="100%" + inkscape:transform-center-x="3.5355339" /> + <use + x="0" + y="0" + xlink:href="#path4135" + inkscape:transform-center-y="-5.25" + id="use4143" + transform="rotate(-180,1732,576)" + width="100%" + height="100%" /> + <use + x="0" + y="0" + xlink:href="#path4135" + inkscape:transform-center-y="-3.5355339" + id="use4145" + transform="rotate(-135,1732,576)" + width="100%" + height="100%" + inkscape:transform-center-x="-3.5355339" /> + <use + x="0" + y="0" + xlink:href="#path4135" + id="use4147" + transform="rotate(-90,1732,576)" + width="100%" + height="100%" + inkscape:transform-center-x="-5.25" /> + <use + x="0" + y="0" + xlink:href="#path4135" + inkscape:transform-center-y="3.5355339" + id="use4149" + transform="rotate(-45,1732,576)" + width="100%" + height="100%" + inkscape:transform-center-x="-3.5355339" /> + </g> + <g + style="display:inline" + transform="translate(144)" + id="src/plugins/languageclient/images/languageclient"> + <use + transform="translate(1740,132)" + height="100%" + width="100%" + id="use4105-8" + xlink:href="#backgroundRect" + y="0" + x="0" /> + <ellipse + style="fill:none;stroke:#000000" + id="path4643-3" + cx="1729" + cy="580.5" + rx="3.5" + ry="2" /> + <use + x="0" + y="0" + xlink:href="#path4643-3" + id="use4684-9" + width="100%" + height="100%" + transform="translate(0,-5)" /> + <rect + style="fill:#ffffff" + id="rect4670-9" + width="8" + height="2.5" + x="1725" + y="578" /> + <path + style="fill:none;stroke:#000000" + d="m 1725.5,575.5 v 5" + id="path4672-0" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> + <use + x="0" + y="0" + xlink:href="#path4672-0" + id="use4686-9" + transform="translate(7)" + width="100%" + height="100%" /> + <path + style="display:inline;fill:#000000" + d="m 1733,569 h 4 c 1,0 2,1 2,2 v 3 c 0,2.5 -1.5,2.5 -5.5,4 l 2,-2 h -2.5 c -1,0 -2,-1 -2,-2 v -3 c 0,-1 1,-2 2,-2 z" + id="path4639-0" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccccc" /> + <path + style="display:inline;fill:none;stroke:#ffffff" + d="m 1734.25,570.75 -1.75,1.75 1.75,1.75" + id="path4676-1" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccc" /> + <use + style="display:inline" + x="0" + y="0" + xlink:href="#path4676-1" + id="use4682-2" + transform="matrix(-1,0,0,1,3470,0)" + width="100%" + height="100%" /> + </g> + <g + style="display:inline" + transform="translate(160)" + id="src/libs/utils/images/toggleprogressdetails"> + <use + style="display:inline" + transform="translate(1740,132)" + height="100%" + width="100%" + id="use4105-8-8" + xlink:href="#backgroundRect" + y="0" + x="0" /> + <rect + style="display:inline;fill:#707070" + id="rect2566" + width="8" + height="2" + x="1726" + y="577" /> + <rect + style="display:inline;fill:none;stroke:#000000" + id="rect2564" + width="13" + height="3" + x="1725.5" + y="576.5" + ry="1" + rx="1" /> + <use + transform="matrix(1,0,0,-1,1529,1167)" + style="display:inline" + x="0" + y="0" + xlink:href="#expandarrow" + id="use2507" + width="100%" + height="100%" /> + </g> </g> <g inkscape:groupmode="layer" @@ -4963,7 +5156,7 @@ </g> <g style="display:inline" - id="src/plugins/autotest/images/sort" + id="src/libs/utils/images/sort_alphabetically" transform="translate(32,0)"> <rect y="568" @@ -6439,10 +6632,28 @@ <path sodipodi:nodetypes="cccc" inkscape:connector-curvature="0" - id="path4784-17" + id="expandarrow" d="m 210,595 -2.5,2.5 -2.5,-2.5 z" style="fill:#000000;fill-opacity:1;stroke:none" /> </g> + <g + id="src/libs/utils/images/pinned"> + <use + style="display:inline" + x="0" + y="0" + xlink:href="#backgroundRect" + id="use5933-0-2-3" + width="100%" + height="100%" + transform="translate(361,148)" /> + <path + sodipodi:nodetypes="ccccccccccccccc" + inkscape:connector-curvature="0" + id="path6750" + d="m 347,597.33936 0.60019,0.60645 3.49128,-3.49127 3.09695,3.09695 c 0.29088,-0.96173 0.20375,-2.0863 -0.1875,-3.07155 l 3.68179,-3.68179 0.55968,0.52841 0.75761,-0.75762 -4.51473,-4.51475 -0.80193,0.80194 0.53076,0.51509 -3.60205,3.60206 c -1.04768,-0.37523 -2.22553,-0.48941 -3.20237,-0.15625 l 3.0615,3.0615 z" + style="fill:#000000" /> + </g> </g> <g inkscape:groupmode="layer" @@ -8914,6 +9125,30 @@ </g> </g> <g + transform="translate(111)" + id="src/plugins/projectexplorer/images/fileoverlay_py"> + <use + x="0" + y="0" + xlink:href="#transparentBackgroundRect" + id="use2479" + width="100%" + height="100%" + transform="translate(113,68)" /> + <path + style="opacity:0.75;fill:#ffffff" + d="m 104,535.99991 c 0.5,-9e-5 1,-0.49991 1,-0.99991 v -1 c 1,0 1.58286,0 2.58286,0 -0.5,0.5 -0.2217,1 0.0332,1.22379 L 108.50001,536 h 0.74644 c 0.27171,0 0.55533,-0.30177 0.75356,-0.5 l 2.24999,-2.25 c 0.25054,-0.25054 0.75001,-0.85547 0.75001,-1.41406 V 530 c 0,-0.5 -0.5,-1 -1,-1 0,0 -8.49999,0 -9,0 -0.50001,0 -1,0.5 -1,1 v 5 c 0,0.5 0.49999,1 0.99999,1 0.5,0 0.5,0 1,-9e-5 z" + id="path5194-1" + inkscape:connector-curvature="0" + sodipodi:nodetypes="zsccscscssszzsszz" /> + <path + sodipodi:nodetypes="cccccccccccc" + inkscape:connector-curvature="0" + d="m 103.49859,532.5 v -2 c 1.02427,-0.0193 2.92783,-0.45188 3,1 0.0722,1.45188 -2,1 -3,1 z M 111.5,530 v 1.73815 c -0.36757,0.7971 -1.47164,1.64275 -3,3.26185 m 0,-5 v 1.97707 c 0.22805,0.82162 1.35083,0.8693 2,1.52293 m -7,-3.5 v 5" + style="fill:none;stroke:#1986a0;stroke-opacity:1" + id="path5210-3" /> + </g> + <g id="src/libs/utils/images/filesave"> <rect style="display:inline;fill:#ffffff;fill-opacity:1" diff --git a/src/tools/iostool/CMakeLists.txt b/src/tools/iostool/CMakeLists.txt new file mode 100644 index 0000000000..d8bd23fe3f --- /dev/null +++ b/src/tools/iostool/CMakeLists.txt @@ -0,0 +1,24 @@ +add_qtc_executable(iostool + DESTINATION ${IDE_LIBEXEC_PATH}/ios + DEPENDS + Qt5::Gui + Qt5::Xml + Qt5::Network + ${FWCoreFoundation} + ${FWCoreServices} + ${FWIOKit} + ${FWSecurity} + ${FWSystemConfiguration} + SOURCES + Info.plist + main.cpp + iosdevicemanager.cpp iosdevicemanager.h +) + +if (TARGET iostool) + if (CMAKE_VERSION VERSION_LESS 3.13) + target_link_libraries(iostool "-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") + else() + target_link_options(iostool PRIVATE "-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") + endif() +endif() diff --git a/src/tools/iostool/main.cpp b/src/tools/iostool/main.cpp index e99fe0dcb5..f62c0c6180 100644 --- a/src/tools/iostool/main.cpp +++ b/src/tools/iostool/main.cpp @@ -227,7 +227,7 @@ void Relayer::setClientSocket(QTcpSocket *clientSocket) m_clientSocket = clientSocket; if (m_clientSocket) { connect(m_clientSocket, - static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error), + QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &Relayer::handleClientHasError); connect(m_clientSocket, &QAbstractSocket::disconnected, this, [this](){server()->removeRelayConnection(this);}); diff --git a/src/tools/perfparser b/src/tools/perfparser -Subproject 25ddba75f0767ef1150c3896fde5c50bc65147c +Subproject 02b36dd2c5fe4d1cf2970bc396fa665b199463d diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt new file mode 100644 index 0000000000..8eda7bf132 --- /dev/null +++ b/src/tools/qml2puppet/CMakeLists.txt @@ -0,0 +1,136 @@ +set(SRCDIR "${CMAKE_SOURCE_DIR}/share/qtcreator/qml/qmlpuppet") + +set(DESTDIR "${IDE_LIBEXEC_PATH}") +if (APPLE) + string(APPEND DESTDIR "/qmldesigner") +endif() + +add_qtc_executable(qml2puppet + DEPENDS + Qt5::CorePrivate Qt5::Widgets Qt5::QmlPrivate + Qt5::QuickPrivate Qt5::Network Qt5::GuiPrivate + SOURCES + "${SRCDIR}/qml2puppet/qml2puppetmain.cpp" + "${SRCDIR}/qmlpuppet.qrc" + DESTINATION ${DESTDIR} +) + +extend_qtc_executable(qml2puppet + SOURCES_PREFIX "${SRCDIR}/commands" + SOURCES + changeauxiliarycommand.cpp changeauxiliarycommand.h + changebindingscommand.cpp changebindingscommand.h + changefileurlcommand.cpp changefileurlcommand.h + changeidscommand.cpp changeidscommand.h + changenodesourcecommand.cpp changenodesourcecommand.h + changestatecommand.cpp changestatecommand.h + changevaluescommand.cpp changevaluescommand.h + childrenchangedcommand.cpp childrenchangedcommand.h + clearscenecommand.cpp clearscenecommand.h + completecomponentcommand.cpp completecomponentcommand.h + componentcompletedcommand.cpp componentcompletedcommand.h + createinstancescommand.cpp createinstancescommand.h + createscenecommand.cpp createscenecommand.h + debugoutputcommand.cpp debugoutputcommand.h + endpuppetcommand.cpp endpuppetcommand.h + informationchangedcommand.cpp informationchangedcommand.h + pixmapchangedcommand.cpp pixmapchangedcommand.h + puppetalivecommand.cpp puppetalivecommand.h + removeinstancescommand.cpp removeinstancescommand.h + removepropertiescommand.cpp removepropertiescommand.h + removesharedmemorycommand.cpp removesharedmemorycommand.h + reparentinstancescommand.cpp reparentinstancescommand.h + statepreviewimagechangedcommand.cpp statepreviewimagechangedcommand.h + synchronizecommand.cpp synchronizecommand.h + tokencommand.cpp tokencommand.h + valueschangedcommand.cpp +) + +extend_qtc_executable(qml2puppet + SOURCES_PREFIX "${SRCDIR}/container" + SOURCES + addimportcontainer.cpp addimportcontainer.h + idcontainer.cpp idcontainer.h + imagecontainer.cpp imagecontainer.h + informationcontainer.cpp informationcontainer.h + instancecontainer.cpp instancecontainer.h + mockuptypecontainer.cpp mockuptypecontainer.h + propertyabstractcontainer.cpp propertyabstractcontainer.h + propertybindingcontainer.cpp propertybindingcontainer.h + propertyvaluecontainer.cpp propertyvaluecontainer.h + reparentcontainer.cpp reparentcontainer.h + sharedmemory.h +) + +extend_qtc_executable(qml2puppet + CONDITION UNIX + SOURCES_PREFIX "${SRCDIR}/container" + SOURCES + sharedmemory_unix.cpp +) +extend_qtc_executable(qml2puppet + CONDITION UNIX AND (NOT APPLE) + DEPENDS rt +) +extend_qtc_executable(qml2puppet + CONDITION NOT UNIX + SOURCES_PREFIX "${SRCDIR}/container" + SOURCES + sharedmemory_qt.cpp +) + +extend_qtc_executable(qml2puppet + SOURCES_PREFIX "${SRCDIR}/instances" + SOURCES + nodeinstanceclientproxy.cpp nodeinstanceclientproxy.h +) + +extend_qtc_executable(qml2puppet + SOURCES_PREFIX "${SRCDIR}/interfaces" + SOURCES + commondefines.h + nodeinstanceclientinterface.h + nodeinstanceglobal.h + nodeinstanceserverinterface.cpp nodeinstanceserverinterface.h +) + +extend_qtc_executable(qml2puppet + SOURCES_PREFIX "${SRCDIR}/qml2puppet/instances" + SOURCES + anchorchangesnodeinstance.cpp anchorchangesnodeinstance.h + behaviornodeinstance.cpp behaviornodeinstance.h + childrenchangeeventfilter.cpp childrenchangeeventfilter.h + componentnodeinstance.cpp componentnodeinstance.h + dummycontextobject.cpp dummycontextobject.h + dummynodeinstance.cpp dummynodeinstance.h + layoutnodeinstance.cpp layoutnodeinstance.h + nodeinstanceserver.cpp nodeinstanceserver.h + nodeinstancesignalspy.cpp nodeinstancesignalspy.h + objectnodeinstance.cpp objectnodeinstance.h + positionernodeinstance.cpp positionernodeinstance.h + qmlpropertychangesnodeinstance.cpp qmlpropertychangesnodeinstance.h + qmlstatenodeinstance.cpp qmlstatenodeinstance.h + qmltransitionnodeinstance.cpp qmltransitionnodeinstance.h + qt3dpresentationnodeinstance.cpp qt3dpresentationnodeinstance.h + qt5informationnodeinstanceserver.cpp qt5informationnodeinstanceserver.h + qt5nodeinstanceclientproxy.cpp qt5nodeinstanceclientproxy.h + qt5nodeinstanceserver.cpp qt5nodeinstanceserver.h + qt5previewnodeinstanceserver.cpp qt5previewnodeinstanceserver.h + qt5rendernodeinstanceserver.cpp qt5rendernodeinstanceserver.h + qt5testnodeinstanceserver.cpp qt5testnodeinstanceserver.h + quickitemnodeinstance.cpp quickitemnodeinstance.h + servernodeinstance.cpp servernodeinstance.h +) + +extend_qtc_executable(qml2puppet + SOURCES_PREFIX "${SRCDIR}/types" + SOURCES + enumeration.cpp enumeration.h +) + +extend_qtc_executable(qml2puppet + SOURCES_PREFIX "${SRCDIR}/qmlprivategate" + SOURCES + designersupportdelegate.h + qmlprivategate_56.cpp qmlprivategate.h +) diff --git a/src/tools/qtcdebugger/CMakeLists.txt b/src/tools/qtcdebugger/CMakeLists.txt new file mode 100644 index 0000000000..22b1ca8e2d --- /dev/null +++ b/src/tools/qtcdebugger/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# Copyright (C) YourCompany. All rights reserved. +# +# GENERATED BY CPP-DEPENDENCIES - do not edit, your changes will be lost +# If you must edit, remove these two lines to avoid regeneration + +project(src.tools.qtcdebugger) + + +add_library(${PROJECT_NAME} STATIC + main.cpp +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + src +) + diff --git a/src/tools/qtcdebugger/main.cpp b/src/tools/qtcdebugger/main.cpp index 38507c8539..6beda7c1ec 100644 --- a/src/tools/qtcdebugger/main.cpp +++ b/src/tools/qtcdebugger/main.cpp @@ -419,6 +419,15 @@ static bool registerDebuggerKey(const WCHAR *key, do { if (!openRegistryKey(HKEY_LOCAL_MACHINE, key, true, &handle, access, errorMessage)) break; + + // Make sure to automatically open the qtcdebugger dialog on a crash + QString autoVal; + registryReadStringKey(handle, autoRegistryValueNameC, &autoVal, errorMessage); + if (autoVal != "1") { + if (!registryWriteStringKey(handle, autoRegistryValueNameC, "1", errorMessage)) + break; + } + // Save old key, which might be missing QString oldDebugger; if (isRegistered(handle, call, errorMessage, &oldDebugger)) { diff --git a/src/tools/qtcrashhandler/CMakeLists.txt b/src/tools/qtcrashhandler/CMakeLists.txt new file mode 100644 index 0000000000..7868ec305d --- /dev/null +++ b/src/tools/qtcrashhandler/CMakeLists.txt @@ -0,0 +1,7 @@ +# +# Copyright (C) YourCompany. All rights reserved. +# +# GENERATED BY CPP-DEPENDENCIES - do not edit, your changes will be lost +# If you must edit, remove these two lines to avoid regeneration + + diff --git a/src/tools/qtcreatorcrashhandler/CMakeLists.txt b/src/tools/qtcreatorcrashhandler/CMakeLists.txt new file mode 100644 index 0000000000..74dfd2199f --- /dev/null +++ b/src/tools/qtcreatorcrashhandler/CMakeLists.txt @@ -0,0 +1,11 @@ +if (LINUX) # Debug build only! + add_qtc_executable(qtcreatorcrashhandler + DEPENDS Utils Qt5::Widgets + SOURCES + backtracecollector.cpp backtracecollector.h + crashhandler.cpp crashhandler.h + crashhandlerdialog.cpp crashhandlerdialog.h crashhandlerdialog.ui + main.cpp + utils.cpp utils.h + ) +endif() diff --git a/src/tools/qtcreatorcrashhandler/backtracecollector.cpp b/src/tools/qtcreatorcrashhandler/backtracecollector.cpp index f4c49ba919..b3bc1939f7 100644 --- a/src/tools/qtcreatorcrashhandler/backtracecollector.cpp +++ b/src/tools/qtcreatorcrashhandler/backtracecollector.cpp @@ -49,10 +49,10 @@ public: BacktraceCollector::BacktraceCollector(QObject *parent) : QObject(parent), d(new BacktraceCollectorPrivate) { - connect(&d->debugger, - static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), + connect(&d->debugger, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &BacktraceCollector::onDebuggerFinished); - connect(&d->debugger, &QProcess::errorOccurred, this, &BacktraceCollector::onDebuggerError); + connect(&d->debugger, &QProcess::errorOccurred, + this, &BacktraceCollector::onDebuggerError); connect(&d->debugger, &QIODevice::readyRead, this, &BacktraceCollector::onDebuggerOutputAvailable); d->debugger.setProcessChannelMode(QProcess::MergedChannels); diff --git a/src/tools/qtcreatorcrashhandler/crashhandler.cpp b/src/tools/qtcreatorcrashhandler/crashhandler.cpp index c6df3c9ad9..89ff098420 100644 --- a/src/tools/qtcreatorcrashhandler/crashhandler.cpp +++ b/src/tools/qtcreatorcrashhandler/crashhandler.cpp @@ -94,7 +94,7 @@ public: dialog(crashHandler, signalName, appName) {} const pid_t pid; - const Utils::FileName creatorInPath; // Backup debugger. + const Utils::FilePath creatorInPath; // Backup debugger. BacktraceCollector backtraceCollector; CrashHandlerDialog dialog; diff --git a/src/tools/qtcreatorwidgets/CMakeLists.txt b/src/tools/qtcreatorwidgets/CMakeLists.txt new file mode 100644 index 0000000000..80fd46c824 --- /dev/null +++ b/src/tools/qtcreatorwidgets/CMakeLists.txt @@ -0,0 +1,20 @@ +# +# Copyright (C) YourCompany. All rights reserved. +# +# GENERATED BY CPP-DEPENDENCIES - do not edit, your changes will be lost +# If you must edit, remove these two lines to avoid regeneration + +project(src.tools.qtcreatorwidgets) + + +add_library(${PROJECT_NAME} STATIC + customwidget.h + customwidgets.cpp + customwidgets.h +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + src.libs.utils +) + diff --git a/src/tools/qtpromaker/CMakeLists.txt b/src/tools/qtpromaker/CMakeLists.txt new file mode 100644 index 0000000000..5c81cdcd6b --- /dev/null +++ b/src/tools/qtpromaker/CMakeLists.txt @@ -0,0 +1 @@ +add_qtc_executable(qtpromaker DEPENDS Qt5::Core SOURCES main.cpp) diff --git a/src/tools/screenshotcropper/CMakeLists.txt b/src/tools/screenshotcropper/CMakeLists.txt new file mode 100644 index 0000000000..c33a1311c8 --- /dev/null +++ b/src/tools/screenshotcropper/CMakeLists.txt @@ -0,0 +1,22 @@ +# +# Copyright (C) YourCompany. All rights reserved. +# +# GENERATED BY CPP-DEPENDENCIES - do not edit, your changes will be lost +# If you must edit, remove these two lines to avoid regeneration + +project(src.tools.screenshotcropper) + + +add_library(${PROJECT_NAME} STATIC + cropimageview.cpp + cropimageview.h + main.cpp + screenshotcropperwindow.cpp + screenshotcropperwindow.h +) + +target_link_libraries(${PROJECT_NAME} + PRIVATE + src.plugins.qtsupport +) + diff --git a/src/tools/sdktool/CMakeLists.txt b/src/tools/sdktool/CMakeLists.txt new file mode 100644 index 0000000000..3997c9763c --- /dev/null +++ b/src/tools/sdktool/CMakeLists.txt @@ -0,0 +1,59 @@ +get_target_property(UtilsSourcesDir Utils SOURCES_DIR) + +add_qtc_executable(sdktool + DEFINES DATA_PATH=\"${IDE_DATA_PATH}\" + DEPENDS Qt5::Core app_version + INCLUDES "${UtilsSourcesDir}/../" + SOURCES + addabiflavor.cpp addabiflavor.h + addcmakeoperation.cpp addcmakeoperation.h + adddebuggeroperation.cpp adddebuggeroperation.h + adddeviceoperation.cpp adddeviceoperation.h + addkeysoperation.cpp addkeysoperation.h + addkitoperation.cpp addkitoperation.h + addqtoperation.cpp addqtoperation.h + addtoolchainoperation.cpp addtoolchainoperation.h + findkeyoperation.cpp findkeyoperation.h + findvalueoperation.cpp findvalueoperation.h + getoperation.cpp getoperation.h + main.cpp + operation.cpp operation.h + rmcmakeoperation.cpp rmcmakeoperation.h + rmdebuggeroperation.cpp rmdebuggeroperation.h + rmdeviceoperation.cpp rmdeviceoperation.h + rmkeysoperation.cpp rmkeysoperation.h + rmkitoperation.cpp rmkitoperation.h + rmqtoperation.cpp rmqtoperation.h + rmtoolchainoperation.cpp rmtoolchainoperation.h + settings.cpp settings.h +) + +extend_qtc_target(sdktool + SOURCES_PREFIX "${UtilsSourcesDir}" + DEFINES QTCREATOR_UTILS_STATIC_LIB + SOURCES + environment.cpp environment.h + fileutils.cpp fileutils.h + hostosinfo.cpp hostosinfo.h + persistentsettings.cpp persistentsettings.h + qtcassert.cpp qtcassert.h + qtcprocess.cpp qtcprocess.h + savefile.cpp savefile.h + stringutils.cpp stringutils.h +) + +extend_qtc_target(sdktool CONDITION APPLE + SOURCES_PREFIX "${UtilsSourcesDir}" + SOURCES + fileutils_mac.mm fileutils_mac.h + DEPENDS + ${FWFoundation} +) + +extend_qtc_target(sdktool CONDITION WIN32 + DEPENDS + user32 iphlpapi ws2_32 shell32 + DEFINES + _UNICODE UNICODE + _CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS +) diff --git a/src/tools/sdktool/addcmakeoperation.cpp b/src/tools/sdktool/addcmakeoperation.cpp index 893b9c5b61..8a23fc42ca 100644 --- a/src/tools/sdktool/addcmakeoperation.cpp +++ b/src/tools/sdktool/addcmakeoperation.cpp @@ -157,7 +157,7 @@ bool AddCMakeOperation::test() const if (!unchanged.isEmpty()) return false; - // Make sure name stays unique: + // add 2nd cmake map = addCMake(map, "{some-cm-id}", "name", "/tmp/test", KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue"))); if (map.value(COUNT).toInt() != 2 @@ -175,7 +175,7 @@ bool AddCMakeOperation::test() const cmData = map.value(QString::fromLatin1(PREFIX) + '1').toMap(); if (cmData.count() != 5 || cmData.value(ID_KEY).toString() != "{some-cm-id}" - || cmData.value(DISPLAYNAME_KEY).toString() != "name2" + || cmData.value(DISPLAYNAME_KEY).toString() != "name" || cmData.value(AUTODETECTED_KEY).toBool() != true || cmData.value(PATH_KEY).toString() != "/tmp/test" || cmData.value("ExtraKey").toString() != "ExtraValue") diff --git a/src/tools/sdktool/addkitoperation.cpp b/src/tools/sdktool/addkitoperation.cpp index 0763c55e46..5eef6e7115 100644 --- a/src/tools/sdktool/addkitoperation.cpp +++ b/src/tools/sdktool/addkitoperation.cpp @@ -57,7 +57,7 @@ const char SDK[] = "PE.Profile.SDK"; const char ENV[] = "PE.Profile.Environment"; const char DATA[] = "PE.Profile.Data"; -// Standard KitInformation: +// Standard KitAspects: const char DEBUGGER[] = "Debugger.Information"; const char DEBUGGER_ENGINE[] = "EngineType"; const char DEBUGGER_BINARY[] = "Binary"; diff --git a/src/tools/sdktool/addqtoperation.cpp b/src/tools/sdktool/addqtoperation.cpp index 30ece83c65..3297eb8dbf 100644 --- a/src/tools/sdktool/addqtoperation.cpp +++ b/src/tools/sdktool/addqtoperation.cpp @@ -231,7 +231,7 @@ bool AddQtOperation::test() const if (!result.isEmpty()) return false; - // Make sure name is unique: + // add 2nd Qt version: map = addQt(map, QLatin1String("testId2"), QLatin1String("Test Qt Version"), QLatin1String("testType3"), QLatin1String("/tmp/test/qmake2"), KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue"))), @@ -251,7 +251,7 @@ bool AddQtOperation::test() const || !version1.contains(QLatin1String(ID)) || version1.value(QLatin1String(ID)).toInt() != -1 || !version1.contains(QLatin1String(DISPLAYNAME)) - || version1.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version2") + || version1.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version") || !version1.contains(QLatin1String(AUTODETECTED)) || version1.value(QLatin1String(AUTODETECTED)).toBool() != true || !version1.contains(QLatin1String(AUTODETECTION_SOURCE)) diff --git a/src/tools/sdktool/addtoolchainoperation.cpp b/src/tools/sdktool/addtoolchainoperation.cpp index 0f5359cff3..afcab9a5e2 100644 --- a/src/tools/sdktool/addtoolchainoperation.cpp +++ b/src/tools/sdktool/addtoolchainoperation.cpp @@ -199,7 +199,7 @@ bool AddToolChainOperation::test() const if (!unchanged.isEmpty()) return false; - // Make sure name stays unique: + // add 2nd tool chain: map = addToolChain(map, "{some-tc-id}", "langId2", "name", "/tmp/test", "test-abi", "test-abi,test-abi2", KeyValuePairList() << KeyValuePair("ExtraKey", QVariant("ExtraValue"))); if (map.value(COUNT).toInt() != 2 @@ -221,7 +221,7 @@ bool AddToolChainOperation::test() const if (tcData.count() != 8 || tcData.value(ID).toString() != "{some-tc-id}" || tcData.value(LANGUAGE_KEY_V2).toString() != "langId2" - || tcData.value(DISPLAYNAME).toString() != "name2" + || tcData.value(DISPLAYNAME).toString() != "name" || tcData.value(AUTODETECTED).toBool() != true || tcData.value(PATH).toString() != "/tmp/test" || tcData.value(TARGET_ABI).toString() != "test-abi" diff --git a/src/tools/sdktool/main.cpp b/src/tools/sdktool/main.cpp index 444752a5a4..808a2652fa 100644 --- a/src/tools/sdktool/main.cpp +++ b/src/tools/sdktool/main.cpp @@ -116,7 +116,7 @@ int parseArguments(const QStringList &args, Settings *s, // sdkpath if (current.startsWith(QLatin1String("--sdkpath="))) { - s->sdkPath = Utils::FileName::fromString(current.mid(10)); + s->sdkPath = Utils::FilePath::fromString(current.mid(10)); continue; } if (current == QLatin1String("-s")) { @@ -125,7 +125,7 @@ int parseArguments(const QStringList &args, Settings *s, printHelp(operations); return 1; } - s->sdkPath = Utils::FileName::fromString(next); + s->sdkPath = Utils::FilePath::fromString(next); ++i; // skip next; continue; } diff --git a/src/tools/sdktool/operation.cpp b/src/tools/sdktool/operation.cpp index 68bad3272d..a31e6ce271 100644 --- a/src/tools/sdktool/operation.cpp +++ b/src/tools/sdktool/operation.cpp @@ -87,7 +87,7 @@ QVariantMap Operation::load(const QString &file) QVariantMap map; // Read values from original file: - Utils::FileName path = Settings::instance()->getPath(file); + Utils::FilePath path = Settings::instance()->getPath(file); if (path.exists()) { Utils::PersistentSettingsReader reader; if (!reader.load(path)) @@ -100,14 +100,14 @@ QVariantMap Operation::load(const QString &file) bool Operation::save(const QVariantMap &map, const QString &file) const { - Utils::FileName path = Settings::instance()->getPath(file); + Utils::FilePath path = Settings::instance()->getPath(file); if (path.isEmpty()) { std::cerr << "Error: No path found for " << qPrintable(file) << "." << std::endl; return false; } - Utils::FileName dirName = path.parentDir(); + Utils::FilePath dirName = path.parentDir(); QDir dir(dirName.toString()); if (!dir.exists() && !dir.mkpath(QLatin1String("."))) { std::cerr << "Error: Could not create directory " << qPrintable(dirName.toString()) diff --git a/src/tools/sdktool/sdktool.pro b/src/tools/sdktool/sdktool.pro index 098897f1e2..9869d50dc4 100644 --- a/src/tools/sdktool/sdktool.pro +++ b/src/tools/sdktool/sdktool.pro @@ -30,11 +30,14 @@ SOURCES += \ rmqtoperation.cpp \ rmtoolchainoperation.cpp \ settings.cpp \ + $$UTILS/environment.cpp \ $$UTILS/fileutils.cpp \ $$UTILS/hostosinfo.cpp \ $$UTILS/persistentsettings.cpp \ $$UTILS/qtcassert.cpp \ + $$UTILS/qtcprocess.cpp \ $$UTILS/savefile.cpp \ + $$UTILS/stringutils.cpp HEADERS += \ addabiflavor.h \ @@ -57,10 +60,12 @@ HEADERS += \ rmqtoperation.h \ rmtoolchainoperation.h \ settings.h \ + $$UTILS/environment.h \ $$UTILS/fileutils.h \ $$UTILS/hostosinfo.h \ $$UTILS/persistentsettings.h \ $$UTILS/qtcassert.h \ + $$UTILS/qtcprocess.h \ $$UTILS/savefile.h \ macos { diff --git a/src/tools/sdktool/sdktool.qbs b/src/tools/sdktool/sdktool.qbs index 67b1d8e3c3..c26db6ad3f 100644 --- a/src/tools/sdktool/sdktool.qbs +++ b/src/tools/sdktool/sdktool.qbs @@ -66,11 +66,14 @@ QtcTool { name: "Utils" prefix: libsDir + "/utils/" files: [ + "environment.cpp", "environment.h", "fileutils.cpp", "fileutils.h", "hostosinfo.cpp", "hostosinfo.h", "persistentsettings.cpp", "persistentsettings.h", "qtcassert.cpp", "qtcassert.h", - "savefile.cpp", "savefile.h" + "qtcprocess.cpp", "qtcprocess.h", + "savefile.cpp", "savefile.h", + "stringutils.cpp" ] } Group { diff --git a/src/tools/sdktool/settings.cpp b/src/tools/sdktool/settings.cpp index e4c74cc19e..01f5120e16 100644 --- a/src/tools/sdktool/settings.cpp +++ b/src/tools/sdktool/settings.cpp @@ -47,30 +47,28 @@ Settings::Settings() : m_instance = this; // autodetect sdk dir: - sdkPath = Utils::FileName::fromString(QCoreApplication::applicationDirPath()); - sdkPath.appendPath(QLatin1String(DATA_PATH)); - sdkPath = Utils::FileName::fromString(QDir::cleanPath(sdkPath.toString())); - sdkPath.appendPath(QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR) - + '/' + Core::Constants::IDE_ID); + sdkPath = Utils::FilePath::fromString(QCoreApplication::applicationDirPath()) + .pathAppended(DATA_PATH); + sdkPath = Utils::FilePath::fromString(QDir::cleanPath(sdkPath.toString())) + .pathAppended(QLatin1String(Core::Constants::IDE_SETTINGSVARIANT_STR) + '/' + Core::Constants::IDE_ID); } -Utils::FileName Settings::getPath(const QString &file) +Utils::FilePath Settings::getPath(const QString &file) { - Utils::FileName result = sdkPath; + Utils::FilePath result = sdkPath; const QString lowerFile = file.toLower(); const QStringList identical = QStringList({ "android", "cmaketools", "debuggers", "devices", "profiles", "qtversions", "toolchains", "abi" }); if (lowerFile == "cmake") - result.appendPath("cmaketools"); + result = result.pathAppended("cmaketools"); else if (lowerFile == "kits") - result.appendPath("profiles"); + result = result.pathAppended("profiles"); else if (lowerFile == "qtversions") - result.appendPath("qtversion"); + result = result.pathAppended("qtversion"); else if (identical.contains(lowerFile)) - result.appendPath(lowerFile); + result = result.pathAppended(lowerFile); else - result.appendPath(file); // handle arbitrary file names not known yet - result.appendString(".xml"); - return result; + result = result.pathAppended(file); // handle arbitrary file names not known yet + return result.stringAppended(".xml"); } diff --git a/src/tools/sdktool/settings.h b/src/tools/sdktool/settings.h index dbf3481c26..b2804e9907 100644 --- a/src/tools/sdktool/settings.h +++ b/src/tools/sdktool/settings.h @@ -37,11 +37,11 @@ public: Settings(); static Settings *instance(); - Utils::FileName sdkPath; + Utils::FilePath sdkPath; Operation *operation; - Utils::FileName getPath(const QString &file); + Utils::FilePath getPath(const QString &file); private: static Settings *m_instance; diff --git a/src/tools/tools.pro b/src/tools/tools.pro index 61a8d07cc5..688ff570af 100644 --- a/src/tools/tools.pro +++ b/src/tools/tools.pro @@ -11,7 +11,8 @@ SUBDIRS = qtpromaker \ isEmpty(QTC_SKIP_SDKTOOL): SUBDIRS += sdktool -qtHaveModule(quick-private): SUBDIRS += qml2puppet +QTC_DO_NOT_BUILD_QMLDESIGNER = $$(QTC_DO_NOT_BUILD_QMLDESIGNER) +isEmpty(QTC_DO_NOT_BUILD_QMLDESIGNER):qtHaveModule(quick-private): SUBDIRS += qml2puppet win32 { SUBDIRS += qtcdebugger \ @@ -26,12 +27,10 @@ mac { SUBDIRS += clangbackend -QTC_ENABLE_CLANG_LIBTOOLING=$$(QTC_ENABLE_CLANG_LIBTOOLING) -!isEmpty(QTC_ENABLE_CLANG_LIBTOOLING) { +QTC_DISABLE_CLANG_REFACTORING=$$(QTC_DISABLE_CLANG_REFACTORING) +isEmpty(QTC_DISABLE_CLANG_REFACTORING) { SUBDIRS += clangrefactoringbackend SUBDIRS += clangpchmanagerbackend -} else { - warning("Not building the clang refactoring backend and the pch manager backend.") } isEmpty(BUILD_CPLUSPLUS_TOOLS):BUILD_CPLUSPLUS_TOOLS=$$(BUILD_CPLUSPLUS_TOOLS) @@ -80,7 +79,10 @@ exists(perfparser/perfparser.pro) { cache(PERFPARSER_APP_INSTALLDIR) } -OTHER_FILES += tools.qbs +OTHER_FILES += \ + tools.qbs \ + icons/exportapplicationicons.sh \ + icons/exportdocumenttypeicons.sh # delegate deployqt target deployqt.CONFIG += recursive diff --git a/src/tools/valgrindfake/CMakeLists.txt b/src/tools/valgrindfake/CMakeLists.txt new file mode 100644 index 0000000000..93944f3913 --- /dev/null +++ b/src/tools/valgrindfake/CMakeLists.txt @@ -0,0 +1,5 @@ +add_qtc_executable(valgrind-fake + DEPENDS Qt5::Network Qt5::Xml + SOURCES main.cpp outputgenerator.cpp outputgenerator.h +) + diff --git a/src/tools/wininterrupt/CMakeLists.txt b/src/tools/wininterrupt/CMakeLists.txt new file mode 100644 index 0000000000..704b417ff5 --- /dev/null +++ b/src/tools/wininterrupt/CMakeLists.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) YourCompany. All rights reserved. +# +# GENERATED BY CPP-DEPENDENCIES - do not edit, your changes will be lost +# If you must edit, remove these two lines to avoid regeneration + +project(src.tools.wininterrupt) + + +add_library(${PROJECT_NAME} INTERFACE +) + diff --git a/src/tools/winrtdebughelper/CMakeLists.txt b/src/tools/winrtdebughelper/CMakeLists.txt new file mode 100644 index 0000000000..0b19c9310c --- /dev/null +++ b/src/tools/winrtdebughelper/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (C) YourCompany. All rights reserved. +# +# GENERATED BY CPP-DEPENDENCIES - do not edit, your changes will be lost +# If you must edit, remove these two lines to avoid regeneration + +project(src.tools.winrtdebughelper) + + +add_library(${PROJECT_NAME} STATIC + winrtdebughelper.cpp +) + |