2009-11-23 12:11:48 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-11-23 12:11:48 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qt4buildconfiguration.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2009-11-23 13:29:45 +01:00
|
|
|
#include "qt4project.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "qt4target.h"
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2010-02-19 10:51:40 +01:00
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
#include <QtGui/QInputDialog>
|
|
|
|
|
|
2009-11-23 12:11:48 +01:00
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
2009-11-25 18:50:20 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace {
|
2010-01-18 12:11:04 +01:00
|
|
|
const char * const QT4_BC_ID_PREFIX("Qt4ProjectManager.Qt4BuildConfiguration.");
|
|
|
|
|
const char * const QT4_BC_ID("Qt4ProjectManager.Qt4BuildConfiguration");
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
const char * const USE_SHADOW_BUILD_KEY("Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild");
|
|
|
|
|
const char * const BUILD_DIRECTORY_KEY("Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory");
|
|
|
|
|
const char * const TOOLCHAIN_KEY("Qt4ProjectManager.Qt4BuildConfiguration.ToolChain");
|
|
|
|
|
const char * const BUILD_CONFIGURATION_KEY("Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration");
|
|
|
|
|
const char * const QT_VERSION_ID_KEY("Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId");
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
enum { debug = 0 };
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target) :
|
|
|
|
|
BuildConfiguration(target, QLatin1String(QT4_BC_ID)),
|
2009-12-08 12:21:11 +01:00
|
|
|
m_shadowBuild(false),
|
2010-02-08 15:50:06 +01:00
|
|
|
m_qtVersionId(-1),
|
2009-12-08 12:21:11 +01:00
|
|
|
m_toolChainType(-1), // toolChainType() makes sure to return the default toolchainType
|
2010-01-13 18:00:02 +01:00
|
|
|
m_qmakeBuildConfiguration(0),
|
|
|
|
|
m_subNodeBuild(0)
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
ctor();
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target, const QString &id) :
|
|
|
|
|
BuildConfiguration(target, id),
|
2010-01-18 12:11:04 +01:00
|
|
|
m_shadowBuild(false),
|
2010-02-08 15:50:06 +01:00
|
|
|
m_qtVersionId(-1),
|
2010-01-18 12:11:04 +01:00
|
|
|
m_toolChainType(-1), // toolChainType() makes sure to return the default toolchainType
|
|
|
|
|
m_qmakeBuildConfiguration(0),
|
|
|
|
|
m_subNodeBuild(0)
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
ctor();
|
2009-12-08 12:21:11 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4BuildConfiguration::Qt4BuildConfiguration(Qt4Target *target, Qt4BuildConfiguration *source) :
|
|
|
|
|
BuildConfiguration(target, source),
|
2009-12-08 12:21:11 +01:00
|
|
|
m_shadowBuild(source->m_shadowBuild),
|
|
|
|
|
m_buildDirectory(source->m_buildDirectory),
|
2010-02-08 15:50:06 +01:00
|
|
|
m_qtVersionId(source->m_qtVersionId),
|
2009-12-08 12:21:11 +01:00
|
|
|
m_toolChainType(source->m_toolChainType),
|
2010-01-13 18:00:02 +01:00
|
|
|
m_qmakeBuildConfiguration(source->m_qmakeBuildConfiguration),
|
|
|
|
|
m_subNodeBuild(0) // temporary value, so not copied
|
2009-11-23 12:11:48 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
cloneSteps(source);
|
2010-01-18 12:11:04 +01:00
|
|
|
ctor();
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4BuildConfiguration::~Qt4BuildConfiguration()
|
|
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
}
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
QVariantMap Qt4BuildConfiguration::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map(BuildConfiguration::toMap());
|
|
|
|
|
map.insert(QLatin1String(USE_SHADOW_BUILD_KEY), m_shadowBuild);
|
|
|
|
|
map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory);
|
2010-02-08 15:50:06 +01:00
|
|
|
map.insert(QLatin1String(QT_VERSION_ID_KEY), m_qtVersionId);
|
2010-01-18 12:11:04 +01:00
|
|
|
map.insert(QLatin1String(TOOLCHAIN_KEY), m_toolChainType);
|
|
|
|
|
map.insert(QLatin1String(BUILD_CONFIGURATION_KEY), int(m_qmakeBuildConfiguration));
|
|
|
|
|
return map;
|
2009-11-23 12:11:48 +01:00
|
|
|
}
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
|
|
|
|
|
bool Qt4BuildConfiguration::fromMap(const QVariantMap &map)
|
2009-12-08 12:21:11 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!BuildConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2010-02-17 16:17:49 +01:00
|
|
|
m_shadowBuild = map.value(QLatin1String(USE_SHADOW_BUILD_KEY), false).toBool();
|
2010-01-18 12:11:04 +01:00
|
|
|
m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString();
|
2010-02-08 15:50:06 +01:00
|
|
|
m_qtVersionId = map.value(QLatin1String(QT_VERSION_ID_KEY)).toInt();
|
2010-01-18 12:11:04 +01:00
|
|
|
m_toolChainType = map.value(QLatin1String(TOOLCHAIN_KEY)).toInt();
|
|
|
|
|
m_qmakeBuildConfiguration = QtVersion::QmakeBuildConfigs(map.value(QLatin1String(BUILD_CONFIGURATION_KEY)).toInt());
|
|
|
|
|
|
2010-02-19 10:51:40 +01:00
|
|
|
// Pick a Qt version if the default version is used:
|
|
|
|
|
// We assume that the default Qt version as used in earlier versions of Qt creator
|
|
|
|
|
// was supporting a desktop flavor of Qt.
|
2010-02-10 17:00:14 +01:00
|
|
|
if (m_qtVersionId == 0) {
|
|
|
|
|
QList<QtVersion *> versions = QtVersionManager::instance()->versions();
|
|
|
|
|
foreach (QtVersion *v, versions) {
|
2010-02-19 10:51:40 +01:00
|
|
|
if (v->isValid() && v->supportsTargetId(QLatin1String(DESKTOP_TARGET_ID))) {
|
2010-02-10 17:00:14 +01:00
|
|
|
m_qtVersionId = v->uniqueId();
|
|
|
|
|
break;
|
2010-02-19 10:51:40 +01:00
|
|
|
}
|
2010-02-10 17:00:14 +01:00
|
|
|
}
|
|
|
|
|
if (m_qtVersionId == 0)
|
|
|
|
|
m_qtVersionId = versions.at(0)->uniqueId();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-19 10:51:40 +01:00
|
|
|
if (!qtVersion()->isValid() || !qtVersion()->supportedTargetIds().contains(target()->id())) {
|
|
|
|
|
qWarning() << "Buildconfiguration" << displayName() << ": Qt" << qtVersion()->displayName() << "not supported by target" << target()->id();
|
2010-02-08 15:50:06 +01:00
|
|
|
return false;
|
2010-02-19 10:51:40 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
QList<ToolChain::ToolChainType> possibleTcs(qt4Target()->filterToolChainTypes(qtVersion()->possibleToolChainTypes()));
|
|
|
|
|
if (!possibleTcs.contains(toolChainType()))
|
|
|
|
|
setToolChainType(qt4Target()->preferredToolChainType(possibleTcs));
|
|
|
|
|
|
2010-02-19 10:51:40 +01:00
|
|
|
if (toolChainType() == ToolChain::INVALID) {
|
|
|
|
|
qWarning() << "No toolchain available for" << qtVersion()->displayName() << "used in" << target()->id() << "!";
|
2010-02-08 15:50:06 +01:00
|
|
|
return false;
|
2010-02-19 10:51:40 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
return true;
|
2009-12-08 12:21:11 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
void Qt4BuildConfiguration::ctor()
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
|
|
|
|
QtVersionManager *vm = QtVersionManager::instance();
|
|
|
|
|
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
|
|
|
|
|
this, SLOT(qtVersionsChanged(QList<int>)));
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void Qt4BuildConfiguration::pickValidQtVersion()
|
|
|
|
|
{
|
|
|
|
|
QList<QtVersion *> versions = QtVersionManager::instance()->versionsForTargetId(qt4Target()->id());
|
|
|
|
|
if (!versions.isEmpty())
|
|
|
|
|
setQtVersion(versions.at(0));
|
|
|
|
|
else
|
|
|
|
|
setQtVersion(QtVersionManager::instance()->emptyVersion());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4Target *Qt4BuildConfiguration::qt4Target() const
|
2009-11-26 14:43:27 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
return static_cast<Qt4Target *>(target());
|
2009-11-26 14:43:27 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
ProjectExplorer::Environment Qt4BuildConfiguration::baseEnvironment() const
|
|
|
|
|
{
|
2010-03-11 17:47:09 +01:00
|
|
|
Environment env = BuildConfiguration::baseEnvironment();
|
2009-11-25 18:50:20 +01:00
|
|
|
qtVersion()->addToEnvironment(env);
|
|
|
|
|
ToolChain *tc = toolChain();
|
|
|
|
|
if (tc)
|
|
|
|
|
tc->addToEnvironment(env);
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-07 15:55:00 +01:00
|
|
|
/// returns the build directory
|
2009-11-25 18:50:20 +01:00
|
|
|
QString Qt4BuildConfiguration::buildDirectory() const
|
|
|
|
|
{
|
|
|
|
|
QString workingDirectory;
|
2009-12-08 12:21:11 +01:00
|
|
|
if (m_shadowBuild)
|
|
|
|
|
workingDirectory = m_buildDirectory;
|
2009-11-25 18:50:20 +01:00
|
|
|
if (workingDirectory.isEmpty())
|
2010-02-08 15:50:06 +01:00
|
|
|
workingDirectory = QFileInfo(target()->project()->file()->fileName()).absolutePath();
|
2009-11-25 18:50:20 +01:00
|
|
|
return workingDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-13 18:00:02 +01:00
|
|
|
/// If only a sub tree should be build this function returns which sub node
|
|
|
|
|
/// should be build
|
|
|
|
|
/// \see Qt4BuildConfiguration::setSubNodeBuild
|
|
|
|
|
Qt4ProjectManager::Internal::Qt4ProFileNode *Qt4BuildConfiguration::subNodeBuild() const
|
|
|
|
|
{
|
|
|
|
|
return m_subNodeBuild;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// A sub node build on builds a sub node of the project
|
|
|
|
|
/// That is triggered by a right click in the project explorer tree
|
|
|
|
|
/// The sub node to be build is set via this function immediately before
|
|
|
|
|
/// calling BuildManager::buildProject( BuildConfiguration * )
|
|
|
|
|
/// and reset immediately afterwards
|
|
|
|
|
/// That is m_subNodesBuild is set only temporarly
|
|
|
|
|
void Qt4BuildConfiguration::setSubNodeBuild(Qt4ProjectManager::Internal::Qt4ProFileNode *node)
|
|
|
|
|
{
|
|
|
|
|
m_subNodeBuild = node;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-07 15:55:00 +01:00
|
|
|
/// returns whether this is a shadow build configuration or not
|
|
|
|
|
/// note, even if shadowBuild() returns true, it might be using the
|
2010-01-11 10:22:55 +01:00
|
|
|
/// source directory as the shadow build directory, thus it
|
|
|
|
|
/// still is a in-source build
|
2009-12-07 15:55:00 +01:00
|
|
|
bool Qt4BuildConfiguration::shadowBuild() const
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
return m_shadowBuild;
|
2009-12-07 15:55:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// returns the shadow build directory if set
|
|
|
|
|
/// \note buildDirectory() is probably the function you want to call
|
|
|
|
|
QString Qt4BuildConfiguration::shadowBuildDirectory() const
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
return m_buildDirectory;
|
2009-12-07 15:55:00 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
void Qt4BuildConfiguration::setShadowBuildAndDirectory(bool shadowBuild, const QString &buildDirectory)
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
if (m_shadowBuild == shadowBuild && m_buildDirectory == buildDirectory)
|
2009-12-07 15:55:00 +01:00
|
|
|
return;
|
2010-03-10 16:55:37 +01:00
|
|
|
|
2009-12-08 12:21:11 +01:00
|
|
|
m_shadowBuild = shadowBuild;
|
|
|
|
|
m_buildDirectory = buildDirectory;
|
2009-12-03 18:37:27 +01:00
|
|
|
emit buildDirectoryChanged();
|
2010-03-10 16:55:37 +01:00
|
|
|
emit proFileEvaluateNeeded(this);
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
ProjectExplorer::ToolChain *Qt4BuildConfiguration::toolChain() const
|
|
|
|
|
{
|
|
|
|
|
ToolChain::ToolChainType tct = toolChainType();
|
|
|
|
|
return qtVersion()->toolChain(tct);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4BuildConfiguration::makeCommand() const
|
|
|
|
|
{
|
|
|
|
|
ToolChain *tc = toolChain();
|
|
|
|
|
return tc ? tc->makeCommand() : "make";
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-02 17:43:43 +01:00
|
|
|
static inline QString symbianMakeTarget(QtVersion::QmakeBuildConfigs buildConfig,
|
2009-11-25 18:50:20 +01:00
|
|
|
const QString &type)
|
|
|
|
|
{
|
|
|
|
|
QString rc = (buildConfig & QtVersion::DebugBuild) ?
|
|
|
|
|
QLatin1String("debug-") : QLatin1String("release-");
|
|
|
|
|
rc += type;
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4BuildConfiguration::defaultMakeTarget() const
|
|
|
|
|
{
|
|
|
|
|
ToolChain *tc = toolChain();
|
|
|
|
|
if (!tc)
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-12-02 17:43:43 +01:00
|
|
|
const QtVersion::QmakeBuildConfigs buildConfig = qmakeBuildConfiguration();
|
2009-11-25 18:50:20 +01:00
|
|
|
|
|
|
|
|
switch (tc->type()) {
|
|
|
|
|
case ToolChain::GCCE:
|
|
|
|
|
return symbianMakeTarget(buildConfig, QLatin1String("gcce"));
|
|
|
|
|
case ToolChain::RVCT_ARMV5:
|
|
|
|
|
return symbianMakeTarget(buildConfig, QLatin1String("armv5"));
|
|
|
|
|
case ToolChain::RVCT_ARMV6:
|
|
|
|
|
return symbianMakeTarget(buildConfig, QLatin1String("armv6"));
|
2010-02-17 17:38:48 +01:00
|
|
|
case ToolChain::RVCT_ARMV5_GNUPOC:
|
|
|
|
|
case ToolChain::GCCE_GNUPOC:
|
2009-11-25 18:50:20 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-02-02 17:09:41 +01:00
|
|
|
return QString();
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QtVersion *Qt4BuildConfiguration::qtVersion() const
|
|
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
QtVersionManager *vm = QtVersionManager::instance();
|
2010-02-08 15:50:06 +01:00
|
|
|
return vm->version(m_qtVersionId);
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void Qt4BuildConfiguration::setQtVersion(QtVersion *version)
|
2009-11-25 18:50:20 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(version);
|
2009-12-03 18:37:27 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (m_qtVersionId == version->uniqueId())
|
2010-01-18 12:11:04 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
m_qtVersionId = version->uniqueId();
|
2010-03-10 16:55:37 +01:00
|
|
|
|
|
|
|
|
emit proFileEvaluateNeeded(this);
|
2009-11-25 18:50:20 +01:00
|
|
|
emit qtVersionChanged();
|
2009-12-08 14:41:56 +01:00
|
|
|
emit environmentChanged();
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4BuildConfiguration::setToolChainType(ProjectExplorer::ToolChain::ToolChainType type)
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qt4Target()->filterToolChainTypes(qtVersion()->possibleToolChainTypes()).contains(type) ||
|
|
|
|
|
m_toolChainType == type)
|
2009-12-03 18:37:27 +01:00
|
|
|
return;
|
2009-12-08 12:21:11 +01:00
|
|
|
m_toolChainType = type;
|
2010-03-10 16:55:37 +01:00
|
|
|
|
|
|
|
|
emit proFileEvaluateNeeded(this);
|
2009-12-03 18:37:27 +01:00
|
|
|
emit toolChainTypeChanged();
|
2009-12-08 14:41:56 +01:00
|
|
|
emit environmentChanged();
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChain::ToolChainType Qt4BuildConfiguration::toolChainType() const
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
return ToolChain::ToolChainType(m_toolChainType);
|
2009-11-25 18:50:20 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
QtVersion::QmakeBuildConfigs Qt4BuildConfiguration::qmakeBuildConfiguration() const
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
return m_qmakeBuildConfiguration;
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4BuildConfiguration::setQMakeBuildConfiguration(QtVersion::QmakeBuildConfigs config)
|
|
|
|
|
{
|
2009-12-08 12:21:11 +01:00
|
|
|
if (m_qmakeBuildConfiguration == config)
|
2009-12-03 18:37:27 +01:00
|
|
|
return;
|
2009-12-08 12:21:11 +01:00
|
|
|
m_qmakeBuildConfiguration = config;
|
2010-03-10 16:55:37 +01:00
|
|
|
|
|
|
|
|
emit proFileEvaluateNeeded(this);
|
2009-12-03 18:37:27 +01:00
|
|
|
emit qmakeBuildConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-12 17:20:15 +01:00
|
|
|
void Qt4BuildConfiguration::emitQMakeBuildConfigurationChanged()
|
|
|
|
|
{
|
|
|
|
|
emit qmakeBuildConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-15 17:33:56 +01:00
|
|
|
void Qt4BuildConfiguration::emitBuildDirectoryInitialized()
|
|
|
|
|
{
|
|
|
|
|
emit buildDirectoryInitialized();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
void Qt4BuildConfiguration::getConfigCommandLineArguments(QStringList *addedUserConfigs, QStringList *removedUserConfigs) const
|
|
|
|
|
{
|
|
|
|
|
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion()->defaultBuildConfig();
|
2009-12-08 12:21:11 +01:00
|
|
|
QtVersion::QmakeBuildConfigs userBuildConfiguration = m_qmakeBuildConfiguration;
|
2009-12-03 18:37:27 +01:00
|
|
|
if (removedUserConfigs) {
|
|
|
|
|
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(userBuildConfiguration & QtVersion::BuildAll))
|
|
|
|
|
(*removedUserConfigs) << "debug_and_release";
|
|
|
|
|
}
|
|
|
|
|
if (addedUserConfigs) {
|
|
|
|
|
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (userBuildConfiguration & QtVersion::BuildAll))
|
|
|
|
|
(*addedUserConfigs) << "debug_and_release";
|
|
|
|
|
if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(userBuildConfiguration & QtVersion::DebugBuild))
|
|
|
|
|
(*addedUserConfigs) << "release";
|
|
|
|
|
if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (userBuildConfiguration & QtVersion::DebugBuild))
|
|
|
|
|
(*addedUserConfigs) << "debug";
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-11-25 18:50:20 +01:00
|
|
|
|
|
|
|
|
QMakeStep *Qt4BuildConfiguration::qmakeStep() const
|
|
|
|
|
{
|
|
|
|
|
QMakeStep *qs = 0;
|
|
|
|
|
foreach(BuildStep *bs, buildSteps())
|
|
|
|
|
if ((qs = qobject_cast<QMakeStep *>(bs)) != 0)
|
|
|
|
|
return qs;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeStep *Qt4BuildConfiguration::makeStep() const
|
|
|
|
|
{
|
|
|
|
|
MakeStep *qs = 0;
|
|
|
|
|
foreach(BuildStep *bs, buildSteps())
|
|
|
|
|
if ((qs = qobject_cast<MakeStep *>(bs)) != 0)
|
|
|
|
|
return qs;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
void Qt4BuildConfiguration::qtVersionsChanged(const QList<int> &changedVersions)
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!changedVersions.contains(m_qtVersionId) ||
|
|
|
|
|
qtVersion()->isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pickValidQtVersion();
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
// returns true if both are equal
|
2009-11-27 13:47:27 +01:00
|
|
|
bool Qt4BuildConfiguration::compareToImportFrom(const QString &workingDirectory)
|
2009-11-25 18:50:20 +01:00
|
|
|
{
|
|
|
|
|
QMakeStep *qs = qmakeStep();
|
|
|
|
|
if (QDir(workingDirectory).exists(QLatin1String("Makefile")) && qs) {
|
|
|
|
|
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory);
|
|
|
|
|
QtVersion *version = qtVersion();
|
|
|
|
|
if (version->qmakeCommand() == qmakePath) {
|
|
|
|
|
// same qtversion
|
|
|
|
|
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
|
|
|
|
QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig());
|
2009-12-02 17:43:43 +01:00
|
|
|
if (qmakeBuildConfiguration() == result.first) {
|
2010-02-16 13:53:29 +01:00
|
|
|
// The qmake Build Configuration are the same,
|
2009-11-25 18:50:20 +01:00
|
|
|
// now compare arguments lists
|
|
|
|
|
// we have to compare without the spec/platform cmd argument
|
|
|
|
|
// and compare that on its own
|
2009-11-26 18:51:07 +01:00
|
|
|
QString actualSpec = extractSpecFromArgumentList(qs->userArguments(), workingDirectory, version);
|
2009-11-25 18:50:20 +01:00
|
|
|
if (actualSpec.isEmpty()) {
|
2010-01-11 10:22:55 +01:00
|
|
|
// Easy one: the user has chosen not to override the settings
|
2009-11-25 18:50:20 +01:00
|
|
|
actualSpec = version->mkspec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-11-26 16:49:45 +01:00
|
|
|
QString parsedSpec = extractSpecFromArgumentList(result.second, workingDirectory, version);
|
2009-11-26 18:51:07 +01:00
|
|
|
QStringList actualArgs = removeSpecFromArgumentList(qs->userArguments());
|
2009-11-26 16:49:45 +01:00
|
|
|
QStringList parsedArgs = removeSpecFromArgumentList(result.second);
|
2009-11-25 18:50:20 +01:00
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
qDebug()<<"Actual args:"<<actualArgs;
|
|
|
|
|
qDebug()<<"Parsed args:"<<parsedArgs;
|
|
|
|
|
qDebug()<<"Actual spec:"<<actualSpec;
|
|
|
|
|
qDebug()<<"Parsed spec:"<<parsedSpec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (actualArgs == parsedArgs) {
|
|
|
|
|
// Specs match exactly
|
|
|
|
|
if (actualSpec == parsedSpec)
|
|
|
|
|
return true;
|
|
|
|
|
// Actual spec is the default one
|
|
|
|
|
// qDebug()<<"AS vs VS"<<actualSpec<<version->mkspec();
|
|
|
|
|
if ((actualSpec == version->mkspec() || actualSpec == "default")
|
|
|
|
|
&& (parsedSpec == version->mkspec() || parsedSpec == "default" || parsedSpec.isEmpty()))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-11-26 16:49:45 +01:00
|
|
|
|
|
|
|
|
// We match -spec and -platfrom separetly
|
|
|
|
|
// We ignore -cache, because qmake contained a bug that it didn't
|
|
|
|
|
// mention the -cache in the Makefile
|
|
|
|
|
// That means changing the -cache option in the additional arguments
|
|
|
|
|
// does not automatically rerun qmake. Alas, we could try more
|
|
|
|
|
// intelligent matching for -cache, but i guess people rarely
|
|
|
|
|
// do use that.
|
|
|
|
|
|
|
|
|
|
QStringList Qt4BuildConfiguration::removeSpecFromArgumentList(const QStringList &old)
|
|
|
|
|
{
|
|
|
|
|
if (!old.contains("-spec") && !old.contains("-platform") && !old.contains("-cache"))
|
|
|
|
|
return old;
|
|
|
|
|
QStringList newList;
|
|
|
|
|
bool ignoreNext = false;
|
|
|
|
|
foreach(const QString &item, old) {
|
|
|
|
|
if (ignoreNext) {
|
|
|
|
|
ignoreNext = false;
|
|
|
|
|
} else if (item == "-spec" || item == "-platform" || item == "-cache") {
|
|
|
|
|
ignoreNext = true;
|
|
|
|
|
} else {
|
|
|
|
|
newList << item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return newList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4BuildConfiguration::extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version)
|
|
|
|
|
{
|
|
|
|
|
int index = list.indexOf("-spec");
|
|
|
|
|
if (index == -1)
|
|
|
|
|
index = list.indexOf("-platform");
|
|
|
|
|
if (index == -1)
|
|
|
|
|
return QString();
|
|
|
|
|
|
|
|
|
|
++index;
|
|
|
|
|
|
|
|
|
|
if (index >= list.length())
|
|
|
|
|
return QString();
|
|
|
|
|
|
|
|
|
|
QString baseMkspecDir = version->versionInfo().value("QMAKE_MKSPECS");
|
|
|
|
|
if (baseMkspecDir.isEmpty())
|
|
|
|
|
baseMkspecDir = version->versionInfo().value("QT_INSTALL_DATA") + "/mkspecs";
|
|
|
|
|
|
|
|
|
|
QString parsedSpec = QDir::cleanPath(list.at(index));
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
baseMkspecDir = baseMkspecDir.toLower();
|
|
|
|
|
parsedSpec = parsedSpec.toLower();
|
|
|
|
|
#endif
|
|
|
|
|
// if the path is relative it can be
|
|
|
|
|
// relative to the working directory (as found in the Makefiles)
|
|
|
|
|
// or relatively to the mkspec directory
|
|
|
|
|
// if it is the former we need to get the canonical form
|
|
|
|
|
// for the other one we don't need to do anything
|
|
|
|
|
if (QFileInfo(parsedSpec).isRelative()) {
|
2010-02-01 12:43:56 +01:00
|
|
|
if(QFileInfo(directory + QLatin1Char('/') + parsedSpec).exists()) {
|
|
|
|
|
parsedSpec = QDir::cleanPath(directory + QLatin1Char('/') + parsedSpec);
|
2009-11-26 16:49:45 +01:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
parsedSpec = parsedSpec.toLower();
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
2010-02-01 12:43:56 +01:00
|
|
|
parsedSpec = baseMkspecDir + QLatin1Char('/') + parsedSpec;
|
2009-11-26 16:49:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QFileInfo f2(parsedSpec);
|
|
|
|
|
while (f2.isSymLink()) {
|
|
|
|
|
parsedSpec = f2.symLinkTarget();
|
|
|
|
|
f2.setFile(parsedSpec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parsedSpec.startsWith(baseMkspecDir)) {
|
|
|
|
|
parsedSpec = parsedSpec.mid(baseMkspecDir.length() + 1);
|
|
|
|
|
} else {
|
|
|
|
|
QString sourceMkSpecPath = version->sourcePath() + "/mkspecs";
|
|
|
|
|
if (parsedSpec.startsWith(sourceMkSpecPath)) {
|
|
|
|
|
parsedSpec = parsedSpec.mid(sourceMkSpecPath.length() + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
parsedSpec = parsedSpec.toLower();
|
|
|
|
|
#endif
|
|
|
|
|
return parsedSpec;
|
2009-12-02 17:43:43 +01:00
|
|
|
}
|
2010-01-07 18:17:24 +01:00
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\class Qt4BuildConfigurationFactory
|
|
|
|
|
*/
|
|
|
|
|
|
2010-01-18 12:11:04 +01:00
|
|
|
Qt4BuildConfigurationFactory::Qt4BuildConfigurationFactory(QObject *parent) :
|
|
|
|
|
ProjectExplorer::IBuildConfigurationFactory(parent)
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
|
|
|
|
update();
|
|
|
|
|
|
|
|
|
|
QtVersionManager *vm = QtVersionManager::instance();
|
|
|
|
|
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
|
|
|
|
|
this, SLOT(update()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4BuildConfigurationFactory::~Qt4BuildConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Qt4BuildConfigurationFactory::update()
|
|
|
|
|
{
|
|
|
|
|
m_versions.clear();
|
|
|
|
|
QtVersionManager *vm = QtVersionManager::instance();
|
|
|
|
|
foreach (const QtVersion *version, vm->versions()) {
|
2010-01-18 12:11:04 +01:00
|
|
|
m_versions.insert(QString::fromLatin1(QT4_BC_ID_PREFIX) + QString::fromLatin1("Qt%1").arg(version->uniqueId()),
|
2010-01-07 18:17:24 +01:00
|
|
|
VersionInfo(tr("Using Qt Version \"%1\"").arg(version->displayName()), version->uniqueId()));
|
|
|
|
|
}
|
|
|
|
|
emit availableCreationIdsChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QStringList Qt4BuildConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qobject_cast<Qt4Target *>(parent))
|
2010-01-18 12:11:04 +01:00
|
|
|
return QStringList();
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
QStringList results;
|
|
|
|
|
QtVersionManager *vm = QtVersionManager::instance();
|
|
|
|
|
for (QMap<QString, VersionInfo>::const_iterator i = m_versions.constBegin();
|
|
|
|
|
i != m_versions.constEnd(); ++i) {
|
|
|
|
|
if (vm->version(i.value().versionId)->supportsTargetId(parent->id()))
|
|
|
|
|
results.append(i.key());
|
|
|
|
|
}
|
|
|
|
|
return results;
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Qt4BuildConfigurationFactory::displayNameForId(const QString &id) const
|
|
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
if (!m_versions.contains(id))
|
|
|
|
|
return QString();
|
|
|
|
|
return m_versions.value(id).displayName;
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool Qt4BuildConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const QString &id) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qobject_cast<Qt4Target *>(parent))
|
2010-01-18 12:11:04 +01:00
|
|
|
return false;
|
|
|
|
|
if (!m_versions.contains(id))
|
|
|
|
|
return false;
|
2010-01-07 18:17:24 +01:00
|
|
|
const VersionInfo &info = m_versions.value(id);
|
|
|
|
|
QtVersion *version = QtVersionManager::instance()->version(info.versionId);
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!version ||
|
|
|
|
|
!version->supportsTargetId(parent->id()))
|
2010-01-07 18:17:24 +01:00
|
|
|
return false;
|
2010-01-18 12:11:04 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration *Qt4BuildConfigurationFactory::create(ProjectExplorer::Target *parent, const QString &id)
|
2010-01-18 12:11:04 +01:00
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
const VersionInfo &info = m_versions.value(id);
|
|
|
|
|
QtVersion *version = QtVersionManager::instance()->version(info.versionId);
|
|
|
|
|
Q_ASSERT(version);
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4Target *qt4Target(static_cast<Qt4Target *>(parent));
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
bool ok;
|
|
|
|
|
QString buildConfigurationName = QInputDialog::getText(0,
|
|
|
|
|
tr("New configuration"),
|
|
|
|
|
tr("New Configuration Name:"),
|
|
|
|
|
QLineEdit::Normal,
|
|
|
|
|
version->displayName(),
|
|
|
|
|
&ok);
|
|
|
|
|
if (!ok || buildConfigurationName.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
qt4Target->addQt4BuildConfiguration(tr("%1 Debug").arg(buildConfigurationName),
|
|
|
|
|
version,
|
|
|
|
|
(version->defaultBuildConfig() | QtVersion::DebugBuild));
|
2010-01-07 18:17:24 +01:00
|
|
|
BuildConfiguration *bc =
|
2010-02-08 15:50:06 +01:00
|
|
|
qt4Target->addQt4BuildConfiguration(tr("%1 Release").arg(buildConfigurationName),
|
|
|
|
|
version,
|
|
|
|
|
(version->defaultBuildConfig() & ~QtVersion::DebugBuild));
|
2010-01-07 18:17:24 +01:00
|
|
|
return bc;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool Qt4BuildConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qobject_cast<Qt4Target *>(parent))
|
|
|
|
|
return false;
|
|
|
|
|
Qt4BuildConfiguration *qt4bc(qobject_cast<Qt4BuildConfiguration *>(source));
|
|
|
|
|
if (!qt4bc)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QtVersion *version = qt4bc->qtVersion();
|
|
|
|
|
if (!version ||
|
|
|
|
|
!version->supportsTargetId(parent->id()))
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration *Qt4BuildConfigurationFactory::clone(Target *parent, BuildConfiguration *source)
|
2010-01-07 18:17:24 +01:00
|
|
|
{
|
2010-01-18 12:11:04 +01:00
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4Target *target(static_cast<Qt4Target *>(parent));
|
2010-01-18 12:11:04 +01:00
|
|
|
Qt4BuildConfiguration *oldbc(static_cast<Qt4BuildConfiguration *>(source));
|
2010-02-08 15:50:06 +01:00
|
|
|
return new Qt4BuildConfiguration(target, oldbc);
|
2010-01-18 12:11:04 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool Qt4BuildConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
2010-01-18 12:11:04 +01:00
|
|
|
{
|
|
|
|
|
QString id(ProjectExplorer::idFromMap(map));
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!qobject_cast<Qt4Target *>(parent))
|
2010-01-18 12:11:04 +01:00
|
|
|
return false;
|
|
|
|
|
return id.startsWith(QLatin1String(QT4_BC_ID_PREFIX)) ||
|
|
|
|
|
id == QLatin1String(QT4_BC_ID);
|
2010-01-07 18:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration *Qt4BuildConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
2010-01-18 12:11:04 +01:00
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4Target *target(static_cast<Qt4Target *>(parent));
|
|
|
|
|
Qt4BuildConfiguration *bc(new Qt4BuildConfiguration(target));
|
2010-01-18 12:11:04 +01:00
|
|
|
if (bc->fromMap(map))
|
|
|
|
|
return bc;
|
|
|
|
|
delete bc;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|