2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeproject.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeprojectmanager.h"
|
2013-08-13 10:52:57 +02:00
|
|
|
#include "qmakeprojectimporter.h"
|
|
|
|
#include "qmakebuildinfo.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qmakestep.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakenodes.h"
|
2017-02-10 11:16:18 +01:00
|
|
|
#include "qmakenodetreebuilder.h"
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeprojectmanagerconstants.h"
|
|
|
|
#include "qmakebuildconfiguration.h"
|
2009-06-22 14:32:54 +02:00
|
|
|
|
2014-06-04 13:11:25 +02:00
|
|
|
#include <utils/algorithm.h>
|
2016-11-30 18:26:44 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2011-04-12 12:17:19 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
2014-03-11 18:09:23 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2010-03-10 16:55:37 +01:00
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2017-02-06 16:59:53 +01:00
|
|
|
#include <cpptools/cpprawprojectpart.h>
|
2016-01-12 12:51:33 +01:00
|
|
|
#include <cpptools/projectinfo.h>
|
2016-01-13 14:12:15 +01:00
|
|
|
#include <cpptools/projectpartheaderpath.h>
|
2017-02-06 16:59:53 +01:00
|
|
|
#include <cpptools/cppprojectupdater.h>
|
2017-02-27 11:34:30 +01:00
|
|
|
#include <cpptools/cppmodelmanager.h>
|
2014-07-24 11:48:30 +02:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
2013-05-29 20:18:51 +02:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2012-08-20 12:41:52 +02:00
|
|
|
#include <projectexplorer/buildtargetinfo.h>
|
|
|
|
#include <projectexplorer/deploymentdata.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
#include <projectexplorer/headerpath.h>
|
2017-03-06 18:03:43 +01:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2011-08-18 16:46:44 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2016-09-23 15:53:31 +02:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2017-03-06 18:03:43 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2013-05-29 20:18:51 +02:00
|
|
|
#include <proparser/qmakevfs.h>
|
2011-05-20 21:40:53 +02:00
|
|
|
#include <qtsupport/profilereader.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2014-10-20 17:23:07 +02:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2016-01-15 16:12:54 +01:00
|
|
|
#include <cpptools/generatedcodemodelsupport.h>
|
2014-06-06 15:34:38 +02:00
|
|
|
#include <resourceeditor/resourcenode.h>
|
2016-01-15 16:12:54 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFileSystemWatcher>
|
2013-04-17 12:33:56 +02:00
|
|
|
#include <QMessageBox>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
using namespace QmakeProjectManager;
|
|
|
|
using namespace QmakeProjectManager::Internal;
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace ProjectExplorer;
|
2014-06-04 12:50:10 +02:00
|
|
|
using namespace Utils;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
namespace QmakeProjectManager {
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
class QmakeProjectFile : public Core::IDocument
|
2011-08-18 16:46:44 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-03-03 18:16:34 +01:00
|
|
|
explicit QmakeProjectFile(const FileName &fileName);
|
2011-08-18 16:46:44 +02:00
|
|
|
|
2015-06-04 15:54:10 +02:00
|
|
|
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
|
|
|
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
2011-08-18 16:46:44 +02:00
|
|
|
};
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
/// Watches folders for QmakePriFile nodes
|
2011-08-18 16:46:44 +02:00
|
|
|
/// use one file system watcher to watch all folders
|
|
|
|
/// such minimizing system ressouce usage
|
|
|
|
|
|
|
|
class CentralizedFolderWatcher : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-10-29 14:22:31 +01:00
|
|
|
CentralizedFolderWatcher(QmakeProject *parent);
|
2016-01-07 18:01:04 +01:00
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void watchFolders(const QList<QString> &folders, QmakePriFile *file);
|
|
|
|
void unwatchFolders(const QList<QString> &folders, QmakePriFile *file);
|
2011-08-18 16:46:44 +02:00
|
|
|
|
2016-01-07 18:01:04 +01:00
|
|
|
private:
|
2011-08-18 16:46:44 +02:00
|
|
|
void folderChanged(const QString &folder);
|
|
|
|
void onTimer();
|
|
|
|
void delayedFolderChanged(const QString &folder);
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *m_project;
|
2011-08-18 16:46:44 +02:00
|
|
|
QSet<QString> recursiveDirs(const QString &folder);
|
|
|
|
QFileSystemWatcher m_watcher;
|
2017-02-10 11:16:18 +01:00
|
|
|
QMultiMap<QString, QmakePriFile *> m_map;
|
2011-08-18 16:46:44 +02:00
|
|
|
|
|
|
|
QSet<QString> m_recursiveWatchedFolders;
|
|
|
|
QTimer m_compressTimer;
|
|
|
|
QSet<QString> m_changedFolders;
|
|
|
|
};
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
// QmakeProjectFiles: Struct for (Cached) lists of files in a project
|
|
|
|
class QmakeProjectFiles {
|
2012-04-24 15:49:09 +02:00
|
|
|
public:
|
2008-12-02 12:01:29 +01:00
|
|
|
void clear();
|
2013-10-29 14:22:31 +01:00
|
|
|
bool equals(const QmakeProjectFiles &f) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-10-31 13:47:42 +01:00
|
|
|
QStringList files[static_cast<int>(FileType::FileTypeSize)];
|
|
|
|
QStringList generatedFiles[static_cast<int>(FileType::FileTypeSize)];
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList proFiles;
|
|
|
|
};
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProjectFiles::clear()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-10-31 13:47:42 +01:00
|
|
|
for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i) {
|
2008-12-02 12:01:29 +01:00
|
|
|
files[i].clear();
|
|
|
|
generatedFiles[i].clear();
|
|
|
|
}
|
|
|
|
proFiles.clear();
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
bool QmakeProjectFiles::equals(const QmakeProjectFiles &f) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-10-31 13:47:42 +01:00
|
|
|
for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
if (files[i] != f.files[i] || generatedFiles[i] != f.generatedFiles[i])
|
|
|
|
return false;
|
|
|
|
if (proFiles != f.proFiles)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
inline bool operator==(const QmakeProjectFiles &f1, const QmakeProjectFiles &f2)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ return f1.equals(f2); }
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
inline bool operator!=(const QmakeProjectFiles &f1, const QmakeProjectFiles &f2)
|
2008-12-02 12:01:29 +01:00
|
|
|
{ return !f1.equals(f2); }
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QDebug operator<<(QDebug d, const QmakeProjectFiles &f)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
QDebug nsp = d.nospace();
|
2013-10-29 14:22:31 +01:00
|
|
|
nsp << "QmakeProjectFiles: proFiles=" << f.proFiles << '\n';
|
2016-10-31 13:47:42 +01:00
|
|
|
for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i)
|
2008-12-02 12:01:29 +01:00
|
|
|
nsp << "Type " << i << " files=" << f.files[i] << " generated=" << f.generatedFiles[i] << '\n';
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
// ----------- QmakeProjectFile
|
2017-03-06 18:03:43 +01:00
|
|
|
|
2017-03-03 18:16:34 +01:00
|
|
|
QmakeProjectFile::QmakeProjectFile(const FileName &fileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-03-05 15:58:12 +01:00
|
|
|
setId("Qmake.ProFile");
|
2017-03-03 18:16:34 +01:00
|
|
|
setMimeType(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
|
|
|
setFilePath(fileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
Core::IDocument::ReloadBehavior QmakeProjectFile::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;
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
bool QmakeProjectFile::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
|
|
|
}
|
|
|
|
|
2017-02-28 18:41:02 +01:00
|
|
|
static QList<QmakeProject *> s_projects;
|
|
|
|
|
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
|
|
|
/*!
|
2013-10-29 14:22:31 +01:00
|
|
|
\class QmakeProject
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject manages information about an individual Qt 4 (.pro) project file.
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
|
|
|
|
2017-03-03 18:16:34 +01:00
|
|
|
QmakeProject::QmakeProject(const FileName &fileName) :
|
2017-02-06 16:59:53 +01:00
|
|
|
m_qmakeVfs(new QMakeVfs),
|
|
|
|
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-02-28 18:41:02 +01:00
|
|
|
s_projects.append(this);
|
2013-10-30 13:34:46 +01:00
|
|
|
setId(Constants::QMAKEPROJECT_ID);
|
2016-01-08 11:09:37 +01:00
|
|
|
setDocument(new QmakeProjectFile(fileName));
|
2013-10-16 11:02:37 +02:00
|
|
|
setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID));
|
2017-01-30 14:59:10 +01:00
|
|
|
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
2017-01-11 17:25:58 +01:00
|
|
|
setRequiredKitPredicate(QtSupport::QtKitInformation::qtVersionPredicate());
|
2011-04-12 12:17:19 +02:00
|
|
|
|
2016-11-30 18:26:44 +01:00
|
|
|
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
|
|
|
m_qmakeVfs->setTextCodec(codec);
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateTimer.setSingleShot(true);
|
2014-10-24 12:43:14 +02:00
|
|
|
m_asyncUpdateTimer.setInterval(3000);
|
2016-01-07 18:01:04 +01:00
|
|
|
connect(&m_asyncUpdateTimer, &QTimer::timeout, this, &QmakeProject::asyncUpdate);
|
2013-05-29 20:18:51 +02:00
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
m_rootProFile = std::make_unique<QmakeProFile>(this, projectFilePath());
|
2016-02-02 12:44:42 +01:00
|
|
|
|
2016-01-07 18:01:04 +01:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
|
|
|
|
this, &QmakeProject::buildFinished);
|
2014-10-20 17:23:07 +02:00
|
|
|
|
2017-01-11 17:25:58 +01:00
|
|
|
setPreferredKitPredicate([this](const Kit *kit) -> bool { return matchesKit(kit); });
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject::~QmakeProject()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-02-28 18:41:02 +01:00
|
|
|
s_projects.removeOne(this);
|
2016-10-05 08:31:16 +02:00
|
|
|
delete m_projectImporter;
|
|
|
|
m_projectImporter = nullptr;
|
2017-02-06 16:59:53 +01:00
|
|
|
delete m_cppCodeModelUpdater;
|
|
|
|
m_cppCodeModelUpdater = nullptr;
|
2010-03-11 17:01:06 +01:00
|
|
|
m_asyncUpdateState = ShuttingDown;
|
2016-04-04 11:27:19 +02:00
|
|
|
|
|
|
|
// Make sure root node (and associated readers) are shut hown before proceeding
|
|
|
|
setRootProjectNode(nullptr);
|
2017-02-10 11:16:18 +01:00
|
|
|
m_rootProFile.reset();
|
2016-04-04 11:27:19 +02:00
|
|
|
|
2010-03-11 17:01:06 +01:00
|
|
|
m_cancelEvaluate = true;
|
2014-09-10 12:53:13 +02:00
|
|
|
Q_ASSERT(m_qmakeGlobalsRefCnt == 0);
|
2014-11-20 12:26:23 +01:00
|
|
|
delete m_qmakeVfs;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
QmakeProFile *QmakeProject::rootProFile() const
|
|
|
|
{
|
|
|
|
return m_rootProFile.get();
|
|
|
|
}
|
|
|
|
|
2015-05-18 16:57:29 +02:00
|
|
|
Project::RestoreResult QmakeProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-05-18 16:57:29 +02:00
|
|
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
|
|
|
if (result != RestoreResult::Ok)
|
|
|
|
return result;
|
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
|
|
|
}
|
|
|
|
|
2012-07-17 15:56:43 +02:00
|
|
|
// On active buildconfiguration changes, reevaluate the .pro files
|
|
|
|
m_activeTarget = activeTarget();
|
2015-02-01 18:44:47 +02:00
|
|
|
if (m_activeTarget) {
|
|
|
|
connect(m_activeTarget, &Target::activeBuildConfigurationChanged,
|
|
|
|
this, &QmakeProject::scheduleAsyncUpdateLater);
|
|
|
|
}
|
2012-07-17 15:56:43 +02:00
|
|
|
|
2015-02-01 18:44:47 +02:00
|
|
|
connect(this, &Project::activeTargetChanged,
|
|
|
|
this, &QmakeProject::activeTargetWasChanged);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2017-02-09 16:45:36 +01:00
|
|
|
scheduleAsyncUpdate(QmakeProFile::ParseNow);
|
2015-05-18 16:57:29 +02:00
|
|
|
return RestoreResult::Ok;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::updateCodeModels()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
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();
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::updateCppCodeModel()
|
2010-09-21 14:28:55 +02:00
|
|
|
{
|
2016-12-05 17:18:54 +01:00
|
|
|
using ProjectPart = CppTools::ProjectPart;
|
2016-09-23 15:53:31 +02:00
|
|
|
|
2016-12-05 17:18:54 +01:00
|
|
|
m_toolChainWarnings.clear();
|
2012-02-16 15:09:56 +01:00
|
|
|
|
2016-12-05 17:18:54 +01:00
|
|
|
const Kit *k = nullptr;
|
2015-02-01 18:44:47 +02:00
|
|
|
if (Target *target = activeTarget())
|
2012-09-03 18:31:44 +02:00
|
|
|
k = target->kit();
|
2012-04-24 15:49:09 +02:00
|
|
|
else
|
2013-08-21 12:48:46 +02:00
|
|
|
k = KitManager::defaultKit();
|
2016-12-05 17:18:54 +01:00
|
|
|
QTC_ASSERT(k, return);
|
2014-11-20 12:50:37 +01:00
|
|
|
|
2017-02-06 16:59:53 +01:00
|
|
|
ToolChain *cToolChain
|
|
|
|
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::C_LANGUAGE_ID);
|
|
|
|
ToolChain *cxxToolChain
|
|
|
|
= ToolChainKitInformation::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
|
|
|
|
|
|
m_cppCodeModelUpdater->cancel();
|
|
|
|
|
2015-02-15 23:13:28 +02:00
|
|
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k);
|
2012-02-16 15:09:56 +01:00
|
|
|
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
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
const QList<QmakeProFile *> proFiles = rootProFile()->allProFiles();
|
2016-12-05 17:30:56 +01:00
|
|
|
|
2016-01-15 16:12:54 +01:00
|
|
|
QList<ProjectExplorer::ExtraCompiler *> generators;
|
2017-02-06 16:59:53 +01:00
|
|
|
CppTools::RawProjectParts rpps;
|
2017-02-10 11:16:18 +01:00
|
|
|
for (const QmakeProFile *pro : proFiles) {
|
2016-09-23 15:53:31 +02:00
|
|
|
warnOnToolChainMismatch(pro);
|
|
|
|
|
2017-02-06 16:59:53 +01:00
|
|
|
CppTools::RawProjectPart rpp;
|
|
|
|
rpp.setDisplayName(pro->displayName());
|
2017-03-09 14:13:22 +01:00
|
|
|
rpp.setProjectFileLocation(pro->filePath().toString());
|
2017-02-27 14:46:45 +01:00
|
|
|
rpp.setBuildSystemTarget(pro->targetInformation().target);
|
2017-02-06 16:59:53 +01:00
|
|
|
// TODO: Handle QMAKE_CFLAGS
|
|
|
|
rpp.setFlagsForCxx({cxxToolChain, pro->variableValue(Variable::CppFlags)});
|
|
|
|
rpp.setDefines(pro->cxxDefines());
|
|
|
|
rpp.setPreCompiledHeaders(pro->variableValue(Variable::PrecompiledHeader));
|
|
|
|
rpp.setSelectedForBuilding(pro->includedInExactParse());
|
2012-12-08 23:38:26 +04:00
|
|
|
|
2016-12-05 17:30:56 +01:00
|
|
|
// Qt Version
|
2017-02-09 14:42:04 +01:00
|
|
|
if (pro->variableValue(Variable::Config).contains(QLatin1String("qt")))
|
2017-02-06 16:59:53 +01:00
|
|
|
rpp.setQtVersion(qtVersionForPart);
|
2012-12-08 23:38:26 +04:00
|
|
|
else
|
2017-02-06 16:59:53 +01:00
|
|
|
rpp.setQtVersion(ProjectPart::NoQt);
|
2011-02-01 18:36:00 +01:00
|
|
|
|
2016-12-05 17:30:56 +01:00
|
|
|
// Header paths
|
|
|
|
CppTools::ProjectPartHeaderPaths headerPaths;
|
|
|
|
using CppToolsHeaderPath = CppTools::ProjectPartHeaderPath;
|
2017-02-09 14:42:04 +01:00
|
|
|
foreach (const QString &inc, pro->variableValue(Variable::IncludePath)) {
|
2016-12-05 17:30:56 +01:00
|
|
|
const auto headerPath = CppToolsHeaderPath(inc, CppToolsHeaderPath::IncludePath);
|
|
|
|
if (!headerPaths.contains(headerPath))
|
|
|
|
headerPaths += headerPath;
|
2015-02-04 10:18:48 +01:00
|
|
|
}
|
|
|
|
|
2016-12-05 17:18:54 +01:00
|
|
|
if (qtVersion && !qtVersion->frameworkInstallPath().isEmpty()) {
|
2016-12-05 17:30:56 +01:00
|
|
|
headerPaths += CppToolsHeaderPath(qtVersion->frameworkInstallPath(),
|
|
|
|
CppToolsHeaderPath::FrameworkPath);
|
2014-08-19 12:01:08 +02:00
|
|
|
}
|
2017-02-06 16:59:53 +01:00
|
|
|
rpp.setHeaderPaths(headerPaths);
|
2012-02-16 15:09:56 +01:00
|
|
|
|
2016-12-05 17:30:56 +01:00
|
|
|
// Files and generators
|
2017-02-09 14:42:04 +01:00
|
|
|
QStringList fileList = pro->variableValue(Variable::Source);
|
2016-01-15 16:12:54 +01:00
|
|
|
QList<ProjectExplorer::ExtraCompiler *> proGenerators = pro->extraCompilers();
|
|
|
|
foreach (ProjectExplorer::ExtraCompiler *ec, proGenerators) {
|
2016-03-11 15:18:20 +02:00
|
|
|
ec->forEachTarget([&](const Utils::FileName &generatedFile) {
|
2016-12-05 17:30:56 +01:00
|
|
|
fileList += generatedFile.toString();
|
2016-03-11 15:18:20 +02:00
|
|
|
});
|
2016-01-15 16:12:54 +01:00
|
|
|
}
|
|
|
|
generators.append(proGenerators);
|
2017-02-27 11:34:30 +01:00
|
|
|
fileList.prepend(CppTools::CppModelManager::configurationFileName());
|
2017-02-06 16:59:53 +01:00
|
|
|
rpp.setFiles(fileList);
|
2016-01-15 16:12:54 +01:00
|
|
|
|
2017-02-06 16:59:53 +01:00
|
|
|
rpps.append(rpp);
|
2014-08-19 12:01:08 +02:00
|
|
|
}
|
2013-04-10 14:45:47 +02:00
|
|
|
|
2016-12-05 17:18:54 +01:00
|
|
|
CppTools::GeneratedCodeModelSupport::update(generators);
|
2017-02-06 16:59:53 +01:00
|
|
|
m_cppCodeModelUpdater->update({this, cToolChain, cxxToolChain, k, rpps});
|
2009-05-04 18:22:40 +02:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::updateQmlJSCodeModel()
|
2010-09-21 14:28:55 +02:00
|
|
|
{
|
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;
|
|
|
|
|
2012-12-06 17:20:58 +01:00
|
|
|
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
|
2014-07-24 11:48:30 +02:00
|
|
|
modelManager->defaultProjectInfoForProject(this);
|
2010-09-21 14:28:55 +02:00
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
const QList<QmakeProFile *> proFiles = rootProFile()->allProFiles();
|
2010-09-21 14:28:55 +02:00
|
|
|
|
2011-06-23 15:09:38 +02:00
|
|
|
projectInfo.importPaths.clear();
|
2012-11-21 16:18:53 +01:00
|
|
|
|
|
|
|
bool hasQmlLib = false;
|
2017-02-10 11:16:18 +01:00
|
|
|
for (QmakeProFile *file : proFiles) {
|
|
|
|
for (const QString &path : file->variableValue(Variable::QmlImportPath)) {
|
2015-02-01 18:44:47 +02:00
|
|
|
projectInfo.importPaths.maybeInsert(FileName::fromString(path),
|
2014-07-22 19:06:44 +02:00
|
|
|
QmlJS::Dialect::Qml);
|
2017-02-10 11:16:18 +01:00
|
|
|
}
|
|
|
|
const QStringList &exactResources = file->variableValue(Variable::ExactResource);
|
|
|
|
const QStringList &cumulativeResources = file->variableValue(Variable::CumulativeResource);
|
2016-10-27 16:36:06 +02:00
|
|
|
projectInfo.activeResourceFiles.append(exactResources);
|
|
|
|
projectInfo.allResourceFiles.append(exactResources);
|
|
|
|
projectInfo.allResourceFiles.append(cumulativeResources);
|
|
|
|
foreach (const QString &rc, exactResources) {
|
2016-10-24 19:30:24 +02:00
|
|
|
QString contents;
|
2016-10-27 16:36:06 +02:00
|
|
|
if (m_qmakeVfs->readVirtualFile(rc, QMakeVfs::VfsExact, &contents))
|
|
|
|
projectInfo.resourceFileContents[rc] = contents;
|
|
|
|
}
|
|
|
|
foreach (const QString &rc, cumulativeResources) {
|
|
|
|
QString contents;
|
|
|
|
if (m_qmakeVfs->readVirtualFile(rc, QMakeVfs::VfsCumulative, &contents))
|
2016-10-24 19:30:24 +02:00
|
|
|
projectInfo.resourceFileContents[rc] = contents;
|
|
|
|
}
|
2012-11-21 16:18:53 +01:00
|
|
|
if (!hasQmlLib) {
|
2017-02-10 11:16:18 +01:00
|
|
|
QStringList qtLibs = file->variableValue(Variable::Qt);
|
2012-11-21 16:18:53 +01:00
|
|
|
hasQmlLib = qtLibs.contains(QLatin1String("declarative")) ||
|
|
|
|
qtLibs.contains(QLatin1String("qml")) ||
|
|
|
|
qtLibs.contains(QLatin1String("quick"));
|
|
|
|
}
|
2010-09-21 14:28:55 +02:00
|
|
|
}
|
2011-09-21 15:54:07 +02:00
|
|
|
|
2013-05-28 13:19:32 +02:00
|
|
|
// If the project directory has a pro/pri file that includes a qml or quick or declarative
|
|
|
|
// library then chances of the project being a QML project is quite high.
|
|
|
|
// This assumption fails when there are no QDeclarativeEngine/QDeclarativeView (QtQuick 1)
|
|
|
|
// or QQmlEngine/QQuickView (QtQuick 2) instances.
|
|
|
|
if (hasQmlLib)
|
2017-01-30 14:59:10 +01:00
|
|
|
addProjectLanguage(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID);
|
2013-05-28 13:19:32 +02:00
|
|
|
|
2013-05-21 11:35:15 +02:00
|
|
|
projectInfo.activeResourceFiles.removeDuplicates();
|
|
|
|
projectInfo.allResourceFiles.removeDuplicates();
|
2010-09-21 14:28:55 +02:00
|
|
|
|
2014-01-23 14:28:31 +01:00
|
|
|
modelManager->updateProjectInfo(projectInfo, this);
|
2010-09-21 14:28:55 +02:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::updateRunConfigurations()
|
2012-07-17 15:56:43 +02:00
|
|
|
{
|
2013-06-19 12:17:59 +02:00
|
|
|
if (activeTarget())
|
|
|
|
activeTarget()->updateDefaultRunConfigurations();
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void QmakeProject::scheduleAsyncUpdate(QmakeProFile *file, QmakeProFile::AsyncUpdateDelay delay)
|
2010-03-10 16:55:37 +01:00
|
|
|
{
|
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
|
|
|
if (m_cancelEvaluate) {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
file->setParseInProgressRecursive(true);
|
2016-11-02 12:10:18 +01:00
|
|
|
setAllBuildConfigurationsEnabled(false);
|
2011-01-19 15:46:01 +01:00
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
if (m_asyncUpdateState == AsyncFullUpdatePending) {
|
|
|
|
// Just postpone
|
2014-10-24 12:43:14 +02:00
|
|
|
startAsyncTimer(delay);
|
2010-03-10 16:55:37 +01:00
|
|
|
} else if (m_asyncUpdateState == AsyncPartialUpdatePending
|
|
|
|
|| m_asyncUpdateState == Base) {
|
|
|
|
// Add the node
|
|
|
|
m_asyncUpdateState = AsyncPartialUpdatePending;
|
|
|
|
|
|
|
|
bool add = true;
|
2017-02-10 11:16:18 +01:00
|
|
|
auto it = m_partialEvaluate.begin();
|
2010-03-10 16:55:37 +01:00
|
|
|
while (it != m_partialEvaluate.end()) {
|
2017-02-10 11:16:18 +01:00
|
|
|
if (*it == file) {
|
2010-03-10 16:55:37 +01:00
|
|
|
add = false;
|
|
|
|
break;
|
2017-02-10 11:16:18 +01:00
|
|
|
} else if (file->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);
|
2017-02-10 11:16:18 +01:00
|
|
|
} else if ((*it)->isParent(file)) { // 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)
|
2017-02-10 11:16:18 +01:00
|
|
|
m_partialEvaluate.append(file);
|
2012-09-04 11:02:11 +02:00
|
|
|
|
|
|
|
// Cancel running code model update
|
2017-02-06 16:59:53 +01:00
|
|
|
m_cppCodeModelUpdater->cancel();
|
2014-10-24 12:43:14 +02:00
|
|
|
|
|
|
|
startAsyncTimer(delay);
|
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
|
2014-10-24 12:43:14 +02:00
|
|
|
scheduleAsyncUpdate(delay);
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-09 16:45:36 +01:00
|
|
|
void QmakeProject::scheduleAsyncUpdate(QmakeProFile::AsyncUpdateDelay delay)
|
2010-03-10 16:55:37 +01:00
|
|
|
{
|
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
|
|
|
if (m_cancelEvaluate) { // we are in progress of canceling
|
|
|
|
// and will start the evaluation after that
|
|
|
|
return;
|
|
|
|
}
|
2016-11-02 12:10:18 +01:00
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
rootProFile()->setParseInProgressRecursive(true);
|
2016-11-02 12:10:18 +01:00
|
|
|
setAllBuildConfigurationsEnabled(false);
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
if (m_asyncUpdateState == AsyncUpdateInProgress) {
|
|
|
|
m_cancelEvaluate = true;
|
|
|
|
m_asyncUpdateState = AsyncFullUpdatePending;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_partialEvaluate.clear();
|
|
|
|
m_asyncUpdateState = AsyncFullUpdatePending;
|
2010-04-22 18:57:43 +02:00
|
|
|
|
|
|
|
// Cancel running code model update
|
2017-02-06 16:59:53 +01:00
|
|
|
m_cppCodeModelUpdater->cancel();
|
2014-10-24 12:43:14 +02:00
|
|
|
startAsyncTimer(delay);
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
|
2017-02-09 16:45:36 +01:00
|
|
|
void QmakeProject::startAsyncTimer(QmakeProFile::AsyncUpdateDelay delay)
|
2014-10-24 12:43:14 +02:00
|
|
|
{
|
|
|
|
m_asyncUpdateTimer.stop();
|
2017-02-09 16:45:36 +01:00
|
|
|
m_asyncUpdateTimer.setInterval(qMin(m_asyncUpdateTimer.interval(), delay == QmakeProFile::ParseLater ? 3000 : 0));
|
2014-10-24 12:43:14 +02:00
|
|
|
m_asyncUpdateTimer.start();
|
|
|
|
}
|
2010-03-10 16:55:37 +01:00
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::incrementPendingEvaluateFutures()
|
2010-03-10 16:55:37 +01:00
|
|
|
{
|
|
|
|
++m_pendingEvaluateFuturesCount;
|
|
|
|
m_asyncUpdateFutureInterface->setProgressRange(m_asyncUpdateFutureInterface->progressMinimum(),
|
|
|
|
m_asyncUpdateFutureInterface->progressMaximum() + 1);
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::decrementPendingEvaluateFutures()
|
2010-03-10 16:55:37 +01:00
|
|
|
{
|
|
|
|
--m_pendingEvaluateFuturesCount;
|
|
|
|
|
|
|
|
m_asyncUpdateFutureInterface->setProgressValue(m_asyncUpdateFutureInterface->progressValue() + 1);
|
|
|
|
if (m_pendingEvaluateFuturesCount == 0) {
|
|
|
|
// We are done!
|
2017-03-03 15:13:06 +01:00
|
|
|
setRootProjectNode(QmakeNodeTreeBuilder::buildTree(this));
|
2012-10-08 14:33:33 +02:00
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
m_asyncUpdateFutureInterface->reportFinished();
|
|
|
|
delete m_asyncUpdateFutureInterface;
|
2016-04-04 11:26:30 +02:00
|
|
|
m_asyncUpdateFutureInterface = nullptr;
|
2010-03-10 16:55:37 +01:00
|
|
|
m_cancelEvaluate = false;
|
|
|
|
|
|
|
|
// TODO clear the profile cache ?
|
|
|
|
if (m_asyncUpdateState == AsyncFullUpdatePending || m_asyncUpdateState == AsyncPartialUpdatePending) {
|
2017-02-10 11:16:18 +01:00
|
|
|
rootProFile()->setParseInProgressRecursive(true);
|
2016-11-02 12:10:18 +01:00
|
|
|
setAllBuildConfigurationsEnabled(false);
|
2017-02-09 16:45:36 +01:00
|
|
|
startAsyncTimer(QmakeProFile::ParseLater);
|
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:
|
2016-11-02 12:10:18 +01:00
|
|
|
setAllBuildConfigurationsEnabled(true);
|
|
|
|
|
2011-09-12 13:25:12 +02:00
|
|
|
m_asyncUpdateState = Base;
|
2011-09-15 12:15:10 +02:00
|
|
|
updateCodeModels();
|
2012-08-20 12:41:52 +02:00
|
|
|
updateBuildSystemData();
|
2014-09-26 15:24:02 +02:00
|
|
|
if (activeTarget())
|
|
|
|
activeTarget()->updateDefaultDeployConfigurations();
|
2012-07-17 15:56:43 +02:00
|
|
|
updateRunConfigurations();
|
|
|
|
emit proFilesEvaluated();
|
2016-10-20 13:18:54 +02:00
|
|
|
emit parsingFinished();
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
bool QmakeProject::wasEvaluateCanceled()
|
2010-03-10 16:55:37 +01:00
|
|
|
{
|
|
|
|
return m_cancelEvaluate;
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::asyncUpdate()
|
2010-03-10 16:55:37 +01:00
|
|
|
{
|
2014-10-13 16:26:10 +02:00
|
|
|
m_asyncUpdateTimer.setInterval(3000);
|
2013-05-29 20:18:51 +02:00
|
|
|
|
|
|
|
m_qmakeVfs->invalidateCache();
|
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
Q_ASSERT(!m_asyncUpdateFutureInterface);
|
|
|
|
m_asyncUpdateFutureInterface = new QFutureInterface<void>();
|
|
|
|
|
2010-04-13 16:32:01 +02:00
|
|
|
m_asyncUpdateFutureInterface->setProgressRange(0, 0);
|
2014-04-17 15:14:14 +02:00
|
|
|
Core::ProgressManager::addTask(m_asyncUpdateFutureInterface->future(),
|
|
|
|
tr("Reading Project \"%1\"").arg(displayName()),
|
|
|
|
Constants::PROFILE_EVALUATE);
|
2010-03-10 16:55:37 +01:00
|
|
|
|
|
|
|
m_asyncUpdateFutureInterface->reportStarted();
|
|
|
|
|
|
|
|
if (m_asyncUpdateState == AsyncFullUpdatePending) {
|
2017-02-10 11:16:18 +01:00
|
|
|
rootProFile()->asyncUpdate();
|
2010-03-10 16:55:37 +01:00
|
|
|
} else {
|
2017-02-10 11:16:18 +01:00
|
|
|
foreach (QmakeProFile *file, m_partialEvaluate)
|
|
|
|
file->asyncUpdate();
|
2010-03-10 16:55:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_partialEvaluate.clear();
|
|
|
|
m_asyncUpdateState = AsyncUpdateInProgress;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::buildFinished(bool success)
|
2013-05-29 20:18:51 +02:00
|
|
|
{
|
|
|
|
if (success)
|
|
|
|
m_qmakeVfs->invalidateContents();
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
bool QmakeProject::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;
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QString QmakeProject::displayName() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-02 12:22:58 +02:00
|
|
|
return projectFilePath().toFileInfo().completeBaseName();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 16:12:54 +01:00
|
|
|
// Find the folder that contains a file with a certain name (recurse down)
|
|
|
|
static FolderNode *folderOf(FolderNode *in, const FileName &fileName)
|
2009-12-03 16:23:15 +01:00
|
|
|
{
|
2012-11-28 20:44:03 +02:00
|
|
|
foreach (FileNode *fn, in->fileNodes())
|
2016-01-15 16:12:54 +01:00
|
|
|
if (fn->filePath() == fileName)
|
2009-12-03 16:23:15 +01:00
|
|
|
return in;
|
2016-11-09 12:28:25 +01:00
|
|
|
foreach (FolderNode *folder, in->folderNodes())
|
2016-01-15 16:12:54 +01:00
|
|
|
if (FolderNode *pn = folderOf(folder, fileName))
|
2009-12-03 16:23:15 +01:00
|
|
|
return pn;
|
2017-02-10 11:52:35 +01:00
|
|
|
return nullptr;
|
2009-12-03 16:23:15 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 16:12:54 +01:00
|
|
|
// Find the QmakeProFileNode that contains a certain file.
|
2009-12-03 16:23:15 +01:00
|
|
|
// First recurse down to folder, then find the pro-file.
|
2016-01-15 16:12:54 +01:00
|
|
|
static FileNode *fileNodeOf(QmakeProFileNode *in, const FileName &fileName)
|
2009-12-03 16:23:15 +01:00
|
|
|
{
|
2016-01-15 16:12:54 +01:00
|
|
|
for (FolderNode *folder = folderOf(in, fileName); folder; folder = folder->parentFolderNode()) {
|
|
|
|
if (QmakeProFileNode *proFile = dynamic_cast<QmakeProFileNode *>(folder)) {
|
|
|
|
foreach (FileNode *fileNode, proFile->fileNodes()) {
|
|
|
|
if (fileNode->filePath() == fileName)
|
|
|
|
return fileNode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-02-10 11:52:35 +01:00
|
|
|
return nullptr;
|
2009-12-03 16:23:15 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 16:12:54 +01:00
|
|
|
QStringList QmakeProject::filesGeneratedFrom(const QString &input) const
|
2009-12-03 16:23:15 +01:00
|
|
|
{
|
2016-01-15 16:12:54 +01:00
|
|
|
if (!rootProjectNode())
|
2017-02-10 11:16:18 +01:00
|
|
|
return { };
|
2016-01-15 16:12:54 +01:00
|
|
|
|
|
|
|
if (const FileNode *file = fileNodeOf(rootProjectNode(), FileName::fromString(input))) {
|
2017-02-10 11:16:18 +01:00
|
|
|
const QmakeProFileNode *pro = static_cast<QmakeProFileNode *>(file->parentFolderNode());
|
|
|
|
if (const QmakeProFile *proFile = pro->proFile())
|
|
|
|
return Utils::transform(proFile->generatedFiles(FileName::fromString(pro->buildDir()),
|
|
|
|
file->filePath(), file->fileType()),
|
|
|
|
&FileName::toString);
|
2016-01-15 16:12:54 +01:00
|
|
|
}
|
2017-02-10 11:16:18 +01:00
|
|
|
return { };
|
2009-12-03 16:23:15 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::proFileParseError(const QString &errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-09-05 01:52:17 +02:00
|
|
|
Core::MessageManager::write(errorMessage);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2017-03-01 15:14:29 +01:00
|
|
|
QtSupport::ProFileReader *QmakeProject::createProFileReader(const QmakeProFile *qmakeProFile)
|
2009-12-07 20:49:39 +01:00
|
|
|
{
|
2012-05-02 15:20:08 +02:00
|
|
|
if (!m_qmakeGlobals) {
|
2016-10-21 20:23:07 +02:00
|
|
|
m_qmakeGlobals = new QMakeGlobals;
|
2012-05-02 15:20:08 +02:00
|
|
|
m_qmakeGlobalsRefCnt = 0;
|
2009-12-07 20:49:39 +01:00
|
|
|
|
2017-03-01 15:14:29 +01:00
|
|
|
Kit *k = KitManager::defaultKit();
|
2015-02-01 18:44:47 +02:00
|
|
|
Environment env = Environment::systemEnvironment();
|
2011-10-28 10:15:04 +00:00
|
|
|
QStringList qmakeArgs;
|
2017-03-01 15:14:29 +01:00
|
|
|
|
|
|
|
if (Target *t = activeTarget()) {
|
|
|
|
k = t->kit();
|
|
|
|
if (auto bc = static_cast<QmakeBuildConfiguration *>(t->activeBuildConfiguration())) {
|
|
|
|
env = bc->environment();
|
|
|
|
if (QMakeStep *qs = bc->qmakeStep())
|
|
|
|
qmakeArgs = qs->parserArguments();
|
|
|
|
else
|
|
|
|
qmakeArgs = bc->configCommandLineArguments();
|
|
|
|
}
|
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);
|
2016-10-21 20:23:07 +02:00
|
|
|
m_qmakeSysroot = SysRootKitInformation::hasSysRoot(k)
|
2012-09-03 18:31:44 +02:00
|
|
|
? 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());
|
2017-01-23 17:40:16 +01:00
|
|
|
qtVersion->applyProperties(m_qmakeGlobals);
|
2012-06-18 18:16:50 +02:00
|
|
|
}
|
2017-02-10 11:16:18 +01:00
|
|
|
m_qmakeGlobals->setDirectories(rootProFile()->sourceDir().toString(),
|
|
|
|
rootProFile()->buildDir().toString());
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2015-02-01 18:44:47 +02:00
|
|
|
Environment::const_iterator eit = env.constBegin(), eend = env.constEnd();
|
2011-10-28 10:15:04 +00:00
|
|
|
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
|
|
|
|
2017-03-03 17:09:41 +01:00
|
|
|
m_qmakeGlobals->setCommandLineArguments(rootProFile()->buildDir().toString(), qmakeArgs);
|
2011-10-28 10:15:04 +00:00
|
|
|
|
2011-05-20 21:40:53 +02:00
|
|
|
QtSupport::ProFileCacheManager::instance()->incRefCount();
|
2014-04-02 03:16:09 +02:00
|
|
|
|
|
|
|
// On ios, qmake is called recursively, and the second call with a different
|
|
|
|
// spec.
|
|
|
|
// macx-ios-clang just creates supporting makefiles, and to avoid being
|
|
|
|
// slow does not evaluate everything, and contains misleading information
|
|
|
|
// (that is never used).
|
|
|
|
// macx-xcode correctly evaluates the variables and generates the xcodeproject
|
|
|
|
// that is actually used to build the application.
|
|
|
|
//
|
|
|
|
// It is important to override the spec file only for the creator evaluator,
|
|
|
|
// and not the qmake buildstep used to build the app (as we use the makefiles).
|
|
|
|
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // from Ios::Constants
|
2014-04-03 10:16:48 +02:00
|
|
|
if (qtVersion && qtVersion->type() == QLatin1String(IOSQT))
|
2014-04-02 03:16:09 +02:00
|
|
|
m_qmakeGlobals->xqmakespec = QLatin1String("macx-xcode");
|
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
|
|
|
|
2016-04-04 11:26:30 +02:00
|
|
|
auto reader = new QtSupport::ProFileReader(m_qmakeGlobals, m_qmakeVfs);
|
2009-12-07 20:49:39 +01:00
|
|
|
|
2017-03-01 15:14:29 +01:00
|
|
|
reader->setOutputDir(qmakeProFile->buildDir().toString());
|
2009-12-07 20:49:39 +01:00
|
|
|
|
|
|
|
return reader;
|
|
|
|
}
|
|
|
|
|
2016-10-21 20:23:07 +02:00
|
|
|
QMakeGlobals *QmakeProject::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
|
|
|
}
|
|
|
|
|
2014-09-10 12:53:55 +02:00
|
|
|
QMakeVfs *QmakeProject::qmakeVfs()
|
|
|
|
{
|
|
|
|
return m_qmakeVfs;
|
|
|
|
}
|
|
|
|
|
2016-10-21 20:23:07 +02:00
|
|
|
QString QmakeProject::qmakeSysroot()
|
|
|
|
{
|
|
|
|
return m_qmakeSysroot;
|
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::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) {
|
2016-01-08 11:09:37 +01:00
|
|
|
QString dir = projectFilePath().toString();
|
2009-12-07 22:58:47 +01:00
|
|
|
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;
|
2016-04-04 11:26:30 +02:00
|
|
|
m_qmakeGlobals = nullptr;
|
2009-12-07 20:49:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-08 12:49:00 +01:00
|
|
|
QmakeProFileNode *QmakeProject::rootProjectNode() const
|
2011-08-18 16:46:44 +02:00
|
|
|
{
|
2016-01-08 12:49:00 +01:00
|
|
|
return static_cast<QmakeProFileNode *>(Project::rootProjectNode());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
bool QmakeProject::validParse(const FileName &proFilePath) const
|
2010-10-27 16:27:22 +02:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
if (!rootProFile())
|
2010-10-29 12:15:30 +02:00
|
|
|
return false;
|
2017-02-10 11:16:18 +01:00
|
|
|
const QmakeProFile *pro = rootProFile()->findProFile(proFilePath);
|
|
|
|
return pro && pro->validParse();
|
2010-10-27 16:27:22 +02:00
|
|
|
}
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
bool QmakeProject::parseInProgress(const FileName &proFilePath) const
|
2011-06-10 15:37:10 +02:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
if (!rootProFile())
|
2011-06-10 15:37:10 +02:00
|
|
|
return false;
|
2017-02-10 11:16:18 +01:00
|
|
|
const QmakeProFile *pro = rootProFile()->findProFile(proFilePath);
|
|
|
|
return pro && pro->parseInProgress();
|
2011-06-10 15:37:10 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
QList<QmakeProFile *>
|
|
|
|
QmakeProject::collectAllProFiles(QmakeProFile *file, Parsing parse,
|
|
|
|
const QList<ProjectType> &projectTypes)
|
2010-07-23 16:37:10 +02:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
QList<QmakeProFile *> result;
|
|
|
|
if (parse == ExactAndCumulativeParse || file->includedInExactParse())
|
|
|
|
if (projectTypes.isEmpty() || projectTypes.contains(file->projectType()))
|
|
|
|
result.append(file);
|
|
|
|
|
|
|
|
for (QmakePriFile *f : file->children()) {
|
|
|
|
auto qmakeProFileNode = dynamic_cast<QmakeProFile *>(f);
|
2013-10-29 17:37:39 +01:00
|
|
|
if (qmakeProFileNode)
|
2017-02-10 11:16:18 +01:00
|
|
|
result.append(collectAllProFiles(qmakeProFileNode, parse, projectTypes));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2017-02-10 11:16:18 +01:00
|
|
|
|
|
|
|
return result;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
QList<QmakeProFile *> QmakeProject::applicationProFiles(Parsing parse) const
|
2010-07-23 16:37:10 +02:00
|
|
|
{
|
2017-02-22 15:09:35 +01:00
|
|
|
return allProFiles({ProjectType::ApplicationTemplate, ProjectType::ScriptTemplate}, parse);
|
2010-07-23 16:37:10 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
QList<QmakeProFile *> QmakeProject::allProFiles(const QList<ProjectType> &projectTypes, Parsing parse) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
QList<QmakeProFile *> list;
|
|
|
|
if (!rootProFile())
|
2010-02-08 15:50:06 +01:00
|
|
|
return list;
|
2017-02-10 11:16:18 +01:00
|
|
|
list = collectAllProFiles(rootProFile(), parse, projectTypes);
|
2008-12-02 12:01:29 +01:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
bool QmakeProject::hasApplicationProFile(const FileName &path) const
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
const QList<QmakeProFile *> list = applicationProFiles();
|
|
|
|
return Utils::contains(list, Utils::equal(&QmakeProFile::filePath, path));
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
2017-02-28 13:19:34 +01:00
|
|
|
QList<Core::Id> QmakeProject::creationIds(Core::Id base,
|
|
|
|
IRunConfigurationFactory::CreationMode mode,
|
|
|
|
const QList<ProjectType> &projectTypes)
|
|
|
|
{
|
|
|
|
QList<ProjectType> realTypes = projectTypes;
|
|
|
|
if (realTypes.isEmpty())
|
|
|
|
realTypes = {ProjectType::ApplicationTemplate, ProjectType::ScriptTemplate};
|
|
|
|
QList<QmakeProFile *> files = allProFiles(realTypes);
|
2017-02-28 11:22:58 +01:00
|
|
|
QList<QmakeProFile *> temp = files;
|
2014-06-12 16:24:52 +02:00
|
|
|
|
2017-02-28 11:22:58 +01:00
|
|
|
if (mode == IRunConfigurationFactory::AutoCreate) {
|
|
|
|
QList<QmakeProFile *> filtered = Utils::filtered(files, [](const QmakeProFile *f) {
|
|
|
|
return f->isQtcRunnable();
|
|
|
|
});
|
|
|
|
temp = filtered.isEmpty() ? files : filtered;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Utils::transform(temp, [&base](QmakeProFile *f) {
|
2017-02-10 11:16:18 +01:00
|
|
|
return base.withSuffix(f->filePath().toString());
|
2014-06-04 13:11:25 +02:00
|
|
|
});
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::activeTargetWasChanged()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2012-08-27 15:11:28 +02:00
|
|
|
if (m_activeTarget) {
|
2015-02-01 18:44:47 +02:00
|
|
|
disconnect(m_activeTarget, &Target::activeBuildConfigurationChanged,
|
|
|
|
this, &QmakeProject::scheduleAsyncUpdateLater);
|
2012-08-27 15:11:28 +02:00
|
|
|
}
|
2012-07-17 15:56:43 +02:00
|
|
|
|
|
|
|
m_activeTarget = activeTarget();
|
|
|
|
|
|
|
|
if (!m_activeTarget)
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
2015-02-01 18:44:47 +02:00
|
|
|
connect(m_activeTarget, &Target::activeBuildConfigurationChanged,
|
|
|
|
this, &QmakeProject::scheduleAsyncUpdateLater);
|
2012-07-17 15:56:43 +02:00
|
|
|
|
2010-03-10 16:55:37 +01:00
|
|
|
scheduleAsyncUpdate();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
2016-11-02 12:10:18 +01:00
|
|
|
void QmakeProject::setAllBuildConfigurationsEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
foreach (Target *t, targets()) {
|
|
|
|
foreach (BuildConfiguration *bc, t->buildConfigurations()) {
|
|
|
|
auto qmakeBc = qobject_cast<QmakeBuildConfiguration *>(bc);
|
|
|
|
if (qmakeBc)
|
|
|
|
qmakeBc->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-28 18:41:02 +01:00
|
|
|
static void notifyChangedHelper(const FileName &fileName, QmakeProFile *file)
|
2008-12-02 18:14:06 +01:00
|
|
|
{
|
2017-02-28 18:41:02 +01:00
|
|
|
if (file->filePath() == fileName) {
|
|
|
|
QtSupport::ProFileCacheManager::instance()->discardFile(fileName.toString());
|
|
|
|
file->scheduleUpdate(QmakeProFile::ParseNow);
|
|
|
|
}
|
2008-12-02 18:14:06 +01:00
|
|
|
|
2017-02-28 18:41:02 +01:00
|
|
|
for (QmakePriFile *fn : file->children()) {
|
2017-02-10 11:16:18 +01:00
|
|
|
if (auto pro = dynamic_cast<QmakeProFile *>(fn))
|
2017-02-28 18:41:02 +01:00
|
|
|
notifyChangedHelper(fileName, pro);
|
2017-02-10 12:49:04 +01:00
|
|
|
}
|
2008-12-02 18:14:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
void QmakeProject::notifyChanged(const FileName &name)
|
2008-12-02 18:14:06 +01:00
|
|
|
{
|
2017-02-28 18:41:02 +01:00
|
|
|
for (QmakeProject *project : s_projects) {
|
|
|
|
if (project->files(QmakeProject::SourceFiles).contains(name.toString()))
|
|
|
|
notifyChangedHelper(name, project->rootProFile());
|
2008-12-05 14:29:18 +01:00
|
|
|
}
|
2008-12-02 18:14:06 +01:00
|
|
|
}
|
2009-03-19 15:04:43 +01:00
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void QmakeProject::watchFolders(const QStringList &l, QmakePriFile *file)
|
2011-08-18 16:46:44 +02:00
|
|
|
{
|
|
|
|
if (l.isEmpty())
|
|
|
|
return;
|
|
|
|
if (!m_centralizedFolderWatcher)
|
|
|
|
m_centralizedFolderWatcher = new Internal::CentralizedFolderWatcher(this);
|
2017-02-10 11:16:18 +01:00
|
|
|
m_centralizedFolderWatcher->watchFolders(l, file);
|
2011-08-18 16:46:44 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void QmakeProject::unwatchFolders(const QStringList &l, QmakePriFile *file)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
2011-08-18 16:46:44 +02:00
|
|
|
if (m_centralizedFolderWatcher && !l.isEmpty())
|
2017-02-10 11:16:18 +01:00
|
|
|
m_centralizedFolderWatcher->unwatchFolders(l, file);
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
/// Centralized Folder Watcher
|
|
|
|
////////////
|
|
|
|
|
|
|
|
// All the folder have a trailing slash!
|
2013-10-29 14:22:31 +01:00
|
|
|
CentralizedFolderWatcher::CentralizedFolderWatcher(QmakeProject *parent)
|
2013-07-01 11:35:38 +02:00
|
|
|
: QObject(parent), m_project(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);
|
2016-01-07 18:01:04 +01:00
|
|
|
connect(&m_compressTimer, &QTimer::timeout, this, &CentralizedFolderWatcher::onTimer);
|
|
|
|
connect(&m_watcher, &QFileSystemWatcher::directoryChanged,
|
|
|
|
this, &CentralizedFolderWatcher::folderChanged);
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void CentralizedFolderWatcher::watchFolders(const QList<QString> &folders, QmakePriFile *file)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
|
|
|
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);
|
2017-02-10 11:16:18 +01:00
|
|
|
m_map.insert(folder, file);
|
2010-08-10 16:27:35 +02:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void CentralizedFolderWatcher::unwatchFolders(const QList<QString> &folders, QmakePriFile *file)
|
2010-08-10 16:27:35 +02:00
|
|
|
{
|
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);
|
2017-02-10 11:16:18 +01:00
|
|
|
m_map.remove(folder, file);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (!m_map.contains(folder))
|
2010-08-10 16:27:35 +02:00
|
|
|
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;
|
2017-02-10 11:15:06 +01:00
|
|
|
auto end = m_map.constEnd();
|
|
|
|
for (auto it = m_map.constBegin(); it != end; ++it) {
|
2010-08-10 16:27:35 +02:00
|
|
|
if (rwf.startsWith(it.key())) {
|
|
|
|
needToWatch = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!needToWatch) {
|
|
|
|
m_watcher.removePath(rwf);
|
|
|
|
toRemove << rwf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:07:11 +01:00
|
|
|
foreach (const QString &tr, toRemove)
|
2010-08-10 16:27:35 +02:00
|
|
|
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
|
|
|
{
|
|
|
|
// 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('/');
|
2013-07-01 11:35:38 +02:00
|
|
|
bool newOrRemovedFiles = false;
|
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);
|
2017-02-10 11:16:18 +01:00
|
|
|
QList<QmakePriFile *> files = m_map.values(dir);
|
|
|
|
if (!files.isEmpty()) {
|
2013-07-01 11:35:38 +02:00
|
|
|
// Collect all the files
|
2015-02-01 18:44:47 +02:00
|
|
|
QSet<FileName> newFiles;
|
2017-02-10 11:16:18 +01:00
|
|
|
newFiles += QmakePriFile::recursiveEnumerate(folder);
|
|
|
|
foreach (QmakePriFile *file, files)
|
|
|
|
newOrRemovedFiles = newOrRemovedFiles || file->folderChanged(folder, newFiles);
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
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-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()) {
|
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;
|
|
|
|
}
|
2013-07-01 11:35:38 +02:00
|
|
|
|
2017-03-27 12:12:38 +02:00
|
|
|
if (newOrRemovedFiles)
|
2013-07-01 11:35:38 +02:00
|
|
|
m_project->updateCodeModels();
|
2010-08-10 16:27:35 +02:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
bool QmakeProject::needsConfiguration() const
|
2011-10-28 10:15:04 +00:00
|
|
|
{
|
|
|
|
return targets().isEmpty();
|
|
|
|
}
|
|
|
|
|
2015-11-27 16:14:14 +01:00
|
|
|
void QmakeProject::configureAsExampleProject(const QSet<Core::Id> &platforms)
|
2012-03-06 13:14:42 +01:00
|
|
|
{
|
2013-08-13 10:52:57 +02:00
|
|
|
QList<const BuildInfo *> infoList;
|
2014-09-12 01:08:28 +02:00
|
|
|
QList<Kit *> kits = KitManager::kits();
|
2012-09-03 18:31:44 +02:00
|
|
|
foreach (Kit *k, kits) {
|
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
2015-12-09 13:57:35 +01:00
|
|
|
if (!version
|
|
|
|
|| (!platforms.isEmpty()
|
|
|
|
&& !Utils::contains(version->targetDeviceTypes(), [platforms](Core::Id i) { return platforms.contains(i); })))
|
2012-04-24 15:49:09 +02:00
|
|
|
continue;
|
|
|
|
|
2014-05-02 12:22:58 +02:00
|
|
|
IBuildConfigurationFactory *factory = IBuildConfigurationFactory::find(k, projectFilePath().toString());
|
2013-08-13 10:52:57 +02:00
|
|
|
if (!factory)
|
2012-04-24 15:49:09 +02:00
|
|
|
continue;
|
2014-05-02 12:22:58 +02:00
|
|
|
foreach (BuildInfo *info, factory->availableSetups(k, projectFilePath().toString()))
|
2013-08-13 10:52:57 +02:00
|
|
|
infoList << info;
|
2012-03-06 13:14:42 +01:00
|
|
|
}
|
2013-08-13 10:52:57 +02:00
|
|
|
setup(infoList);
|
|
|
|
qDeleteAll(infoList);
|
2012-03-06 13:14:42 +01:00
|
|
|
}
|
|
|
|
|
2014-07-11 12:04:30 +02:00
|
|
|
bool QmakeProject::requiresTargetPanel() const
|
2012-09-06 16:19:14 +02:00
|
|
|
{
|
2015-09-16 16:33:33 +02:00
|
|
|
return !targets().isEmpty();
|
2012-09-06 16:19:14 +02:00
|
|
|
}
|
|
|
|
|
2013-10-29 18:24:57 +01:00
|
|
|
// All the Qmake run configurations should share code.
|
2012-05-09 12:44:37 +02:00
|
|
|
// This is a rather suboptimal way to do that for disabledReason()
|
|
|
|
// but more pratical then duplicated the code everywhere
|
2015-02-02 00:37:38 +02:00
|
|
|
QString QmakeProject::disabledReasonForRunConfiguration(const FileName &proFilePath)
|
2012-05-09 12:44:37 +02:00
|
|
|
{
|
2015-02-02 00:37:38 +02:00
|
|
|
if (!proFilePath.exists())
|
2014-04-17 14:09:47 +02:00
|
|
|
return tr("The .pro file \"%1\" does not exist.")
|
2015-02-02 00:37:38 +02:00
|
|
|
.arg(proFilePath.fileName());
|
2012-05-09 12:44:37 +02:00
|
|
|
|
2016-01-08 12:49:00 +01:00
|
|
|
if (!rootProjectNode()) // Shutting down
|
2012-06-28 13:10:33 +02:00
|
|
|
return QString();
|
|
|
|
|
2016-01-08 12:49:00 +01:00
|
|
|
if (!rootProjectNode()->findProFileFor(proFilePath))
|
2014-04-17 14:09:47 +02:00
|
|
|
return tr("The .pro file \"%1\" is not part of the project.")
|
2015-02-02 00:37:38 +02:00
|
|
|
.arg(proFilePath.fileName());
|
2012-05-09 12:44:37 +02:00
|
|
|
|
2014-04-17 14:09:47 +02:00
|
|
|
return tr("The .pro file \"%1\" could not be parsed.")
|
2015-02-02 00:37:38 +02:00
|
|
|
.arg(proFilePath.fileName());
|
2012-05-09 12:44:37 +02:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QString QmakeProject::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
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::updateBuildSystemData()
|
2012-08-20 12:41:52 +02:00
|
|
|
{
|
2017-02-14 15:16:35 +01:00
|
|
|
Target *const target = activeTarget();
|
2012-08-20 12:41:52 +02:00
|
|
|
if (!target)
|
|
|
|
return;
|
2017-02-10 11:16:18 +01:00
|
|
|
const QmakeProFile *const file = rootProFile();
|
|
|
|
if (!file || file->parseInProgress())
|
2012-08-20 12:41:52 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
DeploymentData deploymentData;
|
2017-02-10 11:16:18 +01:00
|
|
|
collectData(file, deploymentData);
|
2012-08-20 12:41:52 +02:00
|
|
|
target->setDeploymentData(deploymentData);
|
|
|
|
|
|
|
|
BuildTargetInfoList appTargetList;
|
2017-02-10 11:16:18 +01:00
|
|
|
for (const QmakeProFile * const file : applicationProFiles()) {
|
|
|
|
appTargetList.list << BuildTargetInfo(file->targetInformation().target,
|
|
|
|
FileName::fromString(executableFor(file)),
|
|
|
|
file->filePath());
|
2014-08-07 15:53:54 +02:00
|
|
|
}
|
2012-08-20 12:41:52 +02:00
|
|
|
target->setApplicationTargets(appTargetList);
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void QmakeProject::collectData(const QmakeProFile *file, DeploymentData &deploymentData)
|
2012-08-20 12:41:52 +02:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
if (!file->isSubProjectDeployable(file->filePath()))
|
2012-08-20 12:41:52 +02:00
|
|
|
return;
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
const InstallsList &installsList = file->installsList();
|
|
|
|
for (const InstallsItem &item : installsList.items) {
|
2016-10-25 21:25:25 +02:00
|
|
|
if (!item.active)
|
|
|
|
continue;
|
|
|
|
foreach (const auto &localFile, item.files)
|
|
|
|
deploymentData.addFile(localFile.fileName, item.path);
|
2012-08-20 12:41:52 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
switch (file->projectType()) {
|
2017-02-09 13:56:22 +01:00
|
|
|
case ProjectType::ApplicationTemplate:
|
2012-08-20 12:41:52 +02:00
|
|
|
if (!installsList.targetPath.isEmpty())
|
2017-02-10 11:16:18 +01:00
|
|
|
collectApplicationData(file, deploymentData);
|
2012-08-20 12:41:52 +02:00
|
|
|
break;
|
2017-02-09 13:56:22 +01:00
|
|
|
case ProjectType::SharedLibraryTemplate:
|
|
|
|
case ProjectType::StaticLibraryTemplate:
|
2017-02-10 11:16:18 +01:00
|
|
|
collectLibraryData(file, deploymentData);
|
2012-08-20 12:41:52 +02:00
|
|
|
break;
|
2017-02-09 13:56:22 +01:00
|
|
|
case ProjectType::SubDirsTemplate:
|
2017-02-10 11:16:18 +01:00
|
|
|
for (const QmakePriFile *const subPriFile : file->subPriFilesExact()) {
|
|
|
|
auto subProFile = dynamic_cast<const QmakeProFile *>(subPriFile);
|
|
|
|
if (subProFile)
|
|
|
|
collectData(subProFile, deploymentData);
|
2012-08-20 12:41:52 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void QmakeProject::collectApplicationData(const QmakeProFile *file, DeploymentData &deploymentData)
|
2013-03-12 14:09:18 +01:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
QString executable = executableFor(file);
|
2013-03-12 14:09:18 +01:00
|
|
|
if (!executable.isEmpty())
|
2017-02-10 11:16:18 +01:00
|
|
|
deploymentData.addFile(executable, file->installsList().targetPath,
|
2013-03-12 14:09:18 +01:00
|
|
|
DeployableFile::TypeExecutable);
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
static FileName destDirFor(const TargetInformation &ti)
|
2014-04-08 17:28:39 +02:00
|
|
|
{
|
|
|
|
if (ti.destDir.isEmpty())
|
2017-02-10 11:16:18 +01:00
|
|
|
return ti.buildDir;
|
2017-02-15 13:44:13 +01:00
|
|
|
if (QDir::isRelativePath(ti.destDir.toString()))
|
2017-02-10 11:16:18 +01:00
|
|
|
return FileName::fromString(QDir::cleanPath(ti.buildDir.toString() + '/' + ti.destDir.toString()));
|
|
|
|
return ti.destDir;
|
2014-04-08 17:28:39 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void QmakeProject::collectLibraryData(const QmakeProFile *file, DeploymentData &deploymentData)
|
2012-08-20 12:41:52 +02:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
const QString targetPath = file->installsList().targetPath;
|
2012-08-20 12:41:52 +02:00
|
|
|
if (targetPath.isEmpty())
|
|
|
|
return;
|
2015-02-01 18:44:47 +02:00
|
|
|
const Kit * const kit = activeTarget()->kit();
|
2016-12-16 00:43:14 +01:00
|
|
|
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
2012-08-20 12:41:52 +02:00
|
|
|
if (!toolchain)
|
|
|
|
return;
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
TargetInformation ti = file->targetInformation();
|
2012-08-20 12:41:52 +02:00
|
|
|
QString targetFileName = ti.target;
|
2017-02-10 11:16:18 +01:00
|
|
|
const QStringList config = file->variableValue(Variable::Config);
|
2012-08-20 12:41:52 +02:00
|
|
|
const bool isStatic = config.contains(QLatin1String("static"));
|
|
|
|
const bool isPlugin = config.contains(QLatin1String("plugin"));
|
|
|
|
switch (toolchain->targetAbi().os()) {
|
2015-02-01 18:44:47 +02:00
|
|
|
case Abi::WindowsOS: {
|
2017-02-10 11:16:18 +01:00
|
|
|
QString targetVersionExt = file->singleVariableValue(Variable::TargetVersionExt);
|
2012-08-20 12:41:52 +02:00
|
|
|
if (targetVersionExt.isEmpty()) {
|
2017-02-10 11:16:18 +01:00
|
|
|
const QString version = file->singleVariableValue(Variable::Version);
|
2012-08-20 12:41:52 +02:00
|
|
|
if (!version.isEmpty()) {
|
|
|
|
targetVersionExt = version.left(version.indexOf(QLatin1Char('.')));
|
|
|
|
if (targetVersionExt == QLatin1String("0"))
|
|
|
|
targetVersionExt.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
targetFileName += targetVersionExt + QLatin1Char('.');
|
|
|
|
targetFileName += QLatin1String(isStatic ? "lib" : "dll");
|
2017-02-10 11:16:18 +01:00
|
|
|
deploymentData.addFile(destDirFor(ti).toString() + '/' + targetFileName, targetPath);
|
2012-08-20 12:41:52 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-07-25 18:39:16 -07:00
|
|
|
case Abi::DarwinOS: {
|
2017-02-10 11:16:18 +01:00
|
|
|
FileName destDir = destDirFor(ti);
|
2012-11-26 15:09:56 +02:00
|
|
|
if (config.contains(QLatin1String("lib_bundle"))) {
|
2017-02-10 11:16:18 +01:00
|
|
|
destDir.appendPath(ti.target + ".framework");
|
2012-08-20 12:41:52 +02:00
|
|
|
} else {
|
2016-10-05 13:25:35 +03:00
|
|
|
if (!(isPlugin && config.contains(QLatin1String("no_plugin_name_prefix"))))
|
|
|
|
targetFileName.prepend(QLatin1String("lib"));
|
|
|
|
|
2012-08-20 12:41:52 +02:00
|
|
|
if (!isPlugin) {
|
|
|
|
targetFileName += QLatin1Char('.');
|
2017-02-10 11:16:18 +01:00
|
|
|
const QString version = file->singleVariableValue(Variable::Version);
|
2012-08-20 12:41:52 +02:00
|
|
|
QString majorVersion = version.left(version.indexOf(QLatin1Char('.')));
|
|
|
|
if (majorVersion.isEmpty())
|
|
|
|
majorVersion = QLatin1String("1");
|
|
|
|
targetFileName += majorVersion;
|
|
|
|
}
|
|
|
|
targetFileName += QLatin1Char('.');
|
2017-02-10 11:16:18 +01:00
|
|
|
targetFileName += file->singleVariableValue(isStatic
|
2017-02-09 14:42:04 +01:00
|
|
|
? Variable::StaticLibExtension : Variable::ShLibExtension);
|
2012-08-20 12:41:52 +02:00
|
|
|
}
|
2017-02-10 11:16:18 +01:00
|
|
|
deploymentData.addFile(destDir.toString() + '/' + targetFileName, targetPath);
|
2012-08-20 12:41:52 +02:00
|
|
|
break;
|
2013-03-12 14:09:18 +01:00
|
|
|
}
|
2015-02-01 18:44:47 +02:00
|
|
|
case Abi::LinuxOS:
|
|
|
|
case Abi::BsdOS:
|
|
|
|
case Abi::UnixOS:
|
2016-10-05 13:25:35 +03:00
|
|
|
if (!(isPlugin && config.contains(QLatin1String("no_plugin_name_prefix"))))
|
|
|
|
targetFileName.prepend(QLatin1String("lib"));
|
|
|
|
|
2012-08-20 12:41:52 +02:00
|
|
|
targetFileName += QLatin1Char('.');
|
|
|
|
if (isStatic) {
|
|
|
|
targetFileName += QLatin1Char('a');
|
|
|
|
} else {
|
|
|
|
targetFileName += QLatin1String("so");
|
2017-02-10 11:16:18 +01:00
|
|
|
deploymentData.addFile(destDirFor(ti).toString() + '/' + targetFileName, targetPath);
|
2012-08-20 12:41:52 +02:00
|
|
|
if (!isPlugin) {
|
2017-02-10 11:16:18 +01:00
|
|
|
QString version = file->singleVariableValue(Variable::Version);
|
2012-08-20 12:41:52 +02:00
|
|
|
if (version.isEmpty())
|
|
|
|
version = QLatin1String("1.0.0");
|
|
|
|
targetFileName += QLatin1Char('.');
|
|
|
|
while (true) {
|
2017-02-10 11:16:18 +01:00
|
|
|
deploymentData.addFile(destDirFor(ti).toString() + '/'
|
2012-08-20 12:41:52 +02:00
|
|
|
+ targetFileName + version, targetPath);
|
|
|
|
const QString tmpVersion = version.left(version.lastIndexOf(QLatin1Char('.')));
|
|
|
|
if (tmpVersion == version)
|
|
|
|
break;
|
|
|
|
version = tmpVersion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-20 17:23:07 +02:00
|
|
|
bool QmakeProject::matchesKit(const Kit *kit)
|
|
|
|
{
|
2015-02-01 18:44:47 +02:00
|
|
|
FileName filePath = projectFilePath();
|
2014-10-20 17:23:07 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
2017-01-11 14:43:48 +01:00
|
|
|
|
|
|
|
return QtSupport::QtVersionManager::version([&filePath, version](const QtSupport::BaseQtVersion *v) {
|
|
|
|
return v->isValid() && v->isSubProject(filePath) && v == version;
|
|
|
|
});
|
2014-10-20 17:23:07 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
static Utils::FileName getFullPathOf(const QmakeProFile *pro, Variable variable,
|
2016-12-23 00:13:28 +02:00
|
|
|
const BuildConfiguration *bc)
|
2016-09-23 15:53:31 +02:00
|
|
|
{
|
2016-12-23 00:13:28 +02:00
|
|
|
// Take last non-flag value, to cover e.g. '@echo $< && $$QMAKE_CC' or 'ccache gcc'
|
|
|
|
const QStringList values = Utils::filtered(pro->variableValue(variable),
|
|
|
|
[](const QString &value) {
|
|
|
|
return !value.startsWith('-');
|
|
|
|
});
|
|
|
|
if (values.isEmpty())
|
|
|
|
return Utils::FileName();
|
|
|
|
const QString exe = values.last();
|
2016-09-23 15:53:31 +02:00
|
|
|
QTC_ASSERT(bc, return Utils::FileName::fromString(exe));
|
|
|
|
QFileInfo fi(exe);
|
|
|
|
if (fi.isAbsolute())
|
|
|
|
return Utils::FileName::fromString(exe);
|
|
|
|
|
|
|
|
return bc->environment().searchInPath(exe);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QmakeProject::testToolChain(ToolChain *tc, const Utils::FileName &path) const
|
|
|
|
{
|
|
|
|
if (!tc || path.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const Utils::FileName expected = tc->compilerCommand();
|
2017-03-23 17:17:58 +01:00
|
|
|
|
|
|
|
Environment env = Environment::systemEnvironment();
|
|
|
|
if (Target *t = activeTarget()) {
|
|
|
|
if (BuildConfiguration *bc = t->activeBuildConfiguration())
|
|
|
|
env = bc->environment();
|
|
|
|
else
|
|
|
|
t->kit()->addToEnvironment(env);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (env.isSameExecutable(path.toString(), expected.toString())) {
|
2016-09-23 15:53:31 +02:00
|
|
|
const QPair<Utils::FileName, Utils::FileName> pair = qMakePair(expected, path);
|
|
|
|
if (!m_toolChainWarnings.contains(pair)) {
|
|
|
|
TaskHub::addTask(Task(Task::Warning,
|
|
|
|
QCoreApplication::translate("QmakeProjectManager", "\"%1\" is used by qmake, but \"%2\" is configured in the kit.\n"
|
|
|
|
"Please update your kit or choose a mkspec for qmake that matches your target environment better.").
|
|
|
|
arg(path.toUserOutput()).arg(expected.toUserOutput()),
|
|
|
|
Utils::FileName(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
m_toolChainWarnings.insert(pair);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
void QmakeProject::warnOnToolChainMismatch(const QmakeProFile *pro) const
|
2016-09-23 15:53:31 +02:00
|
|
|
{
|
2016-11-29 14:33:31 +01:00
|
|
|
const Target *t = activeTarget();
|
2016-09-23 15:53:31 +02:00
|
|
|
const BuildConfiguration *bc = t ? t->activeBuildConfiguration() : nullptr;
|
|
|
|
if (!bc)
|
|
|
|
return;
|
|
|
|
|
2016-12-16 00:43:14 +01:00
|
|
|
testToolChain(ToolChainKitInformation::toolChain(t->kit(), ProjectExplorer::Constants::C_LANGUAGE_ID),
|
2017-02-09 14:42:04 +01:00
|
|
|
getFullPathOf(pro, Variable::QmakeCc, bc));
|
2016-12-16 00:43:14 +01:00
|
|
|
testToolChain(ToolChainKitInformation::toolChain(t->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID),
|
2017-02-09 14:42:04 +01:00
|
|
|
getFullPathOf(pro, Variable::QmakeCxx, bc));
|
2016-09-23 15:53:31 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
QString QmakeProject::executableFor(const QmakeProFile *file)
|
2013-03-12 14:09:18 +01:00
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
const Kit *const kit = activeTarget() ? activeTarget()->kit() : nullptr;
|
|
|
|
const ToolChain *const tc = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
|
|
if (!tc)
|
2013-03-12 14:09:18 +01:00
|
|
|
return QString();
|
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
TargetInformation ti = file->targetInformation();
|
2013-12-23 15:01:10 +02:00
|
|
|
QString target;
|
2013-03-12 14:09:18 +01:00
|
|
|
|
2017-02-10 11:16:18 +01:00
|
|
|
if (tc->targetAbi().os() == Abi::DarwinOS) {
|
|
|
|
if (file->variableValue(Variable::Config).contains(QLatin1String("app_bundle")))
|
2013-12-23 15:01:10 +02:00
|
|
|
target = ti.target + QLatin1String(".app/Contents/MacOS/") + ti.target;
|
2017-02-10 11:16:18 +01:00
|
|
|
} else {
|
|
|
|
QString extension = file->singleVariableValue(Variable::TargetExt);
|
2013-12-23 15:01:10 +02:00
|
|
|
target = ti.target + extension;
|
2013-03-12 14:09:18 +01:00
|
|
|
}
|
2017-02-10 11:16:18 +01:00
|
|
|
return QDir(destDirFor(ti).toString()).absoluteFilePath(target);
|
2013-03-12 14:09:18 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
void QmakeProject::emitBuildDirectoryInitialized()
|
2012-07-13 17:14:42 +02:00
|
|
|
{
|
|
|
|
emit buildDirectoryInitialized();
|
|
|
|
}
|
2013-08-13 10:52:57 +02:00
|
|
|
|
2016-10-05 08:31:16 +02:00
|
|
|
ProjectImporter *QmakeProject::projectImporter() const
|
2013-08-13 10:52:57 +02:00
|
|
|
{
|
2016-10-05 08:31:16 +02:00
|
|
|
if (!m_projectImporter)
|
2016-11-16 11:20:04 +01:00
|
|
|
m_projectImporter = new QmakeProjectImporter(projectFilePath());
|
2016-10-05 08:31:16 +02:00
|
|
|
return m_projectImporter;
|
2013-08-13 10:52:57 +02:00
|
|
|
}
|
|
|
|
|
2014-11-18 17:05:09 +01:00
|
|
|
QmakeProject::AsyncUpdateState QmakeProject::asyncUpdateState() const
|
|
|
|
{
|
|
|
|
return m_asyncUpdateState;
|
|
|
|
}
|
|
|
|
|
2017-01-27 14:28:49 +01:00
|
|
|
QString QmakeProject::mapProFilePathToTarget(const FileName &proFilePath)
|
|
|
|
{
|
2017-02-10 11:16:18 +01:00
|
|
|
const QmakeProFile *pro = rootProFile()->findProFile(proFilePath);
|
|
|
|
return pro ? pro->targetInformation().target : QString();
|
2017-01-27 14:28:49 +01:00
|
|
|
}
|
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
} // namespace QmakeProjectManager
|
2011-08-18 16:55:45 +02:00
|
|
|
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakeproject.moc"
|