forked from qt-creator/qt-creator
Clang: Add lastModified to the precompiled header
It is important to know then the PCH generation started, so we can compare the header file time stamps against it. Change-Id: Id8ee91e886c153d9d4a37cc0438c682f2098f7fa Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -30,8 +30,8 @@ namespace ClangBackEnd {
|
||||
QDebug operator<<(QDebug debug, const ProjectPartPch &projectPartPch)
|
||||
{
|
||||
debug.nospace() << "FileContainer("
|
||||
<< projectPartPch.id() << ", "
|
||||
<< projectPartPch.path() << ")";
|
||||
<< projectPartPch.projectPartId << ", "
|
||||
<< projectPartPch.pchPath << ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
@@ -35,33 +35,26 @@ class ProjectPartPch
|
||||
{
|
||||
public:
|
||||
ProjectPartPch() = default;
|
||||
ProjectPartPch(Utils::SmallString &&projectPartId, Utils::SmallString &&pchPath)
|
||||
: m_projectPartId(std::move(projectPartId)),
|
||||
m_pchPath(std::move(pchPath))
|
||||
ProjectPartPch(Utils::SmallString &&projectPartId,
|
||||
Utils::SmallString &&pchPath,
|
||||
long long lastModified)
|
||||
: projectPartId(std::move(projectPartId)),
|
||||
pchPath(std::move(pchPath)),
|
||||
lastModified(lastModified)
|
||||
{}
|
||||
|
||||
const Utils::SmallString &id() const
|
||||
{
|
||||
return m_projectPartId;
|
||||
}
|
||||
|
||||
const Utils::SmallString &path() const
|
||||
{
|
||||
return m_pchPath;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const ProjectPartPch &container)
|
||||
{
|
||||
out << container.m_projectPartId;
|
||||
out << container.m_pchPath;
|
||||
out << container.projectPartId;
|
||||
out << container.pchPath;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, ProjectPartPch &container)
|
||||
{
|
||||
in >> container.m_projectPartId;
|
||||
in >> container.m_pchPath;
|
||||
in >> container.projectPartId;
|
||||
in >> container.pchPath;
|
||||
|
||||
return in;
|
||||
}
|
||||
@@ -69,18 +62,19 @@ public:
|
||||
friend bool operator==(const ProjectPartPch &first,
|
||||
const ProjectPartPch &second)
|
||||
{
|
||||
return first.m_projectPartId == second.m_projectPartId
|
||||
&& first.m_pchPath == second.m_pchPath;
|
||||
return first.projectPartId == second.projectPartId
|
||||
&& first.pchPath == second.pchPath;
|
||||
}
|
||||
|
||||
ProjectPartPch clone() const
|
||||
{
|
||||
return ProjectPartPch(m_projectPartId.clone(), m_pchPath.clone());
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Utils::SmallString m_projectPartId;
|
||||
Utils::SmallString m_pchPath;
|
||||
public:
|
||||
Utils::SmallString projectPartId;
|
||||
Utils::SmallString pchPath;
|
||||
long long lastModified = -1;
|
||||
};
|
||||
|
||||
CLANGSUPPORT_EXPORT QDebug operator<<(QDebug debug, const ProjectPartPch &projectPartPch);
|
||||
|
||||
@@ -42,8 +42,11 @@ void PchManagerClient::alive()
|
||||
|
||||
void PchManagerClient::precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeadersUpdatedMessage &&message)
|
||||
{
|
||||
for (const ClangBackEnd::ProjectPartPch &projectPartPch : message.projectPartPchs())
|
||||
precompiledHeaderUpdated(QString(projectPartPch.id()), QString(projectPartPch.path()));
|
||||
for (const ClangBackEnd::ProjectPartPch &projectPartPch : message.projectPartPchs()) {
|
||||
precompiledHeaderUpdated(QString(projectPartPch.projectPartId),
|
||||
QString(projectPartPch.pchPath),
|
||||
projectPartPch.lastModified);
|
||||
}
|
||||
}
|
||||
|
||||
void PchManagerClient::precompiledHeaderRemoved(const QString &projectPartId)
|
||||
@@ -78,10 +81,12 @@ const std::vector<PchManagerNotifierInterface *> &PchManagerClient::notifiers()
|
||||
return m_notifiers;
|
||||
}
|
||||
|
||||
void PchManagerClient::precompiledHeaderUpdated(const QString &projectPartId, const QString &pchFilePath)
|
||||
void PchManagerClient::precompiledHeaderUpdated(const QString &projectPartId,
|
||||
const QString &pchFilePath,
|
||||
long long lastModified)
|
||||
{
|
||||
for (auto notifier : m_notifiers)
|
||||
notifier->precompiledHeaderUpdated(projectPartId, pchFilePath);
|
||||
notifier->precompiledHeaderUpdated(projectPartId, pchFilePath, lastModified);
|
||||
}
|
||||
|
||||
} // namespace ClangPchManager
|
||||
|
||||
@@ -47,7 +47,9 @@ public:
|
||||
|
||||
unittest_public:
|
||||
const std::vector<PchManagerNotifierInterface*> ¬ifiers() const;
|
||||
void precompiledHeaderUpdated(const QString &projectPartId, const QString &pchFilePath);
|
||||
void precompiledHeaderUpdated(const QString &projectPartId,
|
||||
const QString &pchFilePath,
|
||||
long long lastModified);
|
||||
|
||||
void attach(PchManagerNotifierInterface *notifier);
|
||||
void detach(PchManagerNotifierInterface *notifier);
|
||||
|
||||
@@ -40,7 +40,8 @@ public:
|
||||
|
||||
virtual ~PchManagerNotifierInterface();
|
||||
virtual void precompiledHeaderUpdated(const QString &projectPartId,
|
||||
const QString &pchFilePath) = 0;
|
||||
const QString &pchFilePath,
|
||||
long long lastModified) = 0;
|
||||
virtual void precompiledHeaderRemoved(const QString &projectPartId) = 0;
|
||||
|
||||
PchManagerClient &m_pchManagerClient;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <projectpartpch.h>
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
@@ -545,6 +546,7 @@ Utils::SmallStringVector PchCreator::generateProjectPartClangCompilerArguments(
|
||||
|
||||
IdPaths PchCreator::generateProjectPartPch(const V2::ProjectPartContainer &projectPart)
|
||||
{
|
||||
long long lastModified = QDateTime::currentSecsSinceEpoch();
|
||||
auto includes = generateProjectPartPchIncludes(projectPart);
|
||||
auto content = generatePchIncludeFileContent(includes);
|
||||
auto pchIncludeFilePath = generateProjectPathPchHeaderFilePath(projectPart);
|
||||
@@ -552,7 +554,7 @@ IdPaths PchCreator::generateProjectPartPch(const V2::ProjectPartContainer &proje
|
||||
generateFileWithContent(pchIncludeFilePath, content);
|
||||
|
||||
generatePch(generateProjectPartClangCompilerArguments(projectPart),
|
||||
{projectPart.projectPartId().clone(), std::move(pchFilePath)});
|
||||
{projectPart.projectPartId().clone(), std::move(pchFilePath), lastModified});
|
||||
|
||||
return {projectPart.projectPartId().clone(), std::move(includes)};
|
||||
}
|
||||
|
||||
@@ -592,8 +592,8 @@ std::ostream &operator<<(std::ostream &os, const ProjectPartContainer &container
|
||||
std::ostream &operator<<(std::ostream &out, const ProjectPartPch &projectPartPch)
|
||||
{
|
||||
out << "("
|
||||
<< projectPartPch.id() << ", "
|
||||
<< projectPartPch.path() << ")";
|
||||
<< projectPartPch.projectPartId << ", "
|
||||
<< projectPartPch.pchPath << ")";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public:
|
||||
: ClangPchManager::PchManagerNotifierInterface(pchManagerClient)
|
||||
{}
|
||||
|
||||
MOCK_METHOD2(precompiledHeaderUpdated,
|
||||
void (const QString &projectPartId, const QString &pchFilePath));
|
||||
MOCK_METHOD3(precompiledHeaderUpdated,
|
||||
void (const QString &projectPartId, const QString &pchFilePath, long long lastModified));
|
||||
MOCK_METHOD1(precompiledHeaderRemoved,
|
||||
void (const QString &projectPartId));
|
||||
};
|
||||
|
||||
@@ -312,10 +312,10 @@ TEST_F(PchCreatorVerySlowTest, ProjectPartPchsForCreatePchsForProjectParts)
|
||||
{
|
||||
EXPECT_CALL(mockPchGeneratorNotifier,
|
||||
taskFinished(ClangBackEnd::TaskFinishStatus::Successfully,
|
||||
Property(&ProjectPartPch::id, "project1")));
|
||||
Field(&ProjectPartPch::projectPartId, "project1")));
|
||||
EXPECT_CALL(mockPchGeneratorNotifier,
|
||||
taskFinished(ClangBackEnd::TaskFinishStatus::Successfully,
|
||||
Property(&ProjectPartPch::id, "project2")));
|
||||
Field(&ProjectPartPch::projectPartId, "project2")));
|
||||
|
||||
creator.generatePchs();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
NiceMock<MockPchGeneratorNotifier> mockNotifier;
|
||||
ClangBackEnd::PchGenerator<FakeProcess> generator{environment, &mockNotifier};
|
||||
Utils::SmallStringVector compilerArguments = {"-DXXXX", "-Ifoo"};
|
||||
ClangBackEnd::ProjectPartPch projectPartPch{"projectPartId", "/path/to/pch"};
|
||||
ClangBackEnd::ProjectPartPch projectPartPch{"projectPartId", "/path/to/pch", 1};
|
||||
};
|
||||
|
||||
TEST_F(PchGenerator, ProcessFinished)
|
||||
|
||||
@@ -57,7 +57,7 @@ protected:
|
||||
ClangPchManager::PchManagerProjectUpdater projectUpdater{mockPchManagerServer, client, filePathCache};
|
||||
Utils::SmallString projectPartId{"projectPartId"};
|
||||
Utils::SmallString pchFilePath{"/path/to/pch"};
|
||||
PrecompiledHeadersUpdatedMessage message{{{projectPartId.clone(), pchFilePath.clone()}}};
|
||||
PrecompiledHeadersUpdatedMessage message{{{projectPartId.clone(), pchFilePath.clone(), 1}}};
|
||||
};
|
||||
|
||||
TEST_F(PchManagerClient, NotifierAttached)
|
||||
@@ -81,7 +81,7 @@ TEST_F(PchManagerClient, NotifierDetached)
|
||||
|
||||
TEST_F(PchManagerClient, Update)
|
||||
{
|
||||
EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderUpdated(projectPartId.toQString(), pchFilePath.toQString()));
|
||||
EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderUpdated(projectPartId.toQString(), pchFilePath.toQString(), Eq(1)));
|
||||
|
||||
client.precompiledHeadersUpdated(message.clone());
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ TEST_F(PchManagerClientServerInProcess, SendRemovePchProjectPartsMessage)
|
||||
|
||||
TEST_F(PchManagerClientServerInProcess, SendPrecompiledHeaderUpdatedMessage)
|
||||
{
|
||||
PrecompiledHeadersUpdatedMessage message{{{"projectPartId", "/path/to/pch"}}};
|
||||
PrecompiledHeadersUpdatedMessage message{{{"projectPartId", "/path/to/pch", 1}}};
|
||||
|
||||
|
||||
EXPECT_CALL(mockPchManagerClient, precompiledHeadersUpdated(message));
|
||||
|
||||
@@ -84,8 +84,8 @@ protected:
|
||||
FileContainer generatedFile{{"/path/to/", "file"}, "content", {}};
|
||||
ClangBackEnd::UpdatePchProjectPartsMessage updatePchProjectPartsMessage{Utils::clone(projectParts),
|
||||
{generatedFile}};
|
||||
ClangBackEnd::ProjectPartPch projectPartPch1{projectPart1.projectPartId().clone(), "/path1/to/pch"};
|
||||
ClangBackEnd::ProjectPartPch projectPartPch2{projectPart2.projectPartId().clone(), "/path2/to/pch"};
|
||||
ClangBackEnd::ProjectPartPch projectPartPch1{projectPart1.projectPartId().clone(), "/path1/to/pch", 1};
|
||||
ClangBackEnd::ProjectPartPch projectPartPch2{projectPart2.projectPartId().clone(), "/path2/to/pch", 1};
|
||||
std::vector<ClangBackEnd::ProjectPartPch> projectPartPchs{projectPartPch1, projectPartPch2};
|
||||
ClangBackEnd::PrecompiledHeadersUpdatedMessage precompiledHeaderUpdatedMessage1{{projectPartPch1}};
|
||||
ClangBackEnd::PrecompiledHeadersUpdatedMessage precompiledHeaderUpdatedMessage2{{projectPartPch2}};
|
||||
|
||||
Reference in New Issue
Block a user