2008-12-02 12:01:29 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-01-13 19:21:51 +01:00
|
|
|
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
|
** Non-Open Source Usage
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Licensees may use this file in accordance with the Qt Beta Version
|
|
|
|
|
** License Agreement, Agreement version 2.2 provided with the Software or,
|
|
|
|
|
** alternatively, in accordance with the terms contained in a written
|
2008-12-02 14:17:16 +01:00
|
|
|
** agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
|
** Public License versions 2.0 or 3.0 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
|
|
|
|
** of this file. Please review the following information to ensure GNU
|
|
|
|
|
** General Public Licensing requirements will be met:
|
|
|
|
|
**
|
|
|
|
|
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
|
|
|
|
** http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2008-12-02 14:17:16 +01:00
|
|
|
** rights. These rights are described in the Nokia Qt GPL Exception
|
2008-12-16 17:20:00 +01:00
|
|
|
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
|
***************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "processstep.h"
|
|
|
|
|
#include "buildstep.h"
|
|
|
|
|
#include "project.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/ifile.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
|
|
|
|
ProcessStep::ProcessStep(Project *pro)
|
|
|
|
|
: AbstractProcessStep(pro)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessStep::init(const QString &buildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
setEnvironment(buildConfiguration, project()->environment(buildConfiguration));
|
|
|
|
|
QVariant wd = value(buildConfiguration, "workingDirectory").toString();
|
|
|
|
|
QString workingDirectory;
|
2008-12-09 11:07:24 +01:00
|
|
|
if (!wd.isValid() || wd.toString().isEmpty())
|
2008-12-02 12:01:29 +01:00
|
|
|
workingDirectory = "$BUILDDIR";
|
|
|
|
|
else
|
|
|
|
|
workingDirectory = wd.toString();
|
|
|
|
|
setWorkingDirectory(buildConfiguration, workingDirectory.replace("$BUILDDIR", project()->buildDirectory(buildConfiguration)));
|
|
|
|
|
return AbstractProcessStep::init(buildConfiguration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStep::run(QFutureInterface<bool> & fi)
|
|
|
|
|
{
|
|
|
|
|
return AbstractProcessStep::run(fi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProcessStep::name()
|
|
|
|
|
{
|
|
|
|
|
return "projectexplorer.processstep";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStep::setDisplayName(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
setValue("ProjectExplorer.ProcessStep.DisplayName", name);
|
|
|
|
|
emit displayNameChanged(this, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProcessStep::displayName()
|
|
|
|
|
{
|
|
|
|
|
QVariant displayName = value("ProjectExplorer.ProcessStep.DisplayName");
|
|
|
|
|
if (displayName.isValid())
|
|
|
|
|
return displayName.toString();
|
|
|
|
|
else
|
|
|
|
|
return tr("Custom Process Step");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepConfigWidget *ProcessStep::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
return new ProcessStepConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessStep::immutable() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//*******
|
|
|
|
|
// ProcessStepFactory
|
|
|
|
|
//*******
|
|
|
|
|
|
|
|
|
|
ProcessStepFactory::ProcessStepFactory()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessStepFactory::canCreate(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
return name == "projectexplorer.processstep";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStep *ProcessStepFactory::create(Project *pro, const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(name);
|
|
|
|
|
return new ProcessStep(pro);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ProcessStepFactory::canCreateForProject(Project *pro) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(pro)
|
|
|
|
|
return QStringList()<<"projectexplorer.processstep";
|
|
|
|
|
}
|
|
|
|
|
QString ProcessStepFactory::displayNameForName(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(name);
|
|
|
|
|
return "Custom Process Step";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//*******
|
|
|
|
|
// ProcessStepConfigWidget
|
|
|
|
|
//*******
|
|
|
|
|
|
|
|
|
|
ProcessStepConfigWidget::ProcessStepConfigWidget(ProcessStep *step)
|
|
|
|
|
: m_step(step)
|
|
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
connect(m_ui.commandBrowseButton, SIGNAL(clicked(bool)),
|
|
|
|
|
this, SLOT(commandBrowseButtonClicked()));
|
|
|
|
|
connect(m_ui.workingDirBrowseButton, SIGNAL(clicked(bool)),
|
|
|
|
|
this, SLOT(workingDirBrowseButtonClicked()));
|
|
|
|
|
|
|
|
|
|
connect(m_ui.nameLineEdit, SIGNAL(textEdited(const QString&)),
|
|
|
|
|
this, SLOT(nameLineEditTextEdited()));
|
|
|
|
|
connect(m_ui.commandLineEdit, SIGNAL(textEdited(const QString&)),
|
|
|
|
|
this, SLOT(commandLineEditTextEdited()));
|
|
|
|
|
connect(m_ui.workingDirectoryLineEdit, SIGNAL(textEdited(const QString&)),
|
|
|
|
|
this, SLOT(workingDirectoryLineEditTextEdited()));
|
|
|
|
|
connect(m_ui.commandArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
|
|
|
|
|
this, SLOT(commandArgumentsLineEditTextEdited()));
|
|
|
|
|
connect(m_ui.enabledGroupBox, SIGNAL(clicked(bool)),
|
|
|
|
|
this, SLOT(enabledGroupBoxClicked(bool)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProcessStepConfigWidget::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_step->name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::workingDirBrowseButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
QString workingDirectory = QFileDialog::getExistingDirectory(this, "Select the working directory", m_ui.workingDirectoryLineEdit->text());
|
2008-12-09 11:07:24 +01:00
|
|
|
if (workingDirectory.isEmpty())
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
m_ui.workingDirectoryLineEdit->setText(workingDirectory);
|
|
|
|
|
workingDirectoryLineEditTextEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::commandBrowseButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
QString filename = QFileDialog::getOpenFileName(this, "Select the executable");
|
2008-12-09 11:07:24 +01:00
|
|
|
if (filename.isEmpty())
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
m_ui.commandLineEdit->setText(filename);
|
|
|
|
|
commandLineEditTextEdited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::init(const QString &buildConfiguration)
|
|
|
|
|
{
|
|
|
|
|
m_buildConfiguration = buildConfiguration;
|
2008-12-09 11:07:24 +01:00
|
|
|
if (buildConfiguration != QString::null) {
|
2008-12-02 12:01:29 +01:00
|
|
|
m_ui.commandLineEdit->setText(m_step->command(buildConfiguration));
|
|
|
|
|
|
|
|
|
|
QString workingDirectory = m_step->value(buildConfiguration, "workingDirectory").toString();
|
|
|
|
|
if (workingDirectory.isEmpty())
|
|
|
|
|
workingDirectory = "$BUILDDIR";
|
|
|
|
|
m_ui.workingDirectoryLineEdit->setText(workingDirectory);
|
|
|
|
|
|
|
|
|
|
m_ui.commandArgumentsLineEdit->setText(m_step->arguments(buildConfiguration).join(" "));
|
|
|
|
|
m_ui.enabledGroupBox->setChecked(m_step->enabled(buildConfiguration));
|
|
|
|
|
}
|
|
|
|
|
m_ui.nameLineEdit->setText(m_step->displayName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::nameLineEditTextEdited()
|
|
|
|
|
{
|
|
|
|
|
m_step->setDisplayName(m_ui.nameLineEdit->text());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::commandLineEditTextEdited()
|
|
|
|
|
{
|
|
|
|
|
m_step->setCommand(m_buildConfiguration, m_ui.commandLineEdit->text());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::workingDirectoryLineEditTextEdited()
|
|
|
|
|
{
|
|
|
|
|
QString wd = m_ui.workingDirectoryLineEdit->text();
|
|
|
|
|
m_step->setValue(m_buildConfiguration, "workingDirectory", wd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::commandArgumentsLineEditTextEdited()
|
|
|
|
|
{
|
|
|
|
|
m_step->setArguments(m_buildConfiguration, m_ui.commandArgumentsLineEdit->text().split(" ",
|
|
|
|
|
QString::SkipEmptyParts));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessStepConfigWidget::enabledGroupBoxClicked(bool)
|
|
|
|
|
{
|
|
|
|
|
m_step->setEnabled(m_buildConfiguration, m_ui.enabledGroupBox->isChecked());
|
|
|
|
|
}
|