QMakeProjectManager: Proliferate FilePath use a bit

Task-number: QTCREATORBUG-29140
Change-Id: I66511871789cd7428695eba8720e7ef6a2236497
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-06-07 09:48:25 +02:00
parent 8c381c719b
commit cab81a5d03

View File

@@ -643,33 +643,29 @@ QString QmakeBuildConfiguration::extractSpecFromArguments(QString *args,
if (parsedSpec.isEmpty()) if (parsedSpec.isEmpty())
return {}; return {};
FilePath baseMkspecDir = FilePath::fromUserInput(version->hostDataPath().toString() const FilePath baseMkspecDir = version->hostDataPath().pathAppended("mkspecs")
+ "/mkspecs"); .canonicalPath();
baseMkspecDir = FilePath::fromString(baseMkspecDir.toFileInfo().canonicalFilePath());
// if the path is relative it can be // if the path is relative it can be
// relative to the working directory (as found in the Makefiles) // relative to the working directory (as found in the Makefiles)
// or relatively to the mkspec directory // or relatively to the mkspec directory
// if it is the former we need to get the canonical form // if it is the former we need to get the canonical form
// for the other one we don't need to do anything // for the other one we don't need to do anything
if (parsedSpec.toFileInfo().isRelative()) { if (parsedSpec.isRelativePath()) {
if (QFileInfo::exists(directory.path() + QLatin1Char('/') + parsedSpec.toString())) FilePath mkspecs = directory.pathAppended(parsedSpec.path());
parsedSpec = FilePath::fromUserInput(directory.path() + QLatin1Char('/') + parsedSpec.toString()); if (mkspecs.exists())
parsedSpec = mkspecs;
else else
parsedSpec = FilePath::fromUserInput(baseMkspecDir.toString() + QLatin1Char('/') + parsedSpec.toString()); parsedSpec = baseMkspecDir.pathAppended(parsedSpec.path());
} }
QFileInfo f2 = parsedSpec.toFileInfo(); while (parsedSpec.isSymLink())
while (f2.isSymLink()) { parsedSpec = parsedSpec.symLinkTarget();
parsedSpec = FilePath::fromString(f2.symLinkTarget());
f2.setFile(parsedSpec.toString());
}
if (parsedSpec.isChildOf(baseMkspecDir)) { if (parsedSpec.isChildOf(baseMkspecDir)) {
parsedSpec = parsedSpec.relativeChildPath(baseMkspecDir); parsedSpec = parsedSpec.relativeChildPath(baseMkspecDir);
} else { } else {
FilePath sourceMkSpecPath = FilePath::fromString(version->sourcePath().toString() FilePath sourceMkSpecPath = version->sourcePath().pathAppended("mkspecs");
+ QLatin1String("/mkspecs"));
if (parsedSpec.isChildOf(sourceMkSpecPath)) if (parsedSpec.isChildOf(sourceMkSpecPath))
parsedSpec = parsedSpec.relativeChildPath(sourceMkSpecPath); parsedSpec = parsedSpec.relativeChildPath(sourceMkSpecPath);
} }