2013-05-15 13:39:00 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2013-05-15 13:39:00 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-05-15 13:39:00 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-05-15 13:39:00 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-05-15 13:39:00 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsrunconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsdeployconfigurationfactory.h"
|
|
|
|
|
#include "qbsinstallstep.h"
|
|
|
|
|
#include "qbsproject.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
2015-08-21 14:35:28 +02:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <projectexplorer/buildstep.h>
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
|
|
|
|
#include <projectexplorer/localapplicationruncontrol.h>
|
|
|
|
|
#include <projectexplorer/localenvironmentaspect.h>
|
2015-05-05 09:48:50 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2015-04-30 08:33:38 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/detailswidget.h>
|
|
|
|
|
#include <utils/stringutils.h>
|
|
|
|
|
#include <utils/persistentsettings.h>
|
|
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
|
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
|
2014-06-04 19:03:55 +02:00
|
|
|
#include "api/runenvironment.h"
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); }
|
|
|
|
|
|
|
|
|
|
static Core::Id idFromProduct(const QbsProject *project, const qbs::ProductData &product)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
QString id = QLatin1String(QBS_RC_PREFIX);
|
|
|
|
|
id.append(QbsProject::uniqueProductName(product)).append(rcNameSeparator())
|
|
|
|
|
.append(QbsProject::productDisplayName(project->qbsProject(), product));
|
|
|
|
|
return Core::Id::fromString(id);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
static QString uniqueProductNameFromId(Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
|
|
|
|
|
return suffix.left(suffix.indexOf(rcNameSeparator()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString productDisplayNameFromId(Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
|
|
|
|
|
const int sepPos = suffix.indexOf(rcNameSeparator());
|
|
|
|
|
if (sepPos == -1)
|
|
|
|
|
return suffix;
|
|
|
|
|
return suffix.mid(sepPos + rcNameSeparator().count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &uniqeName)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2013-06-21 15:09:01 +02:00
|
|
|
foreach (const qbs::ProductData &product, pro.allProducts()) {
|
2014-09-05 12:08:15 +02:00
|
|
|
if (QbsProject::uniqueProductName(product) == uniqeName)
|
2013-06-21 15:09:01 +02:00
|
|
|
return product;
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
2013-06-21 15:09:01 +02:00
|
|
|
return qbs::ProductData();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsRunConfiguration:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
|
2013-05-15 13:39:00 +02:00
|
|
|
LocalApplicationRunConfiguration(parent, id),
|
2014-09-05 12:08:15 +02:00
|
|
|
m_uniqueProductName(uniqueProductNameFromId(id)),
|
2013-05-15 13:39:00 +02:00
|
|
|
m_currentInstallStep(0),
|
|
|
|
|
m_currentBuildStepList(0)
|
|
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
addExtraAspect(new LocalEnvironmentAspect(this));
|
2015-04-30 08:33:38 +02:00
|
|
|
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments")));
|
2015-05-05 09:48:50 +02:00
|
|
|
addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory")));
|
2013-11-01 14:13:41 +01:00
|
|
|
|
2015-05-12 13:05:14 +02:00
|
|
|
addExtraAspect(new TerminalAspect(this,
|
|
|
|
|
QStringLiteral("Qbs.RunConfiguration.UseTerminal"),
|
|
|
|
|
isConsoleApplication()));
|
2014-11-07 11:53:08 +01:00
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
|
2013-05-15 13:39:00 +02:00
|
|
|
LocalApplicationRunConfiguration(parent, source),
|
2014-09-05 12:08:15 +02:00
|
|
|
m_uniqueProductName(source->m_uniqueProductName),
|
2013-10-18 17:45:07 +02:00
|
|
|
m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway.
|
|
|
|
|
m_currentBuildStepList(0) // ditto
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsRunConfiguration::isEnabled() const
|
|
|
|
|
{
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
|
|
|
|
return !project->isParsing() && project->hasParseResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsRunConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
|
|
|
|
if (project->isParsing())
|
|
|
|
|
return tr("The .qbs files are currently being parsed.");
|
|
|
|
|
|
|
|
|
|
if (!project->hasParseResult())
|
|
|
|
|
return tr("Parsing of .qbs files has failed.");
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfiguration::ctor()
|
|
|
|
|
{
|
|
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
|
|
|
|
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
2014-11-07 11:53:08 +01:00
|
|
|
connect(project, &QbsProject::projectParsingStarted, this, &RunConfiguration::enabledChanged);
|
|
|
|
|
connect(project, &QbsProject::projectParsingDone, this, [this](bool success) {
|
2015-05-12 13:05:14 +02:00
|
|
|
auto terminalAspect = extraAspect<TerminalAspect>();
|
|
|
|
|
if (success && !terminalAspect->isUserSet())
|
|
|
|
|
terminalAspect->setUseTerminal(isConsoleApplication());
|
2014-11-07 11:53:08 +01:00
|
|
|
emit enabledChanged();
|
|
|
|
|
});
|
2015-08-21 14:35:28 +02:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged, this,
|
|
|
|
|
[this, project](Project *p) {
|
|
|
|
|
if (p == project && !BuildManager::isBuilding(p))
|
|
|
|
|
emit enabledChanged();
|
|
|
|
|
}
|
|
|
|
|
);
|
2014-11-07 11:53:08 +01:00
|
|
|
|
|
|
|
|
connect(target(), &Target::activeDeployConfigurationChanged,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
2013-05-15 13:39:00 +02:00
|
|
|
installStepChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *QbsRunConfiguration::createConfigurationWidget()
|
|
|
|
|
{
|
|
|
|
|
return new QbsRunConfigurationWidget(this, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfiguration::installStepChanged()
|
|
|
|
|
{
|
|
|
|
|
if (m_currentInstallStep)
|
|
|
|
|
disconnect(m_currentInstallStep, SIGNAL(changed()), this, SIGNAL(targetInformationChanged()));
|
|
|
|
|
if (m_currentBuildStepList) {
|
|
|
|
|
disconnect(m_currentBuildStepList, SIGNAL(stepInserted(int)), this, SLOT(installStepChanged()));
|
|
|
|
|
disconnect(m_currentBuildStepList, SIGNAL(stepRemoved(int)), this, SLOT(installStepChanged()));
|
|
|
|
|
disconnect(m_currentBuildStepList, SIGNAL(stepMoved(int,int)), this, SLOT(installStepChanged()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsDeployConfiguration *activeDc = qobject_cast<QbsDeployConfiguration *>(target()->activeDeployConfiguration());
|
|
|
|
|
m_currentBuildStepList = activeDc ? activeDc->stepList() : 0;
|
|
|
|
|
m_currentInstallStep = activeDc ? activeDc->qbsInstallStep() : 0;
|
|
|
|
|
|
|
|
|
|
if (m_currentInstallStep)
|
|
|
|
|
connect(m_currentInstallStep, SIGNAL(changed()), this, SIGNAL(targetInformationChanged()));
|
|
|
|
|
|
|
|
|
|
if (m_currentBuildStepList) {
|
|
|
|
|
connect(m_currentBuildStepList, SIGNAL(stepInserted(int)), this, SLOT(installStepChanged()));
|
2014-08-26 17:20:42 +02:00
|
|
|
connect(m_currentBuildStepList, SIGNAL(aboutToRemoveStep(int)), this,
|
|
|
|
|
SLOT(installStepToBeRemoved(int)));
|
2013-05-15 13:39:00 +02:00
|
|
|
connect(m_currentBuildStepList, SIGNAL(stepRemoved(int)), this, SLOT(installStepChanged()));
|
|
|
|
|
connect(m_currentBuildStepList, SIGNAL(stepMoved(int,int)), this, SLOT(installStepChanged()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit targetInformationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-26 17:20:42 +02:00
|
|
|
void QbsRunConfiguration::installStepToBeRemoved(int pos)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_currentBuildStepList, return);
|
|
|
|
|
// TODO: Our logic is rather broken. Users can create as many qbs install steps as they want,
|
|
|
|
|
// but we ignore all but the first one.
|
|
|
|
|
if (m_currentBuildStepList->steps().at(pos) != m_currentInstallStep)
|
|
|
|
|
return;
|
|
|
|
|
disconnect(m_currentInstallStep, SIGNAL(changed()), this, SIGNAL(targetInformationChanged()));
|
|
|
|
|
m_currentInstallStep = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
QString QbsRunConfiguration::executable() const
|
|
|
|
|
{
|
|
|
|
|
QbsProject *pro = static_cast<QbsProject *>(target()->project());
|
2014-09-05 12:08:15 +02:00
|
|
|
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_uniqueProductName);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2013-09-06 18:02:46 +02:00
|
|
|
if (!product.isValid() || !pro->qbsProject().isValid())
|
2013-05-15 13:39:00 +02:00
|
|
|
return QString();
|
|
|
|
|
|
2013-09-06 18:02:46 +02:00
|
|
|
return pro->qbsProject().targetExecutable(product, installOptions());
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 23:42:25 +03:00
|
|
|
ApplicationLauncher::Mode QbsRunConfiguration::runMode() const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2015-05-12 13:05:14 +02:00
|
|
|
return extraAspect<TerminalAspect>()->runMode();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2013-11-19 11:30:00 +01:00
|
|
|
bool QbsRunConfiguration::isConsoleApplication() const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2013-08-07 14:18:19 +02:00
|
|
|
QbsProject *pro = static_cast<QbsProject *>(target()->project());
|
2014-09-05 12:08:15 +02:00
|
|
|
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_uniqueProductName);
|
2014-11-07 11:53:08 +01:00
|
|
|
return product.properties().value(QLatin1String("consoleApplication"), false).toBool();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsRunConfiguration::workingDirectory() const
|
|
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
|
2014-11-18 17:34:24 +01:00
|
|
|
QTC_ASSERT(aspect, return baseWorkingDirectory());
|
2013-05-15 13:39:00 +02:00
|
|
|
return QDir::cleanPath(aspect->environment().expandVariables(
|
2014-10-15 14:45:31 +02:00
|
|
|
macroExpander()->expand(baseWorkingDirectory())));
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsRunConfiguration::baseWorkingDirectory() const
|
|
|
|
|
{
|
2015-05-05 09:48:50 +02:00
|
|
|
WorkingDirectoryAspect *aspect = extraAspect<WorkingDirectoryAspect>();
|
2013-05-15 13:39:00 +02:00
|
|
|
// if the user overrode us, then return his working directory
|
2015-05-05 09:48:50 +02:00
|
|
|
QString wd = aspect->unexpandedWorkingDirectory();
|
|
|
|
|
if (!wd.isEmpty())
|
|
|
|
|
return wd;
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
// else what the pro file reader tells us
|
|
|
|
|
const QString exe = executable();
|
|
|
|
|
if (!exe.isEmpty())
|
|
|
|
|
return QFileInfo(executable()).absolutePath();
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsRunConfiguration::commandLineArguments() const
|
|
|
|
|
{
|
2015-04-30 08:33:38 +02:00
|
|
|
return extraAspect<ArgumentsAspect>()->arguments();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfiguration::setBaseWorkingDirectory(const QString &wd)
|
|
|
|
|
{
|
2015-05-05 09:48:50 +02:00
|
|
|
WorkingDirectoryAspect *aspect = extraAspect<WorkingDirectoryAspect>();
|
2013-05-15 13:39:00 +02:00
|
|
|
const QString &oldWorkingDirectory = workingDirectory();
|
|
|
|
|
|
2015-05-05 09:48:50 +02:00
|
|
|
aspect->setWorkingDirectory(wd);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
const QString &newWorkingDirectory = workingDirectory();
|
|
|
|
|
if (oldWorkingDirectory != newWorkingDirectory)
|
|
|
|
|
emit baseWorkingDirectoryChanged(newWorkingDirectory);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 23:42:25 +03:00
|
|
|
void QbsRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2015-05-12 13:05:14 +02:00
|
|
|
extraAspect<TerminalAspect>()->setRunMode(runMode);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
|
|
|
|
{
|
2014-06-04 19:03:55 +02:00
|
|
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
|
|
|
|
if (project) {
|
2014-09-05 12:08:15 +02:00
|
|
|
const qbs::ProductData product = findProduct(project->qbsProjectData(), m_uniqueProductName);
|
2014-06-04 19:03:55 +02:00
|
|
|
if (product.isValid()) {
|
2014-09-27 21:44:37 -04:00
|
|
|
QProcessEnvironment procEnv = env.toProcessEnvironment();
|
|
|
|
|
procEnv.insert(QLatin1String("QBS_RUN_FILE_PATH"), executable());
|
2014-09-16 15:17:21 +02:00
|
|
|
qbs::RunEnvironment qbsRunEnv = project->qbsProject().getRunEnvironment(product, installOptions(),
|
2014-09-27 21:44:37 -04:00
|
|
|
procEnv, QbsManager::settings());
|
|
|
|
|
procEnv = qbsRunEnv.runEnvironment();
|
2014-06-04 19:03:55 +02:00
|
|
|
if (!procEnv.isEmpty()) {
|
|
|
|
|
env = Utils::Environment();
|
|
|
|
|
foreach (const QString &key, procEnv.keys())
|
|
|
|
|
env.set(key, procEnv.value(key));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
|
|
|
|
if (qtVersion)
|
|
|
|
|
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
QString QbsRunConfiguration::uniqueProductName() const
|
2013-05-16 16:10:47 +02:00
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
return m_uniqueProductName;
|
2013-05-16 16:10:47 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
QString QbsRunConfiguration::defaultDisplayName()
|
|
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
QString defaultName = productDisplayNameFromId(id());
|
|
|
|
|
if (defaultName.isEmpty())
|
2013-05-15 13:39:00 +02:00
|
|
|
defaultName = tr("Qbs Run Configuration");
|
|
|
|
|
return defaultName;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-24 16:20:10 +02:00
|
|
|
qbs::InstallOptions QbsRunConfiguration::installOptions() const
|
|
|
|
|
{
|
|
|
|
|
if (m_currentInstallStep)
|
|
|
|
|
return m_currentInstallStep->installOptions();
|
|
|
|
|
return qbs::InstallOptions();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
QString QbsRunConfiguration::installRoot() const
|
|
|
|
|
{
|
|
|
|
|
if (m_currentInstallStep)
|
|
|
|
|
return m_currentInstallStep->absoluteInstallRoot();
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::OutputFormatter *QbsRunConfiguration::createOutputFormatter() const
|
|
|
|
|
{
|
|
|
|
|
return new QtSupport::QtOutputFormatter(target()->project());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsRunConfigurationWidget:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc, QWidget *parent)
|
|
|
|
|
: QWidget(parent),
|
|
|
|
|
m_rc(rc),
|
|
|
|
|
m_ignoreChange(false),
|
|
|
|
|
m_isShown(false)
|
|
|
|
|
{
|
|
|
|
|
QVBoxLayout *vboxTopLayout = new QVBoxLayout(this);
|
|
|
|
|
vboxTopLayout->setMargin(0);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *hl = new QHBoxLayout();
|
|
|
|
|
hl->addStretch();
|
|
|
|
|
m_disabledIcon = new QLabel(this);
|
2014-06-13 11:19:54 +02:00
|
|
|
m_disabledIcon->setPixmap(QPixmap(QLatin1String(Core::Constants::ICON_WARNING)));
|
2013-05-15 13:39:00 +02:00
|
|
|
hl->addWidget(m_disabledIcon);
|
|
|
|
|
m_disabledReason = new QLabel(this);
|
|
|
|
|
m_disabledReason->setVisible(false);
|
|
|
|
|
hl->addWidget(m_disabledReason);
|
|
|
|
|
hl->addStretch();
|
|
|
|
|
vboxTopLayout->addLayout(hl);
|
|
|
|
|
|
|
|
|
|
m_detailsContainer = new Utils::DetailsWidget(this);
|
|
|
|
|
m_detailsContainer->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
vboxTopLayout->addWidget(m_detailsContainer);
|
|
|
|
|
QWidget *detailsWidget = new QWidget(m_detailsContainer);
|
|
|
|
|
m_detailsContainer->setWidget(detailsWidget);
|
|
|
|
|
QFormLayout *toplayout = new QFormLayout(detailsWidget);
|
|
|
|
|
toplayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
|
toplayout->setMargin(0);
|
|
|
|
|
|
2015-01-23 12:05:14 +01:00
|
|
|
m_executableLineLabel = new QLabel(this);
|
|
|
|
|
m_executableLineLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
|
|
|
setExecutableLineText();
|
|
|
|
|
toplayout->addRow(tr("Executable:"), m_executableLineLabel);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2015-04-30 08:33:38 +02:00
|
|
|
m_rc->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, toplayout);
|
2015-05-05 09:48:50 +02:00
|
|
|
m_rc->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, toplayout);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2015-05-12 13:05:14 +02:00
|
|
|
m_rc->extraAspect<TerminalAspect>()->addToMainConfigurationWidget(this, toplayout);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
runConfigurationEnabledChange();
|
|
|
|
|
|
|
|
|
|
connect(m_rc, SIGNAL(targetInformationChanged()),
|
|
|
|
|
this, SLOT(targetInformationHasChanged()), Qt::QueuedConnection);
|
|
|
|
|
|
|
|
|
|
connect(m_rc, SIGNAL(enabledChanged()),
|
|
|
|
|
this, SLOT(runConfigurationEnabledChange()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfigurationWidget::runConfigurationEnabledChange()
|
|
|
|
|
{
|
|
|
|
|
bool enabled = m_rc->isEnabled();
|
|
|
|
|
m_disabledIcon->setVisible(!enabled);
|
|
|
|
|
m_disabledReason->setVisible(!enabled);
|
|
|
|
|
m_disabledReason->setText(m_rc->disabledReason());
|
2013-11-19 11:30:00 +01:00
|
|
|
|
2013-05-24 16:19:55 +02:00
|
|
|
targetInformationHasChanged();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfigurationWidget::targetInformationHasChanged()
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2015-01-23 12:05:14 +01:00
|
|
|
setExecutableLineText(m_rc->executable());
|
2013-05-24 16:19:55 +02:00
|
|
|
|
2015-05-05 09:48:50 +02:00
|
|
|
WorkingDirectoryAspect *aspect = m_rc->extraAspect<WorkingDirectoryAspect>();
|
|
|
|
|
aspect->pathChooser()->setPath(m_rc->baseWorkingDirectory());
|
|
|
|
|
aspect->pathChooser()->setBaseFileName(m_rc->target()->project()->projectDirectory());
|
2013-05-15 13:39:00 +02:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-23 12:05:14 +01:00
|
|
|
void QbsRunConfigurationWidget::setExecutableLineText(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
const QString newText = text.isEmpty() ? tr("<unknown>") : text;
|
|
|
|
|
m_executableLineLabel->setText(newText);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsRunConfigurationFactory:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QbsRunConfigurationFactory::QbsRunConfigurationFactory(QObject *parent) :
|
2014-05-26 22:13:14 +03:00
|
|
|
IRunConfigurationFactory(parent)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("QbsRunConfigurationFactory"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsRunConfigurationFactory::~QbsRunConfigurationFactory()
|
|
|
|
|
{ }
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
bool QbsRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
2014-09-05 12:08:15 +02:00
|
|
|
return findProduct(project->qbsProjectData(), uniqueProductNameFromId(id)).isValid();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
RunConfiguration *QbsRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
return new QbsRunConfiguration(parent, id);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool QbsRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return false;
|
2014-05-26 22:13:14 +03:00
|
|
|
return idFromMap(map).toString().startsWith(QLatin1String(QBS_RC_PREFIX));
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
RunConfiguration *QbsRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
return new QbsRunConfiguration(parent, idFromMap(map));
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool QbsRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
return canCreate(parent, source->id());
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
RunConfiguration *QbsRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
|
|
|
|
QbsRunConfiguration *old = static_cast<QbsRunConfiguration *>(source);
|
|
|
|
|
return new QbsRunConfiguration(parent, old);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 16:24:52 +02:00
|
|
|
QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2014-06-12 16:24:52 +02:00
|
|
|
Q_UNUSED(mode)
|
2013-05-15 13:39:00 +02:00
|
|
|
QList<Core::Id> result;
|
|
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
2013-09-06 18:02:46 +02:00
|
|
|
if (!project || !project->qbsProject().isValid())
|
2013-05-15 13:39:00 +02:00
|
|
|
return result;
|
|
|
|
|
|
2014-03-21 11:02:54 +01:00
|
|
|
foreach (const qbs::ProductData &product, project->qbsProjectData().allProducts()) {
|
2014-04-30 11:03:14 +02:00
|
|
|
if (product.isRunnable() && product.isEnabled())
|
2014-09-05 12:08:15 +02:00
|
|
|
result << idFromProduct(project, product);
|
2014-03-21 11:02:54 +01:00
|
|
|
}
|
2014-03-03 16:04:44 +01:00
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
QString QbsRunConfigurationFactory::displayNameForId(Core::Id id) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
return productDisplayNameFromId(id);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool QbsRunConfigurationFactory::canHandle(Target *t) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!t->project()->supportsKit(t->kit()))
|
|
|
|
|
return false;
|
|
|
|
|
if (!qobject_cast<QbsProject *>(t->project()))
|
|
|
|
|
return false;
|
2014-05-26 22:13:14 +03:00
|
|
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(t->kit());
|
|
|
|
|
return devType == Constants::DESKTOP_DEVICE_TYPE;
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|