Move build environment customization down to BuildConfiguration

The functionality was duplicated between the Qt4 and CMake build
configurations and their configuration widgets. This change moves it
down to BuildConfiguration, in addition also making it available for the
Generic Project.

Also provides an upgrade path for the configuration.

Task-number: QTCREATOR-24
Reviewed-by: dt
Reviewed-by: Tobias Hunger
This commit is contained in:
Thorbjørn Lindeijer
2010-03-11 17:47:09 +01:00
parent 434e51c6be
commit 2a93b5401d
18 changed files with 194 additions and 392 deletions

View File

@@ -44,23 +44,19 @@ using namespace Internal;
namespace {
const char * const CMAKE_BC_ID("CMakeProjectManager.CMakeBuildConfiguration");
const char * const USER_ENVIRONMENT_CHANGES_KEY("CMakeProjectManager.CMakeBuildConfiguration.UserEnvironmentChanges");
const char * const MSVC_VERSION_KEY("CMakeProjectManager.CMakeBuildConfiguration.MsvcVersion");
const char * const BUILD_DIRECTORY_KEY("CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory");
} // namespace
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeTarget *parent) :
BuildConfiguration(parent, QLatin1String(CMAKE_BC_ID)),
m_toolChain(0),
m_clearSystemEnvironment(false)
m_toolChain(0)
{
}
CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeTarget *parent, CMakeBuildConfiguration *source) :
BuildConfiguration(parent, source),
m_toolChain(0),
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_buildDirectory(source->m_buildDirectory),
m_msvcVersion(source->m_msvcVersion)
{
@@ -70,8 +66,6 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(CMakeTarget *parent, CMakeBuild
QVariantMap CMakeBuildConfiguration::toMap() const
{
QVariantMap map(ProjectExplorer::BuildConfiguration::toMap());
map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY),
ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
map.insert(QLatin1String(MSVC_VERSION_KEY), m_msvcVersion);
map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory);
return map;
@@ -79,7 +73,6 @@ QVariantMap CMakeBuildConfiguration::toMap() const
bool CMakeBuildConfiguration::fromMap(const QVariantMap &map)
{
m_userEnvironmentChanges = ProjectExplorer::EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
m_msvcVersion = map.value(QLatin1String(MSVC_VERSION_KEY)).toString();
m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString();
@@ -96,55 +89,6 @@ CMakeTarget *CMakeBuildConfiguration::cmakeTarget() const
return static_cast<CMakeTarget *>(target());
}
ProjectExplorer::Environment CMakeBuildConfiguration::baseEnvironment() const
{
ProjectExplorer::Environment env = useSystemEnvironment() ?
ProjectExplorer::Environment(QProcess::systemEnvironment()) :
ProjectExplorer::Environment();
return env;
}
QString CMakeBuildConfiguration::baseEnvironmentText() const
{
if (useSystemEnvironment())
return tr("System Environment");
else
return tr("Clear Environment");
}
ProjectExplorer::Environment CMakeBuildConfiguration::environment() const
{
ProjectExplorer::Environment env = baseEnvironment();
env.modify(userEnvironmentChanges());
return env;
}
void CMakeBuildConfiguration::setUseSystemEnvironment(bool b)
{
if (b == m_clearSystemEnvironment)
return;
m_clearSystemEnvironment = !b;
emit environmentChanged();
}
bool CMakeBuildConfiguration::useSystemEnvironment() const
{
return !m_clearSystemEnvironment;
}
QList<ProjectExplorer::EnvironmentItem> CMakeBuildConfiguration::userEnvironmentChanges() const
{
return m_userEnvironmentChanges;
}
void CMakeBuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff)
{
if (m_userEnvironmentChanges == diff)
return;
m_userEnvironmentChanges = diff;
emit environmentChanged();
}
QString CMakeBuildConfiguration::buildDirectory() const
{
QString buildDirectory = m_buildDirectory;

View File

@@ -50,14 +50,6 @@ public:
CMakeTarget *cmakeTarget() const;
ProjectExplorer::Environment environment() const;
ProjectExplorer::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
bool useSystemEnvironment() const;
void setUseSystemEnvironment(bool b);
virtual QString buildDirectory() const;
ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
@@ -80,8 +72,6 @@ protected:
private:
void updateToolChain() const;
mutable ProjectExplorer::ToolChain *m_toolChain;
bool m_clearSystemEnvironment;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
QString m_buildDirectory;
QString m_msvcVersion;
};

View File

@@ -34,10 +34,10 @@
#include "cmaketarget.h"
#include "makestep.h"
#include "cmakeopenprojectwizard.h"
#include "cmakebuildenvironmentwidget.h"
#include "cmakebuildconfiguration.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/buildenvironmentwidget.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
@@ -449,7 +449,7 @@ ProjectExplorer::BuildConfigWidget *CMakeProject::createConfigWidget()
QList<ProjectExplorer::BuildConfigWidget*> CMakeProject::subConfigWidgets()
{
QList<ProjectExplorer::BuildConfigWidget*> list;
list << new CMakeBuildEnvironmentWidget(this);
list << new BuildEnvironmentWidget;
return list;
}

View File

@@ -11,7 +11,6 @@ HEADERS = cmakeproject.h \
makestep.h \
cmakerunconfiguration.h \
cmakeopenprojectwizard.h \
cmakebuildenvironmentwidget.h \
cmakebuildconfiguration.h
SOURCES = cmakeproject.cpp \
cmakeprojectplugin.cpp \
@@ -21,7 +20,6 @@ SOURCES = cmakeproject.cpp \
makestep.cpp \
cmakerunconfiguration.cpp \
cmakeopenprojectwizard.cpp \
cmakebuildenvironmentwidget.cpp \
cmakebuildconfiguration.cpp
RESOURCES += cmakeproject.qrc
FORMS +=

View File

@@ -33,6 +33,7 @@
#include "genericprojectconstants.h"
#include "generictarget.h"
#include <projectexplorer/buildenvironmentwidget.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <cpptools/cppmodelmanagerinterface.h>
@@ -399,7 +400,9 @@ ProjectExplorer::BuildConfigWidget *GenericProject::createConfigWidget()
QList<ProjectExplorer::BuildConfigWidget*> GenericProject::subConfigWidgets()
{
return QList<ProjectExplorer::BuildConfigWidget*>();
QList<ProjectExplorer::BuildConfigWidget*> list;
list << new BuildEnvironmentWidget;
return list;
}
GenericProjectNode *GenericProject::rootProjectNode() const

View File

@@ -33,6 +33,8 @@
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QProcess>
using namespace ProjectExplorer;
namespace {
@@ -59,19 +61,24 @@ const char * const BUILD_STEPS_COUNT_KEY("ProjectExplorer.BuildConfiguration.Bui
const char * const BUILD_STEPS_PREFIX("ProjectExplorer.BuildConfiguration.BuildStep.");
const char * const CLEAN_STEPS_COUNT_KEY("ProjectExplorer.BuildConfiguration.CleanStepsCount");
const char * const CLEAN_STEPS_PREFIX("ProjectExplorer.BuildConfiguration.CleanStep.");
const char * const CLEAR_SYSTEM_ENVIRONMENT_KEY("ProjectExplorer.BuildConfiguration.ClearSystemEnvironment");
const char * const USER_ENVIRONMENT_CHANGES_KEY("ProjectExplorer.BuildConfiguration.UserEnvironmentChanges");
} // namespace
BuildConfiguration::BuildConfiguration(Target *target, const QString &id) :
ProjectConfiguration(id),
m_target(target)
m_target(target),
m_clearSystemEnvironment(false)
{
Q_ASSERT(m_target);
}
BuildConfiguration::BuildConfiguration(Target *target, BuildConfiguration *source) :
ProjectConfiguration(source),
m_target(target)
m_target(target),
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
m_userEnvironmentChanges(source->m_userEnvironmentChanges)
{
Q_ASSERT(m_target);
}
@@ -91,6 +98,8 @@ QVariantMap BuildConfiguration::toMap() const
map.insert(QLatin1String(CLEAN_STEPS_COUNT_KEY), m_cleanSteps.count());
for (int i = 0; i < m_cleanSteps.count(); ++i)
map.insert(QString::fromLatin1(CLEAN_STEPS_PREFIX) + QString::number(i), m_cleanSteps.at(i)->toMap());
map.insert(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY), m_clearSystemEnvironment);
map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), EnvironmentItem::toStringList(m_userEnvironmentChanges));
return map;
}
@@ -165,6 +174,9 @@ bool BuildConfiguration::fromMap(const QVariantMap &map)
insertCleanStep(m_cleanSteps.count(), bs);
}
m_clearSystemEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)).toBool();
m_userEnvironmentChanges = EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
return true;
}
@@ -220,6 +232,54 @@ Target *BuildConfiguration::target() const
return m_target;
}
Environment BuildConfiguration::baseEnvironment() const
{
if (useSystemEnvironment())
return Environment(QProcess::systemEnvironment());
return Environment();
}
QString BuildConfiguration::baseEnvironmentText() const
{
if (useSystemEnvironment())
return tr("System Environment");
else
return tr("Clean Environment");
}
Environment BuildConfiguration::environment() const
{
Environment env = baseEnvironment();
env.modify(userEnvironmentChanges());
return env;
}
void BuildConfiguration::setUseSystemEnvironment(bool b)
{
if (useSystemEnvironment() == b)
return;
m_clearSystemEnvironment = !b;
emit environmentChanged();
}
bool BuildConfiguration::useSystemEnvironment() const
{
return !m_clearSystemEnvironment;
}
QList<EnvironmentItem> BuildConfiguration::userEnvironmentChanges() const
{
return m_userEnvironmentChanges;
}
void BuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff)
{
if (m_userEnvironmentChanges == diff)
return;
m_userEnvironmentChanges = diff;
emit environmentChanged();
}
///
// IBuildConfigurationFactory
///

View File

@@ -63,11 +63,19 @@ public:
void removeCleanStep(int position);
void moveCleanStepUp(int position);
virtual Environment environment() const = 0;
virtual QString buildDirectory() const = 0;
Target *target() const;
// TODO: Maybe the BuildConfiguration is not the best place for the environment
virtual Environment baseEnvironment() const;
QString baseEnvironmentText() const;
Environment environment() const;
void setUserEnvironmentChanges(const QList<EnvironmentItem> &diff);
QList<EnvironmentItem> userEnvironmentChanges() const;
bool useSystemEnvironment() const;
void setUseSystemEnvironment(bool b);
virtual QVariantMap toMap() const;
signals:
@@ -85,6 +93,9 @@ private:
QList<BuildStep *> m_buildSteps;
QList<BuildStep *> m_cleanSteps;
Target *m_target;
bool m_clearSystemEnvironment;
QList<EnvironmentItem> m_userEnvironmentChanges;
};
class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory :

View File

@@ -27,29 +27,27 @@
**
**************************************************************************/
#include "cmakebuildenvironmentwidget.h"
#include "cmakeproject.h"
#include "cmakebuildconfiguration.h"
#include <projectexplorer/environmenteditmodel.h>
#include "buildenvironmentwidget.h"
#include "buildconfiguration.h"
#include "environmenteditmodel.h"
#include <utils/qtcassert.h>
#include <QtGui/QVBoxLayout>
#include <QtGui/QCheckBox>
namespace {
bool debug = false;
}
using namespace ProjectExplorer;
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project)
: BuildConfigWidget(), m_pro(project), m_buildConfiguration(0)
BuildEnvironmentWidget::BuildEnvironmentWidget()
: m_buildConfiguration(0)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
m_clearSystemEnvironmentCheckBox = new QCheckBox(this);
m_clearSystemEnvironmentCheckBox->setText(tr("Clear system environment"));
m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this, m_clearSystemEnvironmentCheckBox);
m_buildEnvironmentWidget = new EnvironmentWidget(this, m_clearSystemEnvironmentCheckBox);
vbox->addWidget(m_buildEnvironmentWidget);
connect(m_buildEnvironmentWidget, SIGNAL(userChangesChanged()),
@@ -58,26 +56,31 @@ CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project)
this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool)));
}
QString CMakeBuildEnvironmentWidget::displayName() const
QString BuildEnvironmentWidget::displayName() const
{
return tr("Build Environment");
}
void CMakeBuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc)
void BuildEnvironmentWidget::init(BuildConfiguration *bc)
{
if (debug)
qDebug() << "Qt4BuildConfigWidget::init()";
QTC_ASSERT(bc, return);
if (m_buildConfiguration) {
disconnect(m_buildConfiguration, SIGNAL(environmentChanged()),
this, SLOT(environmentChanged()));
}
m_buildConfiguration = static_cast<CMakeBuildConfiguration *>(bc);
m_buildConfiguration = static_cast<BuildConfiguration *>(bc);
if (!m_buildConfiguration) {
setEnabled(false);
return;
}
setEnabled(true);
connect(m_buildConfiguration, SIGNAL(environmentChanged()),
this, SLOT(environmentChanged()));
m_clearSystemEnvironmentCheckBox->setChecked(!m_buildConfiguration->useSystemEnvironment());
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
@@ -85,19 +88,19 @@ void CMakeBuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc)
m_buildEnvironmentWidget->updateButtons();
}
void CMakeBuildEnvironmentWidget::environmentModelUserChangesChanged()
void BuildEnvironmentWidget::environmentModelUserChangesChanged()
{
m_buildConfiguration->setUserEnvironmentChanges(m_buildEnvironmentWidget->userChanges());
}
void CMakeBuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked)
void BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked)
{
m_buildConfiguration->setUseSystemEnvironment(!checked);
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
}
void CMakeBuildEnvironmentWidget::environmentChanged()
void BuildEnvironmentWidget::environmentChanged()
{
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());

View File

@@ -27,32 +27,29 @@
**
**************************************************************************/
#ifndef QT4BUILDENVIRONMENTWIDGET_H
#define QT4BUILDENVIRONMENTWIDGET_H
#ifndef BUILDENVIRONMENTWIDGET_H
#define BUILDENVIRONMENTWIDGET_H
#include <projectexplorer/buildstep.h>
QT_BEGIN_NAMESPACE
class QCheckBox;
QT_END_NAMESPACE
namespace ProjectExplorer {
class EnvironmentWidget;
}
class BuildConfiguration;
namespace CMakeProjectManager {
namespace Internal {
class CMakeProject;
class CMakeBuildConfiguration;
class CMakeBuildEnvironmentWidget : public ProjectExplorer::BuildConfigWidget
class PROJECTEXPLORER_EXPORT BuildEnvironmentWidget : public BuildConfigWidget
{
Q_OBJECT
public:
CMakeBuildEnvironmentWidget(CMakeProject *project);
BuildEnvironmentWidget();
QString displayName() const;
void init(ProjectExplorer::BuildConfiguration *bc);
void init(BuildConfiguration *bc);
private slots:
void environmentModelUserChangesChanged();
@@ -60,13 +57,11 @@ private slots:
void environmentChanged();
private:
ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget;
EnvironmentWidget *m_buildEnvironmentWidget;
QCheckBox *m_clearSystemEnvironmentCheckBox;
CMakeProject *m_pro;
CMakeBuildConfiguration *m_buildConfiguration;
BuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // QT4BUILDENVIRONMENTWIDGET_H
#endif // BUILDENVIRONMENTWIDGET_H

View File

@@ -75,7 +75,8 @@ HEADERS += projectexplorer.h \
targetselector.h \
targetsettingswidget.h \
doubletabwidget.h \
addtargetdialog.h
addtargetdialog.h \
buildenvironmentwidget.h
SOURCES += projectexplorer.cpp \
projectwindow.cpp \
buildmanager.cpp \
@@ -137,7 +138,8 @@ SOURCES += projectexplorer.cpp \
targetselector.cpp \
targetsettingswidget.cpp \
doubletabwidget.cpp \
addtargetdialog.cpp
addtargetdialog.cpp \
buildenvironmentwidget.cpp
FORMS += processstep.ui \
editorsettingspropertiespage.ui \
runsettingspropertiespage.ui \

View File

@@ -49,13 +49,10 @@ const char * const WAS_UPDATED("ProjectExplorer.Project.Updater.DidUpdate");
const char * const PROJECT_FILE_POSTFIX(".user");
// Version 0 is used in Qt Creator 1.3.x and
// (in a slighly differnt flavour) post 1.3 master.
// (in a slighly different flavour) post 1.3 master.
class Version0Handler : public UserFileVersionHandler
{
public:
Version0Handler();
~Version0Handler();
int userFileVersion() const
{
return 0;
@@ -80,9 +77,6 @@ private:
class Version1Handler : public UserFileVersionHandler
{
public:
Version1Handler();
~Version1Handler();
int userFileVersion() const
{
return 1;
@@ -115,11 +109,29 @@ private:
};
};
// Version 2 is used in master post Qt Creator 2.0 alpha.
class Version2Handler : public UserFileVersionHandler
{
public:
int userFileVersion() const
{
return 2;
}
QString displayUserFileVersion() const
{
return QLatin1String("2.0-alpha+git");
}
QVariantMap update(Project *project, const QVariantMap &map);
};
//
// Helper functions:
//
QString fileNameFor(const QString &name) {
static QString fileNameFor(const QString &name)
{
QString baseName(name);
QString environmentExtension(QString::fromLocal8Bit(qgetenv("QTC_EXTENSION")));
if (!environmentExtension.isEmpty()) {
@@ -147,6 +159,31 @@ UserFileVersionHandler::~UserFileVersionHandler()
{
}
/**
* Performs a simple renaming of the listed keys in \a changes recursively on \a map.
*/
QVariantMap UserFileVersionHandler::renameKeys(const QList<Change> &changes, QVariantMap map)
{
foreach (const Change &change, changes) {
QVariantMap::iterator oldSetting = map.find(change.first);
if (oldSetting != map.end()) {
map.insert(change.second, oldSetting.value());
map.erase(oldSetting);
}
}
QVariantMap::iterator i = map.begin();
while (i != map.end()) {
QVariant v = i.value();
if (v.type() == QVariant::Map)
i.value() = renameKeys(changes, v.toMap());
++i;
}
return map;
}
// -------------------------------------------------------------------------
// UserFileAccessor
// -------------------------------------------------------------------------
@@ -157,6 +194,7 @@ UserFileAccessor::UserFileAccessor() :
{
addVersionHandler(new Version0Handler);
addVersionHandler(new Version1Handler);
addVersionHandler(new Version2Handler);
}
UserFileAccessor::~UserFileAccessor()
@@ -250,14 +288,6 @@ void UserFileAccessor::addVersionHandler(UserFileVersionHandler *handler)
// Version0Handler
// -------------------------------------------------------------------------
Version0Handler::Version0Handler()
{
}
Version0Handler::~Version0Handler()
{
}
QVariantMap Version0Handler::convertBuildConfigurations(Project *project, const QVariantMap &map)
{
Q_ASSERT(project);
@@ -703,14 +733,6 @@ QVariantMap Version0Handler::update(Project *project, const QVariantMap &map)
// Version1Handler
// -------------------------------------------------------------------------
Version1Handler::Version1Handler()
{
}
Version1Handler::~Version1Handler()
{
}
QVariantMap Version1Handler::update(Project *project, const QVariantMap &map)
{
QVariantMap result;
@@ -812,3 +834,22 @@ QVariantMap Version1Handler::update(Project *project, const QVariantMap &map)
return result;
}
// -------------------------------------------------------------------------
// Version2Handler
// -------------------------------------------------------------------------
QVariantMap Version2Handler::update(Project *, const QVariantMap &map)
{
QList<Change> changes;
changes.append(qMakePair(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.UserEnvironmentChanges"),
QLatin1String("ProjectExplorer.BuildConfiguration.UserEnvironmentChanges")));
changes.append(qMakePair(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.ClearSystemEnvironment"),
QLatin1String("ProjectExplorer.BuildConfiguration.ClearSystemEnvironment")));
changes.append(qMakePair(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges"),
QLatin1String("ProjectExplorer.BuildConfiguration.UserEnvironmentChanges")));
changes.append(qMakePair(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment"),
QLatin1String("ProjectExplorer.BuildConfiguration.ClearSystemEnvironment")));
return renameKeys(changes, QVariantMap(map));
}

View File

@@ -47,6 +47,10 @@ public:
virtual QString displayUserFileVersion() const = 0;
// Update from userFileVersion() to userFileVersion() + 1
virtual QVariantMap update(Project *project, const QVariantMap &map) = 0;
protected:
typedef QPair<QLatin1String,QLatin1String> Change;
QVariantMap renameKeys(const QList<Change> &changes, QVariantMap map);
};
class UserFileAccessor

View File

@@ -46,8 +46,6 @@ namespace {
const char * const QT4_BC_ID_PREFIX("Qt4ProjectManager.Qt4BuildConfiguration.");
const char * const QT4_BC_ID("Qt4ProjectManager.Qt4BuildConfiguration");
const char * const CLEAR_SYSTEM_ENVIRONMENT_KEY("Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment");
const char * const USER_ENVIRONMENT_CHANGES_KEY("Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges");
const char * const USE_SHADOW_BUILD_KEY("Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild");
const char * const BUILD_DIRECTORY_KEY("Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory");
const char * const TOOLCHAIN_KEY("Qt4ProjectManager.Qt4BuildConfiguration.ToolChain");
@@ -59,7 +57,6 @@ enum { debug = 0 };
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target) :
BuildConfiguration(target, QLatin1String(QT4_BC_ID)),
m_clearSystemEnvironment(false),
m_shadowBuild(false),
m_qtVersionId(-1),
m_toolChainType(-1), // toolChainType() makes sure to return the default toolchainType
@@ -71,7 +68,6 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target) :
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target, const QString &id) :
BuildConfiguration(target, id),
m_clearSystemEnvironment(false),
m_shadowBuild(false),
m_qtVersionId(-1),
m_toolChainType(-1), // toolChainType() makes sure to return the default toolchainType
@@ -83,8 +79,6 @@ Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target, const QString &i
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target, Qt4BuildConfiguration *source) :
BuildConfiguration(target, source),
m_clearSystemEnvironment(source->m_clearSystemEnvironment),
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
m_shadowBuild(source->m_shadowBuild),
m_buildDirectory(source->m_buildDirectory),
m_qtVersionId(source->m_qtVersionId),
@@ -103,8 +97,6 @@ Qt4BuildConfiguration::~Qt4BuildConfiguration()
QVariantMap Qt4BuildConfiguration::toMap() const
{
QVariantMap map(BuildConfiguration::toMap());
map.insert(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY), m_clearSystemEnvironment);
map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), EnvironmentItem::toStringList(m_userEnvironmentChanges));
map.insert(QLatin1String(USE_SHADOW_BUILD_KEY), m_shadowBuild);
map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory);
map.insert(QLatin1String(QT_VERSION_ID_KEY), m_qtVersionId);
@@ -119,8 +111,6 @@ bool Qt4BuildConfiguration::fromMap(const QVariantMap &map)
if (!BuildConfiguration::fromMap(map))
return false;
m_clearSystemEnvironment = map.value(QLatin1String(CLEAR_SYSTEM_ENVIRONMENT_KEY)).toBool();
m_userEnvironmentChanges = EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
m_shadowBuild = map.value(QLatin1String(USE_SHADOW_BUILD_KEY), false).toBool();
m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString();
m_qtVersionId = map.value(QLatin1String(QT_VERSION_ID_KEY)).toInt();
@@ -179,14 +169,9 @@ Qt4Target *Qt4BuildConfiguration::qt4Target() const
return static_cast<Qt4Target *>(target());
}
QString Qt4BuildConfiguration::baseEnvironmentText() const
{
return useSystemEnvironment() ? tr("System Environment") : tr("Clean Environment");
}
ProjectExplorer::Environment Qt4BuildConfiguration::baseEnvironment() const
{
Environment env = useSystemEnvironment() ? Environment::systemEnvironment() : Environment();
Environment env = BuildConfiguration::baseEnvironment();
qtVersion()->addToEnvironment(env);
ToolChain *tc = toolChain();
if (tc)
@@ -194,39 +179,6 @@ ProjectExplorer::Environment Qt4BuildConfiguration::baseEnvironment() const
return env;
}
ProjectExplorer::Environment Qt4BuildConfiguration::environment() const
{
Environment env = baseEnvironment();
env.modify(userEnvironmentChanges());
return env;
}
void Qt4BuildConfiguration::setUseSystemEnvironment(bool b)
{
if (useSystemEnvironment() == b)
return;
m_clearSystemEnvironment = !b;
emit environmentChanged();
}
bool Qt4BuildConfiguration::useSystemEnvironment() const
{
return !m_clearSystemEnvironment;
}
QList<ProjectExplorer::EnvironmentItem> Qt4BuildConfiguration::userEnvironmentChanges() const
{
return m_userEnvironmentChanges;
}
void Qt4BuildConfiguration::setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff)
{
if (m_userEnvironmentChanges == diff)
return;
m_userEnvironmentChanges = diff;
emit environmentChanged();
}
/// returns the build directory
QString Qt4BuildConfiguration::buildDirectory() const
{

View File

@@ -57,13 +57,7 @@ public:
Qt4Target *qt4Target() const;
ProjectExplorer::Environment environment() const;
ProjectExplorer::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
bool useSystemEnvironment() const;
void setUseSystemEnvironment(bool b);
virtual ProjectExplorer::Environment baseEnvironment() const;
virtual QString buildDirectory() const;
bool shadowBuild() const;
@@ -138,8 +132,6 @@ private:
void ctor();
void pickValidQtVersion();
bool m_clearSystemEnvironment;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
bool m_shadowBuild;
QString m_buildDirectory;
int m_qtVersionId;

View File

@@ -1,116 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "qt4buildenvironmentwidget.h"
#include "qt4project.h"
#include "qt4buildconfiguration.h"
#include <projectexplorer/environmenteditmodel.h>
#include <utils/qtcassert.h>
#include <QtGui/QCheckBox>
namespace {
bool debug = false;
}
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project)
: BuildConfigWidget(), m_pro(project), m_buildConfiguration(0)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
m_clearSystemEnvironmentCheckBox = new QCheckBox(this);
m_clearSystemEnvironmentCheckBox->setText(tr("Clear system environment"));
m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this, m_clearSystemEnvironmentCheckBox);
vbox->addWidget(m_buildEnvironmentWidget);
connect(m_buildEnvironmentWidget, SIGNAL(userChangesChanged()),
this, SLOT(environmentModelUserChangesUpdated()));
connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),
this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool)));
}
QString Qt4BuildEnvironmentWidget::displayName() const
{
return tr("Build Environment");
}
void Qt4BuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc)
{
QTC_ASSERT(bc, return);
if (debug)
qDebug() << "Qt4BuildConfigWidget::init()";
if (m_buildConfiguration) {
disconnect(m_buildConfiguration, SIGNAL(environmentChanged()),
this, SLOT(environmentChanged()));
}
m_buildConfiguration = static_cast<Qt4BuildConfiguration *>(bc);
if (!m_buildConfiguration) {
setEnabled(false);
return;
}
setEnabled(true);
connect(m_buildConfiguration, SIGNAL(environmentChanged()),
this, SLOT(environmentChanged()));
m_clearSystemEnvironmentCheckBox->setChecked(!m_buildConfiguration->useSystemEnvironment());
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges());
m_buildEnvironmentWidget->updateButtons();
}
void Qt4BuildEnvironmentWidget::environmentModelUserChangesUpdated()
{
m_buildConfiguration->setUserEnvironmentChanges(m_buildEnvironmentWidget->userChanges());
}
void Qt4BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked)
{
m_buildConfiguration->setUseSystemEnvironment(!checked);
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
}
void Qt4BuildEnvironmentWidget::environmentChanged()
{
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
}

View File

@@ -1,75 +0,0 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QT4BUILDENVIRONMENTWIDGET_H
#define QT4BUILDENVIRONMENTWIDGET_H
#include <projectexplorer/buildstep.h>
QT_BEGIN_NAMESPACE
class QCheckBox;
QT_END_NAMESPACE
namespace ProjectExplorer {
class EnvironmentWidget;
}
namespace Qt4ProjectManager {
class Qt4Project;
namespace Internal {
class Qt4BuildConfiguration;
class Qt4BuildEnvironmentWidget : public ProjectExplorer::BuildConfigWidget
{
Q_OBJECT
public:
Qt4BuildEnvironmentWidget(Qt4Project *project);
QString displayName() const;
void init(ProjectExplorer::BuildConfiguration *bc);
private slots:
void environmentModelUserChangesUpdated();
void clearSystemEnvironmentCheckBoxClicked(bool checked);
void environmentChanged();
private:
ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget;
QCheckBox *m_clearSystemEnvironmentCheckBox;
Qt4Project *m_pro;
Qt4BuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // QT4BUILDENVIRONMENTWIDGET_H

View File

@@ -36,7 +36,6 @@
#include "qt4runconfiguration.h"
#include "qt4nodes.h"
#include "qt4projectconfigwidget.h"
#include "qt4buildenvironmentwidget.h"
#include "qt4projectmanagerconstants.h"
#include "projectloadwizard.h"
#include "qt4buildconfiguration.h"
@@ -46,6 +45,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildenvironmentwidget.h>
#include <projectexplorer/customexecutablerunconfiguration.h>
#include <projectexplorer/nodesvisitor.h>
#include <projectexplorer/project.h>
@@ -933,7 +933,7 @@ BuildConfigWidget *Qt4Project::createConfigWidget()
QList<BuildConfigWidget*> Qt4Project::subConfigWidgets()
{
QList<BuildConfigWidget*> subWidgets;
subWidgets << new Qt4BuildEnvironmentWidget(this);
subWidgets << new BuildEnvironmentWidget;
return subWidgets;
}

View File

@@ -34,7 +34,6 @@ HEADERS += qt4projectmanagerplugin.h \
qt4runconfiguration.h \
qtmodulesinfo.h \
qt4projectconfigwidget.h \
qt4buildenvironmentwidget.h \
projectloadwizard.h \
qtversionmanager.h \
qtoptionspage.h \
@@ -75,7 +74,6 @@ SOURCES += qt4projectmanagerplugin.cpp \
qt4runconfiguration.cpp \
qtmodulesinfo.cpp \
qt4projectconfigwidget.cpp \
qt4buildenvironmentwidget.cpp \
projectloadwizard.cpp \
qtversionmanager.cpp \
qtoptionspage.cpp \