summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2018-10-25 11:08:39 +0200
committerMarco Bubke <marco.bubke@qt.io>2018-11-06 11:52:11 +0000
commitf644ea0a0165e1d967b5d4654b48143b4534d2b1 (patch)
treea0a2a89fbbeb0e54916951ee085c778fd45b5539 /src
parentace6708b88c4cf0c6bbba45b41de561ac6e4c52f (diff)
downloadqt-creator-f644ea0a0165e1d967b5d4654b48143b4534d2b1.tar.gz
ClangPchManager: Add BuildDependenciesProvider
It is still unfinished but I want to add other changes first. Change-Id: Ife7ac56576f85d800633ea1e8f1c3f4f16486d5f Task-number: QTCREATORBUG-21377 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/tools/clangpchmanagerbackend/source/builddependenciesgeneratorinterface.h43
-rw-r--r--src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp106
-rw-r--r--src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h61
-rw-r--r--src/tools/clangpchmanagerbackend/source/builddependenciesproviderinterface.h4
-rw-r--r--src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h55
-rw-r--r--src/tools/clangpchmanagerbackend/source/builddependency.h (renamed from src/tools/clangpchmanagerbackend/source/builddependencies.h)8
-rw-r--r--src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri10
-rw-r--r--src/tools/clangpchmanagerbackend/source/modifiedtimecheckerinterface.h46
-rw-r--r--src/tools/clangpchmanagerbackend/source/pchtask.h2
-rw-r--r--src/tools/clangpchmanagerbackend/source/sourceentry.h80
10 files changed, 406 insertions, 9 deletions
diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesgeneratorinterface.h b/src/tools/clangpchmanagerbackend/source/builddependenciesgeneratorinterface.h
new file mode 100644
index 0000000000..f3863d8027
--- /dev/null
+++ b/src/tools/clangpchmanagerbackend/source/builddependenciesgeneratorinterface.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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 "builddependency.h"
+
+#include "projectpartcontainerv2.h"
+
+namespace ClangBackEnd {
+
+class BuildDependenciesGeneratorInterface
+{
+public:
+ virtual BuildDependency create(const V2::ProjectPartContainer &projectPart) = 0;
+
+protected:
+ ~BuildDependenciesGeneratorInterface() = default;
+};
+
+} // namespace ClangBackEnd
diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp
new file mode 100644
index 0000000000..5044f9e294
--- /dev/null
+++ b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "builddependenciesprovider.h"
+
+#include "builddependenciesstorageinterface.h"
+#include "modifiedtimecheckerinterface.h"
+#include "builddependenciesgeneratorinterface.h"
+
+#include <algorithm>
+
+namespace ClangBackEnd {
+
+template<class OutputContainer,
+ class InputContainer1,
+ class InputContainer2>
+OutputContainer setUnion(InputContainer1 &&input1,
+ InputContainer2 &&input2)
+{
+ OutputContainer results;
+ results.reserve(input1.size() + input2.size());
+
+ std::set_union(std::begin(input1),
+ std::end(input1),
+ std::begin(input2),
+ std::end(input2),
+ std::back_inserter(results));
+
+ return results;
+}
+
+BuildDependency BuildDependenciesProvider::create(const V2::ProjectPartContainer &projectPart) const
+{
+ SourceEntries includes = createSourceEntriesFromStorage(projectPart.sourcePathIds);
+
+ if (!m_modifiedTimeChecker.isUpToDate(includes))
+ return m_buildDependenciesGenerator.create(projectPart);
+
+ return createBuildDependencyFromStorage(std::move(includes));
+
+}
+
+BuildDependency BuildDependenciesProvider::createBuildDependencyFromStorage(SourceEntries &&includes) const
+{
+ BuildDependency buildDependency;
+
+ buildDependency.usedMacros = createUsedMacrosFromStorage(includes);
+ buildDependency.includes = std::move(includes);
+
+ return buildDependency;
+}
+
+UsedMacros BuildDependenciesProvider::createUsedMacrosFromStorage(const SourceEntries &includes) const
+{
+ UsedMacros usedMacros;
+ usedMacros.reserve(1024);
+
+ for (const SourceEntry &entry : includes) {
+ UsedMacros macros = m_buildDependenciesStorage.fetchUsedMacros(entry.sourceId);
+ std::sort(macros.begin(), macros.end());
+ usedMacros.insert(usedMacros.end(),
+ std::make_move_iterator(macros.begin()),
+ std::make_move_iterator(macros.end()));
+ }
+
+ return usedMacros;
+}
+
+SourceEntries BuildDependenciesProvider::createSourceEntriesFromStorage(
+ const FilePathIds &sourcePathIds) const
+{
+ SourceEntries includes;
+
+ for (FilePathId sourcePathId : sourcePathIds) {
+ SourceEntries entries = m_buildDependenciesStorage.fetchDependSources(sourcePathId);
+ SourceEntries mergedEntries = setUnion<SourceEntries>(includes, entries);
+
+ includes = std::move(mergedEntries);
+ }
+
+ return includes;
+}
+
+} // namespace ClangBackEnd
diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h
new file mode 100644
index 0000000000..c9aab60de4
--- /dev/null
+++ b/src/tools/clangpchmanagerbackend/source/builddependenciesprovider.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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 "builddependenciesproviderinterface.h"
+
+namespace ClangBackEnd {
+
+class BuildDependenciesStorageInterface;
+class ModifiedTimeCheckerInterface;
+class BuildDependenciesGeneratorInterface;
+
+class BuildDependenciesProvider : public BuildDependenciesProviderInterface
+{
+public:
+ BuildDependenciesProvider(BuildDependenciesStorageInterface &buildDependenciesStorage,
+ ModifiedTimeCheckerInterface &modifiedTimeChecker,
+ BuildDependenciesGeneratorInterface &buildDependenciesGenerator)
+ : m_buildDependenciesStorage(buildDependenciesStorage),
+ m_modifiedTimeChecker(modifiedTimeChecker),
+ m_buildDependenciesGenerator(buildDependenciesGenerator)
+ {
+ }
+
+ BuildDependency create(const V2::ProjectPartContainer &projectPart) const override;
+
+private:
+ BuildDependency createBuildDependencyFromStorage(SourceEntries &&includes) const;
+ UsedMacros createUsedMacrosFromStorage(const SourceEntries &includes) const;
+ SourceEntries createSourceEntriesFromStorage(const FilePathIds &sourcePathIds) const;
+
+private:
+ BuildDependenciesStorageInterface &m_buildDependenciesStorage;
+ ModifiedTimeCheckerInterface &m_modifiedTimeChecker;
+ BuildDependenciesGeneratorInterface &m_buildDependenciesGenerator;
+};
+
+} // namespace ClangBackEnd
diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesproviderinterface.h b/src/tools/clangpchmanagerbackend/source/builddependenciesproviderinterface.h
index b02831a7ba..f596b83da9 100644
--- a/src/tools/clangpchmanagerbackend/source/builddependenciesproviderinterface.h
+++ b/src/tools/clangpchmanagerbackend/source/builddependenciesproviderinterface.h
@@ -25,7 +25,7 @@
#pragma once
-#include "builddependencies.h"
+#include "builddependency.h"
#include "projectpartcontainerv2.h"
@@ -34,7 +34,7 @@ namespace ClangBackEnd {
class BuildDependenciesProviderInterface
{
public:
- virtual BuildDependency create(const V2::ProjectPartContainer &projectPart) = 0;
+ virtual BuildDependency create(const V2::ProjectPartContainer &projectPart) const = 0;
protected:
~BuildDependenciesProviderInterface() = default;
diff --git a/src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h b/src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h
new file mode 100644
index 0000000000..265065b0d0
--- /dev/null
+++ b/src/tools/clangpchmanagerbackend/source/builddependenciesstorageinterface.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** 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 <builddependency.h>
+#include <filepathid.h>
+#include <filestatus.h>
+#include <sourcedependency.h>
+#include <usedmacro.h>
+
+namespace ClangBackEnd {
+
+class BuildDependenciesStorageInterface
+{
+public:
+ BuildDependenciesStorageInterface() = default;
+ BuildDependenciesStorageInterface(const BuildDependenciesStorageInterface &) = delete;
+ BuildDependenciesStorageInterface &operator=(const BuildDependenciesStorageInterface &) = delete;
+
+ virtual void updateSources(const SourceEntries &sourceIds) = 0;
+ virtual void insertOrUpdateUsedMacros(const UsedMacros &usedMacros) = 0;
+ virtual void insertFileStatuses(const FileStatuses &fileStatuses) = 0;
+ virtual void insertOrUpdateSourceDependencies(const SourceDependencies &sourceDependencies) = 0;
+ virtual long long fetchLowestLastModifiedTime(FilePathId sourceId) const = 0;
+ virtual SourceEntries fetchDependSources(FilePathId sourceId) const = 0;
+ virtual UsedMacros fetchUsedMacros(FilePathId sourceId) const = 0;
+
+protected:
+ ~BuildDependenciesStorageInterface() = default;
+};
+
+} // namespace ClangBackEnd
diff --git a/src/tools/clangpchmanagerbackend/source/builddependencies.h b/src/tools/clangpchmanagerbackend/source/builddependency.h
index 9e0eb3f629..8821b0162c 100644
--- a/src/tools/clangpchmanagerbackend/source/builddependencies.h
+++ b/src/tools/clangpchmanagerbackend/source/builddependency.h
@@ -25,18 +25,18 @@
#pragma once
-#include <filepathid.h>
-
-#include <vector>
+#include "sourceentry.h"
+#include "usedmacro.h"
namespace ClangBackEnd {
class BuildDependency
{
public:
- FilePathIds includeIds;
+ SourceEntries includes;
FilePathIds topIncludeIds;
FilePathIds topsSystemIncludeIds;
+ UsedMacros usedMacros;
};
using BuildDependencies = std::vector<BuildDependency>;
diff --git a/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri b/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri
index ad17b98f18..4b5ac43a7e 100644
--- a/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri
+++ b/src/tools/clangpchmanagerbackend/source/clangpchmanagerbackend-source.pri
@@ -4,7 +4,8 @@ SOURCES += \
$$PWD/pchmanagerserver.cpp \
$$PWD/projectparts.cpp \
$$PWD/projectpartqueue.cpp \
- $$PWD/pchtaskgenerator.cpp
+ $$PWD/pchtaskgenerator.cpp \
+ $$PWD/builddependenciesprovider.cpp
HEADERS += \
$$PWD/pchmanagerserver.h \
@@ -28,7 +29,12 @@ HEADERS += \
$$PWD/pchtaskgenerator.h \
$$PWD/pchtask.h \
$$PWD/builddependenciesproviderinterface.h \
- $$PWD/builddependencies.h
+ $$PWD/builddependenciesprovider.h \
+ $$PWD/builddependenciesstorageinterface.h \
+ $$PWD/builddependency.h \
+ $$PWD/modifiedtimecheckerinterface.h \
+ $$PWD/sourceentry.h \
+ $$PWD/builddependenciesgeneratorinterface.h
!isEmpty(LIBTOOLING_LIBS) {
SOURCES += \
diff --git a/src/tools/clangpchmanagerbackend/source/modifiedtimecheckerinterface.h b/src/tools/clangpchmanagerbackend/source/modifiedtimecheckerinterface.h
new file mode 100644
index 0000000000..c0cae1cf4b
--- /dev/null
+++ b/src/tools/clangpchmanagerbackend/source/modifiedtimecheckerinterface.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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 "sourceentry.h"
+
+namespace ClangBackEnd {
+
+class ModifiedTimeCheckerInterface
+{
+public:
+ ModifiedTimeCheckerInterface() = default;
+ ModifiedTimeCheckerInterface(const ModifiedTimeCheckerInterface &) = delete;
+ ModifiedTimeCheckerInterface &operator=(const ModifiedTimeCheckerInterface &) = delete;
+
+ virtual bool isUpToDate(const SourceEntries &sourceEntries) const = 0;
+
+protected:
+ ~ModifiedTimeCheckerInterface() = default;
+};
+
+} // namespace ClangBackEnd
+
diff --git a/src/tools/clangpchmanagerbackend/source/pchtask.h b/src/tools/clangpchmanagerbackend/source/pchtask.h
index 39c7bbf01a..48ae6864ea 100644
--- a/src/tools/clangpchmanagerbackend/source/pchtask.h
+++ b/src/tools/clangpchmanagerbackend/source/pchtask.h
@@ -25,7 +25,7 @@
#pragma once
-#include "builddependencies.h"
+#include "builddependency.h"
#include <utils/smallstringvector.h>
diff --git a/src/tools/clangpchmanagerbackend/source/sourceentry.h b/src/tools/clangpchmanagerbackend/source/sourceentry.h
new file mode 100644
index 0000000000..2e0646b987
--- /dev/null
+++ b/src/tools/clangpchmanagerbackend/source/sourceentry.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 SourceType : unsigned char
+{
+ Any,
+ TopInclude,
+ TopSystemInclude
+};
+
+class TimeStamp
+{
+ using int64 = long long;
+public:
+ TimeStamp(int64 value)
+ : value(value)
+ {}
+
+ operator int64() const
+ {
+ return value;
+ }
+
+ int64 value = -1;
+};
+
+class SourceEntry
+{
+public:
+ friend
+ bool operator<(SourceEntry first, SourceEntry second)
+ {
+ return first.sourceId < second.sourceId;
+ }
+
+ friend
+ bool operator==(SourceEntry first, SourceEntry second)
+ {
+ return first.sourceId == second.sourceId;
+ }
+
+public:
+ FilePathId sourceId;
+ SourceType sourceType = SourceType::Any;
+ TimeStamp lastModified;
+};
+
+using SourceEntries = std::vector<SourceEntry>;
+
+}