2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-04 13:06:02 +01:00
|
|
|
#include "makestep.h"
|
|
|
|
|
#include "cmakeprojectconstants.h"
|
|
|
|
|
#include "cmakeproject.h"
|
2009-11-25 18:50:20 +01:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2009-09-29 11:39:55 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
|
2009-01-12 15:10:33 +01:00
|
|
|
#include <QtGui/QFormLayout>
|
|
|
|
|
#include <QtGui/QGroupBox>
|
|
|
|
|
#include <QtGui/QCheckBox>
|
|
|
|
|
#include <QtGui/QLineEdit>
|
|
|
|
|
#include <QtGui/QListWidget>
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
|
using namespace CMakeProjectManager::Internal;
|
2009-10-27 14:16:28 +01:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2009-11-23 15:47:26 +01:00
|
|
|
MakeStep::MakeStep(BuildConfiguration *bc)
|
|
|
|
|
: AbstractMakeStep(bc), m_clean(false), m_futureInterface(0)
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2009-04-07 13:52:28 +02:00
|
|
|
m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]");
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
MakeStep::MakeStep(MakeStep *bs, BuildConfiguration *bc)
|
|
|
|
|
: AbstractMakeStep(bs, bc),
|
|
|
|
|
m_clean(bs->m_clean),
|
|
|
|
|
m_futureInterface(0),
|
|
|
|
|
m_buildTargets(bs->m_buildTargets),
|
|
|
|
|
m_additionalArguments(bs->m_buildTargets)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
MakeStep::~MakeStep()
|
|
|
|
|
{
|
2009-05-05 14:56:59 +02:00
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *MakeStep::cmakeBuildConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<CMakeBuildConfiguration *>(buildConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-15 19:06:51 +02:00
|
|
|
void MakeStep::setClean(bool clean)
|
|
|
|
|
{
|
|
|
|
|
m_clean = clean;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
void MakeStep::restoreFromGlobalMap(const QMap<QString, QVariant> &map)
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
|
|
|
|
if (map.value("clean").isValid() && map.value("clean").toBool())
|
|
|
|
|
m_clean = true;
|
2009-10-27 14:16:28 +01:00
|
|
|
AbstractMakeStep::restoreFromGlobalMap(map);
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
void MakeStep::restoreFromLocalMap(const QMap<QString, QVariant> &map)
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
m_buildTargets = map["buildTargets"].toStringList();
|
|
|
|
|
m_additionalArguments = map["additionalArguments"].toStringList();
|
|
|
|
|
if (map.value("clean").isValid() && map.value("clean").toBool())
|
|
|
|
|
m_clean = true;
|
|
|
|
|
AbstractMakeStep::restoreFromLocalMap(map);
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
void MakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map)
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
map["buildTargets"] = m_buildTargets;
|
|
|
|
|
map["additionalArguments"] = m_additionalArguments;
|
|
|
|
|
if (m_clean)
|
|
|
|
|
map["clean"] = true;
|
|
|
|
|
AbstractMakeStep::storeIntoLocalMap(map);
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
bool MakeStep::init()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
|
2009-11-25 18:50:20 +01:00
|
|
|
setBuildParser(bc->buildParser());
|
2009-02-16 13:12:12 +01:00
|
|
|
|
2009-10-15 19:06:51 +02:00
|
|
|
setEnabled(true);
|
2009-11-25 18:50:20 +01:00
|
|
|
setWorkingDirectory(bc->buildDirectory());
|
2009-07-02 16:44:51 +02:00
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
setCommand(bc->toolChain()->makeCommand());
|
2009-06-22 16:11:45 +02:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
QStringList arguments = m_buildTargets;
|
|
|
|
|
arguments << additionalArguments();
|
|
|
|
|
setArguments(arguments);
|
2009-11-25 18:50:20 +01:00
|
|
|
setEnvironment(bc->environment());
|
2009-10-15 19:06:51 +02:00
|
|
|
setIgnoreReturnValue(m_clean);
|
2009-06-22 16:11:45 +02:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
return AbstractMakeStep::init();
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::run(QFutureInterface<bool> &fi)
|
|
|
|
|
{
|
2009-04-07 13:52:28 +02:00
|
|
|
m_futureInterface = &fi;
|
|
|
|
|
m_futureInterface->setProgressRange(0, 100);
|
2009-05-05 14:56:59 +02:00
|
|
|
AbstractMakeStep::run(fi);
|
2009-05-25 17:09:38 +02:00
|
|
|
m_futureInterface->setProgressValue(100);
|
|
|
|
|
m_futureInterface->reportFinished();
|
2009-04-07 13:52:28 +02:00
|
|
|
m_futureInterface = 0;
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MakeStep::name()
|
|
|
|
|
{
|
2009-01-12 15:29:05 +01:00
|
|
|
return Constants::MAKESTEP;
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MakeStep::displayName()
|
|
|
|
|
{
|
2009-01-12 15:10:33 +01:00
|
|
|
return "Make";
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
BuildStepConfigWidget *MakeStep::createConfigWidget()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2009-03-18 13:33:00 +01:00
|
|
|
return new MakeStepConfigWidget(this);
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::immutable() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-16 13:12:12 +01:00
|
|
|
void MakeStep::stdOut(const QString &line)
|
|
|
|
|
{
|
2009-04-07 13:52:28 +02:00
|
|
|
if (m_percentProgress.indexIn(line) != -1) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
int percent = m_percentProgress.cap(1).toInt(&ok);;
|
|
|
|
|
if (ok)
|
|
|
|
|
m_futureInterface->setProgressValue(percent);
|
|
|
|
|
}
|
2009-05-05 14:56:59 +02:00
|
|
|
AbstractMakeStep::stdOut(line);
|
2009-02-16 13:12:12 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
bool MakeStep::buildsTarget(const QString &target) const
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
return m_buildTargets.contains(target);
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
void MakeStep::setBuildTarget(const QString &target, bool on)
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
QStringList old = m_buildTargets;
|
2009-01-12 15:10:33 +01:00
|
|
|
if (on && !old.contains(target))
|
2009-10-15 19:06:51 +02:00
|
|
|
old << target;
|
2009-01-12 15:10:33 +01:00
|
|
|
else if(!on && old.contains(target))
|
2009-10-27 16:13:09 +01:00
|
|
|
old.removeOne(target);
|
2009-10-27 14:16:28 +01:00
|
|
|
m_buildTargets = old;
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
QStringList MakeStep::additionalArguments() const
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
return m_additionalArguments;
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
void MakeStep::setAdditionalArguments(const QStringList &list)
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
m_additionalArguments = list;
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2009-03-18 13:33:00 +01:00
|
|
|
// MakeStepConfigWidget
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
2009-01-12 15:10:33 +01:00
|
|
|
: m_makeStep(makeStep)
|
|
|
|
|
{
|
|
|
|
|
QFormLayout *fl = new QFormLayout(this);
|
2009-07-23 17:00:38 +02:00
|
|
|
fl->setMargin(0);
|
|
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
2009-01-12 15:10:33 +01:00
|
|
|
setLayout(fl);
|
|
|
|
|
|
2009-03-12 15:51:44 +01:00
|
|
|
m_additionalArguments = new QLineEdit(this);
|
2009-04-17 21:11:52 +02:00
|
|
|
fl->addRow(tr("Additional arguments:"), m_additionalArguments);
|
2009-03-12 15:51:44 +01:00
|
|
|
|
|
|
|
|
connect(m_additionalArguments, SIGNAL(textEdited(const QString &)), this, SLOT(additionalArgumentsEdited()));
|
|
|
|
|
|
2009-01-12 15:10:33 +01:00
|
|
|
m_targetsList = new QListWidget;
|
2009-07-20 16:12:40 +02:00
|
|
|
m_targetsList->setMinimumHeight(200);
|
2009-04-17 21:11:52 +02:00
|
|
|
fl->addRow(tr("Targets:"), m_targetsList);
|
2009-01-12 15:10:33 +01:00
|
|
|
|
|
|
|
|
// TODO update this list also on rescans of the CMakeLists.txt
|
2009-11-24 15:36:31 +01:00
|
|
|
// TODO shouldn't be accessing project
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeProject *pro = m_makeStep->cmakeBuildConfiguration()->cmakeProject();
|
2009-01-12 15:10:33 +01:00
|
|
|
foreach(const QString& target, pro->targets()) {
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(target, m_targetsList);
|
|
|
|
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
|
|
|
|
}
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2009-01-12 15:10:33 +01:00
|
|
|
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
2009-08-12 17:02:28 +02:00
|
|
|
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
|
|
|
|
|
this, SLOT(updateDetails()));
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
void MakeStepConfigWidget::additionalArgumentsEdited()
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
m_makeStep->setAdditionalArguments(Environment::parseCombinedArgString(m_additionalArguments->text()));
|
2009-08-06 17:26:38 +02:00
|
|
|
updateDetails();
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
void MakeStepConfigWidget::itemChanged(QListWidgetItem *item)
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked);
|
2009-08-06 17:26:38 +02:00
|
|
|
updateDetails();
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
QString MakeStepConfigWidget::displayName() const
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
|
|
|
|
return "Make";
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
void MakeStepConfigWidget::init()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2009-01-12 15:10:33 +01:00
|
|
|
// disconnect to make the changes to the items
|
|
|
|
|
disconnect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
|
|
|
|
int count = m_targetsList->count();
|
|
|
|
|
for(int i = 0; i < count; ++i) {
|
|
|
|
|
QListWidgetItem *item = m_targetsList->item(i);
|
2009-10-27 14:16:28 +01:00
|
|
|
item->setCheckState(m_makeStep->buildsTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
// and connect again
|
|
|
|
|
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
m_additionalArguments->setText(Environment::joinArgumentList(m_makeStep->additionalArguments()));
|
2009-08-06 17:26:38 +02:00
|
|
|
updateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStepConfigWidget::updateDetails()
|
|
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
QStringList arguments = m_makeStep->m_buildTargets;
|
|
|
|
|
arguments << m_makeStep->additionalArguments();
|
2009-11-24 15:36:31 +01:00
|
|
|
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *bc = m_makeStep->cmakeBuildConfiguration();
|
2009-11-30 15:21:42 +01:00
|
|
|
ProjectExplorer::ToolChain *tc = bc->toolChain();
|
|
|
|
|
if (tc)
|
|
|
|
|
m_summaryText = tr("<b>Make:</b> %1 %2").arg(tc->makeCommand(), arguments.join(" "));
|
|
|
|
|
else
|
|
|
|
|
m_summaryText = tr("<b>Unknown Toolchain</b>");
|
2009-08-06 17:26:38 +02:00
|
|
|
emit updateSummary();
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
QString MakeStepConfigWidget::summaryText() const
|
|
|
|
|
{
|
2009-08-06 17:26:38 +02:00
|
|
|
return m_summaryText;
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2009-03-18 13:33:00 +01:00
|
|
|
// MakeStepFactory
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
bool MakeStepFactory::canCreate(const QString &name) const
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
|
|
|
|
return (Constants::MAKESTEP == name);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-23 15:47:26 +01:00
|
|
|
BuildStep *MakeStepFactory::create(BuildConfiguration *bc, const QString &name) const
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2008-12-17 15:51:48 +01:00
|
|
|
Q_ASSERT(name == Constants::MAKESTEP);
|
2009-11-23 15:47:26 +01:00
|
|
|
return new MakeStep(bc);
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStep *MakeStepFactory::clone(BuildStep *bs, BuildConfiguration *bc) const
|
|
|
|
|
{
|
|
|
|
|
return new MakeStep(static_cast<MakeStep *>(bs), bc);
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 20:00:28 +01:00
|
|
|
QStringList MakeStepFactory::canCreateForBuildConfiguration(BuildConfiguration * /* pro */) const
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
|
|
|
|
return QStringList();
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
QString MakeStepFactory::displayNameForName(const QString & /* name */) const
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
|
|
|
|
return "Make";
|
|
|
|
|
}
|
|
|
|
|
|