forked from qt-creator/qt-creator
CMakePM: Replace QDir with FilePath in fileapiextractor
This allows remote support. Change-Id: I5ac46b1c2ed0e7e1fcc559522f1fcd902f83b8c0 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include <projectexplorer/projecttree.h>
|
#include <projectexplorer/projecttree.h>
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -148,7 +147,7 @@ PreprocessedData preprocess(FileApiData &data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVector<FolderNode::LocationInfo> extractBacktraceInformation(const BacktraceInfo &backtraces,
|
QVector<FolderNode::LocationInfo> extractBacktraceInformation(const BacktraceInfo &backtraces,
|
||||||
const QDir &sourceDir,
|
const FilePath &sourceDir,
|
||||||
int backtraceIndex,
|
int backtraceIndex,
|
||||||
unsigned int locationInfoPriority)
|
unsigned int locationInfoPriority)
|
||||||
{
|
{
|
||||||
@@ -162,8 +161,7 @@ QVector<FolderNode::LocationInfo> extractBacktraceInformation(const BacktraceInf
|
|||||||
|
|
||||||
const size_t fileIndex = static_cast<size_t>(btNode.file);
|
const size_t fileIndex = static_cast<size_t>(btNode.file);
|
||||||
QTC_ASSERT(fileIndex < backtraces.files.size(), break);
|
QTC_ASSERT(fileIndex < backtraces.files.size(), break);
|
||||||
const FilePath path = FilePath::fromString(
|
const FilePath path = sourceDir.pathAppended(backtraces.files[fileIndex]).absoluteFilePath();
|
||||||
sourceDir.absoluteFilePath(backtraces.files[fileIndex]));
|
|
||||||
|
|
||||||
if (btNode.command < 0) {
|
if (btNode.command < 0) {
|
||||||
// No command, skip: The file itself is already covered:-)
|
// No command, skip: The file itself is already covered:-)
|
||||||
@@ -193,10 +191,8 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
|
|||||||
const FilePath &buildDirectory,
|
const FilePath &buildDirectory,
|
||||||
bool haveLibrariesRelativeToBuildDirectory)
|
bool haveLibrariesRelativeToBuildDirectory)
|
||||||
{
|
{
|
||||||
QDir sourceDir(sourceDirectory.toString());
|
|
||||||
|
|
||||||
const QList<CMakeBuildTarget> result = transform<QList>(input.targetDetails,
|
const QList<CMakeBuildTarget> result = transform<QList>(input.targetDetails,
|
||||||
[&sourceDir, &sourceDirectory, &buildDirectory,
|
[&sourceDirectory, &buildDirectory,
|
||||||
&haveLibrariesRelativeToBuildDirectory](const TargetDetails &t) {
|
&haveLibrariesRelativeToBuildDirectory](const TargetDetails &t) {
|
||||||
const FilePath currentBuildDir = buildDirectory.resolvePath(t.buildDir);
|
const FilePath currentBuildDir = buildDirectory.resolvePath(t.buildDir);
|
||||||
|
|
||||||
@@ -221,29 +217,29 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
|
|||||||
: ct.executable.parentDir();
|
: ct.executable.parentDir();
|
||||||
ct.sourceDirectory = sourceDirectory.resolvePath(t.sourceDir);
|
ct.sourceDirectory = sourceDirectory.resolvePath(t.sourceDir);
|
||||||
|
|
||||||
ct.backtrace = extractBacktraceInformation(t.backtraceGraph, sourceDir, t.backtrace, 0);
|
ct.backtrace = extractBacktraceInformation(t.backtraceGraph, sourceDirectory, t.backtrace, 0);
|
||||||
|
|
||||||
for (const DependencyInfo &d : t.dependencies) {
|
for (const DependencyInfo &d : t.dependencies) {
|
||||||
ct.dependencyDefinitions.append(
|
ct.dependencyDefinitions.append(
|
||||||
extractBacktraceInformation(t.backtraceGraph, sourceDir, d.backtrace, 100));
|
extractBacktraceInformation(t.backtraceGraph, sourceDirectory, d.backtrace, 100));
|
||||||
}
|
}
|
||||||
for (const SourceInfo &si : t.sources) {
|
for (const SourceInfo &si : t.sources) {
|
||||||
ct.sourceDefinitions.append(
|
ct.sourceDefinitions.append(
|
||||||
extractBacktraceInformation(t.backtraceGraph, sourceDir, si.backtrace, 200));
|
extractBacktraceInformation(t.backtraceGraph, sourceDirectory, si.backtrace, 200));
|
||||||
}
|
}
|
||||||
for (const CompileInfo &ci : t.compileGroups) {
|
for (const CompileInfo &ci : t.compileGroups) {
|
||||||
for (const IncludeInfo &ii : ci.includes) {
|
for (const IncludeInfo &ii : ci.includes) {
|
||||||
ct.includeDefinitions.append(
|
ct.includeDefinitions.append(
|
||||||
extractBacktraceInformation(t.backtraceGraph, sourceDir, ii.backtrace, 300));
|
extractBacktraceInformation(t.backtraceGraph, sourceDirectory, ii.backtrace, 300));
|
||||||
}
|
}
|
||||||
for (const DefineInfo &di : ci.defines) {
|
for (const DefineInfo &di : ci.defines) {
|
||||||
ct.defineDefinitions.append(
|
ct.defineDefinitions.append(
|
||||||
extractBacktraceInformation(t.backtraceGraph, sourceDir, di.backtrace, 400));
|
extractBacktraceInformation(t.backtraceGraph, sourceDirectory, di.backtrace, 400));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const InstallDestination &id : t.installDestination) {
|
for (const InstallDestination &id : t.installDestination) {
|
||||||
ct.installDefinitions.append(
|
ct.installDefinitions.append(
|
||||||
extractBacktraceInformation(t.backtraceGraph, sourceDir, id.backtrace, 500));
|
extractBacktraceInformation(t.backtraceGraph, sourceDirectory, id.backtrace, 500));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct.targetType == ExecutableType) {
|
if (ct.targetType == ExecutableType) {
|
||||||
@@ -343,7 +339,6 @@ RawProjectParts generateRawProjectParts(const PreprocessedData &input,
|
|||||||
RawProjectParts rpps;
|
RawProjectParts rpps;
|
||||||
|
|
||||||
for (const TargetDetails &t : input.targetDetails) {
|
for (const TargetDetails &t : input.targetDetails) {
|
||||||
QDir sourceDir(sourceDirectory.toString());
|
|
||||||
bool needPostfix = t.compileGroups.size() > 1;
|
bool needPostfix = t.compileGroups.size() > 1;
|
||||||
int count = 1;
|
int count = 1;
|
||||||
for (const CompileInfo &ci : t.compileGroups) {
|
for (const CompileInfo &ci : t.compileGroups) {
|
||||||
@@ -390,7 +385,7 @@ RawProjectParts generateRawProjectParts(const PreprocessedData &input,
|
|||||||
SourceInfo si = t.sources.at(idx);
|
SourceInfo si = t.sources.at(idx);
|
||||||
if (si.isGenerated)
|
if (si.isGenerated)
|
||||||
continue;
|
continue;
|
||||||
sources.push_back(sourceDir.absoluteFilePath(si.path));
|
sources.push_back(sourceDirectory.pathAppended(si.path).absoluteFilePath().path());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are not in a pch compiler group, add all the headers that are not generated
|
// If we are not in a pch compiler group, add all the headers that are not generated
|
||||||
@@ -410,7 +405,8 @@ RawProjectParts generateRawProjectParts(const PreprocessedData &input,
|
|||||||
const auto mimeTypes = Utils::mimeTypesForFileName(si.path);
|
const auto mimeTypes = Utils::mimeTypesForFileName(si.path);
|
||||||
for (const auto &mime : mimeTypes)
|
for (const auto &mime : mimeTypes)
|
||||||
if (mime.inherits(headerMimeType))
|
if (mime.inherits(headerMimeType))
|
||||||
sources.push_back(sourceDir.absoluteFilePath(si.path));
|
sources.push_back(
|
||||||
|
sourceDirectory.pathAppended(si.path).absoluteFilePath().path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +427,7 @@ RawProjectParts generateRawProjectParts(const PreprocessedData &input,
|
|||||||
}).path);
|
}).path);
|
||||||
if (!precompiled_header.isEmpty()) {
|
if (!precompiled_header.isEmpty()) {
|
||||||
if (precompiled_header.toFileInfo().isRelative()) {
|
if (precompiled_header.toFileInfo().isRelative()) {
|
||||||
const FilePath parentDir = FilePath::fromString(sourceDir.absolutePath());
|
const FilePath parentDir = sourceDirectory.parentDir();
|
||||||
precompiled_header = parentDir.pathAppended(precompiled_header.toString());
|
precompiled_header = parentDir.pathAppended(precompiled_header.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#include <utils/filesystemwatcher.h>
|
#include <utils/filesystemwatcher.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QDir>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
Reference in New Issue
Block a user