2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Openismus GmbH.
|
|
|
|
|
** Author: Peter Penz (ppenz@openismus.com)
|
|
|
|
|
** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com)
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-11-29 14:19:28 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
#include "autoreconfstep.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 <QLineEdit>
|
|
|
|
|
#include <QFormLayout>
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
using namespace AutotoolsProjectManager;
|
|
|
|
|
using namespace AutotoolsProjectManager::Internal;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
const char AUTORECONF_STEP_ID[] = "AutotoolsProjectManager.AutoreconfStep";
|
|
|
|
|
const char AUTORECONF_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.AutoreconfStep.AdditionalArguments";
|
|
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
// AutoreconfStepFactory class
|
|
|
|
|
////////////////////////////////
|
2016-02-03 17:21:12 +01:00
|
|
|
AutoreconfStepFactory::AutoreconfStepFactory(QObject *parent) : IBuildStepFactory(parent)
|
|
|
|
|
{ }
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2016-05-18 12:37:29 +02:00
|
|
|
QList<BuildStepInfo> AutoreconfStepFactory::availableSteps(BuildStepList *parent) const
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2016-05-18 12:37:29 +02:00
|
|
|
if (parent->target()->project()->id() != Constants::AUTOTOOLS_PROJECT_ID
|
|
|
|
|
|| parent->id() != ProjectExplorer::Constants::BUILDSTEPS_BUILD)
|
|
|
|
|
return {};
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2016-05-18 12:37:29 +02:00
|
|
|
QString display = tr("Autoreconf", "Display name for AutotoolsProjectManager::AutoreconfStep id.");
|
|
|
|
|
return {{ AUTORECONF_STEP_ID, display }};
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
BuildStep *AutoreconfStepFactory::create(BuildStepList *parent, Core::Id id)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2016-05-18 12:37:29 +02:00
|
|
|
Q_UNUSED(id);
|
2011-11-29 14:19:28 +01:00
|
|
|
return new AutoreconfStep(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStep *AutoreconfStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
|
|
|
|
{
|
|
|
|
|
return new AutoreconfStep(parent, static_cast<AutoreconfStep *>(source));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////
|
|
|
|
|
// AutoreconfStep class
|
|
|
|
|
/////////////////////////
|
2012-01-13 13:36:45 +01:00
|
|
|
AutoreconfStep::AutoreconfStep(BuildStepList *bsl) :
|
2016-02-03 17:21:12 +01:00
|
|
|
AbstractProcessStep(bsl, Core::Id(AUTORECONF_STEP_ID))
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-03 17:21:12 +01:00
|
|
|
AutoreconfStep::AutoreconfStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
AutoreconfStep::AutoreconfStep(BuildStepList *bsl, AutoreconfStep *bs) :
|
2011-11-29 14:19:28 +01:00
|
|
|
AbstractProcessStep(bsl, bs),
|
|
|
|
|
m_additionalArguments(bs->additionalArguments())
|
|
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AutoreconfStep::ctor()
|
|
|
|
|
{
|
|
|
|
|
setDefaultDisplayName(tr("Autoreconf"));
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
bool AutoreconfStep::init(QList<const BuildStep *> &earlierSteps)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
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());
|
2014-08-24 20:33:40 +01:00
|
|
|
const QString projectDir(bc->target()->project()->projectDirectory().toString());
|
|
|
|
|
pp->setWorkingDirectory(projectDir);
|
2012-04-03 11:53:55 +02:00
|
|
|
pp->setCommand(QLatin1String("autoreconf"));
|
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
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
return AbstractProcessStep::init(earlierSteps);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2016-04-20 12:49:25 +02:00
|
|
|
void AutoreconfStep::run(QFutureInterface<bool> &fi)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
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 autoreconf
|
2014-08-24 20:33:40 +01:00
|
|
|
const QString projectDir(bc->target()->project()->projectDirectory().toString());
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2014-10-24 10:28:28 +02:00
|
|
|
if (!QFileInfo::exists(projectDir + QLatin1String("/configure")))
|
2011-11-29 14:19:28 +01:00
|
|
|
m_runAutoreconf = true;
|
|
|
|
|
|
|
|
|
|
if (!m_runAutoreconf) {
|
|
|
|
|
emit addOutput(tr("Configuration unchanged, skipping autoreconf step."), BuildStep::MessageOutput);
|
2016-04-20 12:49:25 +02:00
|
|
|
reportRunResult(fi, true);
|
2011-11-29 14:19:28 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_runAutoreconf = false;
|
2016-04-20 12:49:25 +02:00
|
|
|
AbstractProcessStep::run(fi);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
BuildStepConfigWidget *AutoreconfStep::createConfigWidget()
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
return new AutoreconfStepConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AutoreconfStep::immutable() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AutoreconfStep::setAdditionalArguments(const QString &list)
|
|
|
|
|
{
|
|
|
|
|
if (list == m_additionalArguments)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_additionalArguments = list;
|
|
|
|
|
m_runAutoreconf = true;
|
|
|
|
|
|
|
|
|
|
emit additionalArgumentsChanged(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AutoreconfStep::additionalArguments() const
|
|
|
|
|
{
|
|
|
|
|
return m_additionalArguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AutoreconfStep::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(AUTORECONF_ADDITIONAL_ARGUMENTS_KEY), m_additionalArguments);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AutoreconfStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
m_additionalArguments = map.value(QLatin1String(AUTORECONF_ADDITIONAL_ARGUMENTS_KEY)).toString();
|
|
|
|
|
|
|
|
|
|
return BuildStep::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
// AutoreconfStepConfigWidget class
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
AutoreconfStepConfigWidget::AutoreconfStepConfigWidget(AutoreconfStep *autoreconfStep) :
|
|
|
|
|
m_autoreconfStep(autoreconfStep),
|
2016-02-03 17:21:12 +01:00
|
|
|
m_additionalArguments(new QLineEdit(this))
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
QFormLayout *fl = new QFormLayout(this);
|
|
|
|
|
fl->setMargin(0);
|
|
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
|
setLayout(fl);
|
|
|
|
|
|
|
|
|
|
fl->addRow(tr("Arguments:"), m_additionalArguments);
|
|
|
|
|
m_additionalArguments->setText(m_autoreconfStep->additionalArguments());
|
|
|
|
|
|
|
|
|
|
updateDetails();
|
|
|
|
|
|
2016-02-10 14:24:19 +01:00
|
|
|
connect(m_additionalArguments, &QLineEdit::textChanged,
|
|
|
|
|
autoreconfStep, &AutoreconfStep::setAdditionalArguments);
|
|
|
|
|
connect(autoreconfStep, &AutoreconfStep::additionalArgumentsChanged,
|
|
|
|
|
this, &AutoreconfStepConfigWidget::updateDetails);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AutoreconfStepConfigWidget::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("Autoreconf", "AutotoolsProjectManager::AutoreconfStepConfigWidget display name.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AutoreconfStepConfigWidget::summaryText() const
|
|
|
|
|
{
|
|
|
|
|
return m_summaryText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AutoreconfStepConfigWidget::updateDetails()
|
|
|
|
|
{
|
2012-11-01 18:15:09 +01:00
|
|
|
BuildConfiguration *bc = m_autoreconfStep->buildConfiguration();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
ProcessParameters param;
|
|
|
|
|
param.setMacroExpander(bc->macroExpander());
|
|
|
|
|
param.setEnvironment(bc->environment());
|
2014-08-24 20:33:40 +01:00
|
|
|
const QString projectDir(bc->target()->project()->projectDirectory().toString());
|
|
|
|
|
param.setWorkingDirectory(projectDir);
|
2012-04-03 11:53:55 +02:00
|
|
|
param.setCommand(QLatin1String("autoreconf"));
|
2011-11-29 14:19:28 +01:00
|
|
|
param.setArguments(m_autoreconfStep->additionalArguments());
|
|
|
|
|
m_summaryText = param.summary(displayName());
|
|
|
|
|
emit updateSummary();
|
|
|
|
|
}
|