forked from qt-creator/qt-creator
ProjectExplorer: filepathify gcc toolchain detection
Change-Id: I4114229033e2e9ba93d628d2014e224e3b1d5c1e Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1104,28 +1104,14 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
|
||||
});
|
||||
|
||||
FilePaths compilerPaths;
|
||||
|
||||
if (device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
// FIXME: Merge with block below
|
||||
FilePaths searchPaths = detector.searchPaths;
|
||||
if (device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
if (searchPaths.isEmpty())
|
||||
searchPaths = device->systemEnvironment().path();
|
||||
for (const FilePath &deviceDir : std::as_const(searchPaths)) {
|
||||
static const QRegularExpression regexp(binaryRegexp);
|
||||
const auto callBack = [&compilerPaths, compilerName](const FilePath &candidate) {
|
||||
if (candidate.fileName() == compilerName)
|
||||
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 = Utils::transform(searchPaths, [&](const FilePath &onDevice) {
|
||||
return device->filePath(onDevice.path());
|
||||
});
|
||||
} else if (searchPaths.isEmpty()) {
|
||||
searchPaths = Environment::systemEnvironment().path();
|
||||
searchPaths << gnuSearchPathsFromRegistry();
|
||||
searchPaths << atmelSearchPathsFromRegistry();
|
||||
@@ -1143,19 +1129,15 @@ static FilePaths findCompilerCandidates(const ToolchainDetector &detector,
|
||||
searchPaths << ccachePath;
|
||||
}
|
||||
}
|
||||
for (const FilePath &dir : std::as_const(searchPaths)) {
|
||||
|
||||
for (const FilePath &searchPath : std::as_const(searchPaths)) {
|
||||
static const QRegularExpression regexp(binaryRegexp);
|
||||
QDir binDir(dir.toString());
|
||||
const QStringList fileNames = binDir.entryList(nameFilters,
|
||||
QDir::Files | QDir::Executable);
|
||||
for (const QString &fileName : fileNames) {
|
||||
if (fileName != compilerName &&
|
||||
!regexp.match(QFileInfo(fileName).completeBaseName()).hasMatch()) {
|
||||
continue;
|
||||
}
|
||||
compilerPaths << FilePath::fromString(binDir.filePath(fileName));
|
||||
}
|
||||
}
|
||||
const auto callBack = [&compilerPaths, compilerName](const FilePath &candidate) {
|
||||
if (candidate.fileName() == compilerName || regexp.match(candidate.path()).hasMatch())
|
||||
compilerPaths << candidate;
|
||||
return IterationPolicy::Continue;
|
||||
};
|
||||
searchPath.iterateDirectory(callBack, {nameFilters, QDir::Files | QDir::Executable});
|
||||
}
|
||||
|
||||
return compilerPaths;
|
||||
|
Reference in New Issue
Block a user