aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2018-04-10 15:35:34 +0200
committerhjk <hjk@qt.io>2018-04-13 13:02:59 +0000
commitd21a43d9a884e0ab9a90c7c2b25d2aa9c1ab23cc (patch)
treee1bd5c05d9cee07d1d2523ec20ab389c0536f844 /src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
parentc3275c935cc470f4fc24c3d63a4396c97e9ba28c (diff)
ProjectExplorer: Introduce runconfig aspects for some bool values
And use it to handle adding extra library path for qbs and qmake and and the DYLD debug suffix for qmake. Could possibly be used more uniformly at some stage e.g. for CMake. Change-Id: I0c4581b4e36960fc76d056c65c487d7c43a1be08 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp')
-rw-r--r--src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp39
1 files changed, 12 insertions, 27 deletions
diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
index f6ee748b37..b2e404c19d 100644
--- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
+++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
@@ -33,8 +33,6 @@
#include <projectexplorer/localenvironmentaspect.h>
#include <projectexplorer/project.h>
-#include <projectexplorer/projectexplorer.h>
-#include <projectexplorer/projectexplorersettings.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
@@ -52,8 +50,6 @@ namespace Internal {
const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
-static QString usingLibraryPathsKey() { return QString("Qbs.RunConfiguration.UsingLibraryPaths"); }
-
// --------------------------------------------------------------------
// QbsRunConfigurationWidget:
// --------------------------------------------------------------------
@@ -61,7 +57,7 @@ static QString usingLibraryPathsKey() { return QString("Qbs.RunConfiguration.Usi
class QbsRunConfigurationWidget : public QWidget
{
public:
- explicit QbsRunConfigurationWidget(QbsRunConfiguration *rc)
+ explicit QbsRunConfigurationWidget(RunConfiguration *rc)
{
auto toplayout = new QFormLayout(this);
@@ -69,13 +65,7 @@ public:
rc->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, toplayout);
rc->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, toplayout);
rc->extraAspect<TerminalAspect>()->addToMainConfigurationWidget(this, toplayout);
-
- auto usingLibPathsCheckBox = new QCheckBox;
- usingLibPathsCheckBox->setText(QbsRunConfiguration::tr("Add library paths to run environment"));
- usingLibPathsCheckBox->setChecked(rc->usingLibraryPaths());
- connect(usingLibPathsCheckBox, &QCheckBox::toggled,
- rc, &QbsRunConfiguration::setUsingLibraryPaths);
- toplayout->addRow(QString(), usingLibPathsCheckBox);
+ rc->extraAspect<UseLibraryPathsAspect>()->addToMainConfigurationWidget(this, toplayout);
Core::VariableChooser::addSupportForChildWidgets(this, rc->macroExpander());
}
@@ -88,8 +78,6 @@ public:
QbsRunConfiguration::QbsRunConfiguration(Target *target)
: RunConfiguration(target, QBS_RC_PREFIX)
{
- m_usingLibraryPaths = ProjectExplorerPlugin::projectExplorerSettings().addLibraryPathsToRunEnv;
-
auto envAspect = new LocalEnvironmentAspect(this,
[](RunConfiguration *rc, Environment &env) {
static_cast<QbsRunConfiguration *>(rc)->addToBaseEnvironment(env);
@@ -103,6 +91,11 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target)
setOutputFormatter<QtSupport::QtOutputFormatter>();
+ auto libAspect = new UseLibraryPathsAspect(this, "Qbs.RunConfiguration.UsingLibraryPaths");
+ addExtraAspect(libAspect);
+ connect(libAspect, &UseLibraryPathsAspect::changed,
+ envAspect, &EnvironmentAspect::environmentChanged);
+
connect(project(), &Project::parsingFinished, this,
[envAspect]() { envAspect->buildEnvironmentHasChanged(); });
@@ -120,9 +113,7 @@ QbsRunConfiguration::QbsRunConfiguration(Target *target)
QVariantMap QbsRunConfiguration::toMap() const
{
- QVariantMap map = RunConfiguration::toMap();
- map.insert(usingLibraryPathsKey(), usingLibraryPaths());
- return map;
+ return RunConfiguration::toMap();
}
bool QbsRunConfiguration::fromMap(const QVariantMap &map)
@@ -130,8 +121,6 @@ bool QbsRunConfiguration::fromMap(const QVariantMap &map)
if (!RunConfiguration::fromMap(map))
return false;
- m_usingLibraryPaths = map.value(usingLibraryPathsKey(), true).toBool();
-
updateTargetInformation();
return true;
}
@@ -158,15 +147,11 @@ Runnable QbsRunConfiguration::runnable() const
return r;
}
-void QbsRunConfiguration::setUsingLibraryPaths(bool useLibPaths)
-{
- m_usingLibraryPaths = useLibPaths;
- extraAspect<LocalEnvironmentAspect>()->environmentChanged();
-}
-
void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
{
- const auto key = qMakePair(env.toStringList(), m_usingLibraryPaths);
+ bool usingLibraryPaths = extraAspect<UseLibraryPathsAspect>()->value();
+
+ const auto key = qMakePair(env.toStringList(), usingLibraryPaths);
const auto it = m_envCache.constFind(key);
if (it != m_envCache.constEnd()) {
env = it.value();
@@ -174,7 +159,7 @@ void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
}
BuildTargetInfo bti = target()->applicationTargets().buildTargetInfo(buildKey());
if (bti.runEnvModifier)
- bti.runEnvModifier(env, m_usingLibraryPaths);
+ bti.runEnvModifier(env, usingLibraryPaths);
m_envCache.insert(key, env);
}