forked from qt-creator/qt-creator
Add the ability to set a build environment also for CMake projects.
Note: as for qt projects, this is also used for running. And we don't use it for running cmake yet.
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (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 qt-sales@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "cmakebuildenvironmentwidget.h"
|
||||
#include "cmakeproject.h"
|
||||
#include <projectexplorer/environmenteditmodel.h>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
|
||||
namespace {
|
||||
bool debug = false;
|
||||
}
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
using ProjectExplorer::EnvironmentModel;
|
||||
|
||||
CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project)
|
||||
: BuildStepConfigWidget(), m_pro(project)
|
||||
{
|
||||
QVBoxLayout *vbox = new QVBoxLayout(this);
|
||||
vbox->setMargin(0);
|
||||
m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this);
|
||||
vbox->addWidget(m_buildEnvironmentWidget);
|
||||
|
||||
connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()),
|
||||
this, SLOT(environmentModelUserChangesUpdated()));
|
||||
connect(m_buildEnvironmentWidget, SIGNAL(clearSystemEnvironmentCheckBoxClicked(bool)),
|
||||
this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool)));
|
||||
}
|
||||
|
||||
QString CMakeBuildEnvironmentWidget::displayName() const
|
||||
{
|
||||
return tr("Build Environment");
|
||||
}
|
||||
|
||||
void CMakeBuildEnvironmentWidget::init(const QString &buildConfiguration)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << "Qt4BuildConfigWidget::init()";
|
||||
|
||||
m_buildConfiguration = buildConfiguration;
|
||||
|
||||
m_buildEnvironmentWidget->setClearSystemEnvironment(!m_pro->useSystemEnvironment(buildConfiguration));
|
||||
m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(buildConfiguration));
|
||||
m_buildEnvironmentWidget->setUserChanges(m_pro->userEnvironmentChanges(buildConfiguration));
|
||||
m_buildEnvironmentWidget->updateButtons();
|
||||
}
|
||||
|
||||
void CMakeBuildEnvironmentWidget::environmentModelUserChangesUpdated()
|
||||
{
|
||||
m_pro->setUserEnvironmentChanges(m_buildConfiguration, m_buildEnvironmentWidget->userChanges());
|
||||
}
|
||||
|
||||
void CMakeBuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked)
|
||||
{
|
||||
m_pro->setUseSystemEnvironment(m_buildConfiguration, !checked);
|
||||
m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(m_buildConfiguration));
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (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 qt-sales@nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QT4BUILDENVIRONMENTWIDGET_H
|
||||
#define QT4BUILDENVIRONMENTWIDGET_H
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class EnvironmentWidget;
|
||||
}
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
class CMakeProject;
|
||||
|
||||
class CMakeBuildEnvironmentWidget : public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMakeBuildEnvironmentWidget(CMakeProject *project);
|
||||
|
||||
QString displayName() const;
|
||||
void init(const QString &buildConfiguration);
|
||||
|
||||
private slots:
|
||||
void environmentModelUserChangesUpdated();
|
||||
void clearSystemEnvironmentCheckBoxClicked(bool checked);
|
||||
|
||||
private:
|
||||
ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget;
|
||||
CMakeProject *m_pro;
|
||||
QString m_buildConfiguration;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qt4ProjectManager
|
||||
|
||||
#endif // QT4BUILDENVIRONMENTWIDGET_H
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "cmakerunconfiguration.h"
|
||||
#include "makestep.h"
|
||||
#include "cmakeopenprojectwizard.h"
|
||||
#include "cmakebuildenvironmentwidget.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
@@ -50,7 +51,8 @@
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
|
||||
using ProjectExplorer::Environment;
|
||||
using ProjectExplorer::EnvironmentItem;
|
||||
|
||||
// QtCreator CMake Generator wishlist:
|
||||
// Which make targets we need to build to get all executables
|
||||
@@ -62,7 +64,6 @@ using namespace CMakeProjectManager::Internal;
|
||||
// Who sets up the environment for cl.exe ? INCLUDEPATH and so on
|
||||
|
||||
|
||||
|
||||
CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
||||
: m_manager(manager),
|
||||
m_fileName(fileName),
|
||||
@@ -436,11 +437,38 @@ bool CMakeProject::isApplication() const
|
||||
return true;
|
||||
}
|
||||
|
||||
ProjectExplorer::Environment CMakeProject::baseEnvironment(const QString &buildConfiguration) const
|
||||
{
|
||||
Environment env = useSystemEnvironment(buildConfiguration) ? Environment(QProcess::systemEnvironment()) : Environment();
|
||||
return env;
|
||||
}
|
||||
|
||||
ProjectExplorer::Environment CMakeProject::environment(const QString &buildConfiguration) const
|
||||
{
|
||||
Q_UNUSED(buildConfiguration)
|
||||
//TODO CMakeProject::Environment;
|
||||
return ProjectExplorer::Environment::systemEnvironment();
|
||||
Environment env = baseEnvironment(buildConfiguration);
|
||||
env.modify(userEnvironmentChanges(buildConfiguration));
|
||||
return env;
|
||||
}
|
||||
|
||||
void CMakeProject::setUseSystemEnvironment(const QString &buildConfiguration, bool b)
|
||||
{
|
||||
setValue(buildConfiguration, "clearSystemEnvironment", !b);
|
||||
}
|
||||
|
||||
bool CMakeProject::useSystemEnvironment(const QString &buildConfiguration) const
|
||||
{
|
||||
bool b = !(value(buildConfiguration, "clearSystemEnvironment").isValid() && value(buildConfiguration, "clearSystemEnvironment").toBool());
|
||||
return b;
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::EnvironmentItem> CMakeProject::userEnvironmentChanges(const QString &buildConfig) const
|
||||
{
|
||||
return EnvironmentItem::fromStringList(value(buildConfig, "userEnvironmentChanges").toStringList());
|
||||
}
|
||||
|
||||
void CMakeProject::setUserEnvironmentChanges(const QString &buildConfig, const QList<ProjectExplorer::EnvironmentItem> &diff)
|
||||
{
|
||||
setValue(buildConfig, "userEnvironmentChanges", EnvironmentItem::toStringList(diff));
|
||||
}
|
||||
|
||||
QString CMakeProject::buildDirectory(const QString &buildConfiguration) const
|
||||
@@ -458,7 +486,9 @@ ProjectExplorer::BuildStepConfigWidget *CMakeProject::createConfigWidget()
|
||||
|
||||
QList<ProjectExplorer::BuildStepConfigWidget*> CMakeProject::subConfigWidgets()
|
||||
{
|
||||
return QList<ProjectExplorer::BuildStepConfigWidget*>();
|
||||
QList<ProjectExplorer::BuildStepConfigWidget*> list;
|
||||
list << new CMakeBuildEnvironmentWidget(this);
|
||||
return list;
|
||||
}
|
||||
|
||||
// This method is called for new build configurations
|
||||
|
||||
@@ -79,7 +79,14 @@ public:
|
||||
|
||||
virtual bool isApplication() const;
|
||||
|
||||
virtual ProjectExplorer::Environment environment(const QString &buildConfiguration) const;
|
||||
//building environment
|
||||
ProjectExplorer::Environment environment(const QString &buildConfiguration) const;
|
||||
ProjectExplorer::Environment baseEnvironment(const QString &buildConfiguration) const;
|
||||
void setUserEnvironmentChanges(const QString &buildConfig, const QList<ProjectExplorer::EnvironmentItem> &diff);
|
||||
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges(const QString &buildConfig) const;
|
||||
bool useSystemEnvironment(const QString &buildConfiguration) const;
|
||||
void setUseSystemEnvironment(const QString &buildConfiguration, bool b);
|
||||
|
||||
virtual QString buildDirectory(const QString &buildConfiguration) const;
|
||||
|
||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||
|
||||
@@ -9,14 +9,16 @@ HEADERS = cmakeproject.h \
|
||||
cmakeprojectnodes.h \
|
||||
makestep.h \
|
||||
cmakerunconfiguration.h \
|
||||
cmakeopenprojectwizard.h
|
||||
cmakeopenprojectwizard.h \
|
||||
cmakebuildenvironmentwidget.h
|
||||
SOURCES = cmakeproject.cpp \
|
||||
cmakeprojectplugin.cpp \
|
||||
cmakeprojectmanager.cpp \
|
||||
cmakeprojectnodes.cpp \
|
||||
makestep.cpp \
|
||||
cmakerunconfiguration.cpp \
|
||||
cmakeopenprojectwizard.cpp
|
||||
cmakeopenprojectwizard.cpp \
|
||||
cmakebuildenvironmentwidget.cpp
|
||||
RESOURCES += cmakeproject.qrc
|
||||
FORMS +=
|
||||
|
||||
|
||||
@@ -82,8 +82,7 @@ QStringList CMakeRunConfiguration::commandLineArguments() const
|
||||
|
||||
ProjectExplorer::Environment CMakeRunConfiguration::environment() const
|
||||
{
|
||||
// TODO have a way for the user to setup the environment
|
||||
return ProjectExplorer::Environment::systemEnvironment();
|
||||
return project()->environment(project()->activeBuildConfiguration());
|
||||
}
|
||||
|
||||
QString CMakeRunConfiguration::title() const
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "qt4buildenvironmentwidget.h"
|
||||
|
||||
#include "ui_qt4buildenvironmentwidget.h"
|
||||
#include "qt4project.h"
|
||||
|
||||
#include <projectexplorer/environmenteditmodel.h>
|
||||
@@ -56,11 +54,6 @@ Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project)
|
||||
this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool)));
|
||||
}
|
||||
|
||||
Qt4BuildEnvironmentWidget::~Qt4BuildEnvironmentWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString Qt4BuildEnvironmentWidget::displayName() const
|
||||
{
|
||||
return tr("Build Environment");
|
||||
|
||||
@@ -47,7 +47,6 @@ class Qt4BuildEnvironmentWidget : public ProjectExplorer::BuildStepConfigWidget
|
||||
|
||||
public:
|
||||
Qt4BuildEnvironmentWidget(Qt4Project *project);
|
||||
~Qt4BuildEnvironmentWidget();
|
||||
|
||||
QString displayName() const;
|
||||
void init(const QString &buildConfiguration);
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Qt4ProjectManager::Internal::Qt4BuildEnvironmentWidget</class>
|
||||
<widget class="QWidget" name="Qt4ProjectManager::Internal::Qt4BuildEnvironmentWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="clearSystemEnvironmentCheckBox">
|
||||
<property name="text">
|
||||
<string>Clear system environment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="environmentTreeView">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="editButton">
|
||||
<property name="text">
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
<string>&Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="unsetButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Unset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -698,6 +698,16 @@ Qt4ProFileNode *Qt4Project::rootProjectNode() const
|
||||
return m_rootProjectNode;
|
||||
}
|
||||
|
||||
QString Qt4Project::buildDirectory(const QString &buildConfiguration) const
|
||||
{
|
||||
QString workingDirectory;
|
||||
if (value(buildConfiguration, "useShadowBuild").toBool())
|
||||
workingDirectory = value(buildConfiguration, "buildDirectory").toString();
|
||||
if (workingDirectory.isEmpty())
|
||||
workingDirectory = QFileInfo(file()->fileName()).absolutePath();
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
ProjectExplorer::Environment Qt4Project::baseEnvironment(const QString &buildConfiguration) const
|
||||
{
|
||||
Environment env = useSystemEnvironment(buildConfiguration) ? Environment(QProcess::systemEnvironment()) : Environment();
|
||||
@@ -712,16 +722,6 @@ ProjectExplorer::Environment Qt4Project::environment(const QString &buildConfigu
|
||||
return env;
|
||||
}
|
||||
|
||||
QString Qt4Project::buildDirectory(const QString &buildConfiguration) const
|
||||
{
|
||||
QString workingDirectory;
|
||||
if (value(buildConfiguration, "useShadowBuild").toBool())
|
||||
workingDirectory = value(buildConfiguration, "buildDirectory").toString();
|
||||
if (workingDirectory.isEmpty())
|
||||
workingDirectory = QFileInfo(file()->fileName()).absolutePath();
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
void Qt4Project::setUseSystemEnvironment(const QString &buildConfiguration, bool b)
|
||||
{
|
||||
setValue(buildConfiguration, "clearSystemEnvironment", !b);
|
||||
@@ -733,6 +733,16 @@ bool Qt4Project::useSystemEnvironment(const QString &buildConfiguration) const
|
||||
return b;
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::EnvironmentItem> Qt4Project::userEnvironmentChanges(const QString &buildConfig) const
|
||||
{
|
||||
return EnvironmentItem::fromStringList(value(buildConfig, "userEnvironmentChanges").toStringList());
|
||||
}
|
||||
|
||||
void Qt4Project::setUserEnvironmentChanges(const QString &buildConfig, const QList<ProjectExplorer::EnvironmentItem> &diff)
|
||||
{
|
||||
setValue(buildConfig, "userEnvironmentChanges", EnvironmentItem::toStringList(diff));
|
||||
}
|
||||
|
||||
QString Qt4Project::qtDir(const QString &buildConfiguration) const
|
||||
{
|
||||
QtVersion *version = qtVersion(buildConfiguration);
|
||||
@@ -802,16 +812,6 @@ QList<BuildStepConfigWidget*> Qt4Project::subConfigWidgets()
|
||||
return subWidgets;
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::EnvironmentItem> Qt4Project::userEnvironmentChanges(const QString &buildConfig) const
|
||||
{
|
||||
return EnvironmentItem::fromStringList(value(buildConfig, "userEnvironmentChanges").toStringList());
|
||||
}
|
||||
|
||||
void Qt4Project::setUserEnvironmentChanges(const QString &buildConfig, const QList<ProjectExplorer::EnvironmentItem> &diff)
|
||||
{
|
||||
setValue(buildConfig, "userEnvironmentChanges", EnvironmentItem::toStringList(diff));
|
||||
}
|
||||
|
||||
/// **************************
|
||||
/// Qt4ProjectBuildConfigWidget
|
||||
/// **************************
|
||||
|
||||
@@ -143,13 +143,10 @@ public:
|
||||
ProjectExplorer::Environment baseEnvironment(const QString &buildConfiguration) const;
|
||||
void setUserEnvironmentChanges(const QString &buildConfig, const QList<ProjectExplorer::EnvironmentItem> &diff);
|
||||
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges(const QString &buildConfig) const;
|
||||
|
||||
virtual QString buildDirectory(const QString &buildConfiguration) const;
|
||||
|
||||
//Qt4Project specific(?)
|
||||
bool useSystemEnvironment(const QString &buildConfiguration) const;
|
||||
void setUseSystemEnvironment(const QString &buildConfiguration, bool b);
|
||||
|
||||
virtual QString buildDirectory(const QString &buildConfiguration) const;
|
||||
// returns the CONFIG variable from the .pro file
|
||||
QStringList qmakeConfig() const;
|
||||
// returns the qtdir (depends on the current QtVersion)
|
||||
|
||||
@@ -77,7 +77,6 @@ FORMS = makestep.ui \
|
||||
qmakestep.ui \
|
||||
qt4projectconfigwidget.ui \
|
||||
embeddedpropertiespage.ui \
|
||||
qt4buildenvironmentwidget.ui \
|
||||
qtversionmanager.ui \
|
||||
showbuildlog.ui
|
||||
RESOURCES = qt4projectmanager.qrc \
|
||||
|
||||
Reference in New Issue
Block a user