forked from qt-creator/qt-creator
Utils: Introduce a FilePath::searchInPath() convenience function
Diverts to searchInDirectory(). Use it in some places. Change-Id: I9e5642f0ae0ed4dd9fb9f34bcaa11a25bd26c690 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -118,8 +118,8 @@ static QVector<Tool> toolsForFilePath(const FilePath &fp)
|
||||
|
||||
static Utils::optional<Tool> resolveTool(const Tool &tool)
|
||||
{
|
||||
const FilePaths dirs = Environment::systemEnvironment().path() + tool.additionalSearchDirs;
|
||||
const FilePath executable = tool.command.executable().withExecutableSuffix().searchInDirectories(dirs);
|
||||
const FilePath executable =
|
||||
tool.command.executable().withExecutableSuffix().searchInPath(tool.additionalSearchDirs);
|
||||
Tool resolvedTool = tool;
|
||||
resolvedTool.command.setExecutable(executable);
|
||||
return executable.isEmpty() ? Utils::nullopt : Utils::make_optional(resolvedTool);
|
||||
|
@@ -1168,6 +1168,11 @@ FilePath FilePath::searchInDirectories(const FilePaths &dirs) const
|
||||
return Environment::systemEnvironment().searchInPath(path(), dirs);
|
||||
}
|
||||
|
||||
FilePath FilePath::searchInPath(const QList<FilePath> &additionalDirs) const
|
||||
{
|
||||
return searchInDirectories(deviceEnvironment().path() + additionalDirs);
|
||||
}
|
||||
|
||||
Environment FilePath::deviceEnvironment() const
|
||||
{
|
||||
if (needsDevice()) {
|
||||
|
@@ -176,6 +176,7 @@ public:
|
||||
QUrl toUrl() const;
|
||||
|
||||
FilePath searchInDirectories(const QList<FilePath> &dirs) const;
|
||||
FilePath searchInPath(const QList<FilePath> &additionalDirs = {}) const;
|
||||
Environment deviceEnvironment() const;
|
||||
|
||||
static QString formatFilePaths(const QList<FilePath> &files, const QString &separator);
|
||||
|
@@ -223,9 +223,7 @@ FilePath PathChooserPrivate::expandedPath(const QString &input) const
|
||||
switch (m_acceptingKind) {
|
||||
case PathChooser::Command:
|
||||
case PathChooser::ExistingCommand: {
|
||||
FilePaths searchPaths = env.path();
|
||||
searchPaths.append(m_baseDirectory);
|
||||
const FilePath expanded = path.searchInDirectories(searchPaths);
|
||||
const FilePath expanded = path.searchInPath({m_baseDirectory});
|
||||
return expanded.isEmpty() ? path : expanded;
|
||||
}
|
||||
case PathChooser::Any:
|
||||
|
@@ -186,9 +186,8 @@ void CMakeToolManager::autoDetectCMakeForDevice(const FilePath &deviceRoot,
|
||||
{
|
||||
QStringList messages{tr("Searching CMake binaries...")};
|
||||
const FilePaths candidates = {deviceRoot.withNewPath("cmake")};
|
||||
const Environment env = deviceRoot.deviceEnvironment();
|
||||
for (const FilePath &candidate : candidates) {
|
||||
const FilePath cmake = candidate.searchInDirectories(env.path());
|
||||
const FilePath cmake = candidate.searchInPath();
|
||||
if (!cmake.isEmpty()) {
|
||||
registerCMakeByPath(cmake, detectionSource);
|
||||
messages.append(tr("Found \"%1\"").arg(cmake.toUserOutput()));
|
||||
|
@@ -70,7 +70,7 @@ static bool runPatchHelper(const QByteArray &input, const FilePath &workingDirec
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!patch.exists() && !patch.searchInDirectories(Environment::systemEnvironment().path()).exists()) {
|
||||
if (!patch.exists() && !patch.searchInPath().exists()) {
|
||||
MessageManager::writeDisrupting(
|
||||
QApplication::translate("Core::PatchTool",
|
||||
"The patch-command configured in the general \"Environment\" "
|
||||
|
Reference in New Issue
Block a user