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)
|
static Utils::optional<Tool> resolveTool(const Tool &tool)
|
||||||
{
|
{
|
||||||
const FilePaths dirs = Environment::systemEnvironment().path() + tool.additionalSearchDirs;
|
const FilePath executable =
|
||||||
const FilePath executable = tool.command.executable().withExecutableSuffix().searchInDirectories(dirs);
|
tool.command.executable().withExecutableSuffix().searchInPath(tool.additionalSearchDirs);
|
||||||
Tool resolvedTool = tool;
|
Tool resolvedTool = tool;
|
||||||
resolvedTool.command.setExecutable(executable);
|
resolvedTool.command.setExecutable(executable);
|
||||||
return executable.isEmpty() ? Utils::nullopt : Utils::make_optional(resolvedTool);
|
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);
|
return Environment::systemEnvironment().searchInPath(path(), dirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FilePath FilePath::searchInPath(const QList<FilePath> &additionalDirs) const
|
||||||
|
{
|
||||||
|
return searchInDirectories(deviceEnvironment().path() + additionalDirs);
|
||||||
|
}
|
||||||
|
|
||||||
Environment FilePath::deviceEnvironment() const
|
Environment FilePath::deviceEnvironment() const
|
||||||
{
|
{
|
||||||
if (needsDevice()) {
|
if (needsDevice()) {
|
||||||
|
@@ -176,6 +176,7 @@ public:
|
|||||||
QUrl toUrl() const;
|
QUrl toUrl() const;
|
||||||
|
|
||||||
FilePath searchInDirectories(const QList<FilePath> &dirs) const;
|
FilePath searchInDirectories(const QList<FilePath> &dirs) const;
|
||||||
|
FilePath searchInPath(const QList<FilePath> &additionalDirs = {}) const;
|
||||||
Environment deviceEnvironment() const;
|
Environment deviceEnvironment() const;
|
||||||
|
|
||||||
static QString formatFilePaths(const QList<FilePath> &files, const QString &separator);
|
static QString formatFilePaths(const QList<FilePath> &files, const QString &separator);
|
||||||
|
@@ -223,9 +223,7 @@ FilePath PathChooserPrivate::expandedPath(const QString &input) const
|
|||||||
switch (m_acceptingKind) {
|
switch (m_acceptingKind) {
|
||||||
case PathChooser::Command:
|
case PathChooser::Command:
|
||||||
case PathChooser::ExistingCommand: {
|
case PathChooser::ExistingCommand: {
|
||||||
FilePaths searchPaths = env.path();
|
const FilePath expanded = path.searchInPath({m_baseDirectory});
|
||||||
searchPaths.append(m_baseDirectory);
|
|
||||||
const FilePath expanded = path.searchInDirectories(searchPaths);
|
|
||||||
return expanded.isEmpty() ? path : expanded;
|
return expanded.isEmpty() ? path : expanded;
|
||||||
}
|
}
|
||||||
case PathChooser::Any:
|
case PathChooser::Any:
|
||||||
|
@@ -186,9 +186,8 @@ void CMakeToolManager::autoDetectCMakeForDevice(const FilePath &deviceRoot,
|
|||||||
{
|
{
|
||||||
QStringList messages{tr("Searching CMake binaries...")};
|
QStringList messages{tr("Searching CMake binaries...")};
|
||||||
const FilePaths candidates = {deviceRoot.withNewPath("cmake")};
|
const FilePaths candidates = {deviceRoot.withNewPath("cmake")};
|
||||||
const Environment env = deviceRoot.deviceEnvironment();
|
|
||||||
for (const FilePath &candidate : candidates) {
|
for (const FilePath &candidate : candidates) {
|
||||||
const FilePath cmake = candidate.searchInDirectories(env.path());
|
const FilePath cmake = candidate.searchInPath();
|
||||||
if (!cmake.isEmpty()) {
|
if (!cmake.isEmpty()) {
|
||||||
registerCMakeByPath(cmake, detectionSource);
|
registerCMakeByPath(cmake, detectionSource);
|
||||||
messages.append(tr("Found \"%1\"").arg(cmake.toUserOutput()));
|
messages.append(tr("Found \"%1\"").arg(cmake.toUserOutput()));
|
||||||
|
@@ -70,7 +70,7 @@ static bool runPatchHelper(const QByteArray &input, const FilePath &workingDirec
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!patch.exists() && !patch.searchInDirectories(Environment::systemEnvironment().path()).exists()) {
|
if (!patch.exists() && !patch.searchInPath().exists()) {
|
||||||
MessageManager::writeDisrupting(
|
MessageManager::writeDisrupting(
|
||||||
QApplication::translate("Core::PatchTool",
|
QApplication::translate("Core::PatchTool",
|
||||||
"The patch-command configured in the general \"Environment\" "
|
"The patch-command configured in the general \"Environment\" "
|
||||||
|
Reference in New Issue
Block a user