forked from qt-creator/qt-creator
CMake: Collect also remote filenames from generateBuildTargets()
QDir::cleanPath(...) doesn't do the right thing on stringified Utils::FilePaths. Use FilePath functions instead. Change-Id: Ied66f38dd30a15694bce12ed57d37411bb87f680 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -997,6 +997,13 @@ FilePath FilePath::absoluteFilePath() const
|
||||
return result;
|
||||
}
|
||||
|
||||
FilePath FilePath::absoluteFilePath(const FilePath &tail) const
|
||||
{
|
||||
if (FileUtils::isRelativePath(tail.m_data))
|
||||
return pathAppended(tail.m_data);
|
||||
return tail;
|
||||
}
|
||||
|
||||
/// Constructs an absolute FilePath from this path which
|
||||
/// is interpreted as being relative to \a anchor.
|
||||
FilePath FilePath::absoluteFromRelativePath(const FilePath &anchor) const
|
||||
|
@@ -137,6 +137,7 @@ public:
|
||||
FilePath parentDir() const;
|
||||
FilePath absolutePath() const;
|
||||
FilePath absoluteFilePath() const;
|
||||
FilePath absoluteFilePath(const FilePath &tail) const;
|
||||
FilePath absoluteFromRelativePath(const FilePath &anchor) const;
|
||||
|
||||
bool operator==(const FilePath &other) const;
|
||||
|
@@ -192,18 +192,15 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
|
||||
const FilePath &buildDirectory)
|
||||
{
|
||||
QDir sourceDir(sourceDirectory.toString());
|
||||
QDir buildDir(buildDirectory.toString());
|
||||
|
||||
const QList<CMakeBuildTarget> result = transform<QList>(
|
||||
input.targetDetails, [&sourceDir, &buildDir](const TargetDetails &t) -> CMakeBuildTarget {
|
||||
const auto currentBuildDir = QDir(buildDir.absoluteFilePath(t.buildDir.toString()));
|
||||
const QList<CMakeBuildTarget> result = transform<QList>(input.targetDetails,
|
||||
[&sourceDir, &sourceDirectory, &buildDirectory](const TargetDetails &t) {
|
||||
const FilePath currentBuildDir = buildDirectory.absoluteFilePath(t.buildDir);
|
||||
|
||||
CMakeBuildTarget ct;
|
||||
ct.title = t.name;
|
||||
ct.executable = t.artifacts.isEmpty()
|
||||
? FilePath()
|
||||
: FilePath::fromString(QDir::cleanPath(
|
||||
buildDir.absoluteFilePath(t.artifacts.at(0).toString())));
|
||||
if (!t.artifacts.isEmpty())
|
||||
ct.executable = buildDirectory.absoluteFilePath(t.artifacts.at(0));
|
||||
TargetType type = UtilityType;
|
||||
if (t.type == "EXECUTABLE")
|
||||
type = ExecutableType;
|
||||
@@ -217,10 +214,9 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
|
||||
type = UtilityType;
|
||||
ct.targetType = type;
|
||||
ct.workingDirectory = ct.executable.isEmpty()
|
||||
? FilePath::fromString(currentBuildDir.absolutePath())
|
||||
? currentBuildDir.absolutePath()
|
||||
: ct.executable.parentDir();
|
||||
ct.sourceDirectory = FilePath::fromString(
|
||||
QDir::cleanPath(sourceDir.absoluteFilePath(t.sourceDir.toString())));
|
||||
ct.sourceDirectory = sourceDirectory.absoluteFilePath(t.sourceDir);
|
||||
|
||||
ct.backtrace = extractBacktraceInformation(t.backtraceGraph, sourceDir, t.backtrace, 0);
|
||||
|
||||
@@ -271,8 +267,7 @@ QList<CMakeBuildTarget> generateBuildTargets(const PreprocessedData &input,
|
||||
if (part.startsWith("-"))
|
||||
continue;
|
||||
|
||||
FilePath tmp = FilePath::fromString(
|
||||
currentBuildDir.absoluteFilePath(QDir::fromNativeSeparators(part)));
|
||||
FilePath tmp = currentBuildDir.absoluteFilePath(FilePath::fromUserInput(part));
|
||||
|
||||
if (f.role == "libraries")
|
||||
tmp = tmp.parentDir();
|
||||
|
Reference in New Issue
Block a user