2010-02-08 15:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qt4target.h"
|
|
|
|
|
|
|
|
|
|
#include "makestep.h"
|
|
|
|
|
#include "qmakestep.h"
|
|
|
|
|
#include "qt4project.h"
|
2010-02-25 16:51:27 +01:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2010-12-06 12:45:05 +01:00
|
|
|
#include "qt4projectconfigwidget.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2010-12-10 19:02:19 +01:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2010-03-30 18:45:04 +02:00
|
|
|
#include <projectexplorer/customexecutablerunconfiguration.h>
|
2010-07-16 14:00:41 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
2010-12-10 19:02:19 +01:00
|
|
|
// Qt4BaseTargetFactory
|
2010-02-08 15:50:06 +01:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
Qt4BaseTargetFactory::Qt4BaseTargetFactory(QObject *parent) :
|
2010-02-08 15:50:06 +01:00
|
|
|
ITargetFactory(parent)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
Qt4BaseTargetFactory::~Qt4BaseTargetFactory()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
|
2010-02-17 16:18:21 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
Qt4BaseTargetFactory *Qt4BaseTargetFactory::qt4BaseTargetFactoryForId(const QString &id)
|
2010-03-26 10:26:28 +01:00
|
|
|
{
|
2010-12-10 19:02:19 +01:00
|
|
|
QList<Qt4BaseTargetFactory *> factories = ExtensionSystem::PluginManager::instance()->getObjects<Qt4BaseTargetFactory>();
|
|
|
|
|
foreach (Qt4BaseTargetFactory *fac, factories) {
|
|
|
|
|
if (fac->supportsTargetId(id))
|
|
|
|
|
return fac;
|
2010-03-26 10:26:28 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 09:59:49 +01:00
|
|
|
// Return name of a build configuration.
|
|
|
|
|
QString Qt4BaseTargetFactory::msgBuildConfigurationName(const BuildConfigurationInfo &info)
|
|
|
|
|
{
|
|
|
|
|
const QString qtVersionName = info.version->displayName();
|
|
|
|
|
return (info.buildConfig & QtVersion::DebugBuild) ?
|
|
|
|
|
//: Name of a debug build configuration to created by a project wizard, %1 being the Qt version name. We recommend not translating it.
|
|
|
|
|
tr("%1 Debug").arg(qtVersionName) :
|
|
|
|
|
//: Name of a release build configuration to created by a project wizard, %1 being the Qt version name. We recommend not translating it.
|
|
|
|
|
tr("%1 Release").arg(qtVersionName);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
// -------------------------------------------------------------------------
|
2010-12-10 19:02:19 +01:00
|
|
|
// Qt4BaseTarget
|
2010-02-08 15:50:06 +01:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
Qt4BaseTarget::Qt4BaseTarget(Qt4Project *parent, const QString &id) :
|
|
|
|
|
ProjectExplorer::Target(parent, id)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
connect(this, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
2010-03-10 16:55:37 +01:00
|
|
|
this, SLOT(emitProFileEvaluateNeeded()));
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(this, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SIGNAL(environmentChanged()));
|
2010-02-15 17:33:56 +01:00
|
|
|
connect(this, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(onAddedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
Qt4BaseTarget::~Qt4BaseTarget()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
ProjectExplorer::BuildConfigWidget *Qt4BaseTarget::createConfigWidget()
|
2010-12-06 12:45:05 +01:00
|
|
|
{
|
|
|
|
|
return new Qt4ProjectConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
Qt4BuildConfiguration *Qt4BaseTarget::activeBuildConfiguration() const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
return static_cast<Qt4BuildConfiguration *>(Target::activeBuildConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
Qt4Project *Qt4BaseTarget::qt4Project() const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
return static_cast<Qt4Project *>(project());
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
QList<ProjectExplorer::ToolChainType> Qt4BaseTarget::filterToolChainTypes(const QList<ProjectExplorer::ToolChainType> &candidates) const
|
|
|
|
|
{
|
|
|
|
|
return candidates;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChainType Qt4BaseTarget::preferredToolChainType(const QList<ProjectExplorer::ToolChainType> &candidates) const
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::ToolChainType preferredType = ProjectExplorer::ToolChain_INVALID;
|
|
|
|
|
if (!candidates.isEmpty())
|
|
|
|
|
preferredType = candidates.at(0);
|
|
|
|
|
return preferredType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4BaseTarget::defaultBuildDirectory() const
|
|
|
|
|
{
|
|
|
|
|
Qt4BaseTargetFactory *fac = Qt4BaseTargetFactory::qt4BaseTargetFactoryForId(id());
|
|
|
|
|
return fac->defaultShadowBuildDirectory(qt4Project()->defaultTopLevelBuildDirectory(), id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4BaseTarget::removeUnconfiguredCustomExectutableRunConfigurations()
|
|
|
|
|
{
|
|
|
|
|
if (runConfigurations().count()) {
|
|
|
|
|
// Remove all run configurations which the new project wizard created
|
|
|
|
|
QList<ProjectExplorer::RunConfiguration*> toRemove;
|
|
|
|
|
foreach (ProjectExplorer::RunConfiguration * rc, runConfigurations()) {
|
|
|
|
|
ProjectExplorer::CustomExecutableRunConfiguration *cerc
|
|
|
|
|
= qobject_cast<ProjectExplorer::CustomExecutableRunConfiguration *>(rc);
|
|
|
|
|
if (cerc && !cerc->isConfigured())
|
|
|
|
|
toRemove.append(rc);
|
|
|
|
|
}
|
|
|
|
|
foreach (ProjectExplorer::RunConfiguration *rc, toRemove)
|
|
|
|
|
removeRunConfiguration(rc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4BuildConfiguration *Qt4BaseTarget::addQt4BuildConfiguration(QString displayName, QtVersion *qtversion,
|
2010-02-08 15:50:06 +01:00
|
|
|
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
|
2010-10-19 11:14:03 +02:00
|
|
|
QString additionalArguments,
|
2010-03-26 10:26:28 +01:00
|
|
|
QString directory)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(qtversion);
|
|
|
|
|
bool debug = qmakeBuildConfiguration & QtVersion::DebugBuild;
|
|
|
|
|
|
|
|
|
|
// Add the buildconfiguration
|
|
|
|
|
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(this);
|
2010-08-19 12:26:21 +02:00
|
|
|
bc->setDefaultDisplayName(displayName);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
|
|
|
|
ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(buildSteps);
|
|
|
|
|
Q_ASSERT(cleanSteps);
|
|
|
|
|
|
|
|
|
|
QMakeStep *qmakeStep = new QMakeStep(buildSteps);
|
|
|
|
|
buildSteps->insertStep(0, qmakeStep);
|
|
|
|
|
|
|
|
|
|
MakeStep *makeStep = new MakeStep(buildSteps);
|
|
|
|
|
buildSteps->insertStep(1, makeStep);
|
2010-03-23 18:54:04 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
MakeStep* cleanStep = new MakeStep(cleanSteps);
|
2010-02-08 15:50:06 +01:00
|
|
|
cleanStep->setClean(true);
|
2010-10-19 11:14:03 +02:00
|
|
|
cleanStep->setUserArguments("clean");
|
2010-07-16 14:00:41 +02:00
|
|
|
cleanSteps->insertStep(0, cleanStep);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!additionalArguments.isEmpty())
|
|
|
|
|
qmakeStep->setUserArguments(additionalArguments);
|
|
|
|
|
|
|
|
|
|
// set some options for qmake and make
|
|
|
|
|
if (qmakeBuildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets
|
2010-10-19 11:14:03 +02:00
|
|
|
makeStep->setUserArguments(debug ? "debug" : "release");
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
bc->setQMakeBuildConfiguration(qmakeBuildConfiguration);
|
|
|
|
|
|
|
|
|
|
// Finally set the qt version & ToolChain
|
|
|
|
|
bc->setQtVersion(qtversion);
|
2010-11-01 14:14:17 +01:00
|
|
|
ProjectExplorer::ToolChainType defaultTc = preferredToolChainType(filterToolChainTypes(bc->qtVersion()->possibleToolChainTypes()));
|
2010-02-08 15:50:06 +01:00
|
|
|
bc->setToolChainType(defaultTc);
|
2010-03-26 10:26:28 +01:00
|
|
|
if (!directory.isEmpty())
|
|
|
|
|
bc->setShadowBuildAndDirectory(directory != project()->projectDirectory(), directory);
|
2010-02-08 15:50:06 +01:00
|
|
|
addBuildConfiguration(bc);
|
|
|
|
|
|
|
|
|
|
return bc;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
void Qt4BaseTarget::onAddedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
|
2010-02-15 17:33:56 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(bc);
|
|
|
|
|
Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration *>(bc);
|
|
|
|
|
Q_ASSERT(qt4bc);
|
|
|
|
|
connect(qt4bc, SIGNAL(buildDirectoryInitialized()),
|
|
|
|
|
this, SIGNAL(buildDirectoryInitialized()));
|
2010-12-06 13:29:18 +01:00
|
|
|
connect(qt4bc, SIGNAL(proFileEvaluateNeeded(Qt4ProjectManager::Qt4BuildConfiguration *)),
|
|
|
|
|
this, SLOT(onProFileEvaluateNeeded(Qt4ProjectManager::Qt4BuildConfiguration *)));
|
2010-02-15 17:33:56 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
void Qt4BaseTarget::onProFileEvaluateNeeded(Qt4ProjectManager::Qt4BuildConfiguration *bc)
|
2010-02-16 13:05:32 +01:00
|
|
|
{
|
|
|
|
|
if (bc && bc == activeBuildConfiguration())
|
2010-03-10 16:55:37 +01:00
|
|
|
emit proFileEvaluateNeeded(this);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
void Qt4BaseTarget::emitProFileEvaluateNeeded()
|
2010-03-10 16:55:37 +01:00
|
|
|
{
|
|
|
|
|
emit proFileEvaluateNeeded(this);
|
2010-02-16 13:05:32 +01:00
|
|
|
}
|