2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-04 13:06:02 +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.
|
2008-12-04 13:06:02 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +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
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
#include "makestep.h"
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2013-07-10 21:43:49 +03:00
|
|
|
#include "cmakebuildconfiguration.h"
|
|
|
|
|
#include "cmakeparser.h"
|
2008-12-04 13:06:02 +01:00
|
|
|
#include "cmakeprojectconstants.h"
|
|
|
|
|
#include "cmakeproject.h"
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2011-11-24 12:42:52 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2013-07-10 21:43:49 +03:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
2009-09-29 11:39:55 +02:00
|
|
|
|
2012-09-26 17:53:25 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
#include <qtsupport/qtparser.h>
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QListWidget>
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
|
using namespace CMakeProjectManager::Internal;
|
2009-10-27 14:16:28 +01:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
namespace {
|
2012-08-03 15:24:33 +02:00
|
|
|
const char MS_ID[] = "CMakeProjectManager.MakeStep";
|
|
|
|
|
const char CLEAN_KEY[] = "CMakeProjectManager.MakeStep.Clean";
|
|
|
|
|
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
|
|
|
|
|
const char ADDITIONAL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
|
2012-10-02 17:46:12 +02:00
|
|
|
const char USE_NINJA_KEY[] = "CMakeProjectManager.MakeStep.UseNinja";
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *bsl) :
|
2013-02-15 16:18:49 +01:00
|
|
|
AbstractProcessStep(bsl, Core::Id(MS_ID)), m_clean(false)
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
MakeStep::MakeStep(BuildStepList *bsl, const Core::Id id) :
|
2013-02-15 16:18:49 +01:00
|
|
|
AbstractProcessStep(bsl, id), m_clean(false)
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
|
|
|
|
ctor();
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) :
|
|
|
|
|
AbstractProcessStep(bsl, bs),
|
2009-10-27 14:16:28 +01:00
|
|
|
m_clean(bs->m_clean),
|
|
|
|
|
m_buildTargets(bs->m_buildTargets),
|
2013-03-21 13:26:18 +01:00
|
|
|
m_additionalArguments(bs->m_additionalArguments)
|
2009-10-27 14:16:28 +01:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
ctor();
|
|
|
|
|
}
|
2009-10-27 14:16:28 +01:00
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
void MakeStep::ctor()
|
|
|
|
|
{
|
2012-11-21 23:54:06 +02:00
|
|
|
m_percentProgress = QRegExp(QLatin1String("^\\[\\s*(\\d*)%\\]"));
|
|
|
|
|
m_ninjaProgress = QRegExp(QLatin1String("^\\[\\s*(\\d*)/\\s*(\\d*)"));
|
2013-11-15 10:22:03 +01:00
|
|
|
m_ninjaProgressString = QLatin1String("[%f/%t "); // ninja: [33/100
|
2010-08-19 12:26:21 +02:00
|
|
|
//: Default display name for the cmake make step.
|
|
|
|
|
setDefaultDisplayName(tr("Make"));
|
2012-10-02 17:46:12 +02:00
|
|
|
|
2012-10-02 17:46:19 +02:00
|
|
|
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
|
2012-10-02 17:46:12 +02:00
|
|
|
if (bc) {
|
2012-10-02 17:46:19 +02:00
|
|
|
m_useNinja = bc->useNinja();
|
2012-10-02 17:46:12 +02:00
|
|
|
m_activeConfiguration = 0;
|
|
|
|
|
connect(bc, SIGNAL(useNinjaChanged(bool)), this, SLOT(setUseNinja(bool)));
|
|
|
|
|
} else {
|
|
|
|
|
// That means the step is in the deploylist, so we listen to the active build config
|
|
|
|
|
// changed signal and react to the activeBuildConfigurationChanged() signal of the buildconfiguration
|
|
|
|
|
m_activeConfiguration = targetsActiveBuildConfiguration();
|
2012-10-02 17:46:19 +02:00
|
|
|
m_useNinja = m_activeConfiguration->useNinja();
|
2012-10-02 17:46:12 +02:00
|
|
|
connect (target(), SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(activeBuildConfigurationChanged()));
|
|
|
|
|
activeBuildConfigurationChanged();
|
|
|
|
|
}
|
2013-08-26 16:01:24 +02:00
|
|
|
|
|
|
|
|
connect(static_cast<CMakeProject *>(project()), SIGNAL(buildTargetsChanged()),
|
|
|
|
|
this, SLOT(buildTargetsChanged()));
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
MakeStep::~MakeStep()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *MakeStep::cmakeBuildConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<CMakeBuildConfiguration *>(buildConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-02 17:46:12 +02:00
|
|
|
CMakeBuildConfiguration *MakeStep::targetsActiveBuildConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<CMakeBuildConfiguration *>(target()->activeBuildConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::activeBuildConfigurationChanged()
|
|
|
|
|
{
|
|
|
|
|
if (m_activeConfiguration)
|
|
|
|
|
disconnect(m_activeConfiguration, SIGNAL(useNinjaChanged(bool)), this, SLOT(setUseNinja(bool)));
|
|
|
|
|
|
|
|
|
|
m_activeConfiguration = targetsActiveBuildConfiguration();
|
|
|
|
|
|
|
|
|
|
if (m_activeConfiguration) {
|
|
|
|
|
connect(m_activeConfiguration, SIGNAL(useNinjaChanged(bool)), this, SLOT(setUseNinja(bool)));
|
|
|
|
|
setUseNinja(m_activeConfiguration->useNinja());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-26 16:01:24 +02:00
|
|
|
void MakeStep::buildTargetsChanged()
|
|
|
|
|
{
|
|
|
|
|
QStringList filteredTargets;
|
|
|
|
|
foreach (const QString t, static_cast<CMakeProject *>(project())->buildTargetTitles()) {
|
|
|
|
|
if (m_buildTargets.contains(t))
|
|
|
|
|
filteredTargets.append(t);
|
|
|
|
|
}
|
|
|
|
|
setBuildTargets(filteredTargets);
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-15 19:06:51 +02:00
|
|
|
void MakeStep::setClean(bool clean)
|
|
|
|
|
{
|
|
|
|
|
m_clean = clean;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
QVariantMap MakeStep::toMap() const
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
QVariantMap map(AbstractProcessStep::toMap());
|
|
|
|
|
map.insert(QLatin1String(CLEAN_KEY), m_clean);
|
|
|
|
|
map.insert(QLatin1String(BUILD_TARGETS_KEY), m_buildTargets);
|
|
|
|
|
map.insert(QLatin1String(ADDITIONAL_ARGUMENTS_KEY), m_additionalArguments);
|
2012-10-02 17:46:12 +02:00
|
|
|
map.insert(QLatin1String(USE_NINJA_KEY), m_useNinja);
|
2010-01-14 17:41:29 +01:00
|
|
|
return map;
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
bool MakeStep::fromMap(const QVariantMap &map)
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
m_clean = map.value(QLatin1String(CLEAN_KEY)).toBool();
|
|
|
|
|
m_buildTargets = map.value(QLatin1String(BUILD_TARGETS_KEY)).toStringList();
|
2010-10-19 11:14:03 +02:00
|
|
|
m_additionalArguments = map.value(QLatin1String(ADDITIONAL_ARGUMENTS_KEY)).toString();
|
2012-10-02 17:46:12 +02:00
|
|
|
m_useNinja = map.value(QLatin1String(USE_NINJA_KEY)).toBool();
|
2009-10-15 19:06:51 +02:00
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
return BuildStep::fromMap(map);
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
bool MakeStep::init()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2009-11-26 14:43:27 +01:00
|
|
|
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
|
2012-05-14 14:07:34 +02:00
|
|
|
if (!bc)
|
|
|
|
|
bc = static_cast<CMakeBuildConfiguration *>(target()->activeBuildConfiguration());
|
2009-02-16 13:12:12 +01:00
|
|
|
|
2012-09-06 13:13:12 +02:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
|
|
|
|
|
if (!tc) {
|
2014-04-03 15:37:02 +02:00
|
|
|
emit addTask(Task(Task::Error, tr("Qt Creator needs a compiler set up to build. Configure a compiler in the kit options."),
|
|
|
|
|
Utils::FileName(), -1,
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
emit addOutput(tr("Configuration is faulty. Check the Issues view for details."), BuildStep::MessageOutput);
|
|
|
|
|
return false;
|
2012-09-06 13:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
QString arguments = Utils::QtcProcess::joinArgs(m_buildTargets);
|
|
|
|
|
Utils::QtcProcess::addArgs(&arguments, additionalArguments());
|
2010-11-12 17:23:55 +01:00
|
|
|
|
2009-10-15 19:06:51 +02:00
|
|
|
setIgnoreReturnValue(m_clean);
|
2009-06-22 16:11:45 +02:00
|
|
|
|
2010-11-12 17:23:55 +01:00
|
|
|
ProcessParameters *pp = processParameters();
|
|
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
2012-11-21 12:04:39 +01:00
|
|
|
Utils::Environment env = bc->environment();
|
|
|
|
|
// Force output to english for the parsers. Do this here and not in the toolchain's
|
|
|
|
|
// addToEnvironment() to not screw up the users run environment.
|
|
|
|
|
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
|
|
|
|
|
if (m_useNinja && !env.value(QLatin1String("NINJA_STATUS")).startsWith(m_ninjaProgressString))
|
|
|
|
|
env.set(QLatin1String("NINJA_STATUS"), m_ninjaProgressString + QLatin1String("%o/sec] "));
|
|
|
|
|
pp->setEnvironment(env);
|
2013-08-16 17:45:16 +02:00
|
|
|
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
2012-10-02 17:46:12 +02:00
|
|
|
pp->setCommand(makeCommand(tc, bc->environment()));
|
2010-11-12 17:23:55 +01:00
|
|
|
pp->setArguments(arguments);
|
2012-11-28 15:29:55 +01:00
|
|
|
pp->resolveAll();
|
2010-11-12 17:23:55 +01:00
|
|
|
|
2013-07-10 21:43:49 +03:00
|
|
|
setOutputParser(new CMakeParser());
|
2012-11-02 12:45:09 +01:00
|
|
|
IOutputParser *parser = target()->kit()->createOutputParser();
|
|
|
|
|
if (parser)
|
|
|
|
|
appendOutputParser(parser);
|
2010-12-06 12:18:38 +01:00
|
|
|
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
|
2009-12-09 13:54:46 +01:00
|
|
|
|
|
|
|
|
return AbstractProcessStep::init();
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::run(QFutureInterface<bool> &fi)
|
|
|
|
|
{
|
2009-12-09 13:54:46 +01:00
|
|
|
AbstractProcessStep::run(fi);
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
BuildStepConfigWidget *MakeStep::createConfigWidget()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2009-03-18 13:33:00 +01:00
|
|
|
return new MakeStepConfigWidget(this);
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MakeStep::immutable() const
|
|
|
|
|
{
|
2010-04-22 17:25:28 +02:00
|
|
|
return false;
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-01 15:14:38 +02:00
|
|
|
void MakeStep::stdOutput(const QString &line)
|
2009-02-16 13:12:12 +01:00
|
|
|
{
|
2009-04-07 13:52:28 +02:00
|
|
|
if (m_percentProgress.indexIn(line) != -1) {
|
|
|
|
|
bool ok = false;
|
2013-09-03 18:48:02 +02:00
|
|
|
int percent = m_percentProgress.cap(1).toInt(&ok);
|
2009-04-07 13:52:28 +02:00
|
|
|
if (ok)
|
2013-02-15 16:18:49 +01:00
|
|
|
futureInterface()->setProgressValue(percent);
|
2012-10-02 17:46:12 +02:00
|
|
|
} else if (m_ninjaProgress.indexIn(line) != -1) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
int done = m_ninjaProgress.cap(1).toInt(&ok);
|
|
|
|
|
if (ok) {
|
|
|
|
|
int all = m_ninjaProgress.cap(2).toInt(&ok);
|
|
|
|
|
if (ok && all != 0) {
|
|
|
|
|
int percent = 100.0 * done/all;
|
2013-02-15 16:18:49 +01:00
|
|
|
futureInterface()->setProgressValue(percent);
|
2012-10-02 17:46:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
2009-04-07 13:52:28 +02:00
|
|
|
}
|
2012-10-02 17:46:12 +02:00
|
|
|
if (m_useNinja)
|
|
|
|
|
AbstractProcessStep::stdError(line);
|
|
|
|
|
else
|
|
|
|
|
AbstractProcessStep::stdOutput(line);
|
2009-02-16 13:12:12 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-21 23:17:58 +02:00
|
|
|
QStringList MakeStep::buildTargets() const
|
|
|
|
|
{
|
|
|
|
|
return m_buildTargets;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
bool MakeStep::buildsBuildTarget(const QString &target) const
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
return m_buildTargets.contains(target);
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
void MakeStep::setBuildTarget(const QString &buildTarget, bool on)
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
QStringList old = m_buildTargets;
|
2010-02-02 12:01:11 +01:00
|
|
|
if (on && !old.contains(buildTarget))
|
|
|
|
|
old << buildTarget;
|
2011-12-01 14:03:15 +01:00
|
|
|
else if (!on && old.contains(buildTarget))
|
2010-02-02 12:01:11 +01:00
|
|
|
old.removeOne(buildTarget);
|
2013-08-26 16:01:24 +02:00
|
|
|
setBuildTargets(old);
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-21 23:17:58 +02:00
|
|
|
void MakeStep::setBuildTargets(const QStringList &targets)
|
|
|
|
|
{
|
2013-08-26 16:01:24 +02:00
|
|
|
if (targets != m_buildTargets) {
|
|
|
|
|
m_buildTargets = targets;
|
|
|
|
|
emit targetsToBuildChanged();
|
|
|
|
|
}
|
2011-10-21 23:17:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::clearBuildTargets()
|
|
|
|
|
{
|
|
|
|
|
m_buildTargets.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
QString MakeStep::additionalArguments() const
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
return m_additionalArguments;
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
void MakeStep::setAdditionalArguments(const QString &list)
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
m_additionalArguments = list;
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2012-10-02 17:46:12 +02:00
|
|
|
QString MakeStep::makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const
|
|
|
|
|
{
|
|
|
|
|
if (m_useNinja)
|
|
|
|
|
return QLatin1String("ninja");
|
|
|
|
|
if (tc)
|
|
|
|
|
return tc->makeCommand(env);
|
|
|
|
|
|
|
|
|
|
return QLatin1String("make");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::setUseNinja(bool useNinja)
|
|
|
|
|
{
|
|
|
|
|
if (m_useNinja != useNinja) {
|
|
|
|
|
m_useNinja = useNinja;
|
|
|
|
|
emit makeCommandChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2009-03-18 13:33:00 +01:00
|
|
|
// MakeStepConfigWidget
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
2009-01-12 15:10:33 +01:00
|
|
|
: m_makeStep(makeStep)
|
|
|
|
|
{
|
|
|
|
|
QFormLayout *fl = new QFormLayout(this);
|
2009-07-23 17:00:38 +02:00
|
|
|
fl->setMargin(0);
|
|
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
2009-01-12 15:10:33 +01:00
|
|
|
setLayout(fl);
|
|
|
|
|
|
2009-03-12 15:51:44 +01:00
|
|
|
m_additionalArguments = new QLineEdit(this);
|
2009-04-17 21:11:52 +02:00
|
|
|
fl->addRow(tr("Additional arguments:"), m_additionalArguments);
|
2011-05-30 13:30:10 +02:00
|
|
|
m_additionalArguments->setText(m_makeStep->additionalArguments());
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
m_buildTargetsList = new QListWidget;
|
|
|
|
|
m_buildTargetsList->setMinimumHeight(200);
|
2013-02-15 17:02:27 +01:00
|
|
|
fl->addRow(tr("Targets:"), m_buildTargetsList);
|
2009-01-12 15:10:33 +01:00
|
|
|
|
|
|
|
|
// TODO update this list also on rescans of the CMakeLists.txt
|
2013-08-26 16:01:24 +02:00
|
|
|
CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->project());
|
2013-03-20 17:48:39 +01:00
|
|
|
QStringList targetList = pro->buildTargetTitles();
|
2013-03-21 15:01:11 +01:00
|
|
|
targetList.sort();
|
2013-03-20 17:48:39 +01:00
|
|
|
foreach (const QString &buildTarget, targetList) {
|
2010-02-02 12:01:11 +01:00
|
|
|
QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList);
|
2009-01-12 15:10:33 +01:00
|
|
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
2011-05-30 13:30:10 +02:00
|
|
|
item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
2009-03-12 15:51:44 +01:00
|
|
|
|
2011-05-30 13:30:10 +02:00
|
|
|
updateDetails();
|
|
|
|
|
|
2012-03-05 22:30:59 +01:00
|
|
|
connect(m_additionalArguments, SIGNAL(textEdited(QString)), this, SLOT(additionalArgumentsEdited()));
|
2010-02-02 12:01:11 +01:00
|
|
|
connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
2009-08-12 17:02:28 +02:00
|
|
|
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
|
|
|
|
|
this, SLOT(updateDetails()));
|
2011-05-30 13:30:10 +02:00
|
|
|
|
2013-08-26 16:01:24 +02:00
|
|
|
connect(pro, SIGNAL(buildTargetsChanged()), this, SLOT(buildTargetsChanged()));
|
|
|
|
|
connect(m_makeStep, SIGNAL(targetsToBuildChanged()), this, SLOT(selectedBuildTargetsChanged()));
|
2012-09-11 15:59:17 +02:00
|
|
|
connect(pro, SIGNAL(environmentChanged()), this, SLOT(updateDetails()));
|
2012-10-02 17:46:12 +02:00
|
|
|
connect(m_makeStep, SIGNAL(makeCommandChanged()), this, SLOT(updateDetails()));
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
void MakeStepConfigWidget::additionalArgumentsEdited()
|
2009-03-12 15:51:44 +01:00
|
|
|
{
|
2010-10-19 11:14:03 +02:00
|
|
|
m_makeStep->setAdditionalArguments(m_additionalArguments->text());
|
2009-08-06 17:26:38 +02:00
|
|
|
updateDetails();
|
2009-03-12 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
void MakeStepConfigWidget::itemChanged(QListWidgetItem *item)
|
2009-01-12 15:10:33 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked);
|
2009-08-06 17:26:38 +02:00
|
|
|
updateDetails();
|
2009-01-12 15:10:33 +01:00
|
|
|
}
|
2008-12-04 13:06:02 +01:00
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
QString MakeStepConfigWidget::displayName() const
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
return tr("Make", "CMakeProjectManager::MakeStepConfigWidget display name.");
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
void MakeStepConfigWidget::buildTargetsChanged()
|
2009-12-03 19:45:09 +01:00
|
|
|
{
|
2010-02-02 12:01:11 +01:00
|
|
|
disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
|
|
|
|
m_buildTargetsList->clear();
|
2012-03-28 13:18:25 +02:00
|
|
|
CMakeProject *pro = static_cast<CMakeProject *>(m_makeStep->target()->project());
|
2011-12-01 14:03:15 +01:00
|
|
|
foreach (const QString& buildTarget, pro->buildTargetTitles()) {
|
2010-02-02 12:01:11 +01:00
|
|
|
QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList);
|
2009-12-03 19:45:09 +01:00
|
|
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
2010-02-02 12:01:11 +01:00
|
|
|
item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
2009-12-03 19:45:09 +01:00
|
|
|
}
|
2010-02-02 12:01:11 +01:00
|
|
|
connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
2009-12-03 19:45:09 +01:00
|
|
|
updateSummary();
|
2009-08-06 17:26:38 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-26 16:01:24 +02:00
|
|
|
void MakeStepConfigWidget::selectedBuildTargetsChanged()
|
|
|
|
|
{
|
|
|
|
|
disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
|
|
|
|
for (int y = 0; y < m_buildTargetsList->count(); ++y) {
|
|
|
|
|
QListWidgetItem *item = m_buildTargetsList->itemAt(0, y);
|
|
|
|
|
item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked);
|
|
|
|
|
}
|
|
|
|
|
connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
|
|
|
|
updateSummary();
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 17:26:38 +02:00
|
|
|
void MakeStepConfigWidget::updateDetails()
|
|
|
|
|
{
|
2012-11-01 18:20:36 +01:00
|
|
|
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
2012-03-28 13:18:25 +02:00
|
|
|
if (!bc)
|
2012-11-01 18:20:36 +01:00
|
|
|
bc = m_makeStep->target()->activeBuildConfiguration();
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!bc) {
|
2012-10-19 17:07:26 +02:00
|
|
|
m_summaryText = tr("<b>No build configuration found on this kit.</b>");
|
2012-04-24 15:49:09 +02:00
|
|
|
updateSummary();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_makeStep->target()->kit());
|
2010-11-12 17:23:55 +01:00
|
|
|
if (tc) {
|
2012-05-03 16:05:03 +02:00
|
|
|
QString arguments = Utils::QtcProcess::joinArgs(m_makeStep->buildTargets());
|
2010-11-12 17:23:55 +01:00
|
|
|
Utils::QtcProcess::addArgs(&arguments, m_makeStep->additionalArguments());
|
|
|
|
|
|
|
|
|
|
ProcessParameters param;
|
|
|
|
|
param.setMacroExpander(bc->macroExpander());
|
|
|
|
|
param.setEnvironment(bc->environment());
|
2013-08-16 17:45:16 +02:00
|
|
|
param.setWorkingDirectory(bc->buildDirectory().toString());
|
2012-10-02 17:46:12 +02:00
|
|
|
param.setCommand(m_makeStep->makeCommand(tc, bc->environment()));
|
2010-11-12 17:23:55 +01:00
|
|
|
param.setArguments(arguments);
|
|
|
|
|
m_summaryText = param.summary(displayName());
|
|
|
|
|
} else {
|
2012-09-03 18:31:44 +02:00
|
|
|
m_summaryText = QLatin1String("<b>") + ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget() + QLatin1String("</b>");
|
2010-11-12 17:23:55 +01:00
|
|
|
}
|
2009-08-06 17:26:38 +02:00
|
|
|
emit updateSummary();
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
QString MakeStepConfigWidget::summaryText() const
|
|
|
|
|
{
|
2009-08-06 17:26:38 +02:00
|
|
|
return m_summaryText;
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
2009-03-18 13:33:00 +01:00
|
|
|
// MakeStepFactory
|
2008-12-04 13:06:02 +01:00
|
|
|
//
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
MakeStepFactory::MakeStepFactory(QObject *parent) :
|
|
|
|
|
ProjectExplorer::IBuildStepFactory(parent)
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
MakeStepFactory::~MakeStepFactory()
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
bool MakeStepFactory::canCreate(BuildStepList *parent, const Core::Id id) const
|
2009-10-27 14:16:28 +01:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (parent->target()->project()->id() == Constants::CMAKEPROJECT_ID)
|
|
|
|
|
return id == MS_ID;
|
|
|
|
|
return false;
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
BuildStep *MakeStepFactory::create(BuildStepList *parent, const Core::Id id)
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!canCreate(parent, id))
|
2010-01-14 17:41:29 +01:00
|
|
|
return 0;
|
2011-11-24 12:42:52 +01:00
|
|
|
MakeStep *step = new MakeStep(parent);
|
2012-08-03 15:24:33 +02:00
|
|
|
if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) {
|
2011-11-24 12:42:52 +01:00
|
|
|
step->setClean(true);
|
2012-11-21 23:54:06 +02:00
|
|
|
step->setAdditionalArguments(QLatin1String("clean"));
|
2011-11-24 12:42:52 +01:00
|
|
|
}
|
|
|
|
|
return step;
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
bool MakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return canCreate(parent, source->id());
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
BuildStep *MakeStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!canClone(parent, source))
|
2010-01-14 17:41:29 +01:00
|
|
|
return 0;
|
|
|
|
|
return new MakeStep(parent, static_cast<MakeStep *>(source));
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
bool MakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
|
2008-12-04 13:06:02 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
return canCreate(parent, idFromMap(map));
|
2008-12-04 13:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
BuildStep *MakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!canRestore(parent, map))
|
2010-01-14 17:41:29 +01:00
|
|
|
return 0;
|
|
|
|
|
MakeStep *bs(new MakeStep(parent));
|
|
|
|
|
if (bs->fromMap(map))
|
|
|
|
|
return bs;
|
|
|
|
|
delete bs;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> MakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (parent->target()->project()->id() == Constants::CMAKEPROJECT_ID)
|
2012-03-15 17:17:40 +01:00
|
|
|
return QList<Core::Id>() << Core::Id(MS_ID);
|
|
|
|
|
return QList<Core::Id>();
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QString MakeStepFactory::displayNameForId(const Core::Id id) const
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (id == MS_ID)
|
2010-01-14 17:41:29 +01:00
|
|
|
return tr("Make", "Display name for CMakeProjectManager::MakeStep id.");
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
2013-02-18 11:14:41 +01:00
|
|
|
|
|
|
|
|
void MakeStep::processStarted()
|
|
|
|
|
{
|
|
|
|
|
futureInterface()->setProgressRange(0, 100);
|
|
|
|
|
AbstractProcessStep::processStarted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
|
|
|
|
{
|
2013-02-20 13:11:34 +01:00
|
|
|
AbstractProcessStep::processFinished(exitCode, status);
|
2013-02-18 11:14:41 +01:00
|
|
|
futureInterface()->setProgressValue(100);
|
|
|
|
|
}
|