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