Commit 10cb0b77 authored by Tobias Hunger's avatar Tobias Hunger

ProjectExplorer: Do not prepend compiler path to PATH everywhere!

Do not unconditionally prepend the (c++) compiler path to PATH for
all projects using GCC-derived toolchains.

Prepend the compiler path in the Qmake- and GenericBuildConfigurations
instead.

Also change the order: Apply buildconfiguration's addToEnvironment first,
only then apply the kit's addToEnvironment.

This does change a few things:
 * CMake and Qbs will now get the normal PATH
 * MSVC compilers will have their compiler path prepended to PATH
   by the effected BuildConfigurations. This should be harmless,
   since that happens before the environment setup script is appended.

Task-number: QTCREATORBUG-18714
Change-Id: I548182bc447d80d24f4de4ce7cf12ee1a753ed26
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 527594bb
......@@ -196,6 +196,11 @@ BuildConfiguration::BuildType GenericBuildConfiguration::buildType() const
return Unknown;
}
void GenericBuildConfiguration::addToEnvironment(Utils::Environment &env) const
{
prependCompilerPathToEnvironment(env);
}
////////////////////////////////////////////////////////////////////////////////////
// GenericBuildSettingsWidget
////////////////////////////////////////////////////////////////////////////////////
......
......@@ -52,6 +52,8 @@ public:
BuildType buildType() const override;
void addToEnvironment(Utils::Environment &env) const final;
protected:
GenericBuildConfiguration(ProjectExplorer::Target *parent, GenericBuildConfiguration *source);
GenericBuildConfiguration(ProjectExplorer::Target *parent, Core::Id id);
......
......@@ -33,7 +33,10 @@
#include "kit.h"
#include <projectexplorer/buildenvironmentwidget.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmacroexpander.h>
#include <projectexplorer/target.h>
#include <extensionsystem/pluginmanager.h>
#include <coreplugin/idocument.h>
......@@ -238,8 +241,8 @@ Utils::Environment BuildConfiguration::baseEnvironment() const
Utils::Environment result;
if (useSystemEnvironment())
result = Utils::Environment::systemEnvironment();
target()->kit()->addToEnvironment(result);
addToEnvironment(result);
target()->kit()->addToEnvironment(result);
return result;
}
......@@ -330,6 +333,25 @@ bool BuildConfiguration::isActive() const
return target()->isActive() && target()->activeBuildConfiguration() == this;
}
/*!
* Helper function that prepends the directory containing the C++ toolchain to
* PATH. This is used to in build configurations targeting broken build systems
* to provide hints about which compiler to use.
*/
void BuildConfiguration::prependCompilerPathToEnvironment(Utils::Environment &env) const
{
const ToolChain *tc
= ToolChainKitInformation::toolChain(target()->kit(),
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
if (!tc)
return;
const Utils::FileName compilerDir = tc->compilerCommand().parentDir();
if (!compilerDir.isEmpty())
env.prependOrSetPath(compilerDir.toString());
}
///
// IBuildConfigurationFactory
///
......
......@@ -90,6 +90,8 @@ public:
bool isActive() const override;
void prependCompilerPathToEnvironment(Utils::Environment &env) const;
signals:
void environmentChanged();
void buildDirectoryChanged();
......
......@@ -718,7 +718,7 @@ GccToolChain::GccToolChain(const GccToolChain &) = default;
void GccToolChain::addToEnvironment(Environment &env) const
{
addCommandPathToEnvironment(m_compilerCommand, env);
Q_UNUSED(env);
}
FileNameList GccToolChain::suggestedMkspecList() const
......
......@@ -756,6 +756,11 @@ BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const
return Release;
}
void QmakeBuildConfiguration::addToEnvironment(Environment &env) const
{
prependCompilerPathToEnvironment(env);
}
QmakeBuildConfiguration::LastKitState::LastKitState() { }
QmakeBuildConfiguration::LastKitState::LastKitState(Kit *k)
......
......@@ -99,6 +99,8 @@ public:
BuildType buildType() const override;
void addToEnvironment(Utils::Environment &env) const override;
void emitProFileEvaluateNeeded();
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment