Skip to content

Commit

Permalink
Discard pch files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed May 20, 2024
1 parent 7f1b979 commit 3d10802
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/IndexerJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ String IndexerJob::encode() const

Server::instance()->filterBlockedArguments(copy);
copy.includePaths.insert(copy.includePaths.begin(), options.includePaths.begin(), options.includePaths.end());
if (Server::instance()->options().options & Server::PCHEnabled)
project->fixPCH(copy);
project->fixPCH(copy);

copy.defines << options.defines;
if (!(options.options & Server::EnableNDEBUG)) {
Expand Down
22 changes: 17 additions & 5 deletions src/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2557,13 +2557,25 @@ uint32_t Project::fileMapOptions() const

void Project::fixPCH(Source &source)
{
for (Source::Include &inc : source.includePaths) {
const bool enabled = Server::instance()->options().options & Server::PCHEnabled;
auto it = source.includePaths.begin();
while (it != source.includePaths.end()) {
auto &inc = *it;
if (inc.type == Source::Include::Type_PCH) {
const uint32_t fileId = Location::insertFile(inc.path);
inc.path = RTags::encodeSourceFilePath(Server::instance()->options().dataDir, mPath,
mIndexParseData.compileCommandsFileId, fileId) + "pch.h";
error() << "PREPARING" << inc.path;
if (enabled) {
const uint32_t fileId = Location::insertFile(inc.path);
inc.path = RTags::encodeSourceFilePath(Server::instance()->options().dataDir, mPath,
mIndexParseData.compileCommandsFileId, fileId) + "pch.h";
error() << "PREPARING" << inc.path;
} else {
it = source.includePaths.erase(it);
continue;
}
} else if (inc.type == Source::Include::Type_File && inc.isPch()) {
it = source.includePaths.erase(it);
continue;
}
++it;
}
}

Expand Down

0 comments on commit 3d10802

Please sign in to comment.