Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
if (node->projectType() == Internal::ApplicationTemplate
|| node->projectType() == Internal::ScriptTemplate) {
list.append(node);
}
foreach (ProjectNode *n, node->subProjectNodes()) {
Qt4ProFileNode *qt4ProFileNode = qobject_cast<Qt4ProFileNode *>(n);
if (qt4ProFileNode)
collectApplicationProFiles(list, qt4ProFileNode);
}
}
void Qt4Project::foldersAboutToBeAdded(FolderNode *, const QList<FolderNode*> &nodes)
{
QList<Qt4ProFileNode *> list;
foreach (FolderNode *node, nodes) {
Qt4ProFileNode *qt4ProFileNode = qobject_cast<Qt4ProFileNode *>(node);
if (qt4ProFileNode)
collectApplicationProFiles(list, qt4ProFileNode);
}
m_applicationProFileChange = list;
}
void Qt4Project::checkForNewApplicationProjects()
{
// Check all new project nodes
// against all runConfigurations
foreach (Qt4ProFileNode *qt4proFile, m_applicationProFileChange) {
bool found = false;
foreach (QSharedPointer<RunConfiguration> rc, runConfigurations()) {
QSharedPointer<Qt4RunConfiguration> qtrc = rc.objectCast<Qt4RunConfiguration>();
if (qtrc && qtrc->proFilePath() == qt4proFile->path()) {
found = true;
break;
}
}
if (!found) {
QSharedPointer<Qt4RunConfiguration> newRc(new Qt4RunConfiguration(this, qt4proFile->path()));
addRunConfiguration(newRc);
m_isApplication = true;
}
}
}
void Qt4Project::checkForDeletedApplicationProjects()
{
QStringList paths;
foreach (Qt4ProFileNode * node, applicationProFiles())
paths.append(node->path());
// qDebug()<<"Still existing paths :"<<paths;
QList<QSharedPointer<Qt4RunConfiguration> > removeList;
foreach (QSharedPointer<RunConfiguration> rc, runConfigurations()) {
if (QSharedPointer<Qt4RunConfiguration> qt4rc = rc.objectCast<Qt4RunConfiguration>()) {
if (!paths.contains(qt4rc->proFilePath())) {
removeList.append(qt4rc);
// qDebug()<<"Removing runConfiguration for "<<qt4rc->proFilePath();
}
}
}
bool resetActiveRunConfiguration = false;
QSharedPointer<RunConfiguration> rc(new ProjectExplorer::CustomExecutableRunConfiguration(this));
foreach (QSharedPointer<Qt4RunConfiguration> qt4rc, removeList) {
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
removeRunConfiguration(qt4rc);
if (activeRunConfiguration() == qt4rc)
resetActiveRunConfiguration = true;
}
if (runConfigurations().isEmpty()) {
QSharedPointer<RunConfiguration> rc(new ProjectExplorer::CustomExecutableRunConfiguration(this));
addRunConfiguration(rc);
setActiveRunConfiguration(rc);
m_isApplication = false;
} else if (resetActiveRunConfiguration) {
setActiveRunConfiguration(runConfigurations().first());
}
}
QList<Qt4ProFileNode *> Qt4Project::applicationProFiles() const
{
QList<Qt4ProFileNode *> list;
collectApplicationProFiles(list, rootProjectNode());
return list;
}
void Qt4Project::projectTypeChanged(Qt4ProFileNode *node, const Qt4ProjectType oldType, const Qt4ProjectType newType)
{
if (oldType == Internal::ApplicationTemplate
|| oldType == Internal::ScriptTemplate) {
// check wheter we need to delete a Run Configuration
checkForDeletedApplicationProjects();
}
if (newType == Internal::ApplicationTemplate
|| newType == Internal::ScriptTemplate) {
// add a new Run Configuration
m_applicationProFileChange.clear();
m_applicationProFileChange.append(node);
checkForNewApplicationProjects();
}
}
void Qt4Project::proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode *node)
{
foreach (QSharedPointer<RunConfiguration> rc, runConfigurations()) {
if (QSharedPointer<Qt4RunConfiguration> qt4rc = rc.objectCast<Qt4RunConfiguration>()) {
qt4rc->invalidateCachedTargetInformation();
QMakeStep *Qt4Project::qmakeStep() const
{
QMakeStep *qs = 0;
foreach(BuildStep *bs, buildSteps())
if ((qs = qobject_cast<QMakeStep *>(bs)) != 0)
return qs;
return 0;
}
MakeStep *Qt4Project::makeStep() const
{
MakeStep *qs = 0;
foreach(BuildStep *bs, buildSteps())
if ((qs = qobject_cast<MakeStep *>(bs)) != 0)
return qs;
return 0;
}
bool Qt4Project::hasSubNode(Qt4PriFileNode *root, const QString &path)
if (root->path() == path)
return true;
foreach (FolderNode *fn, root->subFolderNodes()) {
if (qobject_cast<Qt4ProFileNode *>(fn)) {
// we aren't interested in pro file nodes
} else if (Qt4PriFileNode *qt4prifilenode = qobject_cast<Qt4PriFileNode *>(fn)) {
if (hasSubNode(qt4prifilenode, path))
return true;
}
}
return false;
}
void Qt4Project::findProFile(const QString& fileName, Qt4ProFileNode *root, QList<Qt4ProFileNode *> &list)
{
list.append(root);
foreach (FolderNode *fn, root->subFolderNodes())
if (Qt4ProFileNode *qt4proFileNode = qobject_cast<Qt4ProFileNode *>(fn))
findProFile(fileName, qt4proFileNode, list);
}
void Qt4Project::notifyChanged(const QString &name)
{
if (files(Qt4Project::ExcludeGeneratedFiles).contains(name)) {
QList<Qt4ProFileNode *> list;
findProFile(name, rootProjectNode(), list);
foreach(Qt4ProFileNode *node, list)
node->update();
}
void Qt4Project::invalidateCachedTargetInformation()
{
emit targetInformationChanged();
// 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 Qt4Project::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 Qt4Project::extractSpecFromArgumentList(const QStringList &list)
{
int index = list.indexOf("-spec");
if (index == -1)
index = list.indexOf("-platform");
if (index == -1)
return QString();
if (index + 1 < list.length())
return list.at(index +1);
else
return QString();
}
// returns true if both are equal
bool Qt4Project::compareBuildConfigurationToImportFrom(BuildConfiguration *configuration, const QString &workingDirectory)
QMakeStep *qs = qmakeStep();
if (QDir(workingDirectory).exists(QLatin1String("Makefile")) && qs) {
QString qmakePath = QtVersionManager::findQMakeBinaryFromMakefile(workingDirectory);
QtVersion *version = qtVersion(configuration);
if (version->qmakeCommand() == qmakePath) {
// same qtversion
QPair<QtVersion::QmakeBuildConfig, QStringList> result =
QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig());
if (QtVersion::QmakeBuildConfig(configuration->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->value(configuration->name(), "qmakeArgs").toStringList());
if (actualSpec.isEmpty())
// Now to convert the actualSpec to a absolute path, we go through a few hops
if (QFileInfo(actualSpec).isRelative()) {
QString path = version->sourcePath() + "/mkspecs/" + actualSpec;
if (QFileInfo(path).exists()) {
actualSpec = QDir::cleanPath(path);
} else {
path = version->versionInfo().value("QMAKE_MKSPECS") + "/" + actualSpec;
if (QFileInfo(path).exists()) {
actualSpec = QDir::cleanPath(path);
} else {
path = workingDirectory + "/" + actualSpec;
if (QFileInfo(path).exists())
actualSpec = QDir::cleanPath(path);
}
}
}
QString parsedSpec = extractSpecFromArgumentList(result.second);
// if the MakeFile did not contain a mkspec, then it is the default for that qmake
if (parsedSpec.isEmpty())
parsedSpec = version->sourcePath() + "/mkspecs/" + version->mkspec();
if (QFileInfo(parsedSpec).isRelative())
parsedSpec = QDir::cleanPath(workingDirectory + "/" + parsedSpec);
QStringList actualArgs = removeSpecFromArgumentList(qs->value(configuration->name(), "qmakeArgs").toStringList());
QStringList parsedArgs = removeSpecFromArgumentList(result.second);
#ifdef Q_OS_WIN
actualSpec = actualSpec.toLower();
parsedSpec = parsedSpec.toLower();
#endif
if (debug) {
qDebug()<<"Actual args:"<<actualArgs;
qDebug()<<"Parsed args:"<<parsedArgs;
qDebug()<<"Actual spec:"<<actualSpec;
qDebug()<<"Parsed spec:"<<parsedSpec;
}
if (actualArgs == parsedArgs && actualSpec == parsedSpec)
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
/*!
Handle special case were a subproject of the qt directory is opened, and
qt was configured to be built as a shadow build -> also build in the sub-
project in the correct shadow build directory.
*/
// TODO this function should be called on project first load
// and it should check against all configured qt versions ?
//void Qt4Project::detectQtShadowBuild(const QString &buildConfiguration) const
//{
// if (project()->activeBuildConfiguration() == buildConfiguration)
// return;
//
// const QString currentQtDir = static_cast<Qt4Project *>(project())->qtDir(buildConfiguration);
// const QString qtSourceDir = static_cast<Qt4Project *>(project())->qtVersion(buildConfiguration)->sourcePath();
//
// // if the project is a sub-project of Qt and Qt was shadow-built then automatically
// // adjust the build directory of the sub-project.
// if (project()->file()->fileName().startsWith(qtSourceDir) && qtSourceDir != currentQtDir) {
// project()->setValue(buildConfiguration, "useShadowBuild", true);
// QString buildDir = QFileInfo(project()->file()->fileName()).absolutePath();
// buildDir.replace(qtSourceDir, currentQtDir);
// project()->setValue(buildConfiguration, "buildDirectory", buildDir);
// project()->setValue(buildConfiguration, "autoShadowBuild", true);
// }
//}