forked from qt-creator/qt-creator
Add specialization of environmentaspect for local processes
... and attach that to localapplicationrunconfigurations Change-Id: I1d93820d45295bb0e8dd1ac2648070891eff6ddf Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include "localapplicationrunconfiguration.h"
|
#include "localapplicationrunconfiguration.h"
|
||||||
|
|
||||||
#include "buildconfiguration.h"
|
#include "buildconfiguration.h"
|
||||||
|
#include "localenvironmentaspect.h"
|
||||||
|
|
||||||
#include <coreplugin/variablemanager.h>
|
#include <coreplugin/variablemanager.h>
|
||||||
|
|
||||||
@@ -39,11 +40,20 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, const Core::Id id) :
|
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, const Core::Id id) :
|
||||||
RunConfiguration(target, id)
|
RunConfiguration(target, id)
|
||||||
{ }
|
{
|
||||||
|
ctor();
|
||||||
|
}
|
||||||
|
|
||||||
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc) :
|
LocalApplicationRunConfiguration::LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc) :
|
||||||
RunConfiguration(target, rc)
|
RunConfiguration(target, rc)
|
||||||
{ }
|
{
|
||||||
|
ctor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalApplicationRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(env);
|
||||||
|
}
|
||||||
|
|
||||||
Utils::AbstractMacroExpander *LocalApplicationRunConfiguration::macroExpander() const
|
Utils::AbstractMacroExpander *LocalApplicationRunConfiguration::macroExpander() const
|
||||||
{
|
{
|
||||||
@@ -52,4 +62,9 @@ Utils::AbstractMacroExpander *LocalApplicationRunConfiguration::macroExpander()
|
|||||||
return Core::VariableManager::macroExpander();
|
return Core::VariableManager::macroExpander();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalApplicationRunConfiguration::ctor()
|
||||||
|
{
|
||||||
|
addExtraAspect(new LocalEnvironmentAspect(this));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -57,11 +57,16 @@ public:
|
|||||||
virtual QString dumperLibrary() const = 0;
|
virtual QString dumperLibrary() const = 0;
|
||||||
virtual QStringList dumperLibraryLocations() const = 0;
|
virtual QStringList dumperLibraryLocations() const = 0;
|
||||||
|
|
||||||
|
virtual void addToBaseEnvironment(Utils::Environment &env) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit LocalApplicationRunConfiguration(Target *target, const Core::Id id);
|
explicit LocalApplicationRunConfiguration(Target *target, const Core::Id id);
|
||||||
explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc);
|
explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc);
|
||||||
|
|
||||||
Utils::AbstractMacroExpander *macroExpander() const;
|
Utils::AbstractMacroExpander *macroExpander() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ctor();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
106
src/plugins/projectexplorer/localenvironmentaspect.cpp
Normal file
106
src/plugins/projectexplorer/localenvironmentaspect.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "localenvironmentaspect.h"
|
||||||
|
|
||||||
|
#include "buildconfiguration.h"
|
||||||
|
#include "environmentaspectwidget.h"
|
||||||
|
#include "localapplicationrunconfiguration.h"
|
||||||
|
#include "target.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
// LocalEnvironmentAspect:
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
QList<int> LocalEnvironmentAspect::possibleBaseEnvironments() const
|
||||||
|
{
|
||||||
|
return QList<int>() << static_cast<int>(BuildEnvironmentBase)
|
||||||
|
<< static_cast<int>(SystemEnvironmentBase)
|
||||||
|
<< static_cast<int>(CleanEnvironmentBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LocalEnvironmentAspect::baseEnvironmentDisplayName(int base) const
|
||||||
|
{
|
||||||
|
if (base == static_cast<int>(BuildEnvironmentBase))
|
||||||
|
return tr("Build Environment");
|
||||||
|
if (base == static_cast<int>(SystemEnvironmentBase))
|
||||||
|
return tr("System Environment");
|
||||||
|
if (base == static_cast<int>(CleanEnvironmentBase))
|
||||||
|
return tr("Clean Environment");
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::Environment LocalEnvironmentAspect::baseEnvironment() const
|
||||||
|
{
|
||||||
|
int base = baseEnvironmentBase();
|
||||||
|
Utils::Environment env;
|
||||||
|
if (base == static_cast<int>(BuildEnvironmentBase)) {
|
||||||
|
if (BuildConfiguration *bc = runConfiguration()->target()->activeBuildConfiguration())
|
||||||
|
env = bc->environment();
|
||||||
|
} else if (base == static_cast<int>(SystemEnvironmentBase)) {
|
||||||
|
env = Utils::Environment::systemEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const LocalApplicationRunConfiguration *rc = qobject_cast<const LocalApplicationRunConfiguration *>(runConfiguration()))
|
||||||
|
rc->addToBaseEnvironment(env);
|
||||||
|
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalEnvironmentAspect::buildEnvironmentHasChanged()
|
||||||
|
{
|
||||||
|
if (baseEnvironmentBase() == static_cast<int>(BuildEnvironmentBase)) {
|
||||||
|
emit baseEnvironmentChanged();
|
||||||
|
emit environmentChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalEnvironmentAspect::LocalEnvironmentAspect(RunConfiguration *rc) :
|
||||||
|
EnvironmentAspect(rc)
|
||||||
|
{
|
||||||
|
connect(rc->target(), SIGNAL(environmentChanged()),
|
||||||
|
this, SLOT(buildEnvironmentHasChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalEnvironmentAspect::LocalEnvironmentAspect(const LocalEnvironmentAspect *other,
|
||||||
|
ProjectExplorer::RunConfiguration *parent) :
|
||||||
|
EnvironmentAspect(other, parent)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
LocalEnvironmentAspect *LocalEnvironmentAspect::clone(RunConfiguration *parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
return new LocalEnvironmentAspect(this, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ProjectExplorer
|
65
src/plugins/projectexplorer/localenvironmentaspect.h
Normal file
65
src/plugins/projectexplorer/localenvironmentaspect.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LOCALENVIRONMENTASPECT_H
|
||||||
|
#define LOCALENVIRONMENTASPECT_H
|
||||||
|
|
||||||
|
#include "environmentaspect.h"
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
|
class LocalEnvironmentAspect : public EnvironmentAspect
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
LocalEnvironmentAspect(RunConfiguration *rc);
|
||||||
|
|
||||||
|
LocalEnvironmentAspect *clone(RunConfiguration *parent) const;
|
||||||
|
|
||||||
|
QList<int> possibleBaseEnvironments() const;
|
||||||
|
QString baseEnvironmentDisplayName(int base) const;
|
||||||
|
Utils::Environment baseEnvironment() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void buildEnvironmentHasChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum BaseEnvironmentBase {
|
||||||
|
CleanEnvironmentBase = 0,
|
||||||
|
SystemEnvironmentBase,
|
||||||
|
BuildEnvironmentBase
|
||||||
|
};
|
||||||
|
|
||||||
|
LocalEnvironmentAspect(const LocalEnvironmentAspect *other, RunConfiguration *parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ProjectExplorer
|
||||||
|
|
||||||
|
#endif // LOCALENVIRONMENTASPECT_H
|
@@ -11,6 +11,7 @@ HEADERS += projectexplorer.h \
|
|||||||
environmentaspectwidget.h \
|
environmentaspectwidget.h \
|
||||||
gcctoolchain.h \
|
gcctoolchain.h \
|
||||||
localapplicationrunconfiguration.h \
|
localapplicationrunconfiguration.h \
|
||||||
|
localenvironmentaspect.h \
|
||||||
projectexplorer_export.h \
|
projectexplorer_export.h \
|
||||||
projectwindow.h \
|
projectwindow.h \
|
||||||
removetaskhandler.h \
|
removetaskhandler.h \
|
||||||
@@ -138,6 +139,7 @@ SOURCES += projectexplorer.cpp \
|
|||||||
environmentaspectwidget.cpp \
|
environmentaspectwidget.cpp \
|
||||||
gcctoolchain.cpp \
|
gcctoolchain.cpp \
|
||||||
localapplicationrunconfiguration.cpp \
|
localapplicationrunconfiguration.cpp \
|
||||||
|
localenvironmentaspect.cpp \
|
||||||
projectwindow.cpp \
|
projectwindow.cpp \
|
||||||
removetaskhandler.cpp \
|
removetaskhandler.cpp \
|
||||||
kit.cpp \
|
kit.cpp \
|
||||||
|
@@ -142,6 +142,8 @@ QtcPlugin {
|
|||||||
"localapplicationrunconfiguration.h",
|
"localapplicationrunconfiguration.h",
|
||||||
"localapplicationruncontrol.cpp",
|
"localapplicationruncontrol.cpp",
|
||||||
"localapplicationruncontrol.h",
|
"localapplicationruncontrol.h",
|
||||||
|
"localenvironmentaspect.cpp",
|
||||||
|
"localenvironmentaspect.h",
|
||||||
"metatypedeclarations.h",
|
"metatypedeclarations.h",
|
||||||
"miniprojecttargetselector.cpp",
|
"miniprojecttargetselector.cpp",
|
||||||
"miniprojecttargetselector.h",
|
"miniprojecttargetselector.h",
|
||||||
|
@@ -666,6 +666,34 @@ void Qt4RunConfiguration::setRunMode(RunMode runMode)
|
|||||||
emit runModeChanged(runMode);
|
emit runModeChanged(runMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Qt4RunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
||||||
|
{
|
||||||
|
if (m_isUsingDyldImageSuffix)
|
||||||
|
env.set(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug"));
|
||||||
|
|
||||||
|
// The user could be linking to a library found via a -L/some/dir switch
|
||||||
|
// to find those libraries while actually running we explicitly prepend those
|
||||||
|
// dirs to the library search path
|
||||||
|
const Qt4ProFileNode *node = static_cast<Qt4Project *>(target()->project())->rootQt4ProjectNode()->findProFileFor(m_proFilePath);
|
||||||
|
if (node) {
|
||||||
|
const QStringList libDirectories = node->variableValue(LibDirectoriesVar);
|
||||||
|
if (!libDirectories.isEmpty()) {
|
||||||
|
const QString proDirectory = node->buildDir();
|
||||||
|
foreach (QString dir, libDirectories) {
|
||||||
|
// Fix up relative entries like "LIBS+=-L.."
|
||||||
|
const QFileInfo fi(dir);
|
||||||
|
if (!fi.isAbsolute())
|
||||||
|
dir = QDir::cleanPath(proDirectory + QLatin1Char('/') + dir);
|
||||||
|
env.prependOrSetLibrarySearchPath(dir);
|
||||||
|
} // foreach
|
||||||
|
} // libDirectories
|
||||||
|
} // node
|
||||||
|
|
||||||
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
||||||
|
if (qtVersion)
|
||||||
|
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
|
||||||
|
}
|
||||||
|
|
||||||
QString Qt4RunConfiguration::proFilePath() const
|
QString Qt4RunConfiguration::proFilePath() const
|
||||||
{
|
{
|
||||||
return m_proFilePath;
|
return m_proFilePath;
|
||||||
|
@@ -99,6 +99,9 @@ public:
|
|||||||
Utils::OutputFormatter *createOutputFormatter() const;
|
Utils::OutputFormatter *createOutputFormatter() const;
|
||||||
|
|
||||||
void setRunMode(RunMode runMode);
|
void setRunMode(RunMode runMode);
|
||||||
|
|
||||||
|
void addToBaseEnvironment(Utils::Environment &env) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void commandLineArgumentsChanged(const QString&);
|
void commandLineArgumentsChanged(const QString&);
|
||||||
void baseWorkingDirectoryChanged(const QString&);
|
void baseWorkingDirectoryChanged(const QString&);
|
||||||
|
Reference in New Issue
Block a user