forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -1,104 +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 "cmakebuildenvironmentwidget.h"
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakebuildconfiguration.h"
|
||||
#include <projectexplorer/environmenteditmodel.h>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QCheckBox>
|
||||
|
||||
namespace {
|
||||
bool debug = false;
|
||||
}
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
|
||||
CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *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(environmentModelUserChangesChanged()));
|
||||
connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),
|
||||
this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool)));
|
||||
}
|
||||
|
||||
QString CMakeBuildEnvironmentWidget::displayName() const
|
||||
{
|
||||
return tr("Build Environment");
|
||||
}
|
||||
|
||||
void CMakeBuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << "Qt4BuildConfigWidget::init()";
|
||||
|
||||
if (m_buildConfiguration) {
|
||||
disconnect(m_buildConfiguration, SIGNAL(environmentChanged()),
|
||||
this, SLOT(environmentChanged()));
|
||||
}
|
||||
m_buildConfiguration = static_cast<CMakeBuildConfiguration *>(bc);
|
||||
|
||||
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 CMakeBuildEnvironmentWidget::environmentModelUserChangesChanged()
|
||||
{
|
||||
m_buildConfiguration->setUserEnvironmentChanges(m_buildEnvironmentWidget->userChanges());
|
||||
}
|
||||
|
||||
void CMakeBuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked)
|
||||
{
|
||||
m_buildConfiguration->setUseSystemEnvironment(!checked);
|
||||
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
|
||||
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
|
||||
}
|
||||
|
||||
void CMakeBuildEnvironmentWidget::environmentChanged()
|
||||
{
|
||||
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
|
||||
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
|
||||
}
|
||||
@@ -1,72 +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 CMakeProjectManager {
|
||||
namespace Internal {
|
||||
class CMakeProject;
|
||||
class CMakeBuildConfiguration;
|
||||
|
||||
class CMakeBuildEnvironmentWidget : public ProjectExplorer::BuildConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMakeBuildEnvironmentWidget(CMakeProject *project);
|
||||
|
||||
QString displayName() const;
|
||||
void init(ProjectExplorer::BuildConfiguration *bc);
|
||||
|
||||
private slots:
|
||||
void environmentModelUserChangesChanged();
|
||||
void clearSystemEnvironmentCheckBoxClicked(bool checked);
|
||||
void environmentChanged();
|
||||
|
||||
private:
|
||||
ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget;
|
||||
QCheckBox *m_clearSystemEnvironmentCheckBox;
|
||||
CMakeProject *m_pro;
|
||||
CMakeBuildConfiguration *m_buildConfiguration;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
#endif // QT4BUILDENVIRONMENTWIDGET_H
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 +=
|
||||
|
||||
Reference in New Issue
Block a user