forked from qt-creator/qt-creator
Clang: Fix system pre include search path
We now get the resource path from creator. The -fPIC case is working now too. Change-Id: Id191e89e6d46706748d50440038a06a349972cc9 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -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:
|
||||
}
|
||||
};
|
||||
|
||||
struct Data // because we have a cycle dependency
|
||||
class ApplicationEnvironment final : public ClangBackEnd::Environment
|
||||
{
|
||||
Data(const QString &databasePath)
|
||||
: database{Utils::PathString{databasePath}, 100000ms}
|
||||
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, 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);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "symbolindexertaskqueue.h"
|
||||
|
||||
#include <commandlinebuilder.h>
|
||||
#include <environment.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
@@ -67,7 +68,8 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ
|
||||
FileStatusCache &fileStatusCache,
|
||||
Sqlite::TransactionInterface &transactionInterface,
|
||||
ProjectPartsStorageInterface &projectPartsStorage,
|
||||
ModifiedTimeCheckerInterface<SourceTimeStamps> &modifiedTimeChecker)
|
||||
ModifiedTimeCheckerInterface<SourceTimeStamps> &modifiedTimeChecker,
|
||||
const Environment &environment)
|
||||
: m_symbolIndexerTaskQueue(symbolIndexerTaskQueue)
|
||||
, m_symbolStorage(symbolStorage)
|
||||
, m_buildDependencyStorage(buildDependenciesStorage)
|
||||
@@ -78,6 +80,7 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ
|
||||
, m_transactionInterface(transactionInterface)
|
||||
, m_projectPartsStorage(projectPartsStorage)
|
||||
, m_modifiedTimeChecker(modifiedTimeChecker)
|
||||
, m_environment(environment)
|
||||
{
|
||||
pathWatcher.setNotifier(this);
|
||||
}
|
||||
@@ -99,8 +102,10 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
sourcePathId);
|
||||
|
||||
if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) {
|
||||
auto indexing = [projectPart = std::move(projectPart), sourcePathId, this](
|
||||
SymbolsCollectorInterface &symbolsCollector) {
|
||||
auto indexing = [projectPart = std::move(projectPart),
|
||||
sourcePathId,
|
||||
preIncludeSearchPath = m_environment.preIncludeSearchPath(),
|
||||
this](SymbolsCollectorInterface &symbolsCollector) {
|
||||
auto collect = [&](const FilePath &pchPath) {
|
||||
using Builder = CommandLineBuilder<ProjectPartContainer, Utils::SmallStringVector>;
|
||||
Builder commandLineBuilder{projectPart,
|
||||
@@ -108,7 +113,8 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
InputFileType::Source,
|
||||
{},
|
||||
{},
|
||||
pchPath};
|
||||
pchPath,
|
||||
preIncludeSearchPath};
|
||||
symbolsCollector.setFile(sourcePathId, commandLineBuilder.commandLine);
|
||||
|
||||
return symbolsCollector.collectSymbols();
|
||||
@@ -174,13 +180,21 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
|
||||
|
||||
SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps(filePathId);
|
||||
|
||||
auto indexing = [optionalArtefact = std::move(optionalArtefact), filePathId, this](
|
||||
SymbolsCollectorInterface &symbolsCollector) {
|
||||
auto indexing = [optionalArtefact = std::move(optionalArtefact),
|
||||
filePathId,
|
||||
preIncludeSearchPath = m_environment.preIncludeSearchPath(),
|
||||
this](SymbolsCollectorInterface &symbolsCollector) {
|
||||
auto collect = [&](const FilePath &pchPath) {
|
||||
const ProjectPartArtefact &artefact = *optionalArtefact;
|
||||
|
||||
using Builder = CommandLineBuilder<ProjectPartArtefact, Utils::SmallStringVector>;
|
||||
Builder builder{artefact, artefact.toolChainArguments, InputFileType::Source, {}, {}, pchPath};
|
||||
Builder builder{artefact,
|
||||
artefact.toolChainArguments,
|
||||
InputFileType::Source,
|
||||
{},
|
||||
{},
|
||||
pchPath,
|
||||
preIncludeSearchPath};
|
||||
|
||||
symbolsCollector.setFile(filePathId, builder.commandLine);
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class SymbolsCollectorInterface;
|
||||
class Environment;
|
||||
|
||||
class SymbolIndexer final : public ClangPathWatcherNotifier
|
||||
{
|
||||
@@ -53,7 +54,8 @@ public:
|
||||
FileStatusCache &fileStatusCache,
|
||||
Sqlite::TransactionInterface &transactionInterface,
|
||||
ProjectPartsStorageInterface &projectPartsStorage,
|
||||
ModifiedTimeCheckerInterface<SourceTimeStamps> &modifiedTimeChecker);
|
||||
ModifiedTimeCheckerInterface<SourceTimeStamps> &modifiedTimeChecker,
|
||||
const Environment &environment);
|
||||
|
||||
void updateProjectParts(ProjectPartContainers &&projectParts);
|
||||
void updateProjectPart(ProjectPartContainer &&projectPart);
|
||||
@@ -84,6 +86,7 @@ private:
|
||||
Sqlite::TransactionInterface &m_transactionInterface;
|
||||
ProjectPartsStorageInterface &m_projectPartsStorage;
|
||||
ModifiedTimeCheckerInterface<SourceTimeStamps> &m_modifiedTimeChecker;
|
||||
const Environment &m_environment;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -85,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)
|
||||
@@ -93,6 +94,17 @@ 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_indexerScheduler(m_collectorManger,
|
||||
m_indexerQueue,
|
||||
m_progressCounter,
|
||||
@@ -139,16 +151,7 @@ private:
|
||||
}};
|
||||
ModifiedTimeChecker<ClangBackEnd::SourceTimeStamps> m_modifiedTimeChecker{getModifiedTime,
|
||||
m_filePathCache};
|
||||
SymbolIndexer m_indexer{m_indexerQueue,
|
||||
m_symbolStorage,
|
||||
m_buildDependencyStorage,
|
||||
m_precompiledHeaderStorage,
|
||||
m_sourceWatcher,
|
||||
m_filePathCache,
|
||||
m_fileStatusCache,
|
||||
m_symbolStorage.database,
|
||||
m_projectPartsStorage,
|
||||
m_modifiedTimeChecker};
|
||||
SymbolIndexer m_indexer;
|
||||
SymbolIndexerTaskQueue m_indexerQueue{m_indexerScheduler, m_progressCounter};
|
||||
SymbolIndexerTaskScheduler m_indexerScheduler;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user