forked from qt-creator/qt-creator
ProjectExplorer: Consolidate adding Qt host binaries to path
Change-Id: Ia301ae016d1d79e55040003280360aba095f2c03 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
@@ -91,10 +90,7 @@ GenericBuildConfigurationFactory::GenericBuildConfigurationFactory()
|
||||
|
||||
void GenericBuildConfiguration::addToEnvironment(Utils::Environment &env) const
|
||||
{
|
||||
prependCompilerPathToEnvironment(kit(), env);
|
||||
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(kit());
|
||||
if (qt)
|
||||
env.prependOrSetPath(qt->hostBinPath().toString());
|
||||
QtSupport::QtKitAspect::addHostBinariesToPath(kit(), env);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -577,24 +577,6 @@ 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(Kit *k, Environment &env)
|
||||
{
|
||||
const ToolChain *tc = ToolChainKitAspect::cxxToolChain(k);
|
||||
|
||||
if (!tc)
|
||||
return;
|
||||
|
||||
const FilePath compilerDir = tc->compilerCommand().parentDir();
|
||||
if (!compilerDir.isEmpty())
|
||||
env.prependOrSetPath(compilerDir.toString());
|
||||
}
|
||||
|
||||
///
|
||||
// IBuildConfigurationFactory
|
||||
///
|
||||
|
@@ -110,7 +110,6 @@ public:
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
static void prependCompilerPathToEnvironment(Kit *k, Utils::Environment &env);
|
||||
void updateCacheAndEmitEnvironmentChanged();
|
||||
|
||||
ProjectExplorer::BuildDirectoryAspect *buildDirectoryAspect() const;
|
||||
|
@@ -832,15 +832,7 @@ BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const
|
||||
|
||||
void QmakeBuildConfiguration::addToEnvironment(Environment &env) const
|
||||
{
|
||||
setupBuildEnvironment(kit(), env);
|
||||
}
|
||||
|
||||
void QmakeBuildConfiguration::setupBuildEnvironment(Kit *k, Environment &env)
|
||||
{
|
||||
prependCompilerPathToEnvironment(k, env);
|
||||
const BaseQtVersion *qt = QtKitAspect::qtVersion(k);
|
||||
if (qt && !qt->hostBinPath().isEmpty())
|
||||
env.prependOrSetPath(qt->hostBinPath().toString());
|
||||
QtSupport::QtKitAspect::addHostBinariesToPath(kit(), env);
|
||||
}
|
||||
|
||||
QmakeBuildConfiguration::LastKitState::LastKitState() = default;
|
||||
|
@@ -91,7 +91,6 @@ public:
|
||||
BuildType buildType() const override;
|
||||
|
||||
void addToEnvironment(Utils::Environment &env) const override;
|
||||
static void setupBuildEnvironment(ProjectExplorer::Kit *k, Utils::Environment &env);
|
||||
|
||||
static QString unalignedBuildDirWarning();
|
||||
static bool isBuildDirAtSafeLocation(const QString &sourceDir, const QString &buildDir);
|
||||
|
@@ -371,6 +371,27 @@ void QtKitAspect::setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v)
|
||||
setQtVersionId(k, v->uniqueId());
|
||||
}
|
||||
|
||||
/*!
|
||||
* Helper function that prepends the directory containing the C++ toolchain and Qt
|
||||
* binaries to PATH. This is used to in build configurations targeting broken build
|
||||
* systems to provide hints about which binaries to use.
|
||||
*/
|
||||
|
||||
void QtKitAspect::addHostBinariesToPath(const Kit *k, Environment &env)
|
||||
{
|
||||
if (const ToolChain *tc = ToolChainKitAspect::cxxToolChain(k)) {
|
||||
const FilePath compilerDir = tc->compilerCommand().parentDir();
|
||||
if (!compilerDir.isEmpty())
|
||||
env.prependOrSetPath(compilerDir.toString());
|
||||
}
|
||||
|
||||
if (const BaseQtVersion *qt = qtVersion(k)) {
|
||||
const FilePath hostBinPath = qt->hostBinPath();
|
||||
if (!hostBinPath.isEmpty())
|
||||
env.prependOrSetPath(hostBinPath.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void QtKitAspect::qtVersionsChanged(const QList<int> &addedIds,
|
||||
const QList<int> &removedIds,
|
||||
const QList<int> &changedIds)
|
||||
|
@@ -63,6 +63,8 @@ public:
|
||||
static BaseQtVersion *qtVersion(const ProjectExplorer::Kit *k);
|
||||
static void setQtVersion(ProjectExplorer::Kit *k, const BaseQtVersion *v);
|
||||
|
||||
static void addHostBinariesToPath(const ProjectExplorer::Kit *k, Utils::Environment &env);
|
||||
|
||||
static ProjectExplorer::Kit::Predicate platformPredicate(Utils::Id availablePlatforms);
|
||||
static ProjectExplorer::Kit::Predicate
|
||||
qtVersionPredicate(const QSet<Utils::Id> &required = QSet<Utils::Id>(),
|
||||
|
Reference in New Issue
Block a user