forked from qt-creator/qt-creator
Move most of the BuildConfiguration specific functions
Note: I didn't fix all the connects and there are a few missing things. This compiles, more work is coming.
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include "projectloadwizard.h"
|
||||
#include "qtversionmanager.h"
|
||||
#include "qt4buildconfiguration.h"
|
||||
#include "qt4buildconfiguration.h"
|
||||
|
||||
#ifdef QTCREATOR_WITH_S60
|
||||
#include "qt-s60/gccetoolchain.h"
|
||||
@@ -68,10 +69,6 @@ using namespace ProjectExplorer;
|
||||
|
||||
enum { debug = 0 };
|
||||
|
||||
namespace {
|
||||
const char * const KEY_QT_VERSION_ID = "QtVersionId";
|
||||
}
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
@@ -341,7 +338,7 @@ Qt4Project::~Qt4Project()
|
||||
|
||||
void Qt4Project::defaultQtVersionChanged()
|
||||
{
|
||||
if (qtVersionId(activeBuildConfiguration()) == 0)
|
||||
if (static_cast<Qt4BuildConfiguration *>(activeBuildConfiguration())->qtVersionId() == 0)
|
||||
m_rootProjectNode->update();
|
||||
}
|
||||
|
||||
@@ -349,9 +346,10 @@ void Qt4Project::qtVersionsChanged()
|
||||
{
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
foreach (BuildConfiguration *bc, buildConfigurations()) {
|
||||
if (!vm->version(qtVersionId(bc))->isValid()) {
|
||||
setQtVersion(bc, 0);
|
||||
if (bc == activeBuildConfiguration())
|
||||
Qt4BuildConfiguration *qt4bc = static_cast<Qt4BuildConfiguration *>(bc);
|
||||
if (!vm->version(qt4bc->qtVersionId())->isValid()) {
|
||||
qt4bc->setQtVersion(0);
|
||||
if (qt4bc == activeBuildConfiguration())
|
||||
m_rootProjectNode->update();
|
||||
}
|
||||
}
|
||||
@@ -381,8 +379,9 @@ bool Qt4Project::restoreSettingsImpl(PersistentSettingsReader &settingsReader)
|
||||
// or if not, is reset to the default
|
||||
|
||||
foreach (BuildConfiguration *bc, buildConfigurations()) {
|
||||
qtVersionId(bc);
|
||||
toolChainType(bc);
|
||||
Qt4BuildConfiguration *qt4bc = static_cast<Qt4BuildConfiguration *>(bc);
|
||||
qt4bc->qtVersionId();
|
||||
qt4bc->toolChainType();
|
||||
}
|
||||
|
||||
m_rootProjectNode = new Qt4ProFileNode(this, m_fileInfo->fileName(), this);
|
||||
@@ -473,7 +472,7 @@ Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString buildConfigu
|
||||
cleanStep->setClean(true);
|
||||
bc->insertCleanStep(0, cleanStep);
|
||||
if (!additionalArguments.isEmpty())
|
||||
qmakeStep->m_qmakeArgs = additionalArguments;
|
||||
qmakeStep->setQMakeArguments(additionalArguments);
|
||||
|
||||
// set some options for qmake and make
|
||||
if (qmakeBuildConfiguration & QtVersion::BuildAll) // debug_and_release => explicit targets
|
||||
@@ -484,9 +483,9 @@ Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString buildConfigu
|
||||
// Finally set the qt version
|
||||
bool defaultQtVersion = (qtversion == 0);
|
||||
if (defaultQtVersion)
|
||||
setQtVersion(bc, 0);
|
||||
bc->setQtVersion(0);
|
||||
else
|
||||
setQtVersion(bc, qtversion->uniqueId());
|
||||
bc->setQtVersion(qtversion->uniqueId());
|
||||
return bc;
|
||||
}
|
||||
|
||||
@@ -517,61 +516,13 @@ void Qt4Project::scheduleUpdateCodeModel(Qt4ProjectManager::Internal::Qt4ProFile
|
||||
m_proFilesForCodeModelUpdate.append(pro);
|
||||
}
|
||||
|
||||
ProjectExplorer::ToolChain *Qt4Project::toolChain(BuildConfiguration *configuration) const
|
||||
{
|
||||
ToolChain::ToolChainType tct = toolChainType(configuration);
|
||||
return qtVersion(configuration)->toolChain(tct);
|
||||
}
|
||||
|
||||
QString Qt4Project::makeCommand(BuildConfiguration *configuration) const
|
||||
{
|
||||
ToolChain *tc = toolChain(configuration);
|
||||
return tc ? tc->makeCommand() : "make";
|
||||
}
|
||||
|
||||
#ifdef QTCREATOR_WITH_S60
|
||||
static inline QString symbianMakeTarget(QtVersion::QmakeBuildConfig buildConfig,
|
||||
const QString &type)
|
||||
{
|
||||
QString rc = (buildConfig & QtVersion::DebugBuild) ?
|
||||
QLatin1String("debug-") : QLatin1String("release-");
|
||||
rc += type;
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString Qt4Project::defaultMakeTarget(BuildConfiguration *configuration) const
|
||||
{
|
||||
#ifdef QTCREATOR_WITH_S60
|
||||
ToolChain *tc = toolChain(configuration);
|
||||
if (!tc)
|
||||
return QString::null;
|
||||
const QtVersion::QmakeBuildConfig buildConfig
|
||||
= QtVersion::QmakeBuildConfig(activeBuildConfiguration()->value("buildConfiguration").toInt());
|
||||
|
||||
switch (tc->type()) {
|
||||
case ToolChain::GCCE:
|
||||
case ToolChain::GCCE_GNUPOC:
|
||||
return symbianMakeTarget(buildConfig, QLatin1String("gcce"));
|
||||
case ToolChain::RVCT_ARMV5:
|
||||
return symbianMakeTarget(buildConfig, QLatin1String("armv5"));
|
||||
case ToolChain::RVCT_ARMV6:
|
||||
case ToolChain::RVCT_ARMV6_GNUPOC:
|
||||
return symbianMakeTarget(buildConfig, QLatin1String("armv6"));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(configuration);
|
||||
#endif
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
void Qt4Project::updateCodeModel()
|
||||
{
|
||||
if (debug)
|
||||
qDebug()<<"Qt4Project::updateCodeModel()";
|
||||
|
||||
Qt4BuildConfiguration *activeQt4BuildConfiguration = static_cast<Qt4BuildConfiguration *>(activeBuildConfiguration());
|
||||
|
||||
CppTools::CppModelManagerInterface *modelmanager =
|
||||
ExtensionSystem::PluginManager::instance()
|
||||
->getObject<CppTools::CppModelManagerInterface>();
|
||||
@@ -583,7 +534,7 @@ void Qt4Project::updateCodeModel()
|
||||
QStringList predefinedFrameworkPaths;
|
||||
QByteArray predefinedMacros;
|
||||
|
||||
ToolChain *tc = toolChain(activeBuildConfiguration());
|
||||
ToolChain *tc = activeQt4BuildConfiguration->toolChain();
|
||||
QList<HeaderPath> allHeaderPaths;
|
||||
if (tc) {
|
||||
predefinedMacros = tc->predefinedMacros();
|
||||
@@ -602,7 +553,7 @@ void Qt4Project::updateCodeModel()
|
||||
predefinedIncludePaths.append(headerPath.path());
|
||||
}
|
||||
|
||||
const QHash<QString, QString> versionInfo = qtVersion(activeBuildConfiguration())->versionInfo();
|
||||
const QHash<QString, QString> versionInfo = activeQt4BuildConfiguration->qtVersion()->versionInfo();
|
||||
const QString newQtIncludePath = versionInfo.value(QLatin1String("QT_INSTALL_HEADERS"));
|
||||
|
||||
predefinedIncludePaths.append(newQtIncludePath);
|
||||
@@ -687,7 +638,7 @@ void Qt4Project::updateCodeModel()
|
||||
}
|
||||
|
||||
// Add mkspec directory
|
||||
info.includes.append(qtVersion(activeBuildConfiguration())->mkspecPath());
|
||||
info.includes.append(activeQt4BuildConfiguration->qtVersion()->mkspecPath());
|
||||
|
||||
info.frameworkPaths = allFrameworkPaths;
|
||||
|
||||
@@ -701,7 +652,7 @@ void Qt4Project::updateCodeModel()
|
||||
}
|
||||
|
||||
// Add mkspec directory
|
||||
allIncludePaths.append(qtVersion(activeBuildConfiguration())->mkspecPath());
|
||||
allIncludePaths.append(activeQt4BuildConfiguration->qtVersion()->mkspecPath());
|
||||
|
||||
// Dump things out
|
||||
// This is debugging output...
|
||||
@@ -784,7 +735,6 @@ QStringList Qt4Project::frameworkPaths(const QString &fileName) const
|
||||
// */
|
||||
void Qt4Project::update()
|
||||
{
|
||||
// TODO Maybe remove this method completely?
|
||||
m_rootProjectNode->update();
|
||||
//updateCodeModel();
|
||||
}
|
||||
@@ -859,126 +809,6 @@ Qt4ProFileNode *Qt4Project::rootProjectNode() const
|
||||
return m_rootProjectNode;
|
||||
}
|
||||
|
||||
QString Qt4Project::buildDirectory(BuildConfiguration *configuration) const
|
||||
{
|
||||
QString workingDirectory;
|
||||
if (configuration->value("useShadowBuild").toBool())
|
||||
workingDirectory = configuration->value("buildDirectory").toString();
|
||||
if (workingDirectory.isEmpty())
|
||||
workingDirectory = QFileInfo(file()->fileName()).absolutePath();
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
ProjectExplorer::Environment Qt4Project::baseEnvironment(BuildConfiguration *configuration) const
|
||||
{
|
||||
Environment env = useSystemEnvironment(configuration) ? Environment::systemEnvironment() : Environment();
|
||||
qtVersion(configuration)->addToEnvironment(env);
|
||||
ToolChain *tc = toolChain(configuration);
|
||||
if (tc)
|
||||
tc->addToEnvironment(env);
|
||||
return env;
|
||||
}
|
||||
|
||||
ProjectExplorer::Environment Qt4Project::environment(BuildConfiguration *configuration) const
|
||||
{
|
||||
Environment env = baseEnvironment(configuration);
|
||||
env.modify(userEnvironmentChanges(configuration));
|
||||
return env;
|
||||
}
|
||||
|
||||
void Qt4Project::setUseSystemEnvironment(BuildConfiguration *configuration, bool b)
|
||||
{
|
||||
if (useSystemEnvironment(configuration) == b)
|
||||
return;
|
||||
configuration->setValue("clearSystemEnvironment", !b);
|
||||
emit environmentChanged(configuration);
|
||||
}
|
||||
|
||||
bool Qt4Project::useSystemEnvironment(BuildConfiguration *configuration) const
|
||||
{
|
||||
bool b = !(configuration->value("clearSystemEnvironment").isValid()
|
||||
&& configuration->value("clearSystemEnvironment").toBool());
|
||||
return b;
|
||||
}
|
||||
|
||||
QList<ProjectExplorer::EnvironmentItem> Qt4Project::userEnvironmentChanges(BuildConfiguration *configuration) const
|
||||
{
|
||||
return EnvironmentItem::fromStringList(configuration->value("userEnvironmentChanges").toStringList());
|
||||
}
|
||||
|
||||
void Qt4Project::setUserEnvironmentChanges(BuildConfiguration *configuration, const QList<ProjectExplorer::EnvironmentItem> &diff)
|
||||
{
|
||||
QStringList list = EnvironmentItem::toStringList(diff);
|
||||
if (list == configuration->value("userEnvironmentChanges").toStringList())
|
||||
return;
|
||||
configuration->setValue("userEnvironmentChanges", list);
|
||||
emit environmentChanged(configuration);
|
||||
}
|
||||
|
||||
QString Qt4Project::qtDir(BuildConfiguration *configuration) const
|
||||
{
|
||||
QtVersion *version = qtVersion(configuration);
|
||||
if (version)
|
||||
return version->versionInfo().value("QT_INSTALL_DATA");
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
QtVersion *Qt4Project::qtVersion(BuildConfiguration *configuration) const
|
||||
{
|
||||
return QtVersionManager::instance()->version(qtVersionId(configuration));
|
||||
}
|
||||
|
||||
int Qt4Project::qtVersionId(BuildConfiguration *configuration) const
|
||||
{
|
||||
QtVersionManager *vm = QtVersionManager::instance();
|
||||
if (debug)
|
||||
qDebug()<<"Looking for qtVersion ID of "<<configuration->displayName();
|
||||
int id = 0;
|
||||
QVariant vid = configuration->value(KEY_QT_VERSION_ID);
|
||||
if (vid.isValid()) {
|
||||
id = vid.toInt();
|
||||
if (vm->version(id)->isValid()) {
|
||||
return id;
|
||||
} else {
|
||||
configuration->setValue(KEY_QT_VERSION_ID, 0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
// Backward compatibilty, we might have just the name:
|
||||
QString vname = configuration->value("QtVersion").toString();
|
||||
if (debug)
|
||||
qDebug()<<" Backward compatibility reading QtVersion"<<vname;
|
||||
if (!vname.isEmpty()) {
|
||||
const QList<QtVersion *> &versions = vm->versions();
|
||||
foreach (const QtVersion * const version, versions) {
|
||||
if (version->name() == vname) {
|
||||
if (debug)
|
||||
qDebug()<<"found name in versions";
|
||||
configuration->setValue(KEY_QT_VERSION_ID, version->uniqueId());
|
||||
return version->uniqueId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debug)
|
||||
qDebug()<<" using qtversion with id ="<<id;
|
||||
// Nothing found, reset to default
|
||||
configuration->setValue(KEY_QT_VERSION_ID, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void Qt4Project::setQtVersion(BuildConfiguration *configuration, int id)
|
||||
{
|
||||
configuration->setValue(KEY_QT_VERSION_ID, id);
|
||||
emit qtVersionChanged(configuration);
|
||||
updateActiveRunConfiguration();
|
||||
}
|
||||
|
||||
void Qt4Project::setToolChainType(BuildConfiguration *configuration, ProjectExplorer::ToolChain::ToolChainType type)
|
||||
{
|
||||
configuration->setValue("ToolChain", (int)type);
|
||||
updateActiveRunConfiguration();
|
||||
}
|
||||
|
||||
void Qt4Project::updateActiveRunConfiguration()
|
||||
{
|
||||
@@ -986,18 +816,6 @@ void Qt4Project::updateActiveRunConfiguration()
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
||||
ProjectExplorer::ToolChain::ToolChainType Qt4Project::toolChainType(BuildConfiguration *configuration) const
|
||||
{
|
||||
ToolChain::ToolChainType originalType = ToolChain::ToolChainType(configuration->value("ToolChain").toInt());
|
||||
ToolChain::ToolChainType type = originalType;
|
||||
const QtVersion *version = qtVersion(configuration);
|
||||
if (!version->possibleToolChainTypes().contains(type)) // use default tool chain
|
||||
type = version->defaultToolchainType();
|
||||
if (type != originalType)
|
||||
const_cast<Qt4Project *>(this)->setToolChainType(configuration, type);
|
||||
return type;
|
||||
}
|
||||
|
||||
QString Qt4Project::extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version)
|
||||
{
|
||||
int index = list.indexOf("-spec");
|
||||
@@ -1185,24 +1003,6 @@ void Qt4Project::proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *nod
|
||||
}
|
||||
}
|
||||
|
||||
QMakeStep *Qt4Project::qmakeStep(ProjectExplorer::BuildConfiguration *bc) const
|
||||
{
|
||||
QMakeStep *qs = 0;
|
||||
foreach(BuildStep *bs, bc->buildSteps())
|
||||
if ((qs = qobject_cast<QMakeStep *>(bs)) != 0)
|
||||
return qs;
|
||||
return 0;
|
||||
}
|
||||
|
||||
MakeStep *Qt4Project::makeStep(ProjectExplorer::BuildConfiguration *bc) const
|
||||
{
|
||||
MakeStep *qs = 0;
|
||||
foreach(BuildStep *bs, bc->buildSteps())
|
||||
if ((qs = qobject_cast<MakeStep *>(bs)) != 0)
|
||||
return qs;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Qt4Project::hasSubNode(Qt4PriFileNode *root, const QString &path)
|
||||
{
|
||||
if (root->path() == path)
|
||||
@@ -1243,11 +1043,6 @@ void Qt4Project::invalidateCachedTargetInformation()
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
||||
void Qt4Project::emitBuildDirectoryChanged()
|
||||
{
|
||||
emit buildDirectoryChanged();
|
||||
}
|
||||
|
||||
// We match -spec and -platfrom separetly
|
||||
// We ignore -cache, because qmake contained a bug that it didn't
|
||||
// mention the -cache in the Makefile
|
||||
@@ -1274,56 +1069,6 @@ QStringList Qt4Project::removeSpecFromArgumentList(const QStringList &old)
|
||||
return newList;
|
||||
}
|
||||
|
||||
// returns true if both are equal
|
||||
bool Qt4Project::compareBuildConfigurationToImportFrom(BuildConfiguration *bc, const QString &workingDirectory)
|
||||
{
|
||||
QMakeStep *qs = qmakeStep(bc);
|
||||
if (QDir(workingDirectory).exists(QLatin1String("Makefile")) && qs) {
|
||||
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory);
|
||||
QtVersion *version = qtVersion(bc);
|
||||
if (version->qmakeCommand() == qmakePath) {
|
||||
// same qtversion
|
||||
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
||||
QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig());
|
||||
if (QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt()) == result.first) {
|
||||
// The QMake Build Configuration are the same,
|
||||
// now compare arguments lists
|
||||
// we have to compare without the spec/platform cmd argument
|
||||
// and compare that on its own
|
||||
QString actualSpec = extractSpecFromArgumentList(qs->m_qmakeArgs, workingDirectory, version);
|
||||
if (actualSpec.isEmpty()) {
|
||||
// Easy one the user has choosen not to override the settings
|
||||
actualSpec = version->mkspec();
|
||||
}
|
||||
|
||||
|
||||
QString parsedSpec = extractSpecFromArgumentList(result.second, workingDirectory, version);
|
||||
QStringList actualArgs = removeSpecFromArgumentList(qs->m_qmakeArgs);
|
||||
QStringList parsedArgs = removeSpecFromArgumentList(result.second);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Handle special case were a subproject of the qt directory is opened, and
|
||||
|
||||
Reference in New Issue
Block a user