From 9eb58a90c4fe5f880de3e2c27bed5536b386178e Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 9 May 2019 12:37:15 +0200 Subject: ProjectExplorer: Cache MSVC compiler path Change-Id: Ic849b2dcaed1de2659076c3b4731f4879a04aeb4 Reviewed-by: David Schulz --- src/plugins/projectexplorer/msvctoolchain.cpp | 10 ++++++++-- src/plugins/projectexplorer/msvctoolchain.h | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index dff7ef8559..db65595e3b 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -748,6 +748,7 @@ void MsvcToolChain::updateEnvironmentModifications(QList Utils::EnvironmentItem::sort(&modifications); if (modifications != m_environmentModifications) { m_environmentModifications = modifications; + rescanForCompiler(); toolChainUpdated(); } } @@ -995,6 +996,7 @@ bool MsvcToolChain::fromMap(const QVariantMap &data) m_abi = Abi::fromString(abiString); m_environmentModifications = Utils::EnvironmentItem::itemsFromVariantList( data.value(QLatin1String(environModsKeyC)).toList()); + rescanForCompiler(); initEnvModWatcher(Utils::runAsync(envModThreadPool(), &MsvcToolChain::environmentModifications, @@ -1206,11 +1208,16 @@ QString MsvcToolChain::makeCommand(const Utils::Environment &environment) const } Utils::FileName MsvcToolChain::compilerCommand() const +{ + return m_compilerCommand; +} + +void MsvcToolChain::rescanForCompiler() { Utils::Environment env = Utils::Environment::systemEnvironment(); addToEnvironment(env); - Utils::FileName clexe + m_compilerCommand = env.searchInPath(QLatin1String("cl.exe"), {}, [](const Utils::FileName &name) { QDir dir(QDir::cleanPath(name.toFileInfo().absolutePath() + QStringLiteral("/.."))); do { @@ -1220,7 +1227,6 @@ Utils::FileName MsvcToolChain::compilerCommand() const } while (dir.cdUp() && !dir.isRoot()); return false; }); - return clexe; } IOutputParser *MsvcToolChain::outputParser() const diff --git a/src/plugins/projectexplorer/msvctoolchain.h b/src/plugins/projectexplorer/msvctoolchain.h index bc7361a0ef..a6c08eaeea 100644 --- a/src/plugins/projectexplorer/msvctoolchain.h +++ b/src/plugins/projectexplorer/msvctoolchain.h @@ -111,7 +111,6 @@ public: const QString &batchFile, const QString &batchArgs, QMap &envPairs); - protected: class WarningFlagAdder { @@ -163,6 +162,7 @@ protected: private: void updateEnvironmentModifications(QList modifications); + void rescanForCompiler(); mutable QList m_environmentModifications; mutable QFutureWatcher m_envModWatcher; @@ -174,6 +174,8 @@ private: mutable Utils::Environment m_lastEnvironment; // Last checked 'incoming' environment. mutable Utils::Environment m_resultEnvironment; // Resulting environment for VC + Utils::FileName m_compilerCommand; + protected: Abi m_abi; -- cgit v1.2.1