2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
** 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 "qt4project.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "qt4projectmanager.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "makestep.h"
|
|
|
|
#include "qmakestep.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "qmakerunconfigurationfactory.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4nodes.h"
|
2009-04-20 17:21:31 +02:00
|
|
|
#include "qt4projectconfigwidget.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2009-11-23 12:11:48 +01:00
|
|
|
#include "qt4buildconfiguration.h"
|
2010-08-16 18:23:30 +02:00
|
|
|
#include "findqt4profiles.h"
|
2012-03-06 13:14:42 +01:00
|
|
|
#include "buildconfigurationinfo.h"
|
2009-06-22 14:32:54 +02:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2011-04-12 12:17:19 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/messagemanager.h>
|
|
|
|
#include <coreplugin/coreconstants.h>
|
2010-03-10 16:55:37 +01:00
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2012-10-05 21:34:09 +10:00
|
|
|
#include <coreplugin/documentmanager.h>
|
2012-11-16 19:11:36 +01:00
|
|
|
#include <coreplugin/variablemanager.h>
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2012-03-14 10:25:55 +01:00
|
|
|
#include <cpptools/ModelManagerInterface.h>
|
2010-09-21 14:28:55 +02:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
2012-08-20 12:41:52 +02:00
|
|
|
#include <projectexplorer/buildtargetinfo.h>
|
|
|
|
#include <projectexplorer/deploymentdata.h>
|
2010-11-01 14:14:17 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
#include <projectexplorer/headerpath.h>
|
2011-08-18 16:46:44 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2010-09-27 17:22:57 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2011-04-12 12:17:19 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2009-09-24 16:02:02 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2012-05-16 16:24:16 +02:00
|
|
|
#include <qtsupport/customexecutablerunconfiguration.h>
|
2011-05-20 21:40:53 +02:00
|
|
|
#include <qtsupport/qmldumptool.h>
|
|
|
|
#include <qtsupport/baseqtversion.h>
|
|
|
|
#include <qtsupport/profilereader.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2011-09-21 15:54:07 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2011-10-28 10:15:04 +00:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2012-02-09 09:35:03 +01:00
|
|
|
#include <utils/QtConcurrentTools>
|
2012-11-16 19:11:36 +01:00
|
|
|
#include <utils/stringutils.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFileSystemWatcher>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QInputDialog>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
2011-09-19 09:15:52 +02:00
|
|
|
enum { debug = 0 };
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// Helpers:
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
Qt4BuildConfiguration *enableActiveQt4BuildConfiguration(ProjectExplorer::Target *t, bool enabled)
|
|
|
|
{
|
|
|
|
if (!t)
|
|
|
|
return 0;
|
2012-07-04 15:44:26 +02:00
|
|
|
Qt4BuildConfiguration *bc = static_cast<Qt4BuildConfiguration *>(t->activeBuildConfiguration());
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!bc)
|
|
|
|
return 0;
|
|
|
|
bc->setEnabled(enabled);
|
|
|
|
return bc;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString sanitize(const QString &input)
|
|
|
|
{
|
|
|
|
QString result;
|
|
|
|
result.reserve(input.size());
|
|
|
|
foreach (const QChar &qc, input) {
|
|
|
|
const char c = qc.toLatin1();
|
|
|
|
if ((c >= 'a' && c <='z')
|
|
|
|
|| (c >= 'A' && c <= 'Z')
|
|
|
|
|| (c >= '0' && c <= '9')
|
|
|
|
|| c == '-'
|
|
|
|
|| c == '_')
|
|
|
|
result.append(qc);
|
|
|
|
else
|
|
|
|
result.append(QLatin1Char('_'));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-11-16 19:11:36 +01:00
|
|
|
class Qt4ProjectExpander : public Utils::AbstractQtcMacroExpander
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Qt4ProjectExpander(const QString &proFilePath, const Kit *k, const QString &bcName) :
|
|
|
|
m_proFile(proFilePath), m_kit(k), m_bcName(bcName)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool resolveMacro(const QString &name, QString *ret)
|
|
|
|
{
|
|
|
|
QString result;
|
|
|
|
bool found = false;
|
|
|
|
if (name == QLatin1String(ProjectExplorer::Constants::VAR_CURRENTPROJECT_NAME)) {
|
|
|
|
result = m_proFile.baseName();
|
|
|
|
found = true;
|
|
|
|
} else if (name == QLatin1String(ProjectExplorer::Constants::VAR_CURRENTPROJECT_PATH)) {
|
|
|
|
result = m_proFile.absolutePath();
|
|
|
|
found = true;
|
|
|
|
} else if (name == QLatin1String(ProjectExplorer::Constants::VAR_CURRENTPROJECT_FILEPATH)) {
|
|
|
|
result = m_proFile.absoluteFilePath();
|
|
|
|
found = true;
|
|
|
|
} else if (m_kit && name == QLatin1String(ProjectExplorer::Constants::VAR_CURRENTKIT_NAME)) {
|
|
|
|
result = m_kit->displayName();
|
|
|
|
found = true;
|
|
|
|
} else if (m_kit && name == QLatin1String(ProjectExplorer::Constants::VAR_CURRENTKIT_FILESYSTEMNAME)) {
|
|
|
|
result = m_kit->fileSystemFriendlyName();
|
|
|
|
found = true;
|
|
|
|
} else if (m_kit && name == QLatin1String(ProjectExplorer::Constants::VAR_CURRENTKIT_ID)) {
|
|
|
|
result = m_kit->id().toString();
|
|
|
|
found = true;
|
|
|
|
} else if (name == QLatin1String(ProjectExplorer::Constants::VAR_CURRENTBUILD_NAME)) {
|
|
|
|
result = m_bcName;
|
|
|
|
found = true;
|
|
|
|
} else {
|
|
|
|
result = Core::VariableManager::instance()->value(name.toUtf8(), &found);
|
|
|
|
}
|
|
|
|
if (ret)
|
|
|
|
*ret = result;
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
QFileInfo m_proFile;
|
|
|
|
const Kit *m_kit;
|
|
|
|
QString m_bcName;
|
|
|
|
Utils::AbstractMacroExpander *m_expander;
|
|
|
|
};
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
} // namespace
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
namespace Internal {
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
class Qt4ProjectFile : public Core::IDocument
|
2011-08-18 16:46:44 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-06-28 20:21:08 +02:00
|
|
|
Qt4ProjectFile(const QString &filePath, QObject *parent = 0);
|
2011-08-18 16:46:44 +02:00
|
|
|
|
|
|
|
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
|
|
|
QString fileName() const;
|
|
|
|
virtual void rename(const QString &newName);
|
|
|
|
|
|
|
|
QString defaultPath() const;
|
|
|
|
QString suggestedFileName() const;
|
|
|
|
virtual QString mimeType() const;
|
|
|
|
|
|
|
|
bool isModified() const;
|
|
|
|
bool isSaveAsAllowed() const;
|
|
|
|
|
|
|
|
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
|
|
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
|
|
|
|
|
|
|
private:
|
|
|
|
const QString m_mimeType;
|
|
|
|
QString m_filePath;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Watches folders for Qt4PriFile nodes
|
|
|
|
/// use one file system watcher to watch all folders
|
|
|
|
/// such minimizing system ressouce usage
|
|
|
|
|
|
|
|
class CentralizedFolderWatcher : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
CentralizedFolderWatcher(QObject *parent);
|
|
|
|
~CentralizedFolderWatcher();
|
2011-11-22 13:10:10 +01:00
|
|
|
void watchFolders(const QList<QString> &folders, Qt4ProjectManager::Qt4PriFileNode *node);
|
|
|
|
void unwatchFolders(const QList<QString> &folders, Qt4ProjectManager::Qt4PriFileNode *node);
|
2011-08-18 16:46:44 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void folderChanged(const QString &folder);
|
|
|
|
void onTimer();
|
|
|
|
void delayedFolderChanged(const QString &folder);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QSet<QString> recursiveDirs(const QString &folder);
|
|
|
|
QFileSystemWatcher m_watcher;
|
2011-11-22 13:10:10 +01:00
|
|
|
QMultiMap<QString, Qt4ProjectManager::Qt4PriFileNode *> m_map;
|
2011-08-18 16:46:44 +02:00
|
|
|
|
|
|
|
QSet<QString> m_recursiveWatchedFolders;
|
|
|
|
QTimer m_compressTimer;
|
|
|
|
QSet<QString> m_changedFolders;
|
|
|
|
};
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Qt4ProjectFiles: Struct for (Cached) lists of files in a project
|
2012-04-24 15:49:09 +02:00
|
|
|
class Qt4ProjectFiles {
|
|
|
|
public:
|
2008-12-02 12:01:29 +01:00
|
|
|
void clear();
|
|
|
|
bool equals(const Qt4ProjectFiles &f) const;
|
|
|
|
|
|
|
|
QStringList files[ProjectExplorer::FileTypeSize];
|
|
|
|
QStringList generatedFiles[ProjectExplorer::FileTypeSize];
|
|
|
|
QStringList proFiles;
|
|
|
|
};
|
|
|
|
|
|
|
|
void Qt4ProjectFiles::clear()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < FileTypeSize; ++i) {
|
|
|
|
files[i].clear();
|
|
|
|
generatedFiles[i].clear();
|
|
|
|
}
|
|
|
|
proFiles.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Qt4ProjectFiles::equals(const Qt4ProjectFiles &f) const
|
|
|
|
{
|
|
|
|
for (int i = 0; i < FileTypeSize; ++i)
|
|
|
|
if (files[i] != f.files[i] || generatedFiles[i] != f.generatedFiles[i])
|
|
|
|
return false;
|
|
|
|
if (proFiles != f.proFiles)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator==(const Qt4ProjectFiles &f1, const Qt4ProjectFiles &f2)
|
|
|
|
{ return f1.equals(f2); }
|
|
|
|
|
|
|
|
inline bool operator!=(const Qt4ProjectFiles &f1, const Qt4ProjectFiles &f2)
|
|
|
|
{ return !f1.equals(f2); }
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug d, const Qt4ProjectFiles &f)
|
|
|
|
{
|
|
|
|
QDebug nsp = d.nospace();
|
|
|
|
nsp << "Qt4ProjectFiles: proFiles=" << f.proFiles << '\n';
|
|
|
|
for (int i = 0; i < FileTypeSize; ++i)
|
|
|
|
nsp << "Type " << i << " files=" << f.files[i] << " generated=" << f.generatedFiles[i] << '\n';
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
// A visitor to collect all files of a project in a Qt4ProjectFiles struct
|
|
|
|
class ProjectFilesVisitor : public ProjectExplorer::NodesVisitor
|
|
|
|
{
|
|
|
|
ProjectFilesVisitor(Qt4ProjectFiles *files);
|
2011-07-13 18:02:35 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
static void findProjectFiles(Qt4ProFileNode *rootNode, Qt4ProjectFiles *files);
|
|
|
|
|
|
|
|
void visitProjectNode(ProjectNode *projectNode);
|
|
|
|
void visitFolderNode(FolderNode *folderNode);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Qt4ProjectFiles *m_files;
|
|
|
|
};
|
|
|
|
|
|
|
|
ProjectFilesVisitor::ProjectFilesVisitor(Qt4ProjectFiles *files) :
|
|
|
|
m_files(files)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectFilesVisitor::findProjectFiles(Qt4ProFileNode *rootNode, Qt4ProjectFiles *files)
|
|
|
|
{
|
|
|
|
files->clear();
|
|
|
|
ProjectFilesVisitor visitor(files);
|
|
|
|
rootNode->accept(&visitor);
|
|
|
|
for (int i = 0; i < FileTypeSize; ++i) {
|
|
|
|
qSort(files->files[i]);
|
|
|
|
qSort(files->generatedFiles[i]);
|
|
|
|
}
|
|
|
|
qSort(files->proFiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectFilesVisitor::visitProjectNode(ProjectNode *projectNode)
|
|
|
|
{
|
|
|
|
const QString path = projectNode->path();
|
|
|
|
if (!m_files->proFiles.contains(path))
|
|
|
|
m_files->proFiles.append(path);
|
|
|
|
visitFolderNode(projectNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectFilesVisitor::visitFolderNode(FolderNode *folderNode)
|
|
|
|
{
|
|
|
|
foreach (FileNode *fileNode, folderNode->fileNodes()) {
|
|
|
|
const QString path = fileNode->path();
|
|
|
|
const int type = fileNode->fileType();
|
|
|
|
QStringList &targetList = fileNode->isGenerated() ? m_files->generatedFiles[type] : m_files->files[type];
|
|
|
|
if (!targetList.contains(path))
|
|
|
|
targetList.push_back(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------- Qt4ProjectFile
|
2011-08-18 16:55:45 +02:00
|
|
|
namespace Internal {
|
2012-06-28 20:21:08 +02:00
|
|
|
Qt4ProjectFile::Qt4ProjectFile(const QString &filePath, QObject *parent)
|
2012-02-14 16:43:51 +01:00
|
|
|
: Core::IDocument(parent),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)),
|
|
|
|
m_filePath(filePath)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-05-10 20:43:03 +02:00
|
|
|
bool Qt4ProjectFile::save(QString *, const QString &, bool)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-05 14:29:18 +01:00
|
|
|
// This is never used
|
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2010-05-11 14:13:38 +02:00
|
|
|
void Qt4ProjectFile::rename(const QString &newName)
|
|
|
|
{
|
|
|
|
// Can't happen
|
|
|
|
Q_UNUSED(newName);
|
|
|
|
Q_ASSERT(false);
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QString Qt4ProjectFile::fileName() const
|
|
|
|
{
|
|
|
|
return m_filePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Qt4ProjectFile::defaultPath() const
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Qt4ProjectFile::suggestedFileName() const
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Qt4ProjectFile::mimeType() const
|
|
|
|
{
|
|
|
|
return m_mimeType;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Qt4ProjectFile::isModified() const
|
|
|
|
{
|
2008-12-05 14:29:18 +01:00
|
|
|
return false; // we save after changing anyway
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Qt4ProjectFile::isSaveAsAllowed() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
Core::IDocument::ReloadBehavior Qt4ProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-19 10:28:05 +01:00
|
|
|
Q_UNUSED(state)
|
|
|
|
Q_UNUSED(type)
|
|
|
|
return BehaviorSilent;
|
|
|
|
}
|
|
|
|
|
2011-04-04 15:24:13 +02:00
|
|
|
bool Qt4ProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
2010-03-19 10:28:05 +01:00
|
|
|
{
|
2011-04-04 15:24:13 +02:00
|
|
|
Q_UNUSED(errorString)
|
2010-03-19 10:28:05 +01:00
|
|
|
Q_UNUSED(flag)
|
|
|
|
Q_UNUSED(type)
|
2011-04-04 15:24:13 +02:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2011-08-18 16:46:44 +02:00
|
|
|
} // namespace Internal
|
2012-07-17 15:56:43 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
/*!
|
2009-07-14 15:25:30 +02:00
|
|
|
\class Qt4Project
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
Qt4Project manages information about an individual Qt 4 (.pro) project file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) :
|
|
|
|
m_manager(manager),
|
2009-03-12 15:01:01 +01:00
|
|
|
m_rootProjectNode(0),
|
2008-12-02 12:01:29 +01:00
|
|
|
m_nodesWatcher(new Internal::Qt4NodesWatcher(this)),
|
2012-06-28 20:21:08 +02:00
|
|
|
m_fileInfo(new Qt4ProjectFile(fileName, this)),
|
2009-12-03 18:37:27 +01:00
|
|
|
m_projectFiles(new Qt4ProjectFiles),
|
2012-05-02 15:20:08 +02:00
|
|
|
m_qmakeGlobals(0),
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateFutureInterface(0),
|
|
|
|
m_pendingEvaluateFuturesCount(0),
|
|
|
|
m_asyncUpdateState(NoState),
|
2011-05-30 13:11:31 +02:00
|
|
|
m_cancelEvaluate(false),
|
2012-07-17 15:56:43 +02:00
|
|
|
m_centralizedFolderWatcher(0),
|
|
|
|
m_activeTarget(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-04-12 12:17:19 +02:00
|
|
|
setProjectContext(Core::Context(Qt4ProjectManager::Constants::PROJECT_ID));
|
|
|
|
setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX));
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateTimer.setSingleShot(true);
|
|
|
|
m_asyncUpdateTimer.setInterval(3000);
|
|
|
|
connect(&m_asyncUpdateTimer, SIGNAL(timeout()), this, SLOT(asyncUpdate()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Qt4Project::~Qt4Project()
|
|
|
|
{
|
2010-04-22 18:57:43 +02:00
|
|
|
m_codeModelFuture.cancel();
|
2010-03-11 17:01:06 +01:00
|
|
|
m_asyncUpdateState = ShuttingDown;
|
2008-12-02 18:14:06 +01:00
|
|
|
m_manager->unregisterProject(this);
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_projectFiles;
|
2010-03-11 17:01:06 +01:00
|
|
|
m_cancelEvaluate = true;
|
2011-12-07 17:51:24 +01:00
|
|
|
// Deleting the root node triggers a few things, make sure rootProjectNode
|
|
|
|
// returns 0 already
|
|
|
|
Qt4ProFileNode *root = m_rootProjectNode;
|
|
|
|
m_rootProjectNode = 0;
|
|
|
|
delete root;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::updateFileList()
|
|
|
|
{
|
|
|
|
Qt4ProjectFiles newFiles;
|
|
|
|
ProjectFilesVisitor::findProjectFiles(m_rootProjectNode, &newFiles);
|
|
|
|
if (newFiles != *m_projectFiles) {
|
|
|
|
*m_projectFiles = newFiles;
|
|
|
|
emit fileListChanged();
|
|
|
|
if (debug)
|
|
|
|
qDebug() << Q_FUNC_INFO << *m_projectFiles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-17 12:54:43 +02:00
|
|
|
bool Qt4Project::setupTarget(ProjectExplorer::Target *t)
|
|
|
|
{
|
|
|
|
QList<BuildConfigurationInfo> infoList
|
|
|
|
= Qt4BuildConfigurationFactory::availableBuildConfigurations(t->kit(), m_fileInfo->fileName());
|
|
|
|
setupTarget(t, infoList);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::setupTarget(ProjectExplorer::Target *t, const QList<BuildConfigurationInfo> &infoList)
|
|
|
|
{
|
|
|
|
// Build Configurations:
|
|
|
|
foreach (const BuildConfigurationInfo &info, infoList) {
|
|
|
|
QString name = info.buildConfig & QtSupport::BaseQtVersion::DebugBuild
|
|
|
|
? tr("Debug") : tr("Release");
|
|
|
|
Qt4BuildConfiguration *bc
|
|
|
|
= Qt4BuildConfiguration::setup(t, name, name,
|
|
|
|
info.buildConfig, info.additionalArguments,
|
|
|
|
info.directory, info.importing);
|
|
|
|
t->addBuildConfiguration(bc);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deploy Configurations:
|
|
|
|
t->updateDefaultDeployConfigurations();
|
|
|
|
// Do not create Run Configurations: Those will be generated later anyway.
|
|
|
|
}
|
|
|
|
|
2010-01-19 16:33:44 +01:00
|
|
|
bool Qt4Project::fromMap(const QVariantMap &map)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-19 16:33:44 +01:00
|
|
|
if (!Project::fromMap(map))
|
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
// Prune targets without buildconfigurations:
|
|
|
|
// This can happen esp. when updating from a old version of Qt Creator
|
2010-12-06 16:24:29 +01:00
|
|
|
QList<Target *>ts = targets();
|
2010-02-08 15:50:06 +01:00
|
|
|
foreach (Target *t, ts) {
|
2010-02-18 18:37:11 +01:00
|
|
|
if (t->buildConfigurations().isEmpty()) {
|
2012-03-15 17:17:40 +01:00
|
|
|
qWarning() << "Removing" << t->id().name() << "since it has no buildconfigurations!";
|
2010-02-08 15:50:06 +01:00
|
|
|
removeTarget(t);
|
2010-02-18 18:37:11 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
m_manager->registerProject(this);
|
|
|
|
|
|
|
|
m_rootProjectNode = new Qt4ProFileNode(this, m_fileInfo->fileName(), this);
|
|
|
|
m_rootProjectNode->registerWatcher(m_nodesWatcher);
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
update();
|
|
|
|
updateFileList();
|
2011-09-15 12:15:10 +02:00
|
|
|
// This might be incorrect, need a full update
|
|
|
|
updateCodeModels();
|
2010-06-10 14:48:59 +02:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
// We have the profile nodes now, so we know the runconfigs!
|
2012-10-16 15:56:24 +02:00
|
|
|
connect(m_nodesWatcher, SIGNAL(proFileUpdated(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)),
|
|
|
|
this, SIGNAL(proFileUpdated(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)));
|
2009-12-03 18:37:27 +01:00
|
|
|
|
2010-11-02 16:39:45 +01:00
|
|
|
// Now we emit update once :)
|
2011-09-12 12:40:53 +02:00
|
|
|
m_rootProjectNode->emitProFileUpdatedRecursive();
|
2010-11-02 16:39:45 +01:00
|
|
|
|
2012-07-17 15:56:43 +02:00
|
|
|
// On active buildconfiguration changes, reevaluate the .pro files
|
|
|
|
m_activeTarget = activeTarget();
|
|
|
|
if (m_activeTarget)
|
|
|
|
connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
this, SLOT(scheduleAsyncUpdate()));
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
this, SLOT(activeTargetWasChanged()));
|
|
|
|
|
2009-07-03 16:46:01 +02:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
/// equalFileList compares two file lists ignoring
|
|
|
|
/// <configuration> without generating temporary lists
|
|
|
|
|
|
|
|
bool Qt4Project::equalFileList(const QStringList &a, const QStringList &b)
|
|
|
|
{
|
|
|
|
if (abs(a.length() - b.length()) > 1)
|
|
|
|
return false;
|
|
|
|
QStringList::const_iterator ait = a.constBegin();
|
|
|
|
QStringList::const_iterator bit = b.constBegin();
|
|
|
|
QStringList::const_iterator aend = a.constEnd();
|
|
|
|
QStringList::const_iterator bend = b.constEnd();
|
|
|
|
|
|
|
|
while (ait != aend && bit != bend) {
|
2012-11-28 09:52:19 +01:00
|
|
|
if (*ait == CPlusPlus::CppModelManagerInterface::configurationFileName())
|
2010-03-10 16:55:37 +01:00
|
|
|
++ait;
|
2012-11-28 09:52:19 +01:00
|
|
|
else if (*bit == CPlusPlus::CppModelManagerInterface::configurationFileName())
|
2010-03-10 16:55:37 +01:00
|
|
|
++bit;
|
|
|
|
else if (*ait == *bit)
|
|
|
|
++ait, ++bit;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return (ait == aend && bit == bend);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
2010-09-21 14:28:55 +02:00
|
|
|
void Qt4Project::updateCodeModels()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
if (debug)
|
|
|
|
qDebug()<<"Qt4Project::updateCodeModel()";
|
|
|
|
|
2011-10-28 10:15:04 +00:00
|
|
|
if (activeTarget() && !activeTarget()->activeBuildConfiguration())
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
2010-09-21 14:28:55 +02:00
|
|
|
updateCppCodeModel();
|
|
|
|
updateQmlJSCodeModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::updateCppCodeModel()
|
|
|
|
{
|
2012-02-16 15:09:56 +01:00
|
|
|
typedef CPlusPlus::CppModelManagerInterface::ProjectPart ProjectPart;
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *k = 0;
|
2011-10-28 10:15:04 +00:00
|
|
|
QtSupport::BaseQtVersion *qtVersion = 0;
|
|
|
|
ToolChain *tc = 0;
|
2012-04-24 15:49:09 +02:00
|
|
|
if (ProjectExplorer::Target *target = activeTarget())
|
2012-09-03 18:31:44 +02:00
|
|
|
k = target->kit();
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
2012-09-03 18:31:44 +02:00
|
|
|
k = KitManager::instance()->defaultKit();
|
|
|
|
qtVersion = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
tc = ToolChainKitInformation::toolChain(k);
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
CPlusPlus::CppModelManagerInterface *modelmanager =
|
2011-01-04 18:50:18 +01:00
|
|
|
CPlusPlus::CppModelManagerInterface::instance();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-20 15:31:33 +01:00
|
|
|
if (!modelmanager)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
FindQt4ProFiles findQt4ProFiles;
|
|
|
|
QList<Qt4ProFileNode *> proFiles = findQt4ProFiles(rootProjectNode());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
CPlusPlus::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
|
|
|
|
pinfo.clearProjectParts();
|
|
|
|
ProjectPart::QtVersion qtVersionForPart = ProjectPart::NoQt;
|
|
|
|
if (qtVersion) {
|
|
|
|
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
|
|
|
qtVersionForPart = ProjectPart::Qt4;
|
|
|
|
else
|
|
|
|
qtVersionForPart = ProjectPart::Qt5;
|
|
|
|
}
|
2010-10-18 17:12:44 +02:00
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
QStringList allFiles;
|
|
|
|
foreach (Qt4ProFileNode *pro, proFiles) {
|
|
|
|
ProjectPart::Ptr part(new ProjectPart);
|
2012-12-08 23:38:26 +04:00
|
|
|
|
|
|
|
if (pro->variableValue(ConfigVar).contains(QLatin1String("qt")))
|
|
|
|
part->qtVersion = qtVersionForPart;
|
|
|
|
else
|
|
|
|
part->qtVersion = ProjectPart::NoQt;
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2012-11-20 17:30:05 +01:00
|
|
|
QStringList cxxflags = pro->variableValue(CppFlagsVar);
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
// part->defines
|
|
|
|
if (tc)
|
2012-11-20 17:30:05 +01:00
|
|
|
part->defines = tc->predefinedMacros(cxxflags);
|
2012-02-16 15:09:56 +01:00
|
|
|
part->defines += pro->cxxDefines();
|
|
|
|
|
|
|
|
// part->includePaths
|
|
|
|
part->includePaths.append(pro->variableValue(IncludePathVar));
|
|
|
|
|
|
|
|
QList<HeaderPath> headers;
|
|
|
|
if (tc)
|
2012-11-20 17:30:05 +01:00
|
|
|
headers = tc->systemHeaderPaths(cxxflags, SysRootKitInformation::sysRoot(k));
|
2012-02-16 15:09:56 +01:00
|
|
|
if (qtVersion) {
|
2012-09-03 18:31:44 +02:00
|
|
|
headers.append(qtVersion->systemHeaderPathes(k));
|
2012-02-16 15:09:56 +01:00
|
|
|
}
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
foreach (const HeaderPath &headerPath, headers) {
|
2010-03-10 16:55:37 +01:00
|
|
|
if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
|
2012-02-16 15:09:56 +01:00
|
|
|
part->frameworkPaths.append(headerPath.path());
|
2010-03-10 16:55:37 +01:00
|
|
|
else
|
2012-02-16 15:09:56 +01:00
|
|
|
part->includePaths.append(headerPath.path());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
if (qtVersion) {
|
|
|
|
if (!qtVersion->frameworkInstallPath().isEmpty())
|
|
|
|
part->frameworkPaths.append(qtVersion->frameworkInstallPath());
|
2012-09-04 11:41:32 +02:00
|
|
|
|
2009-05-04 18:22:40 +02:00
|
|
|
}
|
2012-09-04 11:41:32 +02:00
|
|
|
if (Qt4ProFileNode *node = rootQt4ProjectNode())
|
|
|
|
part->includePaths.append(node->resolvedMkspecPath());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
// part->precompiledHeaders
|
|
|
|
part->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));
|
2008-12-08 12:44:28 +01:00
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
// part->language
|
|
|
|
if (tc)
|
2012-11-23 16:29:00 +01:00
|
|
|
part->language = tc->compilerFlags(pro->variableValue(CppFlagsVar)) == ToolChain::STD_CXX11 ? ProjectPart::CXX11 : ProjectPart::CXX;
|
|
|
|
else
|
2013-01-01 14:45:37 +01:00
|
|
|
part->language = CPlusPlus::CppModelManagerInterface::ProjectPart::CXX11;
|
2009-05-04 18:22:40 +02:00
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
part->sourceFiles = pro->variableValue(CppSourceVar);
|
2012-11-23 16:29:00 +01:00
|
|
|
part->headerFiles += pro->variableValue(CppHeaderVar);
|
|
|
|
part->headerFiles += pro->uiFiles();
|
2012-11-28 09:52:19 +01:00
|
|
|
part->sourceFiles.prepend(CPlusPlus::CppModelManagerInterface::configurationFileName());
|
2012-11-23 16:29:00 +01:00
|
|
|
part->objcSourceFiles = pro->variableValue(ObjCSourceVar);
|
2012-02-16 15:09:56 +01:00
|
|
|
pinfo.appendProjectPart(part);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-11-23 16:29:00 +01:00
|
|
|
allFiles += part->headerFiles;
|
2012-02-16 15:09:56 +01:00
|
|
|
allFiles += part->sourceFiles;
|
2012-11-23 16:29:00 +01:00
|
|
|
allFiles += part->objcSourceFiles;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2012-02-16 15:09:56 +01:00
|
|
|
|
|
|
|
modelmanager->updateProjectInfo(pinfo);
|
|
|
|
m_codeModelFuture = modelmanager->updateSourceFiles(allFiles);
|
2009-05-04 18:22:40 +02:00
|
|
|
}
|
|
|
|
|
2010-09-21 14:28:55 +02:00
|
|
|
void Qt4Project::updateQmlJSCodeModel()
|
|
|
|
{
|
2010-09-27 11:16:43 +01:00
|
|
|
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
|
2010-09-21 14:28:55 +02:00
|
|
|
if (!modelManager)
|
|
|
|
return;
|
|
|
|
|
2010-09-27 11:16:43 +01:00
|
|
|
QmlJS::ModelManagerInterface::ProjectInfo projectInfo = modelManager->projectInfo(this);
|
2010-11-09 14:29:43 +01:00
|
|
|
projectInfo.sourceFiles = m_projectFiles->files[QMLType];
|
2010-09-21 14:28:55 +02:00
|
|
|
|
|
|
|
FindQt4ProFiles findQt4ProFiles;
|
|
|
|
QList<Qt4ProFileNode *> proFiles = findQt4ProFiles(rootProjectNode());
|
|
|
|
|
2011-06-23 15:09:38 +02:00
|
|
|
projectInfo.importPaths.clear();
|
2010-09-21 14:28:55 +02:00
|
|
|
foreach (Qt4ProFileNode *node, proFiles) {
|
|
|
|
projectInfo.importPaths.append(node->variableValue(QmlImportPathVar));
|
|
|
|
}
|
2011-09-21 15:54:07 +02:00
|
|
|
|
2011-01-24 13:16:27 +01:00
|
|
|
bool preferDebugDump = false;
|
2011-09-21 15:54:07 +02:00
|
|
|
projectInfo.tryQmlDump = false;
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
ProjectExplorer::Target *t = activeTarget();
|
2012-09-03 18:31:44 +02:00
|
|
|
ProjectExplorer::Kit *k = t ? t->kit() : ProjectExplorer::KitManager::instance()->defaultKit();
|
|
|
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
if (t) {
|
|
|
|
if (Qt4BuildConfiguration *bc = qobject_cast<Qt4BuildConfiguration *>(t->activeBuildConfiguration()))
|
2011-10-28 10:15:04 +00:00
|
|
|
preferDebugDump = bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild;
|
|
|
|
} else {
|
2012-02-07 13:45:21 +01:00
|
|
|
if (qtVersion)
|
|
|
|
preferDebugDump = qtVersion->defaultBuildConfig() & QtSupport::BaseQtVersion::DebugBuild;
|
2011-10-28 10:15:04 +00:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
if (qtVersion && qtVersion->isValid()) {
|
|
|
|
projectInfo.tryQmlDump = qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|
|
|
|
|| qtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT);
|
2012-12-07 09:25:48 +01:00
|
|
|
projectInfo.qtQmlPath = qtVersion->qmakeProperty("QT_INSTALL_QML");
|
|
|
|
if (!projectInfo.qtQmlPath.isEmpty())
|
|
|
|
projectInfo.importPaths += projectInfo.qtQmlPath;
|
2012-07-06 13:29:45 +02:00
|
|
|
projectInfo.qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!projectInfo.qtImportsPath.isEmpty())
|
|
|
|
projectInfo.importPaths += projectInfo.qtImportsPath;
|
|
|
|
projectInfo.qtVersionString = qtVersion->qtVersionString();
|
2010-10-13 13:05:36 +02:00
|
|
|
}
|
2010-09-21 14:28:55 +02:00
|
|
|
projectInfo.importPaths.removeDuplicates();
|
|
|
|
|
2011-09-21 15:54:07 +02:00
|
|
|
if (projectInfo.tryQmlDump) {
|
2012-04-24 15:49:09 +02:00
|
|
|
QtSupport::QmlDumpTool::pathAndEnvironment(this, qtVersion,
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChainKitInformation::toolChain(k),
|
2012-04-24 15:49:09 +02:00
|
|
|
preferDebugDump, &projectInfo.qmlDumpPath,
|
|
|
|
&projectInfo.qmlDumpEnvironment);
|
2011-09-21 15:54:07 +02:00
|
|
|
} else {
|
|
|
|
projectInfo.qmlDumpPath.clear();
|
|
|
|
projectInfo.qmlDumpEnvironment.clear();
|
|
|
|
}
|
|
|
|
|
2010-09-27 11:16:43 +01:00
|
|
|
modelManager->updateProjectInfo(projectInfo);
|
2010-09-21 14:28:55 +02:00
|
|
|
}
|
|
|
|
|
2008-12-09 17:17:12 +01:00
|
|
|
///*!
|
|
|
|
// Updates complete project
|
|
|
|
// */
|
2008-12-02 12:01:29 +01:00
|
|
|
void Qt4Project::update()
|
|
|
|
{
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"Doing sync update";
|
2008-12-02 12:01:29 +01:00
|
|
|
m_rootProjectNode->update();
|
2010-10-27 16:27:22 +02:00
|
|
|
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"State is now Base";
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateState = Base;
|
2012-04-24 15:49:09 +02:00
|
|
|
enableActiveQt4BuildConfiguration(activeTarget(), true);
|
2012-08-20 12:41:52 +02:00
|
|
|
updateBuildSystemData();
|
2012-07-17 15:56:43 +02:00
|
|
|
updateRunConfigurations();
|
|
|
|
emit proFilesEvaluated();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::updateRunConfigurations()
|
|
|
|
{
|
|
|
|
foreach (Target *t, targets())
|
|
|
|
t->updateDefaultRunConfigurations();
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::scheduleAsyncUpdate(Qt4ProFileNode *node)
|
|
|
|
{
|
2010-10-25 17:26:41 +02:00
|
|
|
if (m_asyncUpdateState == ShuttingDown)
|
|
|
|
return;
|
2010-10-27 16:27:22 +02:00
|
|
|
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
2011-09-12 12:40:53 +02:00
|
|
|
qDebug()<<"schduleAsyncUpdate (node)"<<node->path();
|
2010-03-10 16:55:37 +01:00
|
|
|
Q_ASSERT(m_asyncUpdateState != NoState);
|
|
|
|
|
|
|
|
if (m_cancelEvaluate) {
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" Already canceling, nothing to do";
|
2010-03-10 16:55:37 +01:00
|
|
|
// A cancel is in progress
|
|
|
|
// That implies that a full update is going to happen afterwards
|
|
|
|
// So we don't need to do anything
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
enableActiveQt4BuildConfiguration(activeTarget(), false);
|
2011-01-19 15:46:01 +01:00
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
if (m_asyncUpdateState == AsyncFullUpdatePending) {
|
|
|
|
// Just postpone
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" full update pending, restarting timer";
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateTimer.start();
|
|
|
|
} else if (m_asyncUpdateState == AsyncPartialUpdatePending
|
|
|
|
|| m_asyncUpdateState == Base) {
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" adding node to async update list, setting state to AsyncPartialUpdatePending";
|
2010-03-10 16:55:37 +01:00
|
|
|
// Add the node
|
|
|
|
m_asyncUpdateState = AsyncPartialUpdatePending;
|
|
|
|
|
2011-05-25 11:23:25 +02:00
|
|
|
QList<Qt4ProFileNode *>::iterator it;
|
2010-03-10 16:55:37 +01:00
|
|
|
bool add = true;
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"scheduleAsyncUpdate();"<<m_partialEvaluate.size()<<"nodes";
|
2010-03-10 16:55:37 +01:00
|
|
|
it = m_partialEvaluate.begin();
|
|
|
|
while (it != m_partialEvaluate.end()) {
|
|
|
|
if (*it == node) {
|
|
|
|
add = false;
|
|
|
|
break;
|
|
|
|
} else if (node->isParent(*it)) { // We already have the parent in the list, nothing to do
|
2011-09-12 12:40:53 +02:00
|
|
|
it = m_partialEvaluate.erase(it);
|
|
|
|
} else if ((*it)->isParent(node)) { // The node is the parent of a child already in the list
|
2010-03-10 16:55:37 +01:00
|
|
|
add = false;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (add)
|
|
|
|
m_partialEvaluate.append(node);
|
|
|
|
// and start the timer anew
|
|
|
|
m_asyncUpdateTimer.start();
|
2012-09-04 11:02:11 +02:00
|
|
|
|
|
|
|
// Cancel running code model update
|
|
|
|
m_codeModelFuture.cancel();
|
2010-03-10 16:55:37 +01:00
|
|
|
} else if (m_asyncUpdateState == AsyncUpdateInProgress) {
|
|
|
|
// A update is in progress
|
|
|
|
// And this slot only gets called if a file changed on disc
|
|
|
|
// So we'll play it safe and schedule a complete evaluate
|
|
|
|
// This might trigger if due to version control a few files
|
|
|
|
// change a partial update gets in progress and then another
|
|
|
|
// batch of changes come in, which triggers a full update
|
|
|
|
// even if that's not really needed
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" Async update in progress, scheduling new one afterwards";
|
2010-03-10 16:55:37 +01:00
|
|
|
scheduleAsyncUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::scheduleAsyncUpdate()
|
|
|
|
{
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"scheduleAsyncUpdate";
|
2010-10-25 17:26:41 +02:00
|
|
|
if (m_asyncUpdateState == ShuttingDown)
|
|
|
|
return;
|
2010-10-27 16:27:22 +02:00
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
Q_ASSERT(m_asyncUpdateState != NoState);
|
|
|
|
if (m_cancelEvaluate) { // we are in progress of canceling
|
|
|
|
// and will start the evaluation after that
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" canceling is in progress, doing nothing";
|
2010-03-10 16:55:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (m_asyncUpdateState == AsyncUpdateInProgress) {
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" update in progress, canceling and setting state to full update pending";
|
2010-03-10 16:55:37 +01:00
|
|
|
m_cancelEvaluate = true;
|
|
|
|
m_asyncUpdateState = AsyncFullUpdatePending;
|
2012-04-24 15:49:09 +02:00
|
|
|
enableActiveQt4BuildConfiguration(activeTarget(), false);
|
2011-09-12 12:40:53 +02:00
|
|
|
m_rootProjectNode->setParseInProgressRecursive(true);
|
2010-03-10 16:55:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" starting timer for full update, setting state to full update pending";
|
2010-03-10 16:55:37 +01:00
|
|
|
m_partialEvaluate.clear();
|
2012-04-24 15:49:09 +02:00
|
|
|
enableActiveQt4BuildConfiguration(activeTarget(), false);
|
2011-09-12 12:40:53 +02:00
|
|
|
m_rootProjectNode->setParseInProgressRecursive(true);
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateState = AsyncFullUpdatePending;
|
|
|
|
m_asyncUpdateTimer.start();
|
2010-04-22 18:57:43 +02:00
|
|
|
|
|
|
|
// Cancel running code model update
|
|
|
|
m_codeModelFuture.cancel();
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Qt4Project::incrementPendingEvaluateFutures()
|
|
|
|
{
|
|
|
|
++m_pendingEvaluateFuturesCount;
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"incrementPendingEvaluateFutures to"<<m_pendingEvaluateFuturesCount;
|
2010-03-10 16:55:37 +01:00
|
|
|
|
|
|
|
m_asyncUpdateFutureInterface->setProgressRange(m_asyncUpdateFutureInterface->progressMinimum(),
|
|
|
|
m_asyncUpdateFutureInterface->progressMaximum() + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::decrementPendingEvaluateFutures()
|
|
|
|
{
|
|
|
|
--m_pendingEvaluateFuturesCount;
|
|
|
|
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"decrementPendingEvaluateFutures to"<<m_pendingEvaluateFuturesCount;
|
2010-03-10 16:55:37 +01:00
|
|
|
|
|
|
|
m_asyncUpdateFutureInterface->setProgressValue(m_asyncUpdateFutureInterface->progressValue() + 1);
|
|
|
|
if (m_pendingEvaluateFuturesCount == 0) {
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" WOHOO, no pending futures, cleaning up";
|
2010-03-10 16:55:37 +01:00
|
|
|
// We are done!
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" reporting finished";
|
2012-10-08 14:33:33 +02:00
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateFutureInterface->reportFinished();
|
|
|
|
delete m_asyncUpdateFutureInterface;
|
|
|
|
m_asyncUpdateFutureInterface = 0;
|
|
|
|
m_cancelEvaluate = false;
|
|
|
|
|
|
|
|
// TODO clear the profile cache ?
|
|
|
|
if (m_asyncUpdateState == AsyncFullUpdatePending || m_asyncUpdateState == AsyncPartialUpdatePending) {
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" Oh update is pending start the timer";
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateTimer.start();
|
2010-03-11 17:01:06 +01:00
|
|
|
} else if (m_asyncUpdateState != ShuttingDown){
|
2010-10-30 21:54:23 +02:00
|
|
|
// After being done, we need to call:
|
2011-09-12 13:25:12 +02:00
|
|
|
m_asyncUpdateState = Base;
|
2012-04-24 15:49:09 +02:00
|
|
|
enableActiveQt4BuildConfiguration(activeTarget(), true);
|
2010-03-11 17:01:06 +01:00
|
|
|
updateFileList();
|
2011-09-15 12:15:10 +02:00
|
|
|
updateCodeModels();
|
2012-08-20 12:41:52 +02:00
|
|
|
updateBuildSystemData();
|
2012-07-17 15:56:43 +02:00
|
|
|
updateRunConfigurations();
|
|
|
|
emit proFilesEvaluated();
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" Setting state to Base";
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Qt4Project::wasEvaluateCanceled()
|
|
|
|
{
|
|
|
|
return m_cancelEvaluate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::asyncUpdate()
|
|
|
|
{
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<"async update, timer expired, doing now";
|
2010-03-10 16:55:37 +01:00
|
|
|
Q_ASSERT(!m_asyncUpdateFutureInterface);
|
|
|
|
m_asyncUpdateFutureInterface = new QFutureInterface<void>();
|
|
|
|
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ProgressManager *progressManager = Core::ICore::progressManager();
|
2010-03-10 16:55:37 +01:00
|
|
|
|
2010-04-13 16:32:01 +02:00
|
|
|
m_asyncUpdateFutureInterface->setProgressRange(0, 0);
|
2012-01-13 14:20:45 +01:00
|
|
|
progressManager->addTask(m_asyncUpdateFutureInterface->future(), tr("Evaluating"),
|
|
|
|
QLatin1String(Constants::PROFILE_EVALUATE));
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" adding task";
|
2010-03-10 16:55:37 +01:00
|
|
|
|
|
|
|
m_asyncUpdateFutureInterface->reportStarted();
|
|
|
|
|
|
|
|
if (m_asyncUpdateState == AsyncFullUpdatePending) {
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" full update, starting with root node";
|
2010-03-10 16:55:37 +01:00
|
|
|
m_rootProjectNode->asyncUpdate();
|
|
|
|
} else {
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" partial update,"<<m_partialEvaluate.size()<<"nodes to update";
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (Qt4ProFileNode *node, m_partialEvaluate)
|
2010-03-10 16:55:37 +01:00
|
|
|
node->asyncUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_partialEvaluate.clear();
|
2010-03-12 15:12:46 +01:00
|
|
|
if (debug)
|
|
|
|
qDebug()<<" Setting state to AsyncUpdateInProgress";
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateState = AsyncUpdateInProgress;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExplorer::IProjectManager *Qt4Project::projectManager() const
|
|
|
|
{
|
|
|
|
return m_manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt4Manager *Qt4Project::qt4ProjectManager() const
|
|
|
|
{
|
|
|
|
return m_manager;
|
|
|
|
}
|
|
|
|
|
2012-09-20 11:16:47 +02:00
|
|
|
bool Qt4Project::supportsKit(Kit *k, QString *errorMessage) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
2012-09-20 11:16:47 +02:00
|
|
|
if (!version && errorMessage)
|
|
|
|
*errorMessage = tr("No Qt version set in kit.");
|
2012-04-24 15:49:09 +02:00
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString Qt4Project::displayName() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-02-14 16:43:51 +01:00
|
|
|
return QFileInfo(document()->fileName()).completeBaseName();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
Core::Id Qt4Project::id() const
|
2010-01-22 15:59:44 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
return Core::Id(Constants::QT4PROJECT_ID);
|
2010-01-22 15:59:44 +01:00
|
|
|
}
|
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
Core::IDocument *Qt4Project::document() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
return m_fileInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList Qt4Project::files(FilesMode fileMode) const
|
|
|
|
{
|
|
|
|
QStringList files;
|
|
|
|
for (int i = 0; i < FileTypeSize; ++i) {
|
|
|
|
files += m_projectFiles->files[i];
|
|
|
|
if (fileMode == AllFiles)
|
|
|
|
files += m_projectFiles->generatedFiles[i];
|
|
|
|
}
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2009-12-03 16:23:15 +01:00
|
|
|
// Find the folder that contains a file a certain type (recurse down)
|
|
|
|
static FolderNode *folderOf(FolderNode *in, FileType fileType, const QString &fileName)
|
|
|
|
{
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (FileNode *fn, in->fileNodes())
|
2009-12-03 16:23:15 +01:00
|
|
|
if (fn->fileType() == fileType && fn->path() == fileName)
|
|
|
|
return in;
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (FolderNode *folder, in->subFolderNodes())
|
2009-12-03 16:23:15 +01:00
|
|
|
if (FolderNode *pn = folderOf(folder, fileType, fileName))
|
|
|
|
return pn;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the Qt4ProFileNode that contains a file of a certain type.
|
|
|
|
// First recurse down to folder, then find the pro-file.
|
|
|
|
static Qt4ProFileNode *proFileNodeOf(Qt4ProFileNode *in, FileType fileType, const QString &fileName)
|
|
|
|
{
|
|
|
|
for (FolderNode *folder = folderOf(in, fileType, fileName); folder; folder = folder->parentFolderNode())
|
|
|
|
if (Qt4ProFileNode *proFile = qobject_cast<Qt4ProFileNode *>(folder))
|
|
|
|
return proFile;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Qt4Project::generatedUiHeader(const QString &formFile) const
|
|
|
|
{
|
|
|
|
// Look in sub-profiles as SessionManager::projectForFile returns
|
|
|
|
// the top-level project only.
|
|
|
|
if (m_rootProjectNode)
|
|
|
|
if (const Qt4ProFileNode *pro = proFileNodeOf(m_rootProjectNode, FormType, formFile))
|
|
|
|
return Qt4ProFileNode::uiHeaderFile(pro->uiDirectory(), formFile);
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Qt4Project::proFileParseError(const QString &errorMessage)
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ICore::messageManager()->printToOutputPanePopup(errorMessage);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2012-10-23 17:40:10 +02:00
|
|
|
QtSupport::ProFileReader *Qt4Project::createProFileReader(const Qt4ProFileNode *qt4ProFileNode, Qt4BuildConfiguration *bc)
|
2009-12-07 20:49:39 +01:00
|
|
|
{
|
2012-05-02 15:20:08 +02:00
|
|
|
if (!m_qmakeGlobals) {
|
2012-08-28 18:18:07 +02:00
|
|
|
m_qmakeGlobals = new ProFileGlobals;
|
2012-05-02 15:20:08 +02:00
|
|
|
m_qmakeGlobalsRefCnt = 0;
|
2009-12-07 20:49:39 +01:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
Kit *k;
|
2011-10-28 10:15:04 +00:00
|
|
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
|
|
|
QStringList qmakeArgs;
|
2012-06-24 20:30:02 +03:00
|
|
|
if (!bc)
|
2012-07-04 15:44:26 +02:00
|
|
|
bc = activeTarget() ? static_cast<Qt4BuildConfiguration *>(activeTarget()->activeBuildConfiguration()) : 0;
|
2012-06-24 20:30:02 +03:00
|
|
|
|
|
|
|
if (bc) {
|
2012-09-03 18:31:44 +02:00
|
|
|
k = bc->target()->kit();
|
2012-06-24 20:30:02 +03:00
|
|
|
env = bc->environment();
|
2012-08-15 18:17:26 +02:00
|
|
|
if (bc->qmakeStep())
|
2012-06-24 20:30:02 +03:00
|
|
|
qmakeArgs = bc->qmakeStep()->parserArguments();
|
2012-08-15 18:17:26 +02:00
|
|
|
else
|
2011-10-28 10:15:04 +00:00
|
|
|
qmakeArgs = bc->configCommandLineArguments();
|
|
|
|
} else {
|
2012-09-03 18:31:44 +02:00
|
|
|
k = KitManager::instance()->defaultKit();
|
2009-12-07 20:49:39 +01:00
|
|
|
}
|
2009-12-07 22:58:47 +01:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
QString systemRoot = SysRootKitInformation::hasSysRoot(k)
|
|
|
|
? SysRootKitInformation::sysRoot(k).toString() : QString();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-06-18 18:16:50 +02:00
|
|
|
if (qtVersion && qtVersion->isValid()) {
|
|
|
|
m_qmakeGlobals->qmake_abslocation = QDir::cleanPath(qtVersion->qmakeCommand().toString());
|
2012-06-18 17:42:20 +02:00
|
|
|
m_qmakeGlobals->setProperties(qtVersion->versionInfo());
|
2012-06-18 18:16:50 +02:00
|
|
|
}
|
2012-07-25 19:10:07 +02:00
|
|
|
m_qmakeGlobals->setDirectories(m_rootProjectNode->sourceDir(), m_rootProjectNode->buildDir());
|
2012-05-02 15:20:08 +02:00
|
|
|
m_qmakeGlobals->sysroot = systemRoot;
|
2011-10-28 10:15:04 +00:00
|
|
|
|
|
|
|
Utils::Environment::const_iterator eit = env.constBegin(), eend = env.constEnd();
|
|
|
|
for (; eit != eend; ++eit)
|
2012-05-02 15:20:08 +02:00
|
|
|
m_qmakeGlobals->environment.insert(env.key(eit), env.value(eit));
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2012-08-15 18:11:54 +02:00
|
|
|
m_qmakeGlobals->setCommandLineArguments(m_rootProjectNode->buildDir(), qmakeArgs);
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2011-05-20 21:40:53 +02:00
|
|
|
QtSupport::ProFileCacheManager::instance()->incRefCount();
|
2009-12-07 20:49:39 +01:00
|
|
|
}
|
2012-05-02 15:20:08 +02:00
|
|
|
++m_qmakeGlobalsRefCnt;
|
2009-12-07 20:49:39 +01:00
|
|
|
|
2012-05-02 15:20:08 +02:00
|
|
|
QtSupport::ProFileReader *reader = new QtSupport::ProFileReader(m_qmakeGlobals);
|
2009-12-07 20:49:39 +01:00
|
|
|
|
|
|
|
reader->setOutputDir(qt4ProFileNode->buildDir());
|
|
|
|
|
|
|
|
return reader;
|
|
|
|
}
|
|
|
|
|
2012-08-28 18:18:07 +02:00
|
|
|
ProFileGlobals *Qt4Project::qmakeGlobals()
|
2011-10-07 15:40:38 +02:00
|
|
|
{
|
2012-05-02 15:20:08 +02:00
|
|
|
return m_qmakeGlobals;
|
2011-10-07 15:40:38 +02:00
|
|
|
}
|
|
|
|
|
2011-05-20 21:40:53 +02:00
|
|
|
void Qt4Project::destroyProFileReader(QtSupport::ProFileReader *reader)
|
2009-12-07 20:49:39 +01:00
|
|
|
{
|
|
|
|
delete reader;
|
2012-05-02 15:20:08 +02:00
|
|
|
if (!--m_qmakeGlobalsRefCnt) {
|
2009-12-07 22:58:47 +01:00
|
|
|
QString dir = QFileInfo(m_fileInfo->fileName()).absolutePath();
|
|
|
|
if (!dir.endsWith(QLatin1Char('/')))
|
|
|
|
dir += QLatin1Char('/');
|
2011-05-20 21:40:53 +02:00
|
|
|
QtSupport::ProFileCacheManager::instance()->discardFiles(dir);
|
|
|
|
QtSupport::ProFileCacheManager::instance()->decRefCount();
|
2009-12-07 22:58:47 +01:00
|
|
|
|
2012-05-02 15:20:08 +02:00
|
|
|
delete m_qmakeGlobals;
|
|
|
|
m_qmakeGlobals = 0;
|
2009-12-07 20:49:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-18 16:46:44 +02:00
|
|
|
ProjectExplorer::ProjectNode *Qt4Project::rootProjectNode() const
|
|
|
|
{
|
|
|
|
return m_rootProjectNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt4ProFileNode *Qt4Project::rootQt4ProjectNode() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
return m_rootProjectNode;
|
|
|
|
}
|
|
|
|
|
2010-10-27 16:27:22 +02:00
|
|
|
bool Qt4Project::validParse(const QString &proFilePath) const
|
|
|
|
{
|
2010-10-29 12:15:30 +02:00
|
|
|
if (!m_rootProjectNode)
|
|
|
|
return false;
|
2010-10-27 16:27:22 +02:00
|
|
|
const Qt4ProFileNode *node = m_rootProjectNode->findProFileFor(proFilePath);
|
|
|
|
return node && node->validParse();
|
|
|
|
}
|
|
|
|
|
2011-06-10 15:37:10 +02:00
|
|
|
bool Qt4Project::parseInProgress(const QString &proFilePath) const
|
|
|
|
{
|
|
|
|
if (!m_rootProjectNode)
|
|
|
|
return false;
|
|
|
|
const Qt4ProFileNode *node = m_rootProjectNode->findProFileFor(proFilePath);
|
|
|
|
return node && node->parseInProgress();
|
|
|
|
}
|
|
|
|
|
2011-01-24 15:36:46 +01:00
|
|
|
void Qt4Project::collectAllfProFiles(QList<Qt4ProFileNode *> &list, Qt4ProFileNode *node)
|
2010-07-23 16:37:10 +02:00
|
|
|
{
|
2011-01-24 15:36:46 +01:00
|
|
|
list.append(node);
|
2010-07-23 16:37:10 +02:00
|
|
|
foreach (ProjectNode *n, node->subProjectNodes()) {
|
|
|
|
Qt4ProFileNode *qt4ProFileNode = qobject_cast<Qt4ProFileNode *>(n);
|
|
|
|
if (qt4ProFileNode)
|
2011-01-24 15:36:46 +01:00
|
|
|
collectAllfProFiles(list, qt4ProFileNode);
|
2010-07-23 16:37:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void Qt4Project::collectApplicationProFiles(QList<Qt4ProFileNode *> &list, Qt4ProFileNode *node)
|
|
|
|
{
|
2011-05-25 11:23:25 +02:00
|
|
|
if (node->projectType() == ApplicationTemplate
|
|
|
|
|| node->projectType() == ScriptTemplate) {
|
2008-12-02 12:01:29 +01:00
|
|
|
list.append(node);
|
|
|
|
}
|
|
|
|
foreach (ProjectNode *n, node->subProjectNodes()) {
|
|
|
|
Qt4ProFileNode *qt4ProFileNode = qobject_cast<Qt4ProFileNode *>(n);
|
|
|
|
if (qt4ProFileNode)
|
|
|
|
collectApplicationProFiles(list, qt4ProFileNode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-24 15:36:46 +01:00
|
|
|
QList<Qt4ProFileNode *> Qt4Project::allProFiles() const
|
2010-07-23 16:37:10 +02:00
|
|
|
{
|
|
|
|
QList<Qt4ProFileNode *> list;
|
|
|
|
if (!rootProjectNode())
|
|
|
|
return list;
|
2011-08-18 16:46:44 +02:00
|
|
|
collectAllfProFiles(list, rootQt4ProjectNode());
|
2010-07-23 16:37:10 +02:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<Qt4ProFileNode *> Qt4Project::applicationProFiles() const
|
|
|
|
{
|
|
|
|
QList<Qt4ProFileNode *> list;
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!rootProjectNode())
|
|
|
|
return list;
|
2011-08-18 16:46:44 +02:00
|
|
|
collectApplicationProFiles(list, rootQt4ProjectNode());
|
2008-12-02 12:01:29 +01:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
bool Qt4Project::hasApplicationProFile(const QString &path) const
|
|
|
|
{
|
|
|
|
if (path.isEmpty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QList<Qt4ProFileNode *> list = applicationProFiles();
|
|
|
|
foreach (Qt4ProFileNode * node, list)
|
|
|
|
if (node->path() == path)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList Qt4Project::applicationProFilePathes(const QString &prepend) const
|
|
|
|
{
|
|
|
|
QStringList proFiles;
|
|
|
|
foreach (Qt4ProFileNode *node, applicationProFiles())
|
|
|
|
proFiles.append(prepend + node->path());
|
|
|
|
return proFiles;
|
|
|
|
}
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void Qt4Project::activeTargetWasChanged()
|
|
|
|
{
|
2012-08-27 15:11:28 +02:00
|
|
|
if (m_activeTarget) {
|
|
|
|
disconnect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
this, SLOT(scheduleAsyncUpdate()));
|
|
|
|
}
|
2012-07-17 15:56:43 +02:00
|
|
|
|
|
|
|
m_activeTarget = activeTarget();
|
|
|
|
|
|
|
|
if (!m_activeTarget)
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
2012-07-17 15:56:43 +02:00
|
|
|
connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
this, SLOT(scheduleAsyncUpdate()));
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
scheduleAsyncUpdate();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
2008-12-05 14:29:18 +01:00
|
|
|
bool Qt4Project::hasSubNode(Qt4PriFileNode *root, const QString &path)
|
2008-12-02 18:14:06 +01:00
|
|
|
{
|
2008-12-05 14:29:18 +01:00
|
|
|
if (root->path() == path)
|
|
|
|
return true;
|
|
|
|
foreach (FolderNode *fn, root->subFolderNodes()) {
|
|
|
|
if (qobject_cast<Qt4ProFileNode *>(fn)) {
|
|
|
|
// we aren't interested in pro file nodes
|
2008-12-09 11:07:24 +01:00
|
|
|
} else if (Qt4PriFileNode *qt4prifilenode = qobject_cast<Qt4PriFileNode *>(fn)) {
|
2008-12-05 14:29:18 +01:00
|
|
|
if (hasSubNode(qt4prifilenode, path))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2008-12-02 18:14:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::findProFile(const QString& fileName, Qt4ProFileNode *root, QList<Qt4ProFileNode *> &list)
|
|
|
|
{
|
2008-12-05 14:29:18 +01:00
|
|
|
if (hasSubNode(root, fileName))
|
2008-12-02 18:14:06 +01:00
|
|
|
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)
|
|
|
|
{
|
2008-12-05 14:29:18 +01:00
|
|
|
if (files(Qt4Project::ExcludeGeneratedFiles).contains(name)) {
|
|
|
|
QList<Qt4ProFileNode *> list;
|
2011-08-18 16:46:44 +02:00
|
|
|
findProFile(name, rootQt4ProjectNode(), list);
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (Qt4ProFileNode *node, list) {
|
2011-05-20 21:40:53 +02:00
|
|
|
QtSupport::ProFileCacheManager::instance()->discardFile(name);
|
2008-12-05 14:29:18 +01:00
|
|
|
node->update();
|
2009-12-07 22:58:47 +01:00
|
|
|
}
|
2011-05-25 12:54:14 +02:00
|
|
|
updateFileList();
|
2008-12-05 14:29:18 +01:00
|
|
|
}
|
2008-12-02 18:14:06 +01:00
|
|
|
}
|
2009-03-19 15:04:43 +01:00
|
|
|
|
2011-08-18 16:46:44 +02:00
|
|
|
void Qt4Project::watchFolders(const QStringList &l, Qt4PriFileNode *node)
|
|
|
|
{
|
|
|
|
if (l.isEmpty())
|
|
|
|
return;
|
|
|
|
if (!m_centralizedFolderWatcher)
|
|
|
|
m_centralizedFolderWatcher = new Internal::CentralizedFolderWatcher(this);
|
|
|
|
m_centralizedFolderWatcher->watchFolders(l, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::unwatchFolders(const QStringList &l, Qt4PriFileNode *node)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
2011-08-18 16:46:44 +02:00
|
|
|
if (m_centralizedFolderWatcher && !l.isEmpty())
|
|
|
|
m_centralizedFolderWatcher->unwatchFolders(l, node);
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
/// Centralized Folder Watcher
|
|
|
|
////////////
|
|
|
|
|
|
|
|
// All the folder have a trailing slash!
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
bool debugCFW = false;
|
|
|
|
}
|
|
|
|
|
2011-08-18 16:46:44 +02:00
|
|
|
CentralizedFolderWatcher::CentralizedFolderWatcher(QObject *parent) : QObject(parent)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
2010-10-13 15:33:51 +02:00
|
|
|
m_compressTimer.setSingleShot(true);
|
|
|
|
m_compressTimer.setInterval(200);
|
|
|
|
connect(&m_compressTimer, SIGNAL(timeout()),
|
|
|
|
this, SLOT(onTimer()));
|
2010-08-10 16:27:35 +02:00
|
|
|
connect (&m_watcher, SIGNAL(directoryChanged(QString)),
|
|
|
|
this, SLOT(folderChanged(QString)));
|
|
|
|
}
|
|
|
|
|
|
|
|
CentralizedFolderWatcher::~CentralizedFolderWatcher()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QSet<QString> CentralizedFolderWatcher::recursiveDirs(const QString &folder)
|
|
|
|
{
|
|
|
|
QSet<QString> result;
|
|
|
|
QDir dir(folder);
|
|
|
|
QStringList list = dir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
|
|
|
foreach (const QString &f, list) {
|
2012-01-13 14:20:45 +01:00
|
|
|
const QString a = folder + f + QLatin1Char('/');
|
2011-02-25 15:27:13 +01:00
|
|
|
result.insert(a);
|
|
|
|
result += recursiveDirs(a);
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-11-22 13:10:10 +01:00
|
|
|
void CentralizedFolderWatcher::watchFolders(const QList<QString> &folders, Qt4ProjectManager::Qt4PriFileNode *node)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
|
|
|
if (debugCFW)
|
|
|
|
qDebug()<<"CFW::watchFolders()"<<folders<<"for node"<<node->path();
|
|
|
|
m_watcher.addPaths(folders);
|
|
|
|
|
2012-01-13 14:20:45 +01:00
|
|
|
const QChar slash = QLatin1Char('/');
|
2010-08-10 16:27:35 +02:00
|
|
|
foreach (const QString &f, folders) {
|
|
|
|
QString folder = f;
|
2012-01-13 14:20:45 +01:00
|
|
|
if (!folder.endsWith(slash))
|
|
|
|
folder.append(slash);
|
2010-08-10 16:27:35 +02:00
|
|
|
m_map.insert(folder, node);
|
|
|
|
|
|
|
|
// Support for recursive watching
|
|
|
|
// we add the recursive directories we find
|
|
|
|
QSet<QString> tmp = recursiveDirs(folder);
|
2010-08-12 13:38:21 +02:00
|
|
|
if (!tmp.isEmpty())
|
|
|
|
m_watcher.addPaths(tmp.toList());
|
2010-08-10 16:27:35 +02:00
|
|
|
m_recursiveWatchedFolders += tmp;
|
|
|
|
|
|
|
|
if (debugCFW)
|
|
|
|
qDebug()<<"adding recursive dirs for"<< folder<<":"<<tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-22 13:10:10 +01:00
|
|
|
void CentralizedFolderWatcher::unwatchFolders(const QList<QString> &folders, Qt4ProjectManager::Qt4PriFileNode *node)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
|
|
|
if (debugCFW)
|
|
|
|
qDebug()<<"CFW::unwatchFolders()"<<folders<<"for node"<<node->path();
|
2012-01-13 14:20:45 +01:00
|
|
|
const QChar slash = QLatin1Char('/');
|
2010-08-10 16:27:35 +02:00
|
|
|
foreach (const QString &f, folders) {
|
|
|
|
QString folder = f;
|
2012-01-13 14:20:45 +01:00
|
|
|
if (!folder.endsWith(slash))
|
|
|
|
folder.append(slash);
|
2010-08-10 16:27:35 +02:00
|
|
|
m_map.remove(folder, node);
|
|
|
|
if (!m_map.contains(folder)) {
|
|
|
|
m_watcher.removePath(folder);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Figure out which recursive directories we can remove
|
2012-05-03 16:15:38 +02:00
|
|
|
// this might not scale. I'm pretty sure it doesn't
|
2010-08-10 16:27:35 +02:00
|
|
|
// A scaling implementation would need to save more information
|
|
|
|
// where a given directory watcher actual comes from...
|
|
|
|
|
|
|
|
QStringList toRemove;
|
|
|
|
foreach (const QString &rwf, m_recursiveWatchedFolders) {
|
|
|
|
if (rwf.startsWith(folder)) {
|
|
|
|
// So the rwf is a subdirectory of a folder we aren't watching
|
|
|
|
// but maybe someone else wants us to watch
|
|
|
|
bool needToWatch = false;
|
2011-11-22 13:10:10 +01:00
|
|
|
QMultiMap<QString, Qt4ProjectManager::Qt4PriFileNode *>::const_iterator it, end;
|
2010-08-10 16:27:35 +02:00
|
|
|
end = m_map.constEnd();
|
|
|
|
for (it = m_map.constEnd(); it != end; ++it) {
|
|
|
|
if (rwf.startsWith(it.key())) {
|
|
|
|
needToWatch = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!needToWatch) {
|
|
|
|
m_watcher.removePath(rwf);
|
|
|
|
toRemove << rwf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (debugCFW)
|
|
|
|
qDebug()<<"removing recursive dirs for"<<folder<<":"<<toRemove;
|
|
|
|
|
|
|
|
foreach (const QString &tr, toRemove) {
|
|
|
|
m_recursiveWatchedFolders.remove(tr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CentralizedFolderWatcher::folderChanged(const QString &folder)
|
2010-10-13 15:33:51 +02:00
|
|
|
{
|
|
|
|
m_changedFolders.insert(folder);
|
|
|
|
m_compressTimer.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CentralizedFolderWatcher::onTimer()
|
|
|
|
{
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (const QString &folder, m_changedFolders)
|
2010-10-13 15:33:51 +02:00
|
|
|
delayedFolderChanged(folder);
|
|
|
|
m_changedFolders.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CentralizedFolderWatcher::delayedFolderChanged(const QString &folder)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
|
|
|
if (debugCFW)
|
|
|
|
qDebug()<<"CFW::folderChanged"<<folder;
|
|
|
|
// Figure out whom to inform
|
|
|
|
|
2010-08-18 12:53:37 +02:00
|
|
|
QString dir = folder;
|
2012-01-13 14:20:45 +01:00
|
|
|
const QChar slash = QLatin1Char('/');
|
2010-08-10 16:27:35 +02:00
|
|
|
while (true) {
|
2012-01-13 14:20:45 +01:00
|
|
|
if (!dir.endsWith(slash))
|
|
|
|
dir.append(slash);
|
2011-11-22 13:10:10 +01:00
|
|
|
QList<Qt4ProjectManager::Qt4PriFileNode *> nodes = m_map.values(dir);
|
|
|
|
foreach (Qt4ProjectManager::Qt4PriFileNode *node, nodes) {
|
2010-08-10 16:27:35 +02:00
|
|
|
node->folderChanged(folder);
|
|
|
|
}
|
|
|
|
|
2010-08-18 12:53:37 +02:00
|
|
|
// Chop off last part, and break if there's nothing to chop off
|
|
|
|
//
|
|
|
|
if (dir.length() < 2)
|
2010-08-10 16:27:35 +02:00
|
|
|
break;
|
2010-08-18 12:53:37 +02:00
|
|
|
|
|
|
|
// We start before the last slash
|
2012-01-13 14:20:45 +01:00
|
|
|
const int index = dir.lastIndexOf(slash, dir.length() - 2);
|
2010-08-18 12:53:37 +02:00
|
|
|
if (index == -1)
|
|
|
|
break;
|
2012-01-13 14:20:45 +01:00
|
|
|
dir.truncate(index + 1);
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 12:53:37 +02:00
|
|
|
|
2010-08-16 13:01:36 +02:00
|
|
|
QString folderWithSlash = folder;
|
2012-01-13 14:20:45 +01:00
|
|
|
if (!folder.endsWith(slash))
|
|
|
|
folderWithSlash.append(slash);
|
2010-08-16 13:01:36 +02:00
|
|
|
|
2010-08-10 16:27:35 +02:00
|
|
|
// If a subdirectory was added, watch it too
|
2010-08-16 13:01:36 +02:00
|
|
|
QSet<QString> tmp = recursiveDirs(folderWithSlash);
|
2010-08-10 16:27:35 +02:00
|
|
|
if (!tmp.isEmpty()) {
|
|
|
|
if (debugCFW)
|
|
|
|
qDebug()<<"found new recursive dirs"<<tmp;
|
2010-10-13 14:44:32 +02:00
|
|
|
|
|
|
|
QSet<QString> alreadyAdded = m_watcher.directories().toSet();
|
|
|
|
tmp.subtract(alreadyAdded);
|
|
|
|
if (!tmp.isEmpty())
|
|
|
|
m_watcher.addPaths(tmp.toList());
|
2010-08-10 16:27:35 +02:00
|
|
|
m_recursiveWatchedFolders += tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-28 10:15:04 +00:00
|
|
|
bool Qt4Project::needsConfiguration() const
|
|
|
|
{
|
|
|
|
return targets().isEmpty();
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:14:42 +01:00
|
|
|
void Qt4Project::configureAsExampleProject(const QStringList &platforms)
|
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
QList<Kit *> kits = ProjectExplorer::KitManager::instance()->kits();
|
|
|
|
foreach (Kit *k, kits) {
|
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!version)
|
|
|
|
continue;
|
|
|
|
if (!platforms.isEmpty() && !platforms.contains(version->platformName()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
QList<BuildConfigurationInfo> infoList
|
2012-09-03 18:31:44 +02:00
|
|
|
= Qt4BuildConfigurationFactory::availableBuildConfigurations(k, document()->fileName());
|
2012-04-24 15:49:09 +02:00
|
|
|
if (infoList.isEmpty())
|
|
|
|
continue;
|
2012-09-03 18:31:44 +02:00
|
|
|
addTarget(createTarget(k, infoList));
|
2012-03-06 13:14:42 +01:00
|
|
|
}
|
|
|
|
ProjectExplorer::ProjectExplorerPlugin::instance()->requestProjectModeUpdate(this);
|
|
|
|
}
|
|
|
|
|
2012-09-06 16:19:14 +02:00
|
|
|
bool Qt4Project::supportsNoTargetPanel() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-09 12:44:37 +02:00
|
|
|
// All the Qt4 run configurations should share code.
|
|
|
|
// This is a rather suboptimal way to do that for disabledReason()
|
|
|
|
// but more pratical then duplicated the code everywhere
|
|
|
|
QString Qt4Project::disabledReasonForRunConfiguration(const QString &proFilePath)
|
|
|
|
{
|
|
|
|
if (!QFileInfo(proFilePath).exists())
|
|
|
|
return tr("The .pro file '%1' does not exist.")
|
|
|
|
.arg(QFileInfo(proFilePath).fileName());
|
|
|
|
|
2012-06-28 13:10:33 +02:00
|
|
|
if (!m_rootProjectNode) // Shutting down
|
|
|
|
return QString();
|
|
|
|
|
2012-05-09 12:44:37 +02:00
|
|
|
if (!m_rootProjectNode->findProFileFor(proFilePath))
|
|
|
|
return tr("The .pro file '%1' is not part of the project.")
|
|
|
|
.arg(QFileInfo(proFilePath).fileName());
|
|
|
|
|
|
|
|
return tr("The .pro file '%1' could not be parsed.")
|
|
|
|
.arg(QFileInfo(proFilePath).fileName());
|
|
|
|
}
|
|
|
|
|
2012-11-16 19:11:36 +01:00
|
|
|
QString Qt4Project::shadowBuildDirectory(const QString &proFilePath, const Kit *k, const QString &suffix)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-11-16 19:11:36 +01:00
|
|
|
if (proFilePath.isEmpty())
|
2012-04-24 15:49:09 +02:00
|
|
|
return QString();
|
2012-11-16 19:11:36 +01:00
|
|
|
QFileInfo info(proFilePath);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
2012-04-24 15:49:09 +02:00
|
|
|
if (version && !version->supportsShadowBuilds())
|
|
|
|
return info.absolutePath();
|
|
|
|
|
2012-11-16 19:11:36 +01:00
|
|
|
Qt4ProjectExpander expander(proFilePath, k, suffix);
|
|
|
|
QDir projectDir = QDir(projectDirectory(proFilePath));
|
|
|
|
QString buildPath = Utils::expandMacros(Core::DocumentManager::buildDirectory(), &expander);
|
|
|
|
return QDir::cleanPath(projectDir.absoluteFilePath(buildPath));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
QString Qt4Project::buildNameFor(const Kit *k)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
if (!k)
|
2012-04-24 15:49:09 +02:00
|
|
|
return QLatin1String("unknown");
|
2012-10-04 14:40:29 +02:00
|
|
|
|
|
|
|
return k->fileSystemFriendlyName();
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
Target *Qt4Project::createTarget(Kit *k, const QList<BuildConfigurationInfo> &infoList)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-09 20:41:30 +03:00
|
|
|
if (target(k))
|
2012-04-24 15:49:09 +02:00
|
|
|
return 0;
|
|
|
|
|
2012-09-09 20:41:30 +03:00
|
|
|
Target *t = new Target(this, k);
|
2012-10-17 12:54:43 +02:00
|
|
|
setupTarget(t, infoList);
|
2012-04-24 15:49:09 +02:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2012-08-20 12:41:52 +02:00
|
|
|
void Qt4Project::updateBuildSystemData()
|
|
|
|
{
|
|
|
|
Target * const target = activeTarget();
|
|
|
|
if (!target)
|
|
|
|
return;
|
|
|
|
const Qt4ProFileNode * const rootNode = rootQt4ProjectNode();
|
|
|
|
if (!rootNode || rootNode->parseInProgress())
|
|
|
|
return;
|
|
|
|
|
|
|
|
DeploymentData deploymentData;
|
|
|
|
collectData(rootNode, deploymentData);
|
|
|
|
target->setDeploymentData(deploymentData);
|
|
|
|
|
|
|
|
BuildTargetInfoList appTargetList;
|
|
|
|
foreach (const Qt4ProFileNode * const node, applicationProFiles())
|
|
|
|
appTargetList.list << BuildTargetInfo(node->targetInformation().executable, node->path());
|
|
|
|
target->setApplicationTargets(appTargetList);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::collectData(const Qt4ProFileNode *node, DeploymentData &deploymentData)
|
|
|
|
{
|
|
|
|
if (!node->isSubProjectDeployable(node->path()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
const InstallsList &installsList = node->installsList();
|
|
|
|
foreach (const InstallsItem &item, installsList.items) {
|
|
|
|
foreach (const QString &localFile, item.files)
|
|
|
|
deploymentData.addFile(localFile, item.path);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (node->projectType()) {
|
|
|
|
case ApplicationTemplate:
|
|
|
|
if (!installsList.targetPath.isEmpty())
|
2012-10-08 15:46:38 +02:00
|
|
|
deploymentData.addFile(node->targetInformation().executable, installsList.targetPath,
|
|
|
|
DeployableFile::TypeExecutable);
|
2012-08-20 12:41:52 +02:00
|
|
|
break;
|
|
|
|
case LibraryTemplate:
|
|
|
|
collectLibraryData(node, deploymentData);
|
|
|
|
break;
|
|
|
|
case SubDirsTemplate:
|
|
|
|
foreach (const ProjectNode * const subProject, node->subProjectNodesExact()) {
|
|
|
|
const Qt4ProFileNode * const qt4SubProject
|
|
|
|
= qobject_cast<const Qt4ProFileNode *>(subProject);
|
|
|
|
if (!qt4SubProject)
|
|
|
|
continue;
|
|
|
|
collectData(qt4SubProject, deploymentData);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Qt4Project::collectLibraryData(const Qt4ProFileNode *node, DeploymentData &deploymentData)
|
|
|
|
{
|
|
|
|
const QString targetPath = node->installsList().targetPath;
|
|
|
|
if (targetPath.isEmpty())
|
|
|
|
return;
|
2012-09-03 18:31:44 +02:00
|
|
|
const ProjectExplorer::Kit * const kit = activeTarget()->kit();
|
2012-08-20 12:41:52 +02:00
|
|
|
const ProjectExplorer::ToolChain * const toolchain
|
2012-09-03 18:31:44 +02:00
|
|
|
= ProjectExplorer::ToolChainKitInformation::toolChain(kit);
|
2012-08-20 12:41:52 +02:00
|
|
|
if (!toolchain)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TargetInformation ti = node->targetInformation();
|
|
|
|
QString targetFileName = ti.target;
|
|
|
|
const QStringList config = node->variableValue(ConfigVar);
|
|
|
|
const bool isStatic = config.contains(QLatin1String("static"));
|
|
|
|
const bool isPlugin = config.contains(QLatin1String("plugin"));
|
|
|
|
switch (toolchain->targetAbi().os()) {
|
|
|
|
case ProjectExplorer::Abi::WindowsOS: {
|
|
|
|
QString targetVersionExt = node->singleVariableValue(TargetVersionExtVar);
|
|
|
|
if (targetVersionExt.isEmpty()) {
|
|
|
|
const QString version = node->singleVariableValue(VersionVar);
|
|
|
|
if (!version.isEmpty()) {
|
|
|
|
targetVersionExt = version.left(version.indexOf(QLatin1Char('.')));
|
|
|
|
if (targetVersionExt == QLatin1String("0"))
|
|
|
|
targetVersionExt.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
targetFileName += targetVersionExt + QLatin1Char('.');
|
|
|
|
targetFileName += QLatin1String(isStatic ? "lib" : "dll");
|
|
|
|
deploymentData.addFile(ti.workingDir + QLatin1Char('/') + targetFileName, targetPath);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ProjectExplorer::Abi::MacOS:
|
2012-11-26 15:09:56 +02:00
|
|
|
if (config.contains(QLatin1String("lib_bundle"))) {
|
2012-08-20 12:41:52 +02:00
|
|
|
ti.workingDir.append(QLatin1Char('/')).append(ti.target)
|
|
|
|
.append(QLatin1String(".framework"));
|
|
|
|
} else {
|
|
|
|
targetFileName.prepend(QLatin1String("lib"));
|
|
|
|
if (!isPlugin) {
|
|
|
|
targetFileName += QLatin1Char('.');
|
|
|
|
const QString version = node->singleVariableValue(VersionVar);
|
|
|
|
QString majorVersion = version.left(version.indexOf(QLatin1Char('.')));
|
|
|
|
if (majorVersion.isEmpty())
|
|
|
|
majorVersion = QLatin1String("1");
|
|
|
|
targetFileName += majorVersion;
|
|
|
|
}
|
|
|
|
targetFileName += QLatin1Char('.');
|
|
|
|
targetFileName += node->singleVariableValue(isStatic
|
|
|
|
? StaticLibExtensionVar : ShLibExtensionVar);
|
|
|
|
}
|
|
|
|
deploymentData.addFile(ti.workingDir + QLatin1Char('/') + targetFileName, targetPath);
|
|
|
|
break;
|
|
|
|
case ProjectExplorer::Abi::LinuxOS:
|
|
|
|
case ProjectExplorer::Abi::BsdOS:
|
|
|
|
case ProjectExplorer::Abi::UnixOS:
|
|
|
|
targetFileName.prepend(QLatin1String("lib"));
|
|
|
|
targetFileName += QLatin1Char('.');
|
|
|
|
if (isStatic) {
|
|
|
|
targetFileName += QLatin1Char('a');
|
|
|
|
} else {
|
|
|
|
targetFileName += QLatin1String("so");
|
|
|
|
deploymentData.addFile(ti.workingDir + QLatin1Char('/') + targetFileName, targetPath);
|
|
|
|
if (!isPlugin) {
|
|
|
|
QString version = node->singleVariableValue(VersionVar);
|
|
|
|
if (version.isEmpty())
|
|
|
|
version = QLatin1String("1.0.0");
|
|
|
|
targetFileName += QLatin1Char('.');
|
|
|
|
while (true) {
|
|
|
|
deploymentData.addFile(ti.workingDir + QLatin1Char('/')
|
|
|
|
+ targetFileName + version, targetPath);
|
|
|
|
const QString tmpVersion = version.left(version.lastIndexOf(QLatin1Char('.')));
|
|
|
|
if (tmpVersion == version)
|
|
|
|
break;
|
|
|
|
version = tmpVersion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-13 17:14:42 +02:00
|
|
|
void Qt4Project::emitBuildDirectoryInitialized()
|
|
|
|
{
|
|
|
|
emit buildDirectoryInitialized();
|
|
|
|
}
|
2011-08-18 16:55:45 +02:00
|
|
|
} // namespace Qt4ProjectManager
|
|
|
|
|
2011-08-18 16:46:44 +02:00
|
|
|
#include "qt4project.moc"
|