ProjectExplorer: filepathify gcc toolchain detection

Change-Id: I4114229033e2e9ba93d628d2014e224e3b1d5c1e
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2023-08-31 13:50:56 +02:00
parent 6f50addc1c
commit f2a93943f5

View File

@@ -1104,28 +1104,14 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
}); });
FilePaths compilerPaths; FilePaths compilerPaths;
if (device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
// FIXME: Merge with block below
FilePaths searchPaths = detector.searchPaths; FilePaths searchPaths = detector.searchPaths;
if (device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
if (searchPaths.isEmpty()) if (searchPaths.isEmpty())
searchPaths = device->systemEnvironment().path(); searchPaths = device->systemEnvironment().path();
for (const FilePath &deviceDir : std::as_const(searchPaths)) { searchPaths = Utils::transform(searchPaths, [&](const FilePath &onDevice) {
static const QRegularExpression regexp(binaryRegexp); return device->filePath(onDevice.path());
const auto callBack = [&compilerPaths, compilerName](const FilePath &candidate) { });
if (candidate.fileName() == compilerName) } else if (searchPaths.isEmpty()) {
compilerPaths << candidate;
else if (regexp.match(candidate.path()).hasMatch())
compilerPaths << candidate;
return IterationPolicy::Continue;
};
const FilePath globalDir = device->filePath(deviceDir.path());
globalDir.iterateDirectory(callBack, {nameFilters, QDir::Files | QDir::Executable});
}
} else {
// The normal, local host case.
FilePaths searchPaths = detector.searchPaths;
if (searchPaths.isEmpty()) {
searchPaths = Environment::systemEnvironment().path(); searchPaths = Environment::systemEnvironment().path();
searchPaths << gnuSearchPathsFromRegistry(); searchPaths << gnuSearchPathsFromRegistry();
searchPaths << atmelSearchPathsFromRegistry(); searchPaths << atmelSearchPathsFromRegistry();
@@ -1143,19 +1129,15 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
searchPaths << ccachePath; searchPaths << ccachePath;
} }
} }
for (const FilePath &dir : std::as_const(searchPaths)) {
for (const FilePath &searchPath : std::as_const(searchPaths)) {
static const QRegularExpression regexp(binaryRegexp); static const QRegularExpression regexp(binaryRegexp);
QDir binDir(dir.toString()); const auto callBack = [&compilerPaths, compilerName](const FilePath &candidate) {
const QStringList fileNames = binDir.entryList(nameFilters, if (candidate.fileName() == compilerName || regexp.match(candidate.path()).hasMatch())
QDir::Files | QDir::Executable); compilerPaths << candidate;
for (const QString &fileName : fileNames) { return IterationPolicy::Continue;
if (fileName != compilerName && };
!regexp.match(QFileInfo(fileName).completeBaseName()).hasMatch()) { searchPath.iterateDirectory(callBack, {nameFilters, QDir::Files | QDir::Executable});
continue;
}
compilerPaths << FilePath::fromString(binDir.filePath(fileName));
}
}
} }
return compilerPaths; return compilerPaths;