forked from qt-creator/qt-creator
Utils: Replace Environment::isSameExecutable()
... by FilePath::isSameExecutable(). The only non-mechanical case is the use inside QmakeBuildSystem::testToolChain using a build environment instead of the FilePath's device environment. This make a difference in theory due to the use of PATHEXT in the actual check, but I believe the case that someone creates a 'qmake.foo' and a 'qmake.bar', adds .foo and .bar to PATHEXT and then complains that there's a warning missing about not-matching mkspecs has zero likelihood in reality (and will break other places in Creator anyway). Change-Id: Id6a8d1e4dc2eb74ca81610ccb1c4ee94c6f47e12 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -168,21 +168,6 @@ static QStringList appendExeExtensions(const Environment &env, const QString &ex
|
||||
return execs;
|
||||
}
|
||||
|
||||
bool Environment::isSameExecutable(const QString &exe1, const QString &exe2) const
|
||||
{
|
||||
const QStringList exe1List = appendExeExtensions(*this, exe1);
|
||||
const QStringList exe2List = appendExeExtensions(*this, exe2);
|
||||
for (const QString &i1 : exe1List) {
|
||||
for (const QString &i2 : exe2List) {
|
||||
const FilePath f1 = FilePath::fromString(i1);
|
||||
const FilePath f2 = FilePath::fromString(i2);
|
||||
if (f1.isSameFile(f2))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Environment::expandedValueForKey(const QString &key) const
|
||||
{
|
||||
return expandVariables(m_dict.value(key));
|
||||
|
@@ -65,8 +65,6 @@ public:
|
||||
FilePaths path() const;
|
||||
FilePaths pathListValue(const QString &varName) const;
|
||||
|
||||
bool isSameExecutable(const QString &exe1, const QString &exe2) const;
|
||||
|
||||
QString expandedValueForKey(const QString &key) const;
|
||||
QString expandVariables(const QString &input) const;
|
||||
FilePath expandVariables(const FilePath &input) const;
|
||||
|
@@ -1189,9 +1189,7 @@ Toolchains GccToolChainFactory::autoDetectToolchains(
|
||||
|| compilerPath.toString().contains("ccache")) {
|
||||
existingTcMatches = existingCommand == compilerPath;
|
||||
} else {
|
||||
existingTcMatches = Environment::systemEnvironment()
|
||||
.isSameExecutable(existingCommand.toString(),
|
||||
compilerPath.toString());
|
||||
existingTcMatches = existingCommand.isSameExecutable(compilerPath);
|
||||
if (!existingTcMatches
|
||||
&& HostOsInfo::isWindowsHost()
|
||||
&& !existingCommand.needsDevice()
|
||||
@@ -1560,8 +1558,7 @@ ClangToolChain::~ClangToolChain()
|
||||
QObject::disconnect(m_mingwToolchainAddedConnection);
|
||||
}
|
||||
|
||||
bool ClangToolChain::matchesCompilerCommand(const Utils::FilePath &command,
|
||||
const Utils::Environment &env) const
|
||||
bool ClangToolChain::matchesCompilerCommand(const FilePath &command) const
|
||||
{
|
||||
if (!m_resolvedCompilerCommand) {
|
||||
m_resolvedCompilerCommand = FilePath();
|
||||
@@ -1576,9 +1573,9 @@ bool ClangToolChain::matchesCompilerCommand(const Utils::FilePath &command,
|
||||
}
|
||||
}
|
||||
if (!m_resolvedCompilerCommand->isEmpty()
|
||||
&& env.isSameExecutable(m_resolvedCompilerCommand->toString(), command.toString()))
|
||||
&& m_resolvedCompilerCommand->isSameExecutable(command))
|
||||
return true;
|
||||
return GccToolChain::matchesCompilerCommand(command, env);
|
||||
return GccToolChain::matchesCompilerCommand(command);
|
||||
}
|
||||
|
||||
static FilePath mingwAwareMakeCommand(const Environment &environment)
|
||||
|
@@ -190,9 +190,7 @@ public:
|
||||
explicit ClangToolChain(Utils::Id typeId);
|
||||
~ClangToolChain() override;
|
||||
|
||||
bool matchesCompilerCommand(
|
||||
const Utils::FilePath &command,
|
||||
const Utils::Environment &env = Utils::Environment::systemEnvironment()) const override;
|
||||
bool matchesCompilerCommand(const Utils::FilePath &command) const override;
|
||||
|
||||
Utils::FilePath makeCommand(const Utils::Environment &environment) const override;
|
||||
|
||||
|
@@ -1598,7 +1598,6 @@ static Toolchains detectClangClToolChainInPath(const FilePath &clangClPath,
|
||||
return res;
|
||||
}
|
||||
|
||||
Utils::Environment systemEnvironment = Utils::Environment::systemEnvironment();
|
||||
const Abi targetAbi = toolChain->targetAbi();
|
||||
const QString name = QString("%1LLVM %2 bit based on %3")
|
||||
.arg(QLatin1String(isDefault ? "Default " : ""))
|
||||
@@ -1613,8 +1612,7 @@ static Toolchains detectClangClToolChainInPath(const FilePath &clangClPath,
|
||||
return false;
|
||||
if (tc->language() != language)
|
||||
return false;
|
||||
return systemEnvironment.isSameExecutable(tc->compilerCommand().toString(),
|
||||
clangClPath.toString());
|
||||
return tc->compilerCommand().isSameExecutable(clangClPath);
|
||||
}));
|
||||
if (tc) {
|
||||
res << tc;
|
||||
|
@@ -325,9 +325,9 @@ void ToolChain::setCompilerCommand(const FilePath &command)
|
||||
toolChainUpdated();
|
||||
}
|
||||
|
||||
bool ToolChain::matchesCompilerCommand(const Utils::FilePath &command, const Environment &env) const
|
||||
bool ToolChain::matchesCompilerCommand(const FilePath &command) const
|
||||
{
|
||||
return env.isSameExecutable(compilerCommand().toString(), command.toString());
|
||||
return compilerCommand().isSameExecutable(command);
|
||||
}
|
||||
|
||||
void ToolChain::setCompilerCommandKey(const QString &commandKey)
|
||||
|
@@ -134,9 +134,7 @@ public:
|
||||
|
||||
virtual Utils::FilePath compilerCommand() const; // FIXME: De-virtualize.
|
||||
void setCompilerCommand(const Utils::FilePath &command);
|
||||
virtual bool matchesCompilerCommand(
|
||||
const Utils::FilePath &command,
|
||||
const Utils::Environment &env = Utils::Environment::systemEnvironment()) const;
|
||||
virtual bool matchesCompilerCommand(const Utils::FilePath &command) const;
|
||||
|
||||
virtual QList<Utils::OutputLineParser *> createOutputParsers() const = 0;
|
||||
|
||||
|
@@ -1395,9 +1395,7 @@ void QmakeBuildSystem::testToolChain(ToolChain *tc, const FilePath &path) const
|
||||
return;
|
||||
|
||||
const FilePath expected = tc->compilerCommand();
|
||||
Environment env = buildConfiguration()->environment();
|
||||
|
||||
if (tc->matchesCompilerCommand(expected, env))
|
||||
if (tc->matchesCompilerCommand(expected))
|
||||
return;
|
||||
const QPair<FilePath, FilePath> pair{expected, path};
|
||||
if (m_toolChainWarnings.contains(pair))
|
||||
|
@@ -421,8 +421,7 @@ static void findSystemQt()
|
||||
if (BuildableHelperLibrary::isQtChooser(qmakePath))
|
||||
continue;
|
||||
const auto isSameQmake = [qmakePath](const QtVersion *version) {
|
||||
return Environment::systemEnvironment().
|
||||
isSameExecutable(qmakePath.toString(), version->qmakeFilePath().toString());
|
||||
return qmakePath.isSameExecutable(version->qmakeFilePath());
|
||||
};
|
||||
if (contains(m_versions, isSameQmake))
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user