2011-11-29 14:19:28 +01:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Openismus GmbH.
|
2012-10-02 09:12:39 +02:00
|
|
|
** Authors: Peter Penz (ppenz@openismus.com)
|
|
|
|
** Patricia Santana Cruz (patriciasantanacruz@gmail.com)
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02: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.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-11-29 14:19:28 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
#include "configurestep.h"
|
|
|
|
#include "autotoolsproject.h"
|
|
|
|
#include "autotoolsbuildconfiguration.h"
|
|
|
|
#include "autotoolsprojectconstants.h"
|
|
|
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-11-29 14:19:28 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
|
|
|
#include <projectexplorer/gnumakeparser.h>
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVariantMap>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QFormLayout>
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
using namespace AutotoolsProjectManager;
|
|
|
|
using namespace AutotoolsProjectManager::Internal;
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
const char CONFIGURE_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.ConfigureStep.AdditionalArguments";
|
|
|
|
const char CONFIGURE_STEP_ID[] = "AutotoolsProjectManager.ConfigureStep";
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
// ConfigureStepFactory Class
|
|
|
|
////////////////////////////////
|
|
|
|
ConfigureStepFactory::ConfigureStepFactory(QObject *parent) :
|
2012-01-13 13:36:45 +01:00
|
|
|
IBuildStepFactory(parent)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> ConfigureStepFactory::availableCreationIds(BuildStepList *parent) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
|
|
|
return QList<Core::Id>();
|
|
|
|
return QList<Core::Id>() << Core::Id(CONFIGURE_STEP_ID);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
QString ConfigureStepFactory::displayNameForId(Core::Id id) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (id == CONFIGURE_STEP_ID)
|
2011-11-29 14:19:28 +01:00
|
|
|
return tr("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id.");
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
bool ConfigureStepFactory::canCreate(BuildStepList *parent, Core::Id id) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
return canHandle(parent) && id == CONFIGURE_STEP_ID;
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
BuildStep *ConfigureStepFactory::create(BuildStepList *parent, Core::Id id)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
return 0;
|
|
|
|
return new ConfigureStep(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureStepFactory::canClone(BuildStepList *parent, BuildStep *source) const
|
|
|
|
{
|
|
|
|
return canCreate(parent, source->id());
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildStep *ConfigureStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
|
|
|
{
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
return 0;
|
|
|
|
return new ConfigureStep(parent, static_cast<ConfigureStep *>(source));
|
|
|
|
}
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
bool ConfigureStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
return canCreate(parent, idFromMap(map));
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BuildStep *ConfigureStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
|
|
|
|
{
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
return 0;
|
|
|
|
ConfigureStep *bs = new ConfigureStep(parent);
|
|
|
|
if (bs->fromMap(map))
|
|
|
|
return bs;
|
|
|
|
delete bs;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool ConfigureStepFactory::canHandle(BuildStepList *parent) const
|
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (parent->target()->project()->id() == Constants::AUTOTOOLS_PROJECT_ID)
|
|
|
|
return parent->id() == ProjectExplorer::Constants::BUILDSTEPS_BUILD;
|
|
|
|
return false;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
2011-11-29 14:19:28 +01:00
|
|
|
////////////////////////
|
|
|
|
// ConfigureStep class
|
|
|
|
////////////////////////
|
2012-01-13 13:36:45 +01:00
|
|
|
ConfigureStep::ConfigureStep(BuildStepList* bsl) :
|
2012-03-15 17:17:40 +01:00
|
|
|
AbstractProcessStep(bsl, Core::Id(CONFIGURE_STEP_ID)),
|
2011-11-29 14:19:28 +01:00
|
|
|
m_runConfigure(false)
|
|
|
|
{
|
|
|
|
ctor();
|
|
|
|
}
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
ConfigureStep::ConfigureStep(BuildStepList *bsl, Core::Id id) :
|
2011-11-29 14:19:28 +01:00
|
|
|
AbstractProcessStep(bsl, id)
|
|
|
|
{
|
|
|
|
ctor();
|
|
|
|
}
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
ConfigureStep::ConfigureStep(BuildStepList *bsl, ConfigureStep *bs) :
|
2011-11-29 14:19:28 +01:00
|
|
|
AbstractProcessStep(bsl, bs),
|
|
|
|
m_additionalArguments(bs->additionalArguments())
|
|
|
|
{
|
|
|
|
ctor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureStep::ctor()
|
|
|
|
{
|
|
|
|
setDefaultDisplayName(tr("Configure"));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureStep::init()
|
|
|
|
{
|
2012-11-01 18:15:09 +01:00
|
|
|
BuildConfiguration *bc = buildConfiguration();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
ProcessParameters *pp = processParameters();
|
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
|
|
|
pp->setEnvironment(bc->environment());
|
2013-08-16 17:45:16 +02:00
|
|
|
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
2012-04-03 11:53:55 +02:00
|
|
|
pp->setCommand(QLatin1String("configure"));
|
2011-11-29 14:19:28 +01:00
|
|
|
pp->setArguments(additionalArguments());
|
2012-11-28 15:29:55 +01:00
|
|
|
pp->resolveAll();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
return AbstractProcessStep::init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureStep::run(QFutureInterface<bool>& interface)
|
|
|
|
{
|
2012-11-01 18:15:09 +01:00
|
|
|
BuildConfiguration *bc = buildConfiguration();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2011-11-30 15:54:22 +01:00
|
|
|
//Check whether we need to run configure
|
2013-08-16 17:45:16 +02:00
|
|
|
QString buildDir = bc->buildDirectory().toString();
|
|
|
|
const QFileInfo configureInfo(buildDir +QLatin1String("/configure"));
|
|
|
|
const QFileInfo configStatusInfo(buildDir + QLatin1String("/config.status"));
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
if (!configStatusInfo.exists()
|
|
|
|
|| configStatusInfo.lastModified() < configureInfo.lastModified()) {
|
|
|
|
m_runConfigure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_runConfigure) {
|
|
|
|
emit addOutput(tr("Configuration unchanged, skipping configure step."), BuildStep::MessageOutput);
|
|
|
|
interface.reportResult(true);
|
2013-02-12 12:56:02 +01:00
|
|
|
emit finished();
|
2011-11-29 14:19:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_runConfigure = false;
|
|
|
|
AbstractProcessStep::run(interface);
|
|
|
|
}
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
BuildStepConfigWidget *ConfigureStep::createConfigWidget()
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
return new ConfigureStepConfigWidget(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureStep::immutable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureStep::setAdditionalArguments(const QString &list)
|
|
|
|
{
|
|
|
|
if (list == m_additionalArguments)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_additionalArguments = list;
|
|
|
|
m_runConfigure = true;
|
|
|
|
|
|
|
|
emit additionalArgumentsChanged(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ConfigureStep::additionalArguments() const
|
|
|
|
{
|
|
|
|
return m_additionalArguments;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariantMap ConfigureStep::toMap() const
|
|
|
|
{
|
2011-11-30 15:08:34 +01:00
|
|
|
QVariantMap map = AbstractProcessStep::toMap();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
map.insert(QLatin1String(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY), m_additionalArguments);
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureStep::fromMap(const QVariantMap &map)
|
|
|
|
{
|
|
|
|
m_additionalArguments = map.value(QLatin1String(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY)).toString();
|
|
|
|
|
|
|
|
return BuildStep::fromMap(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////
|
|
|
|
// ConfigureStepConfigWidget class
|
|
|
|
/////////////////////////////////////
|
|
|
|
ConfigureStepConfigWidget::ConfigureStepConfigWidget(ConfigureStep *configureStep) :
|
|
|
|
m_configureStep(configureStep),
|
|
|
|
m_summaryText(),
|
|
|
|
m_additionalArguments(0)
|
|
|
|
{
|
|
|
|
QFormLayout *fl = new QFormLayout(this);
|
|
|
|
fl->setMargin(0);
|
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
setLayout(fl);
|
|
|
|
|
|
|
|
m_additionalArguments = new QLineEdit(this);
|
|
|
|
fl->addRow(tr("Arguments:"), m_additionalArguments);
|
|
|
|
m_additionalArguments->setText(m_configureStep->additionalArguments());
|
|
|
|
|
|
|
|
updateDetails();
|
|
|
|
|
|
|
|
connect(m_additionalArguments, SIGNAL(textChanged(QString)),
|
|
|
|
configureStep, SLOT(setAdditionalArguments(QString)));
|
|
|
|
connect(configureStep, SIGNAL(additionalArgumentsChanged(QString)),
|
|
|
|
this, SLOT(updateDetails()));
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ConfigureStepConfigWidget::displayName() const
|
|
|
|
{
|
|
|
|
return tr("Configure", "AutotoolsProjectManager::ConfigureStepConfigWidget display name.");
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ConfigureStepConfigWidget::summaryText() const
|
|
|
|
{
|
|
|
|
return m_summaryText;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureStepConfigWidget::updateDetails()
|
|
|
|
{
|
2012-11-01 18:15:09 +01:00
|
|
|
BuildConfiguration *bc = m_configureStep->buildConfiguration();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
ProcessParameters param;
|
|
|
|
param.setMacroExpander(bc->macroExpander());
|
|
|
|
param.setEnvironment(bc->environment());
|
2013-08-16 17:45:16 +02:00
|
|
|
param.setWorkingDirectory(bc->buildDirectory().toString());
|
2012-04-03 11:53:55 +02:00
|
|
|
param.setCommand(QLatin1String("configure"));
|
2011-11-29 14:19:28 +01:00
|
|
|
param.setArguments(m_configureStep->additionalArguments());
|
|
|
|
m_summaryText = param.summary(displayName());
|
|
|
|
emit updateSummary();
|
|
|
|
}
|