2017-01-30 11:24:46 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2016 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 "pchcreator.h"
|
|
|
|
|
|
|
|
|
|
#include "environment.h"
|
|
|
|
|
#include "includecollector.h"
|
|
|
|
|
#include "pchnotcreatederror.h"
|
|
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
#include <clangpathwatcherinterface.h>
|
2017-09-21 11:43:59 +02:00
|
|
|
#include <filepathcachinginterface.h>
|
2018-09-11 14:02:59 +02:00
|
|
|
#include <generatedfiles.h>
|
2018-09-11 17:02:45 +02:00
|
|
|
#include <pchmanagerclientinterface.h>
|
|
|
|
|
#include <precompiledheadersupdatedmessage.h>
|
2017-01-30 11:24:46 +01:00
|
|
|
#include <projectpartpch.h>
|
|
|
|
|
|
|
|
|
|
#include <QCryptographicHash>
|
2018-02-15 14:29:20 +01:00
|
|
|
#include <QDateTime>
|
2017-01-30 11:24:46 +01:00
|
|
|
#include <QFile>
|
2018-09-11 17:02:45 +02:00
|
|
|
#include <QProcess>
|
2017-02-16 18:25:19 +01:00
|
|
|
#include <QTemporaryFile>
|
2017-01-30 11:24:46 +01:00
|
|
|
|
|
|
|
|
namespace ClangBackEnd {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
template <typename Source,
|
|
|
|
|
typename Target>
|
|
|
|
|
void append(Target &target, const Source &source)
|
|
|
|
|
{
|
2017-08-29 12:54:10 +02:00
|
|
|
using ValueType = typename Target::value_type;
|
2017-01-30 11:24:46 +01:00
|
|
|
Source clonedSource = source.clone();
|
|
|
|
|
|
|
|
|
|
target.reserve(target.size() + source.size());
|
|
|
|
|
|
2017-08-29 18:41:21 +02:00
|
|
|
for (auto &&entry : clonedSource)
|
2017-08-29 12:54:10 +02:00
|
|
|
target.push_back(ValueType(std::move(entry)));
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
2018-01-22 14:21:01 +01:00
|
|
|
void appendFilePathId(Utils::PathStringVector &target,
|
|
|
|
|
const ClangBackEnd::FilePathIds &source,
|
|
|
|
|
const ClangBackEnd::FilePathCachingInterface &filePathCache)
|
|
|
|
|
{
|
|
|
|
|
for (FilePathId id : source)
|
|
|
|
|
target.emplace_back(filePathCache.filePath(id).path());
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
2017-02-01 13:43:28 +01:00
|
|
|
Utils::PathStringVector generatedFilePaths(const V2::FileContainers &generaredFiles)
|
|
|
|
|
{
|
|
|
|
|
Utils::PathStringVector generaredFilePaths;
|
|
|
|
|
generaredFilePaths.reserve(generaredFiles.size());
|
|
|
|
|
|
|
|
|
|
for (const V2::FileContainer &generatedFile : generaredFiles)
|
2018-04-08 01:20:42 +03:00
|
|
|
generaredFilePaths.push_back(generatedFile.filePath.path());
|
2017-02-01 13:43:28 +01:00
|
|
|
|
|
|
|
|
return generaredFilePaths;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
2017-09-21 11:43:59 +02:00
|
|
|
std::size_t contentSize(const FilePaths &includes)
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2018-01-22 14:21:01 +01:00
|
|
|
auto countIncludeSize = [] (std::size_t size, const auto &include) {
|
2017-01-30 11:24:46 +01:00
|
|
|
return size + include.size();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return std::accumulate(includes.begin(), includes.end(), std::size_t(0), countIncludeSize);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-21 11:43:59 +02:00
|
|
|
Utils::SmallString PchCreator::generatePchIncludeFileContent(const FilePathIds &includeIds) const
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
|
|
|
|
Utils::SmallString fileContent;
|
|
|
|
|
const std::size_t lineTemplateSize = 12;
|
2017-09-21 11:43:59 +02:00
|
|
|
auto includes = m_filePathCache.filePaths(includeIds);
|
2017-01-30 11:24:46 +01:00
|
|
|
|
|
|
|
|
fileContent.reserve(includes.size() * lineTemplateSize + contentSize(includes));
|
|
|
|
|
|
2018-09-11 14:02:59 +02:00
|
|
|
for (Utils::SmallStringView include : includes)
|
2017-09-21 11:43:59 +02:00
|
|
|
fileContent += {"#include \"", include, "\"\n"};
|
2017-01-30 11:24:46 +01:00
|
|
|
|
|
|
|
|
return fileContent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
bool PchCreator::generatePch(Utils::SmallStringVector &&compilerArguments)
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2018-09-11 17:02:45 +02:00
|
|
|
QProcess process;
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
process.setProcessChannelMode(QProcess::ForwardedChannels);
|
|
|
|
|
process.setArguments(QStringList(compilerArguments));
|
|
|
|
|
process.setProgram(QString(m_environment.clangCompilerPath()));
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
process.start();
|
|
|
|
|
process.waitForFinished(300000);
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
return process.exitStatus() == QProcess::NormalExit && process.exitCode() == 0;
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList PchCreator::convertToQStringList(const Utils::SmallStringVector &compilerArguments)
|
|
|
|
|
{
|
|
|
|
|
QStringList qStringList;
|
|
|
|
|
|
|
|
|
|
append(qStringList, compilerArguments);
|
|
|
|
|
|
|
|
|
|
return qStringList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
void hashProjectPart(QCryptographicHash &hash, const V2::ProjectPartContainer &projectPart)
|
|
|
|
|
{
|
2018-04-08 01:20:42 +03:00
|
|
|
const auto &projectPartId = projectPart.projectPartId;
|
2018-09-11 17:02:45 +02:00
|
|
|
hash.addData(projectPartId.data(), int(projectPartId.size()));
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-04-08 01:20:42 +03:00
|
|
|
for (const auto &argument : projectPart.arguments)
|
2018-09-11 17:02:45 +02:00
|
|
|
hash.addData(argument.data(), int(argument.size()));
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::SmallStringVector PchCreator::generateProjectPartCommandLine(
|
|
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
2018-04-08 01:20:42 +03:00
|
|
|
const Utils::SmallStringVector &arguments = projectPart.arguments;
|
2017-01-30 11:24:46 +01:00
|
|
|
|
|
|
|
|
Utils::SmallStringVector commandLine;
|
|
|
|
|
commandLine.reserve(arguments.size() + 1);
|
|
|
|
|
|
|
|
|
|
commandLine.emplace_back(m_environment.clangCompilerPath());
|
|
|
|
|
|
|
|
|
|
append(commandLine , arguments);
|
|
|
|
|
|
|
|
|
|
return commandLine;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::SmallString PchCreator::generateProjectPartPchFilePathWithoutExtension(
|
|
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
|
|
|
|
QByteArray fileName = m_environment.pchBuildDirectory().toUtf8();
|
|
|
|
|
fileName += '/';
|
|
|
|
|
fileName += projectPartHash(projectPart);
|
|
|
|
|
|
|
|
|
|
return Utils::SmallString::fromQByteArray(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-01 13:43:28 +01:00
|
|
|
Utils::PathStringVector PchCreator::generateProjectPartHeaders(
|
|
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
|
|
|
|
Utils::PathStringVector headerPaths;
|
2018-09-11 17:02:45 +02:00
|
|
|
headerPaths.reserve(projectPart.headerPathIds.size() + m_unsavedFiles.size());
|
2017-02-01 13:43:28 +01:00
|
|
|
|
2018-04-08 01:20:42 +03:00
|
|
|
std::transform(projectPart.headerPathIds.begin(),
|
|
|
|
|
projectPart.headerPathIds.end(),
|
2018-01-22 14:21:01 +01:00
|
|
|
std::back_inserter(headerPaths),
|
|
|
|
|
[&] (FilePathId filePathId) {
|
|
|
|
|
return m_filePathCache.filePath(filePathId);
|
|
|
|
|
});
|
2017-02-01 13:43:28 +01:00
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
Utils::PathStringVector generatedPath = generatedFilePaths(m_unsavedFiles);
|
2017-02-01 13:43:28 +01:00
|
|
|
|
|
|
|
|
std::copy(std::make_move_iterator(generatedPath.begin()),
|
|
|
|
|
std::make_move_iterator(generatedPath.end()),
|
|
|
|
|
std::back_inserter(headerPaths));
|
|
|
|
|
|
|
|
|
|
return headerPaths;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-16 18:25:19 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
std::size_t sizeOfContent(const Utils::PathStringVector &paths)
|
|
|
|
|
{
|
|
|
|
|
return std::accumulate(paths.begin(),
|
|
|
|
|
paths.end(),
|
|
|
|
|
std::size_t(0),
|
|
|
|
|
[] (std::size_t size, const Utils::PathString &path) {
|
|
|
|
|
const char includeTemplate[] = "#include \"\"\n";
|
|
|
|
|
return size + path.size() + sizeof(includeTemplate);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::SmallString concatContent(const Utils::PathStringVector &paths, std::size_t size)
|
|
|
|
|
{
|
|
|
|
|
Utils::SmallString content;
|
|
|
|
|
content.reserve(size);
|
|
|
|
|
|
|
|
|
|
for (const Utils::PathString &path : paths) {
|
|
|
|
|
content += "#include \"";
|
|
|
|
|
content += path;
|
|
|
|
|
content += "\"\n";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-11 14:02:59 +02:00
|
|
|
Utils::SmallString PchCreator::generateProjectPartSourcesContent(
|
2018-01-22 14:21:01 +01:00
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
2017-02-16 18:25:19 +01:00
|
|
|
{
|
2018-09-11 14:02:59 +02:00
|
|
|
Utils::PathStringVector paths = generateProjectPartSourcePaths(projectPart);
|
2017-02-16 18:25:19 +01:00
|
|
|
|
|
|
|
|
return concatContent(paths, sizeOfContent(paths));
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-11 14:02:59 +02:00
|
|
|
Utils::PathStringVector PchCreator::generateProjectPartSourcePaths(
|
2018-01-22 14:21:01 +01:00
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2017-02-01 13:43:28 +01:00
|
|
|
Utils::PathStringVector includeAndSources;
|
2018-09-06 11:57:36 +02:00
|
|
|
includeAndSources.reserve(projectPart.sourcePathIds.size());
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-04-08 01:20:42 +03:00
|
|
|
appendFilePathId(includeAndSources, projectPart.sourcePathIds, m_filePathCache);
|
2017-01-30 11:24:46 +01:00
|
|
|
|
|
|
|
|
return includeAndSources;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-18 11:27:49 +02:00
|
|
|
PchCreatorIncludes PchCreator::generateProjectPartPchIncludes(
|
2017-01-30 11:24:46 +01:00
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
2018-09-11 14:02:59 +02:00
|
|
|
Utils::SmallString jointedFileContent = generateProjectPartSourcesContent(projectPart);
|
2017-02-16 18:25:19 +01:00
|
|
|
Utils::SmallString jointedFilePath = generateProjectPartSourceFilePath(projectPart);
|
|
|
|
|
auto jointFile = generateFileWithContent(jointedFilePath, jointedFileContent);
|
|
|
|
|
Utils::SmallStringVector arguments = generateProjectPartCommandLine(projectPart);
|
|
|
|
|
arguments.push_back(jointedFilePath);
|
2017-08-29 12:54:10 +02:00
|
|
|
FilePath filePath{Utils::PathString(jointedFilePath)};
|
2017-02-16 18:25:19 +01:00
|
|
|
|
2017-01-30 11:24:46 +01:00
|
|
|
IncludeCollector collector(m_filePathCache);
|
|
|
|
|
|
2018-09-11 14:02:59 +02:00
|
|
|
collector.setExcludedIncludes(generateProjectPartSourcePaths(projectPart));
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2017-08-29 12:54:10 +02:00
|
|
|
collector.addFile(std::string(filePath.directory()),
|
|
|
|
|
std::string(filePath.name()),
|
2017-02-16 18:25:19 +01:00
|
|
|
{},
|
|
|
|
|
arguments);
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
collector.addUnsavedFiles(m_unsavedFiles);
|
2017-02-01 13:43:28 +01:00
|
|
|
|
2017-01-30 11:24:46 +01:00
|
|
|
collector.collectIncludes();
|
|
|
|
|
|
2017-02-16 18:25:19 +01:00
|
|
|
jointFile->remove();
|
|
|
|
|
|
2018-10-18 11:27:49 +02:00
|
|
|
return {collector.takeIncludeIds(), collector.takeTopIncludeIds(), collector.takeTopsSystemIncludeIds()};
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::SmallString PchCreator::generateProjectPathPchHeaderFilePath(
|
|
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
2017-02-16 18:25:19 +01:00
|
|
|
return Utils::SmallString{generateProjectPartPchFilePathWithoutExtension(projectPart), ".h"};
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::SmallString PchCreator::generateProjectPartPchFilePath(
|
|
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
2017-02-16 18:25:19 +01:00
|
|
|
return Utils::SmallString{generateProjectPartPchFilePathWithoutExtension(projectPart), ".pch"};
|
|
|
|
|
}
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2017-02-16 18:25:19 +01:00
|
|
|
Utils::SmallString PchCreator::generateProjectPartSourceFilePath(const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
|
|
|
|
return Utils::SmallString{generateProjectPartPchFilePathWithoutExtension(projectPart), ".cpp"};
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::SmallStringVector PchCreator::generateProjectPartPchCompilerArguments(
|
|
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
|
|
|
|
Utils::SmallStringVector arguments;
|
|
|
|
|
arguments.reserve(5);
|
|
|
|
|
|
|
|
|
|
arguments.emplace_back("-x");
|
|
|
|
|
arguments.emplace_back("c++-header");
|
|
|
|
|
arguments.emplace_back("-Xclang");
|
|
|
|
|
arguments.emplace_back("-emit-pch");
|
|
|
|
|
arguments.emplace_back("-o");
|
|
|
|
|
arguments.emplace_back(generateProjectPartPchFilePath(projectPart));
|
|
|
|
|
arguments.emplace_back(generateProjectPathPchHeaderFilePath(projectPart));
|
|
|
|
|
|
|
|
|
|
return arguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::SmallStringVector PchCreator::generateProjectPartClangCompilerArguments(
|
|
|
|
|
const V2::ProjectPartContainer &projectPart) const
|
|
|
|
|
{
|
2018-04-08 01:20:42 +03:00
|
|
|
Utils::SmallStringVector compilerArguments = projectPart.arguments.clone();
|
2017-01-30 11:24:46 +01:00
|
|
|
const auto pchArguments = generateProjectPartPchCompilerArguments(projectPart);
|
|
|
|
|
|
|
|
|
|
append(compilerArguments, pchArguments);
|
|
|
|
|
|
|
|
|
|
return compilerArguments;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-31 14:21:05 +01:00
|
|
|
IdPaths PchCreator::generateProjectPartPch(const V2::ProjectPartContainer &projectPart)
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2018-02-15 14:29:20 +01:00
|
|
|
long long lastModified = QDateTime::currentSecsSinceEpoch();
|
2018-10-18 11:27:49 +02:00
|
|
|
auto includes = generateProjectPartPchIncludes(projectPart);
|
|
|
|
|
auto content = generatePchIncludeFileContent(includes.topIncludeIds);
|
2017-01-30 11:24:46 +01:00
|
|
|
auto pchIncludeFilePath = generateProjectPathPchHeaderFilePath(projectPart);
|
|
|
|
|
auto pchFilePath = generateProjectPartPchFilePath(projectPart);
|
2017-02-16 18:25:19 +01:00
|
|
|
generateFileWithContent(pchIncludeFilePath, content);
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
bool success = generatePch(generateProjectPartClangCompilerArguments(projectPart));
|
|
|
|
|
|
|
|
|
|
m_projectPartPch.projectPartId = projectPart.projectPartId;
|
|
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
|
m_projectPartPch.pchPath = std::move(pchFilePath);
|
|
|
|
|
m_projectPartPch.lastModified = lastModified;
|
|
|
|
|
}
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-10-18 11:27:49 +02:00
|
|
|
return {projectPart.projectPartId.clone(), std::move(includes.includeIds)};
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
void PchCreator::generatePch(const V2::ProjectPartContainer &projectPart)
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2018-09-11 17:02:45 +02:00
|
|
|
m_projectIncludeIds = generateProjectPartPch(projectPart);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IdPaths PchCreator::takeProjectIncludes()
|
|
|
|
|
{
|
|
|
|
|
return std::move(m_projectIncludeIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ProjectPartPch &PchCreator::projectPartPch()
|
|
|
|
|
{
|
|
|
|
|
return m_projectPartPch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PchCreator::setUnsavedFiles(const V2::FileContainers &fileContainers)
|
|
|
|
|
{
|
|
|
|
|
m_unsavedFiles = fileContainers;
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
void PchCreator::setIsUsed(bool isUsed)
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2018-09-11 17:02:45 +02:00
|
|
|
m_isUsed = isUsed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PchCreator::isUsed() const
|
|
|
|
|
{
|
|
|
|
|
return m_isUsed;
|
|
|
|
|
}
|
2017-01-30 11:24:46 +01:00
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
void PchCreator::clear()
|
|
|
|
|
{
|
|
|
|
|
m_projectPartPch = ProjectPartPch{};
|
|
|
|
|
m_projectIncludeIds = IdPaths{};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PchCreator::doInMainThreadAfterFinished()
|
|
|
|
|
{
|
|
|
|
|
m_pchManagerClient.precompiledHeadersUpdated(ProjectPartPchs{m_projectPartPch});
|
|
|
|
|
m_fileSystemWatcher.updateIdPaths({takeProjectIncludes()});
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
const IdPaths &PchCreator::projectIncludes() const
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2018-09-11 17:02:45 +02:00
|
|
|
return m_projectIncludeIds;
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
const FilePathCaching &PchCreator::filePathCache()
|
2017-01-30 11:24:46 +01:00
|
|
|
{
|
2018-09-11 17:02:45 +02:00
|
|
|
return m_filePathCache;
|
2017-01-30 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
|
2017-02-16 18:25:19 +01:00
|
|
|
std::unique_ptr<QFile> PchCreator::generateFileWithContent(
|
2017-01-30 11:24:46 +01:00
|
|
|
const Utils::SmallString &filePath,
|
|
|
|
|
const Utils::SmallString &content)
|
|
|
|
|
{
|
2017-08-29 12:54:10 +02:00
|
|
|
std::unique_ptr<QFile> precompiledIncludeFile(new QFile(QString(filePath)));
|
2017-01-30 11:24:46 +01:00
|
|
|
|
|
|
|
|
precompiledIncludeFile->open(QIODevice::WriteOnly);
|
|
|
|
|
|
2017-08-29 12:54:10 +02:00
|
|
|
precompiledIncludeFile->write(content.data(), qint64(content.size()));
|
2017-01-30 11:24:46 +01:00
|
|
|
precompiledIncludeFile->close();
|
|
|
|
|
|
|
|
|
|
return precompiledIncludeFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray PchCreator::projectPartHash(const V2::ProjectPartContainer &projectPart)
|
|
|
|
|
{
|
|
|
|
|
QCryptographicHash hash(QCryptographicHash::Sha1);
|
|
|
|
|
|
|
|
|
|
hashProjectPart(hash, projectPart);
|
|
|
|
|
|
|
|
|
|
auto result = hash.result();
|
|
|
|
|
|
|
|
|
|
return result.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ClangBackEnd
|