Clang: Reuse thread based pipeline for pch creation

The pch creation so far used signal and slots but there was no explicit
pipeline. This patch is introducing the same architecture like the
refactoring plugin. It is filtering out older project parts from the
pipeline.

Change-Id: Iaa6bd2ca1272231b97ebe1f5f7b2ce8e43bc590c
Task-number: QTCREATORBUG-21111
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-09-11 17:02:45 +02:00
parent a334650953
commit 4e6d09d8e1
74 changed files with 1502 additions and 1773 deletions

View File

@@ -12,10 +12,7 @@ HEADERS += \
$$PWD/pchmanagerconnectionclient.h \
$$PWD/clangpchmanager_global.h \
$$PWD/projectupdater.h \
$$PWD/pchmanagerprojectupdater.h \
$$PWD/precompiledheaderstorage.h \
$$PWD/precompiledheaderstorageinterface.h
$$PWD/pchmanagerprojectupdater.h
SOURCES += \
$$PWD/pchmanagerclient.cpp \
@@ -23,4 +20,3 @@ SOURCES += \
$$PWD/pchmanagerconnectionclient.cpp \
$$PWD/projectupdater.cpp \
$$PWD/pchmanagerprojectupdater.cpp

View File

@@ -27,7 +27,6 @@
#include "pchmanagerconnectionclient.h"
#include "pchmanagerclient.h"
#include "precompiledheaderstorage.h"
#include "qtcreatorprojectupdater.h"
#include <filepathcaching.h>
@@ -62,8 +61,7 @@ public:
Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}, 1000ms};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
PrecompiledHeaderStorage<> preCompiledHeaderStorage{database};
PchManagerClient pchManagerClient{preCompiledHeaderStorage};
PchManagerClient pchManagerClient;
PchManagerConnectionClient connectionClient{&pchManagerClient};
QtCreatorProjectUpdater<PchManagerProjectUpdater> projectUpdate{connectionClient.serverProxy(),
pchManagerClient,

View File

@@ -34,11 +34,6 @@
namespace ClangPchManager {
PchManagerClient::PchManagerClient(PrecompiledHeaderStorageInterface &precompiledHeaderStorage)
: m_precompiledHeaderStorage(precompiledHeaderStorage)
{
}
void PchManagerClient::alive()
{
if (m_connectionClient)
@@ -50,7 +45,6 @@ void PchManagerClient::precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeader
for (ClangBackEnd::ProjectPartPch &projectPartPch : message.takeProjectPartPchs()) {
const QString projectPartId{projectPartPch.projectPartId};
const QString pchPath{projectPartPch.pchPath};
addPchToDatabase(projectPartPch);
addProjectPartPch(std::move(projectPartPch));
precompiledHeaderUpdated(projectPartId, pchPath, projectPartPch.lastModified);
}
@@ -60,7 +54,6 @@ void PchManagerClient::precompiledHeaderRemoved(const QString &projectPartId)
{
for (auto notifier : m_notifiers) {
Utils::SmallString id(projectPartId);
removePchFromDatabase(id);
removeProjectPartPch(id);
notifier->precompiledHeaderRemoved(projectPartId);
}
@@ -117,18 +110,6 @@ void PchManagerClient::removeProjectPartPch(Utils::SmallStringView projectPartId
}
}
void PchManagerClient::addPchToDatabase(const ClangBackEnd::ProjectPartPch &projectPartPch)
{
m_precompiledHeaderStorage.insertPrecompiledHeader(projectPartPch.projectPartId,
projectPartPch.pchPath,
projectPartPch.lastModified);
}
void PchManagerClient::removePchFromDatabase(const Utils::SmallStringView &projectPartId)
{
m_precompiledHeaderStorage.deletePrecompiledHeader(projectPartId);
}
void PchManagerClient::addProjectPartPch(ClangBackEnd::ProjectPartPch &&projectPartPch)
{
auto found = std::lower_bound(m_projectPartPchs.begin(),

View File

@@ -26,7 +26,6 @@
#pragma once
#include "clangpchmanager_global.h"
#include "precompiledheaderstorageinterface.h"
#include <pchmanagerclientinterface.h>
#include <projectpartpchproviderinterface.h>
@@ -43,7 +42,7 @@ class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchMa
{
friend class PchManagerNotifierInterface;
public:
PchManagerClient(PrecompiledHeaderStorageInterface &precompiledHeaderStorage);
PchManagerClient() = default;
void alive() override;
void precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeadersUpdatedMessage &&message) override;
@@ -71,14 +70,10 @@ unittest_public:
void addProjectPartPch(ClangBackEnd::ProjectPartPch &&projectPartPch);
void removeProjectPartPch(Utils::SmallStringView projectPartId);
void addPchToDatabase(const ClangBackEnd::ProjectPartPch &projectPartPch);
void removePchFromDatabase(const Utils::SmallStringView &projectPartId);
private:
ClangBackEnd::ProjectPartPchs m_projectPartPchs;
std::vector<PchManagerNotifierInterface*> m_notifiers;
PchManagerConnectionClient *m_connectionClient=nullptr;
PrecompiledHeaderStorageInterface &m_precompiledHeaderStorage;
};
} // namespace ClangPchManager

View File

@@ -1,97 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 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 "precompiledheaderstorageinterface.h"
#include <sqlitetransaction.h>
#include <sqliteexception.h>
#include <utils/smallstringview.h>
namespace ClangPchManager {
template<typename Database=Sqlite::Database>
class PrecompiledHeaderStorage final : public PrecompiledHeaderStorageInterface
{
using ReadStatement = typename Database::ReadStatement;
using WriteStatement = typename Database::WriteStatement;
public:
PrecompiledHeaderStorage(Database &database)
: m_transaction(database),
m_database(database)
{
m_transaction.commit();
}
void insertPrecompiledHeader(Utils::SmallStringView projectPartName,
Utils::SmallStringView pchPath,
long long pchBuildTime) override
{
try {
Sqlite::ImmediateTransaction transaction{m_database};
m_insertProjectPartStatement.write(projectPartName);
m_insertPrecompiledHeaderStatement .write(projectPartName, pchPath, pchBuildTime);
transaction.commit();
} catch (const Sqlite::StatementIsBusy) {
insertPrecompiledHeader(projectPartName, pchPath, pchBuildTime);
}
}
void deletePrecompiledHeader(Utils::SmallStringView projectPartName) override
{
try {
Sqlite::ImmediateTransaction transaction{m_database};
m_deletePrecompiledHeaderStatement.write(projectPartName);
transaction.commit();
} catch (const Sqlite::StatementIsBusy) {
deletePrecompiledHeader(projectPartName);
}
}
public:
Sqlite::ImmediateNonThrowingDestructorTransaction m_transaction;
Database &m_database;
WriteStatement m_insertPrecompiledHeaderStatement {
"INSERT OR REPLACE INTO precompiledHeaders(projectPartId, pchPath, pchBuildTime) VALUES((SELECT projectPartId FROM projectParts WHERE projectPartName = ?),?,?)",
m_database
};
WriteStatement m_insertProjectPartStatement{
"INSERT OR IGNORE INTO projectParts(projectPartName) VALUES (?)",
m_database
};
WriteStatement m_deletePrecompiledHeaderStatement{
"DELETE FROM precompiledHeaders WHERE projectPartId = (SELECT projectPartId FROM projectParts WHERE projectPartName = ?)",
m_database
};
};
}

View File

@@ -1,50 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 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 <utils/smallstringview.h>
namespace ClangPchManager {
class PrecompiledHeaderStorageInterface
{
public:
PrecompiledHeaderStorageInterface() = default;
PrecompiledHeaderStorageInterface(const PrecompiledHeaderStorageInterface&) = delete;
PrecompiledHeaderStorageInterface &operator=(const PrecompiledHeaderStorageInterface&) = delete;
virtual void insertPrecompiledHeader(Utils::SmallStringView projectPartName,
Utils::SmallStringView pchPath,
long long pchBuildTime) = 0;
virtual void deletePrecompiledHeader(Utils::SmallStringView projectPartName) = 0;
protected:
~PrecompiledHeaderStorageInterface() = default;
};
} // namespace ClangPchManager

View File

@@ -72,9 +72,10 @@ void ProjectUpdater::updateProjectParts(const std::vector<CppTools::ProjectPart
void ProjectUpdater::removeProjectParts(const QStringList &projectPartIds)
{
ClangBackEnd::RemoveProjectPartsMessage message{Utils::SmallStringVector(projectPartIds)};
Utils::SmallStringVector sortedIds(projectPartIds);
std::sort(sortedIds.begin(), sortedIds.end());
m_server.removeProjectParts(std::move(message));
m_server.removeProjectParts(ClangBackEnd::RemoveProjectPartsMessage{std::move(sortedIds)});
}
void ProjectUpdater::updateGeneratedFiles(ClangBackEnd::V2::FileContainers &&generatedFiles)