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 "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";
|
|
|
|
|
2014-08-24 20:33:40 +01:00
|
|
|
/////////////////////
|
|
|
|
// Helper Function
|
|
|
|
/////////////////////
|
|
|
|
static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) {
|
|
|
|
const QDir buildDir(bc->buildDirectory().toString());
|
|
|
|
QString projDirToBuildDir = buildDir.relativeFilePath(
|
|
|
|
bc->target()->project()->projectDirectory().toString());
|
|
|
|
if (projDirToBuildDir.isEmpty())
|
2017-06-12 14:23:34 +02:00
|
|
|
return "./";
|
|
|
|
if (!projDirToBuildDir.endsWith('/'))
|
|
|
|
projDirToBuildDir.append('/');
|
2014-08-24 20:33:40 +01:00
|
|
|
return projDirToBuildDir;
|
|
|
|
}
|
|
|
|
|
2011-11-29 14:19:28 +01:00
|
|
|
////////////////////////////////
|
|
|
|
// ConfigureStepFactory Class
|
|
|
|
////////////////////////////////
|
2016-02-03 17:21:12 +01:00
|
|
|
ConfigureStepFactory::ConfigureStepFactory(QObject *parent) : IBuildStepFactory(parent)
|
|
|
|
{ }
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2016-05-18 12:37:29 +02:00
|
|
|
QList<BuildStepInfo> ConfigureStepFactory::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("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id.");
|
2017-02-22 15:09:35 +01:00
|
|
|
return {{CONFIGURE_STEP_ID, display}};
|
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
|
|
|
{
|
2016-05-18 12:37:29 +02:00
|
|
|
Q_UNUSED(id)
|
2011-11-29 14:19:28 +01:00
|
|
|
return new ConfigureStep(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
BuildStep *ConfigureStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
|
|
|
{
|
|
|
|
return new ConfigureStep(parent, static_cast<ConfigureStep *>(source));
|
|
|
|
}
|
|
|
|
|
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) :
|
2016-02-03 17:21:12 +01:00
|
|
|
AbstractProcessStep(bsl, Core::Id(CONFIGURE_STEP_ID))
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
ctor();
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:21:12 +01:00
|
|
|
ConfigureStep::ConfigureStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
ctor();
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:21:12 +01:00
|
|
|
ConfigureStep::ConfigureStep(BuildStepList *bsl, ConfigureStep *bs) : AbstractProcessStep(bsl, bs),
|
2011-11-29 14:19:28 +01:00
|
|
|
m_additionalArguments(bs->additionalArguments())
|
|
|
|
{
|
|
|
|
ctor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureStep::ctor()
|
|
|
|
{
|
|
|
|
setDefaultDisplayName(tr("Configure"));
|
|
|
|
}
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
bool ConfigureStep::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());
|
2013-08-16 17:45:16 +02:00
|
|
|
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
2017-06-12 14:23:34 +02:00
|
|
|
pp->setCommand(projectDirRelativeToBuildDir(bc) + "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
|
|
|
|
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 ConfigureStep::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 configure
|
2014-08-24 20:33:40 +01:00
|
|
|
const QString projectDir(bc->target()->project()->projectDirectory().toString());
|
2017-06-12 14:23:34 +02:00
|
|
|
const QFileInfo configureInfo(projectDir + "/configure");
|
|
|
|
const QFileInfo configStatusInfo(bc->buildDirectory().toString() + "/config.status");
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
if (!configStatusInfo.exists()
|
|
|
|
|| configStatusInfo.lastModified() < configureInfo.lastModified()) {
|
|
|
|
m_runConfigure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_runConfigure) {
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Configuration unchanged, skipping configure step."), BuildStep::OutputFormat::NormalMessage);
|
2016-04-20 12:49:25 +02:00
|
|
|
reportRunResult(fi, true);
|
2011-11-29 14:19:28 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_runConfigure = 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 *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);
|
|
|
|
}
|
|
|
|
|
2014-08-24 20:33:40 +01:00
|
|
|
void ConfigureStep::notifyBuildDirectoryChanged()
|
|
|
|
{
|
|
|
|
emit buildDirectoryChanged();
|
|
|
|
}
|
|
|
|
|
2011-11-29 14:19:28 +01:00
|
|
|
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
|
|
|
|
2017-06-12 14:23:34 +02:00
|
|
|
map.insert(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY, m_additionalArguments);
|
2011-11-29 14:19:28 +01:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureStep::fromMap(const QVariantMap &map)
|
|
|
|
{
|
2017-06-12 14:23:34 +02:00
|
|
|
m_additionalArguments = map.value(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY).toString();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
return BuildStep::fromMap(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////
|
|
|
|
// ConfigureStepConfigWidget class
|
|
|
|
/////////////////////////////////////
|
|
|
|
ConfigureStepConfigWidget::ConfigureStepConfigWidget(ConfigureStep *configureStep) :
|
|
|
|
m_configureStep(configureStep),
|
2016-02-03 17:21:12 +01:00
|
|
|
m_additionalArguments(new QLineEdit)
|
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_configureStep->additionalArguments());
|
|
|
|
|
|
|
|
updateDetails();
|
|
|
|
|
2016-02-10 14:24:19 +01:00
|
|
|
connect(m_additionalArguments, &QLineEdit::textChanged,
|
|
|
|
configureStep, &ConfigureStep::setAdditionalArguments);
|
|
|
|
connect(configureStep, &ConfigureStep::additionalArgumentsChanged,
|
|
|
|
this, &ConfigureStepConfigWidget::updateDetails);
|
|
|
|
connect(configureStep, &ConfigureStep::buildDirectoryChanged,
|
|
|
|
this, &ConfigureStepConfigWidget::updateDetails);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
2017-06-12 14:23:34 +02:00
|
|
|
param.setCommand(projectDirRelativeToBuildDir(bc) + "configure");
|
2011-11-29 14:19:28 +01:00
|
|
|
param.setArguments(m_configureStep->additionalArguments());
|
2014-09-10 00:20:34 +01:00
|
|
|
m_summaryText = param.summaryInWorkdir(displayName());
|
2011-11-29 14:19:28 +01:00
|
|
|
emit updateSummary();
|
|
|
|
}
|