forked from qt-creator/qt-creator
ClangPchManager: Add PchTaskGenerator
Task-number: QTCREATORBUG-21358 Change-Id: Ia460ce82c3c896f4d0ac00638d03800a55dd27dc Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
include(../../qtcreatorlibrary.pri)
|
||||
include(clangsupport-lib.pri)
|
||||
|
||||
HEADERS += \
|
||||
commandlinebuilderinterface.h
|
||||
|
41
src/libs/clangsupport/commandlinebuilderinterface.h
Normal file
41
src/libs/clangsupport/commandlinebuilderinterface.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <utils/smallstringvector.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CommandLineBuilderInterface
|
||||
{
|
||||
public:
|
||||
virtual Utils::PathStringVector create() = 0;
|
||||
|
||||
protected:
|
||||
~CommandLineBuilderInterface() = default;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
44
src/tools/clangpchmanagerbackend/source/builddependencies.h
Normal file
44
src/tools/clangpchmanagerbackend/source/builddependencies.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 {
|
||||
|
||||
class BuildDependency
|
||||
{
|
||||
public:
|
||||
FilePathIds includeIds;
|
||||
FilePathIds topIncludeIds;
|
||||
FilePathIds topsSystemIncludeIds;
|
||||
};
|
||||
|
||||
using BuildDependencies = std::vector<BuildDependency>;
|
||||
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "builddependencies.h"
|
||||
|
||||
#include "projectpartcontainerv2.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class BuildDependenciesProviderInterface
|
||||
{
|
||||
public:
|
||||
virtual BuildDependency create(const V2::ProjectPartContainer &projectPart) = 0;
|
||||
|
||||
protected:
|
||||
~BuildDependenciesProviderInterface() = default;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
@@ -3,7 +3,8 @@ INCLUDEPATH += $$PWD
|
||||
SOURCES += \
|
||||
$$PWD/pchmanagerserver.cpp \
|
||||
$$PWD/projectparts.cpp \
|
||||
$$PWD/projectpartqueue.cpp
|
||||
$$PWD/projectpartqueue.cpp \
|
||||
$$PWD/pchtaskgenerator.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/pchmanagerserver.h \
|
||||
@@ -23,7 +24,11 @@ HEADERS += \
|
||||
$$PWD/precompiledheaderstorage.h \
|
||||
$$PWD/precompiledheaderstorageinterface.h \
|
||||
$$PWD/usedmacroandsourcestorageinterface.h \
|
||||
$$PWD/usedmacroandsourcestorage.h
|
||||
$$PWD/usedmacroandsourcestorage.h \
|
||||
$$PWD/pchtaskgenerator.h \
|
||||
$$PWD/pchtask.h \
|
||||
$$PWD/builddependenciesproviderinterface.h \
|
||||
$$PWD/builddependencies.h
|
||||
|
||||
!isEmpty(LIBTOOLING_LIBS) {
|
||||
SOURCES += \
|
||||
|
48
src/tools/clangpchmanagerbackend/source/pchtask.h
Normal file
48
src/tools/clangpchmanagerbackend/source/pchtask.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "builddependencies.h"
|
||||
|
||||
#include <utils/smallstringvector.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class PchTask
|
||||
{
|
||||
public:
|
||||
PchTask(Utils::SmallStringVector &&ids, BuildDependency &&buildDependency)
|
||||
: ids(std::move(ids)),
|
||||
buildDependency(std::move(buildDependency))
|
||||
{
|
||||
}
|
||||
|
||||
Utils::SmallStringVector ids;
|
||||
BuildDependency buildDependency;
|
||||
};
|
||||
|
||||
using PchTasks = std::vector<PchTask>;
|
||||
}
|
47
src/tools/clangpchmanagerbackend/source/pchtaskgenerator.cpp
Normal file
47
src/tools/clangpchmanagerbackend/source/pchtaskgenerator.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "pchtaskgenerator.h"
|
||||
|
||||
#include "builddependenciesproviderinterface.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
PchTasks PchTaskGenerator::create(V2::ProjectPartContainers &&projectParts)
|
||||
{
|
||||
PchTasks tasks;
|
||||
tasks.reserve(projectParts.size() * 2);
|
||||
|
||||
for (auto &projectPart : projectParts) {
|
||||
tasks.emplace_back(std::initializer_list<Utils::SmallString>{{projectPart.projectPartId}},
|
||||
m_buildDependenciesProvider.create(projectPart));
|
||||
}
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
50
src/tools/clangpchmanagerbackend/source/pchtaskgenerator.h
Normal file
50
src/tools/clangpchmanagerbackend/source/pchtaskgenerator.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "pchtask.h"
|
||||
|
||||
#include <projectpartcontainerv2.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class BuildDependenciesProviderInterface;
|
||||
|
||||
class PchTaskGenerator
|
||||
{
|
||||
public:
|
||||
PchTaskGenerator(BuildDependenciesProviderInterface &buildDependenciesProvider)
|
||||
: m_buildDependenciesProvider(buildDependenciesProvider)
|
||||
{}
|
||||
|
||||
PchTasks create(V2::ProjectPartContainers &&projectParts);
|
||||
|
||||
private:
|
||||
BuildDependenciesProviderInterface &m_buildDependenciesProvider;
|
||||
};
|
||||
|
||||
|
||||
} // namespace ClangBackEnd
|
@@ -63,11 +63,11 @@ public:
|
||||
using ProcessorInterface = typename ProcessorManager::Processor;
|
||||
using Future = std::future<ProcessorInterface&>;
|
||||
|
||||
TaskScheduler(ProcessorManager &symbolsCollectorManager,
|
||||
TaskScheduler(ProcessorManager &processorManager,
|
||||
QueueInterface &queue,
|
||||
uint hardwareConcurrency,
|
||||
std::launch launchPolicy = std::launch::async)
|
||||
: m_processorManager(symbolsCollectorManager),
|
||||
: m_processorManager(processorManager),
|
||||
m_queue(queue),
|
||||
m_hardwareConcurrency(hardwareConcurrency),
|
||||
m_launchPolicy(launchPolicy)
|
||||
|
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <sourcelocations.h>
|
||||
|
||||
#include <builddependencies.h>
|
||||
#include <clangcodemodelclientmessages.h>
|
||||
#include <clangcodemodelservermessages.h>
|
||||
#include <clangdocumentsuspenderresumer.h>
|
||||
@@ -43,6 +44,7 @@
|
||||
#include <fulltokeninfo.h>
|
||||
#include <nativefilepath.h>
|
||||
#include <pchcreator.h>
|
||||
#include <pchtask.h>
|
||||
#include <precompiledheadersupdatedmessage.h>
|
||||
#include <projectpartartefact.h>
|
||||
#include <sourcedependency.h>
|
||||
@@ -1005,6 +1007,18 @@ std::ostream &operator<<(std::ostream &out, const PchCreatorIncludes &includes)
|
||||
{
|
||||
return out << "(" << includes.includeIds << ", " << includes.topIncludeIds << ", " << includes.topSystemIncludeIds << ")";
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &out, const PchTask &task)
|
||||
{
|
||||
return out << "(" << task.ids << ", " << task.buildDependency << ")";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const BuildDependency &dependency)
|
||||
{
|
||||
return out << "("
|
||||
<< dependency.includeIds << ", "
|
||||
<< dependency.topsSystemIncludeIds << ", "
|
||||
<< dependency.topIncludeIds << ")";
|
||||
}
|
||||
|
||||
void PrintTo(const FilePath &filePath, ::std::ostream *os)
|
||||
{
|
||||
|
@@ -170,6 +170,8 @@ class SuspendResumeJobsEntry;
|
||||
class ReferencesResult;
|
||||
class SymbolIndexerTask;
|
||||
class PchCreatorIncludes;
|
||||
class PchTask;
|
||||
class BuildDependency;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry);
|
||||
std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths);
|
||||
@@ -250,6 +252,8 @@ std::ostream &operator<<(std::ostream &os, const SuspendResumeJobsEntry &entry);
|
||||
std::ostream &operator<<(std::ostream &os, const ReferencesResult &value);
|
||||
std::ostream &operator<<(std::ostream &out, const SymbolIndexerTask &task);
|
||||
std::ostream &operator<<(std::ostream &out, const PchCreatorIncludes &includes);
|
||||
std::ostream &operator<<(std::ostream &out, const PchTask &task);
|
||||
std::ostream &operator<<(std::ostream &out, const BuildDependency &dependency);
|
||||
|
||||
void PrintTo(const FilePath &filePath, ::std::ostream *os);
|
||||
void PrintTo(const FilePathView &filePathView, ::std::ostream *os);
|
||||
|
37
tests/unit/unittest/mockbuilddependenciesprovider.h
Normal file
37
tests/unit/unittest/mockbuilddependenciesprovider.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "googletest.h"
|
||||
|
||||
#include <builddependenciesproviderinterface.h>
|
||||
|
||||
class MockBuildDependenciesProvider : public ClangBackEnd::BuildDependenciesProviderInterface
|
||||
{
|
||||
public:
|
||||
MOCK_METHOD1(create,
|
||||
ClangBackEnd::BuildDependency (const ClangBackEnd::V2::ProjectPartContainer &projectPart));
|
||||
};
|
66
tests/unit/unittest/pchtaskgenerator-test.cpp
Normal file
66
tests/unit/unittest/pchtaskgenerator-test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "googletest.h"
|
||||
|
||||
#include "mockbuilddependenciesprovider.h"
|
||||
|
||||
#include <pchtaskgenerator.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using ClangBackEnd::BuildDependency;
|
||||
using ClangBackEnd::BuildDependencies;
|
||||
using ClangBackEnd::FilePathId;
|
||||
using ClangBackEnd::PchTask;
|
||||
|
||||
class PchTaskGenerator : public testing::Test
|
||||
{
|
||||
protected:
|
||||
NiceMock<MockBuildDependenciesProvider> mockBuildDependenciesProvider;
|
||||
ClangBackEnd::PchTaskGenerator generator{mockBuildDependenciesProvider};
|
||||
ClangBackEnd::V2::ProjectPartContainer projectPart1{"ProjectPart1",
|
||||
{"--yi"},
|
||||
{{"YI","1"}},
|
||||
{"/yi"},
|
||||
{{1, 1}},
|
||||
{{1, 2}}};
|
||||
BuildDependency buildDependency{{{1, 1}}, {}, {}};
|
||||
};
|
||||
|
||||
TEST_F(PchTaskGenerator, Create)
|
||||
{
|
||||
ON_CALL(mockBuildDependenciesProvider, create(_)).WillByDefault(Return(buildDependency));
|
||||
|
||||
auto tasks = generator.create({projectPart1});
|
||||
|
||||
ASSERT_THAT(tasks,
|
||||
ElementsAre(
|
||||
AllOf(Field(&PchTask::ids, ElementsAre("ProjectPart1")),
|
||||
Field(&PchTask::buildDependency,
|
||||
Field(&BuildDependency::includeIds, ElementsAre(FilePathId{1, 1}))))));
|
||||
}
|
||||
|
||||
}
|
@@ -103,7 +103,8 @@ SOURCES += \
|
||||
processormanager-test.cpp \
|
||||
taskscheduler-test.cpp \
|
||||
compileroptionsbuilder-test.cpp \
|
||||
usedmacroandsourcestorage-test.cpp
|
||||
usedmacroandsourcestorage-test.cpp \
|
||||
pchtaskgenerator-test.cpp
|
||||
|
||||
!isEmpty(LIBCLANG_LIBS) {
|
||||
SOURCES += \
|
||||
@@ -247,7 +248,8 @@ HEADERS += \
|
||||
mockprocessor.h \
|
||||
mockprocessormanager.h \
|
||||
mocktaskscheduler.h \
|
||||
mockusedmacroandsourcestorage.h
|
||||
mockusedmacroandsourcestorage.h \
|
||||
mockbuilddependenciesprovider.h
|
||||
|
||||
!isEmpty(LIBCLANG_LIBS) {
|
||||
HEADERS += \
|
||||
|
Reference in New Issue
Block a user