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 "makestep.h"
|
|
|
|
|
#include "autotoolsproject.h"
|
|
|
|
|
#include "autotoolsprojectconstants.h"
|
|
|
|
|
#include "autotoolsbuildconfiguration.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>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2011-11-29 14:19:28 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-09-26 17:53:25 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
#include <qtsupport/qtparser.h>
|
2011-11-29 14:19:28 +01:00
|
|
|
#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;
|
2012-01-13 13:36:45 +01:00
|
|
|
using namespace AutotoolsProjectManager::Constants;
|
2011-11-29 14:19:28 +01:00
|
|
|
using namespace ProjectExplorer;
|
2012-01-13 13:36:45 +01:00
|
|
|
using namespace ProjectExplorer::Constants;
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
const char MAKE_STEP_ID[] = "AutotoolsProjectManager.MakeStep";
|
|
|
|
|
const char CLEAN_KEY[] = "AutotoolsProjectManager.MakeStep.Clean";
|
|
|
|
|
const char BUILD_TARGETS_KEY[] = "AutotoolsProjectManager.MakeStep.BuildTargets";
|
|
|
|
|
const char MAKE_STEP_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.MakeStep.AdditionalArguments";
|
|
|
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
|
// MakeStepFactory class
|
|
|
|
|
//////////////////////////
|
2016-02-03 17:21:12 +01:00
|
|
|
MakeStepFactory::MakeStepFactory(QObject *parent) : IBuildStepFactory(parent)
|
2017-06-12 14:23:34 +02:00
|
|
|
{ setObjectName("Autotools::MakeStepFactory"); }
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2016-05-18 12:37:29 +02:00
|
|
|
QList<BuildStepInfo> MakeStepFactory::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() != AUTOTOOLS_PROJECT_ID)
|
|
|
|
|
return {};
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2017-02-22 15:09:35 +01:00
|
|
|
return {{MAKE_STEP_ID, tr("Make", "Display name for AutotoolsProjectManager::MakeStep id.")}};
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
BuildStep *MakeStepFactory::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 MakeStep(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStep *MakeStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
|
|
|
|
{
|
|
|
|
|
return new MakeStep(parent, static_cast<MakeStep *>(source));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
|
// MakeStep class
|
|
|
|
|
/////////////////////
|
2016-02-03 17:21:12 +01:00
|
|
|
MakeStep::MakeStep(BuildStepList* bsl) : AbstractProcessStep(bsl, Core::Id(MAKE_STEP_ID))
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-03 17:21:12 +01:00
|
|
|
MakeStep::MakeStep(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
|
|
|
MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) : AbstractProcessStep(bsl, bs),
|
2011-11-29 14:19:28 +01:00
|
|
|
m_buildTargets(bs->m_buildTargets),
|
|
|
|
|
m_additionalArguments(bs->additionalArguments()),
|
|
|
|
|
m_clean(bs->m_clean)
|
|
|
|
|
{
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::ctor()
|
|
|
|
|
{
|
|
|
|
|
setDefaultDisplayName(tr("Make"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setClean(bool clean)
|
|
|
|
|
{
|
|
|
|
|
m_clean = clean;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
bool MakeStep::init(QList<const BuildStep *> &earlierSteps)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2012-11-01 18:15:09 +01:00
|
|
|
BuildConfiguration *bc = buildConfiguration();
|
2012-09-06 13:13:12 +02:00
|
|
|
if (!bc)
|
2012-11-01 18:15:09 +01:00
|
|
|
bc = target()->activeBuildConfiguration();
|
2014-06-20 14:32:40 +02:00
|
|
|
if (!bc)
|
|
|
|
|
emit addTask(Task::buildConfigurationMissingTask());
|
2012-09-06 13:13:12 +02:00
|
|
|
|
2016-07-12 16:27:45 +02:00
|
|
|
QList<ToolChain *> tcList = ToolChainKitInformation::toolChains(target()->kit());
|
|
|
|
|
if (tcList.isEmpty())
|
2014-06-20 14:32:40 +02:00
|
|
|
emit addTask(Task::compilerMissingTask());
|
|
|
|
|
|
2016-07-12 16:27:45 +02:00
|
|
|
if (tcList.isEmpty() || !bc) {
|
2014-06-20 14:32:40 +02:00
|
|
|
emitFaultyConfigurationMessage();
|
2014-04-03 17:02:21 +02:00
|
|
|
return false;
|
2012-09-06 13:13:12 +02:00
|
|
|
}
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
QString arguments = Utils::QtcProcess::joinArgs(m_buildTargets);
|
|
|
|
|
Utils::QtcProcess::addArgs(&arguments, additionalArguments());
|
|
|
|
|
|
|
|
|
|
setIgnoreReturnValue(m_clean);
|
|
|
|
|
|
|
|
|
|
ProcessParameters *pp = processParameters();
|
|
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
2012-11-21 12:04:39 +01:00
|
|
|
Utils::Environment env = bc->environment();
|
2016-04-07 13:06:01 +02:00
|
|
|
Utils::Environment::setupEnglishOutput(&env);
|
2012-11-21 12:04:39 +01:00
|
|
|
pp->setEnvironment(env);
|
2013-08-16 17:45:16 +02:00
|
|
|
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
2016-07-12 16:27:45 +02:00
|
|
|
pp->setCommand(tcList.at(0)->makeCommand(bc->environment()));
|
2011-11-29 14:19:28 +01:00
|
|
|
pp->setArguments(arguments);
|
2012-11-28 15:29:55 +01:00
|
|
|
pp->resolveAll();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
setOutputParser(new GnuMakeParser());
|
2012-11-02 12:45:09 +01:00
|
|
|
IOutputParser *parser = target()->kit()->createOutputParser();
|
|
|
|
|
if (parser)
|
|
|
|
|
appendOutputParser(parser);
|
2011-11-29 14:19:28 +01:00
|
|
|
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
|
|
|
|
|
|
2015-11-13 12:19:35 +01:00
|
|
|
return AbstractProcessStep::init(earlierSteps);
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::run(QFutureInterface<bool> &interface)
|
|
|
|
|
{
|
|
|
|
|
AbstractProcessStep::run(interface);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 13:36:45 +01:00
|
|
|
BuildStepConfigWidget *MakeStep::createConfigWidget()
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
|
|
|
|
return new MakeStepConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::immutable() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setBuildTarget(const QString &target, bool on)
|
|
|
|
|
{
|
|
|
|
|
QStringList old = m_buildTargets;
|
|
|
|
|
if (on && !old.contains(target))
|
|
|
|
|
old << target;
|
|
|
|
|
else if (!on && old.contains(target))
|
|
|
|
|
old.removeOne(target);
|
|
|
|
|
|
|
|
|
|
m_buildTargets = old;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setAdditionalArguments(const QString &list)
|
|
|
|
|
{
|
|
|
|
|
if (list == m_additionalArguments)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_additionalArguments = list;
|
|
|
|
|
|
|
|
|
|
emit additionalArgumentsChanged(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MakeStep::additionalArguments() const
|
|
|
|
|
{
|
|
|
|
|
return m_additionalArguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap MakeStep::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(BUILD_TARGETS_KEY, m_buildTargets);
|
|
|
|
|
map.insert(MAKE_STEP_ADDITIONAL_ARGUMENTS_KEY, m_additionalArguments);
|
|
|
|
|
map.insert(CLEAN_KEY, m_clean);
|
2011-11-29 14:19:28 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2017-06-12 14:23:34 +02:00
|
|
|
m_buildTargets = map.value(BUILD_TARGETS_KEY).toStringList();
|
|
|
|
|
m_additionalArguments = map.value(MAKE_STEP_ADDITIONAL_ARGUMENTS_KEY).toString();
|
|
|
|
|
m_clean = map.value(CLEAN_KEY).toBool();
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
return BuildStep::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////
|
|
|
|
|
// MakeStepConfigWidget class
|
|
|
|
|
///////////////////////////////
|
|
|
|
|
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) :
|
|
|
|
|
m_makeStep(makeStep),
|
|
|
|
|
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_makeStep->additionalArguments());
|
|
|
|
|
|
|
|
|
|
updateDetails();
|
|
|
|
|
|
2016-02-10 14:24:19 +01:00
|
|
|
connect(m_additionalArguments, &QLineEdit::textChanged,
|
|
|
|
|
makeStep, &MakeStep::setAdditionalArguments);
|
|
|
|
|
connect(makeStep, &MakeStep::additionalArgumentsChanged,
|
|
|
|
|
this, &MakeStepConfigWidget::updateDetails);
|
2017-07-29 23:34:56 +02:00
|
|
|
m_makeStep->project()->subscribeSignal(&BuildConfiguration::environmentChanged, this, [this]() {
|
|
|
|
|
if (static_cast<BuildConfiguration *>(sender())->isActive())
|
|
|
|
|
updateDetails();
|
|
|
|
|
});
|
|
|
|
|
connect(makeStep->project(), &Project::activeProjectConfigurationChanged,
|
|
|
|
|
this, [this](ProjectConfiguration *pc) {
|
2017-09-08 12:02:17 +02:00
|
|
|
if (pc && pc->isActive())
|
2017-07-29 23:34:56 +02:00
|
|
|
updateDetails();
|
|
|
|
|
});
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MakeStepConfigWidget::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("Make", "AutotoolsProjectManager::MakeStepConfigWidget display name.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MakeStepConfigWidget::summaryText() const
|
|
|
|
|
{
|
|
|
|
|
return m_summaryText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStepConfigWidget::updateDetails()
|
|
|
|
|
{
|
2012-11-01 18:15:09 +01:00
|
|
|
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
2013-11-28 13:47:09 +01:00
|
|
|
if (!bc)
|
|
|
|
|
bc = m_makeStep->target()->activeBuildConfiguration();
|
2016-07-12 16:27:45 +02:00
|
|
|
QList<ToolChain *> tcList = ToolChainKitInformation::toolChains(m_makeStep->target()->kit());
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2016-07-12 16:27:45 +02:00
|
|
|
if (!tcList.isEmpty()) {
|
2011-11-29 14:19:28 +01:00
|
|
|
QString arguments = Utils::QtcProcess::joinArgs(m_makeStep->m_buildTargets);
|
|
|
|
|
Utils::QtcProcess::addArgs(&arguments, m_makeStep->additionalArguments());
|
|
|
|
|
|
|
|
|
|
ProcessParameters param;
|
2017-03-17 00:27:13 +02:00
|
|
|
param.setMacroExpander(m_makeStep->macroExpander());
|
2011-11-29 14:19:28 +01:00
|
|
|
param.setEnvironment(bc->environment());
|
2013-08-16 17:45:16 +02:00
|
|
|
param.setWorkingDirectory(bc->buildDirectory().toString());
|
2016-07-12 16:27:45 +02:00
|
|
|
param.setCommand(tcList.at(0)->makeCommand(bc->environment()));
|
2011-11-29 14:19:28 +01:00
|
|
|
param.setArguments(arguments);
|
|
|
|
|
m_summaryText = param.summary(displayName());
|
|
|
|
|
} else {
|
2017-06-12 14:23:34 +02:00
|
|
|
m_summaryText = "<b>" + ToolChainKitInformation::msgNoToolChainInTarget() + "</b>";
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit updateSummary();
|
|
|
|
|
}
|