2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +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-02 14:17:16 +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
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "makestep.h"
|
2010-03-17 17:45:33 +01:00
|
|
|
#include "ui_makestep.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2013-05-02 16:13:18 +02:00
|
|
|
#include "qmakeparser.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4project.h"
|
2011-08-18 16:46:44 +02:00
|
|
|
#include "qt4nodes.h"
|
2009-11-25 18:50:20 +01:00
|
|
|
#include "qt4buildconfiguration.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2010-11-01 14:14:17 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2012-11-02 12:45:09 +01:00
|
|
|
#include <projectexplorer/gnumakeparser.h>
|
2010-03-17 17:45:33 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2010-10-19 11:14:03 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2009-02-16 13:12:12 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
|
|
|
#include <QFileInfo>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
using ExtensionSystem::PluginManager;
|
2012-07-26 13:21:57 +02:00
|
|
|
using namespace ProjectExplorer;
|
2013-10-16 11:02:37 +02:00
|
|
|
using namespace QmakeProjectManager;
|
|
|
|
using namespace QmakeProjectManager::Internal;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
namespace {
|
2012-07-26 13:21:57 +02:00
|
|
|
const char MAKESTEP_BS_ID[] = "Qt4ProjectManager.MakeStep";
|
|
|
|
const char MAKE_ARGUMENTS_KEY[] = "Qt4ProjectManager.MakeStep.MakeArguments";
|
2013-02-05 15:41:23 +01:00
|
|
|
const char AUTOMATICLY_ADDED_MAKE_ARGUMENTS_KEY[] = "Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments";
|
2012-07-26 13:21:57 +02:00
|
|
|
const char MAKE_COMMAND_KEY[] = "Qt4ProjectManager.MakeStep.MakeCommand";
|
|
|
|
const char CLEAN_KEY[] = "Qt4ProjectManager.MakeStep.Clean";
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *bsl) :
|
2012-03-15 17:17:40 +01:00
|
|
|
AbstractProcessStep(bsl, Core::Id(MAKESTEP_BS_ID)),
|
2010-01-14 17:41:29 +01:00
|
|
|
m_clean(false)
|
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
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) :
|
2010-07-16 14:00:41 +02:00
|
|
|
AbstractProcessStep(bsl, bs),
|
2009-10-27 14:16:28 +01:00
|
|
|
m_clean(bs->m_clean),
|
2009-11-30 19:30:51 +01:00
|
|
|
m_userArgs(bs->m_userArgs),
|
2009-10-27 14:16:28 +01:00
|
|
|
m_makeCmd(bs->m_makeCmd)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-14 17:41:29 +01:00
|
|
|
ctor();
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
MakeStep::MakeStep(BuildStepList *bsl, const Core::Id id) :
|
2010-07-16 14:00:41 +02:00
|
|
|
AbstractProcessStep(bsl, id),
|
2010-01-14 17:41:29 +01:00
|
|
|
m_clean(false)
|
|
|
|
{
|
|
|
|
ctor();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
void MakeStep::ctor()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-11-06 13:45:14 +01:00
|
|
|
setDefaultDisplayName(tr("Make", "Qt MakeStep display name."));
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-05-16 11:48:23 +02:00
|
|
|
void MakeStep::setMakeCommand(const QString &make)
|
|
|
|
{
|
|
|
|
m_makeCmd = make;
|
|
|
|
}
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
MakeStep::~MakeStep()
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-11-26 14:43:27 +01:00
|
|
|
Qt4BuildConfiguration *MakeStep::qt4BuildConfiguration() const
|
|
|
|
{
|
|
|
|
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
|
|
|
}
|
|
|
|
|
2009-10-15 19:06:51 +02:00
|
|
|
void MakeStep::setClean(bool clean)
|
|
|
|
{
|
|
|
|
m_clean = clean;
|
|
|
|
}
|
|
|
|
|
2011-03-14 14:39:02 +01:00
|
|
|
bool MakeStep::isClean() const
|
|
|
|
{
|
|
|
|
return m_clean;
|
|
|
|
}
|
|
|
|
|
2012-05-03 16:15:38 +02:00
|
|
|
QString MakeStep::makeCommand() const
|
|
|
|
{
|
|
|
|
return m_makeCmd;
|
|
|
|
}
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
QVariantMap MakeStep::toMap() const
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2012-07-26 13:21:57 +02:00
|
|
|
QVariantMap map(AbstractProcessStep::toMap());
|
2010-01-14 17:41:29 +01:00
|
|
|
map.insert(QLatin1String(MAKE_ARGUMENTS_KEY), m_userArgs);
|
|
|
|
map.insert(QLatin1String(MAKE_COMMAND_KEY), m_makeCmd);
|
|
|
|
map.insert(QLatin1String(CLEAN_KEY), m_clean);
|
2013-02-05 15:41:23 +01:00
|
|
|
map.insert(QLatin1String(AUTOMATICLY_ADDED_MAKE_ARGUMENTS_KEY), automaticallyAddedArguments());
|
2010-01-14 17:41:29 +01:00
|
|
|
return map;
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
2013-02-05 15:41:23 +01:00
|
|
|
QStringList MakeStep::automaticallyAddedArguments() const
|
|
|
|
{
|
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
|
|
|
|
if (!tc || tc->targetAbi().binaryFormat() == Abi::PEFormat)
|
|
|
|
return QStringList();
|
|
|
|
return QStringList() << QLatin1String("-w") << QLatin1String("-r");
|
|
|
|
}
|
|
|
|
|
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_makeCmd = map.value(QLatin1String(MAKE_COMMAND_KEY)).toString();
|
2010-10-19 11:14:03 +02:00
|
|
|
m_userArgs = map.value(QLatin1String(MAKE_ARGUMENTS_KEY)).toString();
|
2010-01-14 17:41:29 +01:00
|
|
|
m_clean = map.value(QLatin1String(CLEAN_KEY)).toBool();
|
2013-02-05 15:41:23 +01:00
|
|
|
QStringList oldAddedArgs
|
|
|
|
= map.value(QLatin1String(AUTOMATICLY_ADDED_MAKE_ARGUMENTS_KEY)).toStringList();
|
|
|
|
foreach (const QString &newArg, automaticallyAddedArguments()) {
|
|
|
|
if (oldAddedArgs.contains(newArg))
|
|
|
|
continue;
|
|
|
|
m_userArgs.prepend(newArg + QLatin1Char(' '));
|
|
|
|
}
|
2009-10-15 19:06:51 +02:00
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
return AbstractProcessStep::fromMap(map);
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
2009-10-27 14:16:28 +01:00
|
|
|
bool MakeStep::init()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-11-26 14:43:27 +01:00
|
|
|
Qt4BuildConfiguration *bc = qt4BuildConfiguration();
|
2012-01-10 15:08:50 +01:00
|
|
|
if (!bc)
|
|
|
|
bc = qobject_cast<Qt4BuildConfiguration *>(target()->activeBuildConfiguration());
|
2011-03-24 12:43:45 +01:00
|
|
|
|
2011-03-24 19:45:19 +01:00
|
|
|
m_tasks.clear();
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!tc) {
|
2012-09-06 13:13:12 +02:00
|
|
|
m_tasks.append(Task(Task::Error, tr("Qt Creator needs a compiler set up to build. Configure a compiler in the kit options."),
|
|
|
|
Utils::FileName(), -1,
|
|
|
|
Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
2012-08-10 14:13:55 +02:00
|
|
|
return true; // otherwise the tasks will not get reported
|
2011-03-24 12:43:45 +01:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
ProcessParameters *pp = processParameters();
|
2010-11-12 17:23:55 +01:00
|
|
|
pp->setMacroExpander(bc->macroExpander());
|
|
|
|
|
2010-01-13 18:00:02 +01:00
|
|
|
QString workingDirectory;
|
|
|
|
if (bc->subNodeBuild())
|
|
|
|
workingDirectory = bc->subNodeBuild()->buildDir();
|
|
|
|
else
|
2013-08-16 17:45:16 +02:00
|
|
|
workingDirectory = bc->buildDirectory().toString();
|
2010-11-12 17:23:55 +01:00
|
|
|
pp->setWorkingDirectory(workingDirectory);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-09-11 15:59:17 +02:00
|
|
|
QString makeCmd = tc->makeCommand(bc->environment());
|
2009-10-27 14:16:28 +01:00
|
|
|
if (!m_makeCmd.isEmpty())
|
|
|
|
makeCmd = m_makeCmd;
|
2010-11-12 17:23:55 +01:00
|
|
|
pp->setCommand(makeCmd);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-06-22 16:11:45 +02:00
|
|
|
// If we are cleaning, then make can fail with a error code, but that doesn't mean
|
|
|
|
// we should stop the clean queue
|
2010-01-11 10:22:55 +01:00
|
|
|
// That is mostly so that rebuild works on a already clean project
|
2009-10-15 19:06:51 +02:00
|
|
|
setIgnoreReturnValue(m_clean);
|
2010-10-19 11:14:03 +02:00
|
|
|
|
|
|
|
QString args;
|
2010-10-05 17:38:45 +02:00
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
QmakeProjectManager::Qt4ProFileNode *subNode = bc->subNodeBuild();
|
2012-05-14 22:58:34 +03:00
|
|
|
if (subNode) {
|
|
|
|
QString makefile = subNode->makefile();
|
|
|
|
if (makefile.isEmpty())
|
|
|
|
makefile = QLatin1String("Makefile");
|
2013-03-08 18:35:28 +01:00
|
|
|
// Use Makefile.Debug and Makefile.Release
|
|
|
|
// for file builds, since the rules for that are
|
|
|
|
// only in those files.
|
|
|
|
if (subNode->isDebugAndRelease() && bc->fileNodeBuild()) {
|
2012-05-14 22:58:34 +03:00
|
|
|
if (bc->buildType() == Qt4BuildConfiguration::Debug)
|
|
|
|
makefile += QLatin1String(".Debug");
|
|
|
|
else
|
|
|
|
makefile += QLatin1String(".Release");
|
|
|
|
}
|
|
|
|
if (makefile != QLatin1String("Makefile")) {
|
2010-10-19 11:14:03 +02:00
|
|
|
Utils::QtcProcess::addArg(&args, QLatin1String("-f"));
|
2011-03-24 20:44:46 +01:00
|
|
|
Utils::QtcProcess::addArg(&args, makefile);
|
|
|
|
}
|
2012-05-14 22:58:34 +03:00
|
|
|
m_makeFileToCheck = QDir(workingDirectory).filePath(makefile);
|
2011-03-24 20:44:46 +01:00
|
|
|
} else {
|
|
|
|
if (!bc->makefile().isEmpty()) {
|
|
|
|
Utils::QtcProcess::addArg(&args, QLatin1String("-f"));
|
|
|
|
Utils::QtcProcess::addArg(&args, bc->makefile());
|
2011-03-25 17:20:27 +01:00
|
|
|
m_makeFileToCheck = QDir(workingDirectory).filePath(bc->makefile());
|
2011-03-24 20:44:46 +01:00
|
|
|
} else {
|
2012-01-13 14:20:45 +01:00
|
|
|
m_makeFileToCheck = QDir(workingDirectory).filePath(QLatin1String("Makefile"));
|
2010-10-05 17:38:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
Utils::QtcProcess::addArgs(&args, m_userArgs);
|
2012-05-14 22:58:34 +03:00
|
|
|
if (bc->fileNodeBuild() && subNode) {
|
|
|
|
QString objectsDir = subNode->objectsDirectory();
|
|
|
|
if (objectsDir.isEmpty()) {
|
|
|
|
objectsDir = subNode->buildDir(bc);
|
|
|
|
if (subNode->isDebugAndRelease()) {
|
|
|
|
if (bc->buildType() == Qt4BuildConfiguration::Debug)
|
|
|
|
objectsDir += QLatin1String("/debug");
|
|
|
|
else
|
|
|
|
objectsDir += QLatin1String("/release");
|
|
|
|
}
|
2012-05-04 16:25:41 +03:00
|
|
|
}
|
2012-05-14 22:58:34 +03:00
|
|
|
QString relObjectsDir = QDir(pp->workingDirectory()).relativeFilePath(objectsDir);
|
|
|
|
if (!relObjectsDir.isEmpty())
|
|
|
|
relObjectsDir += QLatin1Char('/');
|
|
|
|
QString objectFile = relObjectsDir +
|
|
|
|
QFileInfo(bc->fileNodeBuild()->path()).baseName() +
|
|
|
|
subNode->objectExtension();
|
|
|
|
Utils::QtcProcess::addArg(&args, objectFile);
|
2012-05-04 16:25:41 +03:00
|
|
|
}
|
2011-11-16 16:08:15 +01:00
|
|
|
Utils::Environment env = bc->environment();
|
2011-11-25 09:48:25 +01:00
|
|
|
// 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"));
|
2011-11-16 16:08:15 +01:00
|
|
|
// We also prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose
|
2012-04-24 15:49:09 +02:00
|
|
|
if (tc && m_makeCmd.isEmpty()) {
|
2012-07-26 13:21:57 +02:00
|
|
|
if (tc->targetAbi().os() == Abi::WindowsOS
|
|
|
|
&& tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) {
|
2012-01-13 14:20:45 +01:00
|
|
|
const QString makeFlags = QLatin1String("MAKEFLAGS");
|
|
|
|
env.set(makeFlags, QLatin1Char('L') + env.value(makeFlags));
|
2011-11-16 16:08:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pp->setEnvironment(env);
|
2010-11-12 17:23:55 +01:00
|
|
|
pp->setArguments(args);
|
2012-11-28 15:29:55 +01:00
|
|
|
pp->resolveAll();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-11-02 12:45:09 +01:00
|
|
|
setOutputParser(new ProjectExplorer::GnuMakeParser());
|
|
|
|
IOutputParser *parser = target()->kit()->createOutputParser();
|
2011-05-04 13:14:46 +02:00
|
|
|
if (parser)
|
2012-11-02 12:45:09 +01:00
|
|
|
appendOutputParser(parser);
|
|
|
|
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
|
2013-05-03 15:56:58 +02:00
|
|
|
appendOutputParser(new QMakeParser); // make may cause qmake to be run, add last to make sure
|
|
|
|
// it has a low priority.
|
2009-12-09 13:54:46 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
m_scriptTarget = (static_cast<Qt4Project *>(bc->target()->project())->rootQt4ProjectNode()->projectType() == ScriptTemplate);
|
2012-01-12 15:00:21 +01:00
|
|
|
|
2009-12-09 13:54:46 +01:00
|
|
|
return AbstractProcessStep::init();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MakeStep::run(QFutureInterface<bool> & fi)
|
|
|
|
{
|
2011-03-24 12:43:45 +01:00
|
|
|
bool canContinue = true;
|
2012-07-26 13:21:57 +02:00
|
|
|
foreach (const Task &t, m_tasks) {
|
2011-03-24 12:43:45 +01:00
|
|
|
addTask(t);
|
2012-09-06 13:13:12 +02:00
|
|
|
canContinue = false;
|
2011-03-24 12:43:45 +01:00
|
|
|
}
|
|
|
|
if (!canContinue) {
|
2011-10-21 16:39:14 +02:00
|
|
|
emit addOutput(tr("Configuration is faulty. Check the Issues view for details."), BuildStep::MessageOutput);
|
2011-03-24 12:43:45 +01:00
|
|
|
fi.reportResult(false);
|
2013-02-12 12:56:02 +01:00
|
|
|
emit finished();
|
2011-03-24 12:43:45 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-10 14:13:55 +02:00
|
|
|
if (m_scriptTarget) {
|
|
|
|
fi.reportResult(true);
|
2013-02-12 12:56:02 +01:00
|
|
|
emit finished();
|
2012-08-10 14:13:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!QFileInfo(m_makeFileToCheck).exists()) {
|
|
|
|
if (!ignoreReturnValue())
|
|
|
|
emit addOutput(tr("Cannot find Makefile. Check your build settings."), BuildStep::MessageOutput);
|
|
|
|
fi.reportResult(ignoreReturnValue());
|
2013-02-12 12:56:02 +01:00
|
|
|
emit finished();
|
2012-08-10 14:13:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-09 13:54:46 +01:00
|
|
|
AbstractProcessStep::run(fi);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MakeStep::immutable() const
|
|
|
|
{
|
2009-07-27 16:36:27 +02:00
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
BuildStepConfigWidget *MakeStep::createConfigWidget()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
return new MakeStepConfigWidget(this);
|
|
|
|
}
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
QString MakeStep::userArguments()
|
2009-10-15 19:06:51 +02:00
|
|
|
{
|
2009-11-30 19:30:51 +01:00
|
|
|
return m_userArgs;
|
2009-10-15 19:06:51 +02:00
|
|
|
}
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
void MakeStep::setUserArguments(const QString &arguments)
|
2009-07-24 18:53:54 +02:00
|
|
|
{
|
2009-11-30 19:30:51 +01:00
|
|
|
m_userArgs = arguments;
|
|
|
|
emit userArgumentsChanged();
|
2009-07-24 18:53:54 +02:00
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
2012-01-13 16:29:38 +01:00
|
|
|
: BuildStepConfigWidget(), m_ui(new Internal::Ui::MakeStep), m_makeStep(makeStep), m_bc(0), m_ignoreChange(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-17 17:45:33 +01:00
|
|
|
m_ui->setupUi(this);
|
2010-09-28 11:49:43 +02:00
|
|
|
|
|
|
|
m_ui->makePathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
|
|
m_ui->makePathChooser->setBaseDirectory(Utils::PathChooser::homePath());
|
|
|
|
|
2011-05-30 13:30:10 +02:00
|
|
|
|
2012-05-03 16:15:38 +02:00
|
|
|
const QString &makeCmd = m_makeStep->makeCommand();
|
2011-05-30 13:30:10 +02:00
|
|
|
m_ui->makePathChooser->setPath(makeCmd);
|
|
|
|
m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments());
|
|
|
|
|
|
|
|
updateDetails();
|
|
|
|
|
2010-09-28 18:11:52 +02:00
|
|
|
connect(m_ui->makePathChooser, SIGNAL(changed(QString)),
|
2009-12-03 18:37:27 +01:00
|
|
|
this, SLOT(makeEdited()));
|
2010-03-17 17:45:33 +01:00
|
|
|
connect(m_ui->makeArgumentsLineEdit, SIGNAL(textEdited(QString)),
|
2009-12-03 18:37:27 +01:00
|
|
|
this, SLOT(makeArgumentsLineEdited()));
|
2009-07-24 18:53:54 +02:00
|
|
|
|
2009-11-30 19:30:51 +01:00
|
|
|
connect(makeStep, SIGNAL(userArgumentsChanged()),
|
|
|
|
this, SLOT(userArgumentsChanged()));
|
2009-10-29 12:24:25 +01:00
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
BuildConfiguration *bc = makeStep->buildConfiguration();
|
2012-01-13 16:29:38 +01:00
|
|
|
if (!bc) {
|
|
|
|
// That means the step is in the deploylist, so we listen to the active build config
|
2012-04-24 15:49:09 +02:00
|
|
|
// changed signal and react to the buildDirectoryChanged() signal of the buildconfiguration
|
2012-01-13 16:29:38 +01:00
|
|
|
bc = makeStep->target()->activeBuildConfiguration();
|
|
|
|
m_bc = bc;
|
2012-09-19 14:43:23 +02:00
|
|
|
connect (makeStep->target(), SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
2012-01-13 16:29:38 +01:00
|
|
|
this, SLOT(activeBuildConfigurationChanged()));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bc) {
|
|
|
|
connect(bc, SIGNAL(buildDirectoryChanged()),
|
|
|
|
this, SLOT(updateDetails()));
|
|
|
|
}
|
2010-03-30 17:08:00 +02:00
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
connect(ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
|
2009-08-13 13:47:33 +02:00
|
|
|
this, SLOT(updateDetails()));
|
2012-09-03 18:31:44 +02:00
|
|
|
connect(m_makeStep->target(), SIGNAL(kitChanged()), this, SLOT(updateDetails()));
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
2012-01-13 16:29:38 +01:00
|
|
|
void MakeStepConfigWidget::activeBuildConfigurationChanged()
|
|
|
|
{
|
|
|
|
if (m_bc) {
|
|
|
|
disconnect(m_bc, SIGNAL(buildDirectoryChanged()),
|
|
|
|
this, SLOT(updateDetails()));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bc = m_makeStep->target()->activeBuildConfiguration();
|
|
|
|
updateDetails();
|
|
|
|
|
|
|
|
if (m_bc) {
|
|
|
|
connect(m_bc, SIGNAL(buildDirectoryChanged()),
|
|
|
|
this, SLOT(updateDetails()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void MakeStepConfigWidget::setSummaryText(const QString &text)
|
2010-03-17 17:45:33 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (text == m_summaryText)
|
|
|
|
return;
|
|
|
|
m_summaryText = text;
|
|
|
|
emit updateSummary();
|
2010-03-17 17:45:33 +01:00
|
|
|
}
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
MakeStepConfigWidget::~MakeStepConfigWidget()
|
2010-03-30 17:08:00 +02:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
delete m_ui;
|
2010-03-30 17:08:00 +02:00
|
|
|
}
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void MakeStepConfigWidget::updateDetails()
|
2009-08-12 17:02:28 +02:00
|
|
|
{
|
2012-07-26 13:21:57 +02:00
|
|
|
ToolChain *tc
|
2012-09-03 18:31:44 +02:00
|
|
|
= ToolChainKitInformation::toolChain(m_makeStep->target()->kit());
|
2012-09-11 15:59:17 +02:00
|
|
|
Qt4BuildConfiguration *bc = m_makeStep->qt4BuildConfiguration();
|
|
|
|
if (!bc)
|
|
|
|
bc = qobject_cast<Qt4BuildConfiguration *>(m_makeStep->target()->activeBuildConfiguration());
|
|
|
|
|
|
|
|
if (tc && bc)
|
2013-09-09 14:20:39 +02:00
|
|
|
m_ui->makeLabel->setText(tr("Override %1:").arg(QDir::toNativeSeparators(tc->makeCommand(bc->environment()))));
|
2012-01-12 15:00:21 +01:00
|
|
|
else
|
|
|
|
m_ui->makeLabel->setText(tr("Make:"));
|
2009-08-12 17:02:28 +02:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!tc) {
|
2012-09-03 18:31:44 +02:00
|
|
|
setSummaryText(tr("<b>Make:</b> %1").arg(ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget()));
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!bc) {
|
2012-11-06 13:45:14 +01:00
|
|
|
setSummaryText(tr("<b>Make:</b> No Qt build configuration."));
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
|
|
|
}
|
2009-07-24 18:53:54 +02:00
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
ProcessParameters param;
|
2010-11-12 17:23:55 +01:00
|
|
|
param.setMacroExpander(bc->macroExpander());
|
2013-08-16 17:45:16 +02:00
|
|
|
param.setWorkingDirectory(bc->buildDirectory().toString());
|
2012-09-11 15:59:17 +02:00
|
|
|
QString makeCmd = tc->makeCommand(bc->environment());
|
2012-05-03 16:15:38 +02:00
|
|
|
if (!m_makeStep->makeCommand().isEmpty())
|
|
|
|
makeCmd = m_makeStep->makeCommand();
|
2010-11-12 17:23:55 +01:00
|
|
|
param.setCommand(makeCmd);
|
2011-03-14 14:39:02 +01:00
|
|
|
|
|
|
|
QString args = m_makeStep->userArguments();
|
2011-09-29 18:52:57 +02:00
|
|
|
|
|
|
|
Utils::Environment env = bc->environment();
|
2011-11-25 09:48:25 +01:00
|
|
|
// 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"));
|
2013-02-05 15:41:23 +01:00
|
|
|
// We prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose
|
2009-08-13 17:21:18 +02:00
|
|
|
// FIXME doing this without the user having a way to override this is rather bad
|
2012-04-24 15:49:09 +02:00
|
|
|
if (tc && m_makeStep->makeCommand().isEmpty()) {
|
2012-07-26 13:21:57 +02:00
|
|
|
if (tc->targetAbi().os() == Abi::WindowsOS
|
|
|
|
&& tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) {
|
2012-01-13 14:20:45 +01:00
|
|
|
const QString makeFlags = QLatin1String("MAKEFLAGS");
|
|
|
|
env.set(makeFlags, QLatin1Char('L') + env.value(makeFlags));
|
2011-09-29 18:52:57 +02:00
|
|
|
}
|
|
|
|
}
|
2010-11-12 17:23:55 +01:00
|
|
|
param.setArguments(args);
|
2011-09-29 18:52:57 +02:00
|
|
|
param.setEnvironment(env);
|
2011-10-20 14:39:59 +00:00
|
|
|
|
|
|
|
if (param.commandMissing())
|
2012-04-24 15:49:09 +02:00
|
|
|
setSummaryText(tr("<b>Make:</b> %1 not found in the environment.").arg(makeCmd)); // Override display text
|
|
|
|
else
|
|
|
|
setSummaryText(param.summaryInWorkdir(displayName()));
|
2009-08-06 15:31:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString MakeStepConfigWidget::summaryText() const
|
|
|
|
{
|
|
|
|
return m_summaryText;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString MakeStepConfigWidget::displayName() const
|
|
|
|
{
|
|
|
|
return m_makeStep->displayName();
|
|
|
|
}
|
|
|
|
|
2009-11-30 19:30:51 +01:00
|
|
|
void MakeStepConfigWidget::userArgumentsChanged()
|
2009-07-24 18:53:54 +02:00
|
|
|
{
|
2010-02-15 16:04:01 +01:00
|
|
|
if (m_ignoreChange)
|
|
|
|
return;
|
2010-10-19 11:14:03 +02:00
|
|
|
m_ui->makeArgumentsLineEdit->setText(m_makeStep->userArguments());
|
2009-11-30 19:30:51 +01:00
|
|
|
updateDetails();
|
2009-07-24 18:53:54 +02:00
|
|
|
}
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
void MakeStepConfigWidget::makeEdited()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-05-16 11:48:23 +02:00
|
|
|
m_makeStep->setMakeCommand(m_ui->makePathChooser->rawPath());
|
2009-08-13 11:47:34 +02:00
|
|
|
updateDetails();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
void MakeStepConfigWidget::makeArgumentsLineEdited()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-11-30 19:30:51 +01:00
|
|
|
m_ignoreChange = true;
|
2010-10-19 11:14:03 +02:00
|
|
|
m_makeStep->setUserArguments(m_ui->makeArgumentsLineEdit->text());
|
2009-11-30 19:30:51 +01:00
|
|
|
m_ignoreChange = false;
|
2009-08-13 11:47:34 +02:00
|
|
|
updateDetails();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-04-20 16:25:48 +02:00
|
|
|
|
|
|
|
///
|
2010-01-14 17:41:29 +01:00
|
|
|
// MakeStepFactory
|
2009-04-20 16:25:48 +02:00
|
|
|
///
|
|
|
|
|
2010-01-14 17:41:29 +01:00
|
|
|
MakeStepFactory::MakeStepFactory(QObject *parent) :
|
2012-07-26 13:21:57 +02:00
|
|
|
IBuildStepFactory(parent)
|
2009-04-20 16:25:48 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
MakeStepFactory::~MakeStepFactory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
bool MakeStepFactory::canCreate(BuildStepList *parent, const Core::Id id) const
|
2009-04-20 16:25:48 +02:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (parent->target()->project()->id() == Constants::QT4PROJECT_ID)
|
|
|
|
return id == MAKESTEP_BS_ID;
|
|
|
|
return false;
|
2009-04-20 16:25:48 +02:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
BuildStep *MakeStepFactory::create(BuildStepList *parent, const Core::Id id)
|
2009-04-20 16:25:48 +02: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-01-13 14:20:45 +01:00
|
|
|
step->setUserArguments(QLatin1String("clean"));
|
2011-11-24 12:42:52 +01:00
|
|
|
}
|
|
|
|
return step;
|
2009-10-27 14:16:28 +01:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
bool MakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const
|
2009-10-27 14:16:28 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return canCreate(parent, source->id());
|
2009-04-20 16:25:48 +02:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
BuildStep *MakeStepFactory::clone(BuildStepList *parent, BuildStep *source)
|
2009-04-20 16:25:48 +02: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));
|
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +02:00
|
|
|
bool MakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
|
2010-01-14 17:41:29 +01:00
|
|
|
{
|
2012-07-26 13:21:57 +02:00
|
|
|
return canCreate(parent, idFromMap(map));
|
2010-01-14 17:41:29 +01:00
|
|
|
}
|
|
|
|
|
2012-07-26 13:21:57 +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-07-26 13:21:57 +02:00
|
|
|
QList<Core::Id> MakeStepFactory::availableCreationIds(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::QT4PROJECT_ID)
|
2012-03-15 17:17:40 +01:00
|
|
|
return QList<Core::Id>() << Core::Id(MAKESTEP_BS_ID);
|
|
|
|
return QList<Core::Id>();
|
2009-04-20 16:25:48 +02:00
|
|
|
}
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
QString MakeStepFactory::displayNameForId(const Core::Id id) const
|
2009-04-20 16:25:48 +02:00
|
|
|
{
|
2012-08-03 15:24:33 +02:00
|
|
|
if (id == MAKESTEP_BS_ID)
|
2010-01-14 17:41:29 +01:00
|
|
|
return tr("Make");
|
|
|
|
return QString();
|
2009-04-20 16:25:48 +02:00
|
|
|
}
|