forked from qt-creator/qt-creator
Utils: allow specifying the requested extension for searchInPath
Reducing the expected executable extensions can improve the performance for search in path on Window. Especially if PATHEXT and PATH has a lot of entries, since we collect file attributes for PATHEXT entry count times PATH entry count file paths. Use this optimization in the android toolchain to search for java.exe on windows. Change-Id: I2c2865d685c2de0c03a0fa1fbe7e8afd283174da Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -225,11 +225,12 @@ QString Environment::expandedValueForKey(const QString &key) const
|
||||
|
||||
FilePath Environment::searchInPath(const QString &executable,
|
||||
const FilePaths &additionalDirs,
|
||||
const FilePathPredicate &filter) const
|
||||
const FilePathPredicate &filter,
|
||||
FilePath::MatchScope scope) const
|
||||
{
|
||||
const FilePath exec = FilePath::fromUserInput(expandVariables(executable));
|
||||
const FilePaths dirs = path() + additionalDirs;
|
||||
return exec.searchInDirectories(dirs, filter, FilePath::WithAnySuffix);
|
||||
return exec.searchInDirectories(dirs, filter, scope);
|
||||
}
|
||||
|
||||
FilePaths Environment::path() const
|
||||
|
||||
@@ -61,7 +61,8 @@ public:
|
||||
|
||||
FilePath searchInPath(const QString &executable,
|
||||
const FilePaths &additionalDirs = FilePaths(),
|
||||
const FilePathPredicate &func = {}) const;
|
||||
const FilePathPredicate &func = {},
|
||||
FilePath::MatchScope = FilePath::WithAnySuffix) const;
|
||||
|
||||
FilePaths path() const;
|
||||
FilePaths pathListValue(const QString &varName) const;
|
||||
|
||||
@@ -94,7 +94,8 @@ void AndroidToolChain::addToEnvironment(Environment &env) const
|
||||
if (javaHome.exists()) {
|
||||
env.set(Constants::JAVA_HOME_ENV_VAR, javaHome.toUserOutput());
|
||||
const FilePath javaBin = javaHome.pathAppended("bin");
|
||||
const FilePath currentJavaFilePath = env.searchInPath("java");
|
||||
const FilePath currentJavaFilePath
|
||||
= env.searchInPath("java", {}, {}, FilePath::WithExeSuffix);
|
||||
if (!currentJavaFilePath.isChildOf(javaBin))
|
||||
env.prependOrSetPath(javaBin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user