2013-01-30 18:19:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
2013-01-30 18:19:31 +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.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsproject.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsbuildconfiguration.h"
|
2013-02-06 11:28:33 +01:00
|
|
|
#include "qbslogsink.h"
|
2016-03-11 11:21:11 +01:00
|
|
|
#include "qbspmlogging.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
#include "qbsprojectfile.h"
|
2014-11-11 11:03:17 +01:00
|
|
|
#include "qbsprojectmanager.h"
|
2014-06-16 14:42:21 +02:00
|
|
|
#include "qbsprojectparser.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
#include "qbsprojectmanagerconstants.h"
|
|
|
|
|
#include "qbsnodes.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/documentmanager.h>
|
|
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <coreplugin/id.h>
|
2014-08-18 16:30:43 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/iversioncontrol.h>
|
|
|
|
|
#include <coreplugin/vcsmanager.h>
|
2014-07-18 15:46:24 +02:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2014-09-15 00:12:27 +02:00
|
|
|
#include <cpptools/cppmodelmanager.h>
|
2016-01-12 12:51:33 +01:00
|
|
|
#include <cpptools/projectpartbuilder.h>
|
2016-01-15 16:12:54 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <projectexplorer/buildenvironmentwidget.h>
|
2014-02-25 13:50:56 +01:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2013-09-02 10:12:37 +02:00
|
|
|
#include <projectexplorer/buildtargetinfo.h>
|
|
|
|
|
#include <projectexplorer/deploymentdata.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <projectexplorer/kit.h>
|
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/taskhub.h>
|
2013-03-26 15:06:51 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2013-03-27 09:15:01 +01:00
|
|
|
#include <projectexplorer/headerpath.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2016-01-15 16:12:54 +01:00
|
|
|
#include <cpptools/generatedcodemodelsupport.h>
|
2012-12-06 17:20:58 +01:00
|
|
|
#include <qmljstools/qmljsmodelmanager.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
2014-03-28 13:26:46 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2014-07-18 15:46:24 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
#include <qbs.h>
|
|
|
|
|
|
2014-02-25 16:39:09 +01:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDir>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <QFileInfo>
|
2014-08-18 16:30:43 +02:00
|
|
|
#include <QMessageBox>
|
2014-07-22 09:49:51 +02:00
|
|
|
#include <QVariantMap>
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-08-29 17:56:28 +02:00
|
|
|
using namespace Core;
|
2013-08-29 18:25:59 +02:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
2013-08-29 17:56:28 +02:00
|
|
|
|
|
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// Constants:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
static const char CONFIG_CPP_MODULE[] = "cpp";
|
2014-01-14 16:48:19 +01:00
|
|
|
static const char CONFIG_CXXFLAGS[] = "cxxFlags";
|
|
|
|
|
static const char CONFIG_CFLAGS[] = "cFlags";
|
2013-02-20 17:40:52 +01:00
|
|
|
static const char CONFIG_DEFINES[] = "defines";
|
|
|
|
|
static const char CONFIG_INCLUDEPATHS[] = "includePaths";
|
2014-07-23 10:48:29 +02:00
|
|
|
static const char CONFIG_SYSTEM_INCLUDEPATHS[] = "systemIncludePaths";
|
2013-02-20 17:40:52 +01:00
|
|
|
static const char CONFIG_FRAMEWORKPATHS[] = "frameworkPaths";
|
2014-07-23 10:48:29 +02:00
|
|
|
static const char CONFIG_SYSTEM_FRAMEWORKPATHS[] = "systemFrameworkPaths";
|
2013-02-20 17:40:52 +01:00
|
|
|
static const char CONFIG_PRECOMPILEDHEADER[] = "precompiledHeader";
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsProject:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
|
2013-05-16 16:20:06 +02:00
|
|
|
m_projectName(QFileInfo(fileName).completeBaseName()),
|
2014-06-16 14:42:21 +02:00
|
|
|
m_qbsProjectParser(0),
|
2013-01-30 18:19:31 +01:00
|
|
|
m_qbsUpdateFutureInterface(0),
|
2014-07-11 12:44:12 +02:00
|
|
|
m_parsingScheduled(false),
|
2014-07-14 14:22:27 +02:00
|
|
|
m_cancelStatus(CancelStatusNone),
|
2016-03-02 13:04:48 +01:00
|
|
|
m_currentBc(0),
|
|
|
|
|
m_extraCompilersPending(false)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2013-06-11 18:10:42 +02:00
|
|
|
m_parsingDelay.setInterval(1000); // delay parsing by 1s.
|
2013-06-06 18:45:53 +02:00
|
|
|
|
2013-09-27 16:30:20 +02:00
|
|
|
setId(Constants::PROJECT_ID);
|
2016-01-08 11:31:06 +01:00
|
|
|
setProjectManager(manager);
|
2016-01-08 12:12:27 +01:00
|
|
|
setDocument(new QbsProjectFile(this, fileName));
|
2016-01-08 11:09:37 +01:00
|
|
|
DocumentManager::addDocument(document());
|
2016-01-08 12:49:00 +01:00
|
|
|
setRootProjectNode(new QbsRootProjectNode(this));
|
2016-01-08 11:09:37 +01:00
|
|
|
|
2013-08-29 17:56:28 +02:00
|
|
|
setProjectContext(Context(Constants::PROJECT_ID));
|
|
|
|
|
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX));
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(this, &Project::activeTargetChanged, this, &QbsProject::changeActiveTarget);
|
|
|
|
|
connect(this, &Project::addedTarget, this, &QbsProject::targetWasAdded);
|
2016-07-15 11:02:10 +02:00
|
|
|
connect(this, &Project::removedTarget, this, &QbsProject::targetWasRemoved);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(this, &Project::environmentChanged, this, &QbsProject::delayParsing);
|
2013-06-06 18:45:53 +02:00
|
|
|
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(&m_parsingDelay, &QTimer::timeout, this, &QbsProject::startParsing);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsProject::~QbsProject()
|
|
|
|
|
{
|
|
|
|
|
m_codeModelFuture.cancel();
|
2014-06-16 14:42:21 +02:00
|
|
|
delete m_qbsProjectParser;
|
2014-08-22 09:39:38 +02:00
|
|
|
if (m_qbsUpdateFutureInterface) {
|
|
|
|
|
m_qbsUpdateFutureInterface->reportCanceled();
|
2014-09-13 21:25:32 +03:00
|
|
|
m_qbsUpdateFutureInterface->reportFinished();
|
2014-08-22 09:39:38 +02:00
|
|
|
delete m_qbsUpdateFutureInterface;
|
|
|
|
|
m_qbsUpdateFutureInterface = 0;
|
|
|
|
|
}
|
2016-01-15 16:12:54 +01:00
|
|
|
qDeleteAll(m_extraCompilers);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsProject::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_projectName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsManager *QbsProject::projectManager() const
|
|
|
|
|
{
|
2016-01-08 11:31:06 +01:00
|
|
|
return static_cast<QbsManager *>(Project::projectManager());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-08 12:49:00 +01:00
|
|
|
QbsRootProjectNode *QbsProject::rootProjectNode() const
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2016-01-08 12:49:00 +01:00
|
|
|
return static_cast<QbsRootProjectNode *>(Project::rootProjectNode());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-02 10:20:43 +02:00
|
|
|
void QbsProject::projectLoaded()
|
|
|
|
|
{
|
|
|
|
|
m_parsingDelay.start(0);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-29 08:51:08 +02:00
|
|
|
static void collectFilesForProject(const qbs::ProjectData &project, Project::FilesMode mode,
|
|
|
|
|
QSet<QString> &result)
|
2013-10-08 14:17:46 +02:00
|
|
|
{
|
2016-09-29 08:51:08 +02:00
|
|
|
if (mode & Project::SourceFiles)
|
|
|
|
|
result.insert(project.location().filePath());
|
|
|
|
|
|
2013-10-08 14:17:46 +02:00
|
|
|
foreach (const qbs::ProductData &prd, project.products()) {
|
2016-09-29 08:51:08 +02:00
|
|
|
if (mode & Project::SourceFiles) {
|
|
|
|
|
foreach (const qbs::GroupData &grp, prd.groups()) {
|
|
|
|
|
foreach (const QString &file, grp.allFilePaths())
|
|
|
|
|
result.insert(file);
|
|
|
|
|
result.insert(grp.location().filePath());
|
|
|
|
|
}
|
|
|
|
|
result.insert(prd.location().filePath());
|
|
|
|
|
}
|
|
|
|
|
if (mode & Project::GeneratedFiles) {
|
|
|
|
|
foreach (const qbs::ProductData &prd, project.products()) {
|
|
|
|
|
foreach (const qbs::ArtifactData &artifact, prd.generatedArtifacts())
|
|
|
|
|
result.insert(artifact.filePath());
|
|
|
|
|
}
|
2013-10-08 14:17:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-09-29 08:51:08 +02:00
|
|
|
|
2013-10-08 14:17:46 +02:00
|
|
|
foreach (const qbs::ProjectData &subProject, project.subProjects())
|
2016-09-29 08:51:08 +02:00
|
|
|
collectFilesForProject(subProject, mode, result);
|
2013-10-08 14:17:46 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 18:25:59 +02:00
|
|
|
QStringList QbsProject::files(Project::FilesMode fileMode) const
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2016-09-29 08:51:08 +02:00
|
|
|
qCDebug(qbsPmLog) << Q_FUNC_INFO << fileMode << m_qbsProject.isValid() << isParsing();
|
2014-09-12 17:38:12 +02:00
|
|
|
if (!m_qbsProject.isValid() || isParsing())
|
2013-10-08 14:17:46 +02:00
|
|
|
return QStringList();
|
2013-03-05 11:23:00 +01:00
|
|
|
QSet<QString> result;
|
2016-09-29 08:51:08 +02:00
|
|
|
collectFilesForProject(m_projectData, fileMode, result);
|
2014-09-12 17:38:12 +02:00
|
|
|
result.unite(m_qbsProject.buildSystemFiles());
|
2016-03-11 11:21:11 +01:00
|
|
|
qCDebug(qbsPmLog) << "file count:" << result.count();
|
2013-03-05 11:23:00 +01:00
|
|
|
return result.toList();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-01 16:03:58 +01:00
|
|
|
QStringList QbsProject::filesGeneratedFrom(const QString &sourceFile) const
|
|
|
|
|
{
|
|
|
|
|
QStringList generated;
|
|
|
|
|
foreach (const qbs::ProductData &data, m_projectData.allProducts())
|
|
|
|
|
generated << m_qbsProject.generatedFiles(data, sourceFile, false);
|
|
|
|
|
return generated;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 12:18:29 +02:00
|
|
|
bool QbsProject::isProjectEditable() const
|
|
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
return m_qbsProject.isValid() && !isParsing() && !BuildManager::isBuilding();
|
2014-07-24 12:18:29 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:46:24 +02:00
|
|
|
class ChangeExpector
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-02-03 23:56:02 +02:00
|
|
|
ChangeExpector(const QString &filePath, const QSet<IDocument *> &documents)
|
2014-07-18 15:46:24 +02:00
|
|
|
: m_document(0)
|
|
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
foreach (IDocument * const doc, documents) {
|
2014-12-21 21:54:30 +02:00
|
|
|
if (doc->filePath().toString() == filePath) {
|
2014-07-18 15:46:24 +02:00
|
|
|
m_document = doc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QTC_ASSERT(m_document, return);
|
2015-02-03 23:56:02 +02:00
|
|
|
DocumentManager::expectFileChange(filePath);
|
|
|
|
|
m_wasInDocumentManager = DocumentManager::removeDocument(m_document);
|
2014-07-18 15:46:24 +02:00
|
|
|
QTC_CHECK(m_wasInDocumentManager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~ChangeExpector()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_document, return);
|
2015-02-03 23:56:02 +02:00
|
|
|
DocumentManager::addDocument(m_document);
|
|
|
|
|
DocumentManager::unexpectFileChange(m_document->filePath().toString());
|
2014-07-18 15:46:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2015-02-03 23:56:02 +02:00
|
|
|
IDocument *m_document;
|
2014-07-18 15:46:24 +02:00
|
|
|
bool m_wasInDocumentManager;
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-18 16:30:43 +02:00
|
|
|
bool QbsProject::ensureWriteableQbsFile(const QString &file)
|
|
|
|
|
{
|
|
|
|
|
// Ensure that the file is not read only
|
|
|
|
|
QFileInfo fi(file);
|
|
|
|
|
if (!fi.isWritable()) {
|
|
|
|
|
// Try via vcs manager
|
2015-02-03 23:56:02 +02:00
|
|
|
IVersionControl *versionControl =
|
|
|
|
|
VcsManager::findVersionControlForDirectory(fi.absolutePath());
|
2014-08-18 16:30:43 +02:00
|
|
|
if (!versionControl || !versionControl->vcsOpen(file)) {
|
|
|
|
|
bool makeWritable = QFile::setPermissions(file, fi.permissions() | QFile::WriteUser);
|
|
|
|
|
if (!makeWritable) {
|
2015-02-03 23:56:02 +02:00
|
|
|
QMessageBox::warning(ICore::mainWindow(),
|
2016-11-04 10:42:39 +01:00
|
|
|
tr("Failed"),
|
2014-08-18 16:30:43 +02:00
|
|
|
tr("Could not write project file %1.").arg(file));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-10 16:41:59 +01:00
|
|
|
qbs::GroupData QbsProject::reRetrieveGroupData(const qbs::ProductData &oldProduct,
|
|
|
|
|
const qbs::GroupData &oldGroup)
|
|
|
|
|
{
|
|
|
|
|
qbs::GroupData newGroup;
|
|
|
|
|
foreach (const qbs::ProductData &pd, m_projectData.allProducts()) {
|
|
|
|
|
if (uniqueProductName(pd) == uniqueProductName(oldProduct)) {
|
|
|
|
|
foreach (const qbs::GroupData &gd, pd.groups()) {
|
|
|
|
|
if (gd.location() == oldGroup.location()) {
|
|
|
|
|
newGroup = gd;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QTC_CHECK(newGroup.isValid());
|
|
|
|
|
return newGroup;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-18 15:46:24 +02:00
|
|
|
bool QbsProject::addFilesToProduct(QbsBaseProjectNode *node, const QStringList &filePaths,
|
|
|
|
|
const qbs::ProductData &productData, const qbs::GroupData &groupData, QStringList *notAdded)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_qbsProject.isValid(), return false);
|
|
|
|
|
QStringList allPaths = groupData.allFilePaths();
|
2014-11-07 13:40:49 +01:00
|
|
|
const QString productFilePath = productData.location().filePath();
|
2014-07-18 15:46:24 +02:00
|
|
|
ChangeExpector expector(productFilePath, m_qbsDocuments);
|
2014-08-18 16:30:43 +02:00
|
|
|
ensureWriteableQbsFile(productFilePath);
|
2014-07-18 15:46:24 +02:00
|
|
|
foreach (const QString &path, filePaths) {
|
|
|
|
|
qbs::ErrorInfo err = m_qbsProject.addFiles(productData, groupData, QStringList() << path);
|
|
|
|
|
if (err.hasError()) {
|
2015-02-03 23:56:02 +02:00
|
|
|
MessageManager::write(err.toString());
|
2014-07-18 15:46:24 +02:00
|
|
|
*notAdded += path;
|
|
|
|
|
} else {
|
|
|
|
|
allPaths += path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (notAdded->count() != filePaths.count()) {
|
|
|
|
|
m_projectData = m_qbsProject.projectData();
|
2015-03-10 16:41:59 +01:00
|
|
|
QbsGroupNode::setupFiles(node, reRetrieveGroupData(productData, groupData),
|
2016-07-28 17:41:58 +02:00
|
|
|
allPaths, QFileInfo(productFilePath).absolutePath(), true, false);
|
2016-01-08 12:49:00 +01:00
|
|
|
rootProjectNode()->update();
|
2015-04-10 16:17:55 +02:00
|
|
|
emit fileListChanged();
|
2014-07-18 15:46:24 +02:00
|
|
|
}
|
|
|
|
|
return notAdded->isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsProject::removeFilesFromProduct(QbsBaseProjectNode *node, const QStringList &filePaths,
|
|
|
|
|
const qbs::ProductData &productData, const qbs::GroupData &groupData,
|
|
|
|
|
QStringList *notRemoved)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_qbsProject.isValid(), return false);
|
|
|
|
|
QStringList allPaths = groupData.allFilePaths();
|
2014-11-07 13:40:49 +01:00
|
|
|
const QString productFilePath = productData.location().filePath();
|
2014-07-18 15:46:24 +02:00
|
|
|
ChangeExpector expector(productFilePath, m_qbsDocuments);
|
2014-08-18 16:30:43 +02:00
|
|
|
ensureWriteableQbsFile(productFilePath);
|
2014-07-18 15:46:24 +02:00
|
|
|
foreach (const QString &path, filePaths) {
|
|
|
|
|
qbs::ErrorInfo err
|
|
|
|
|
= m_qbsProject.removeFiles(productData, groupData, QStringList() << path);
|
|
|
|
|
if (err.hasError()) {
|
2015-02-03 23:56:02 +02:00
|
|
|
MessageManager::write(err.toString());
|
2014-07-18 15:46:24 +02:00
|
|
|
*notRemoved += path;
|
|
|
|
|
} else {
|
|
|
|
|
allPaths.removeOne(path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (notRemoved->count() != filePaths.count()) {
|
|
|
|
|
m_projectData = m_qbsProject.projectData();
|
2015-03-10 16:41:59 +01:00
|
|
|
QbsGroupNode::setupFiles(node, reRetrieveGroupData(productData, groupData), allPaths,
|
2016-07-28 17:41:58 +02:00
|
|
|
QFileInfo(productFilePath).absolutePath(), true, false);
|
2016-01-08 12:49:00 +01:00
|
|
|
rootProjectNode()->update();
|
2015-04-10 16:17:55 +02:00
|
|
|
emit fileListChanged();
|
2014-07-18 15:46:24 +02:00
|
|
|
}
|
|
|
|
|
return notRemoved->isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 17:12:03 +02:00
|
|
|
bool QbsProject::renameFileInProduct(QbsBaseProjectNode *node, const QString &oldPath,
|
|
|
|
|
const QString &newPath, const qbs::ProductData &productData,
|
|
|
|
|
const qbs::GroupData &groupData)
|
|
|
|
|
{
|
|
|
|
|
if (newPath.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
QStringList dummy;
|
|
|
|
|
if (!removeFilesFromProduct(node, QStringList() << oldPath, productData, groupData, &dummy))
|
|
|
|
|
return false;
|
|
|
|
|
qbs::ProductData newProductData;
|
|
|
|
|
foreach (const qbs::ProductData &p, m_projectData.allProducts()) {
|
|
|
|
|
if (uniqueProductName(p) == uniqueProductName(productData)) {
|
|
|
|
|
newProductData = p;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!newProductData.isValid())
|
|
|
|
|
return false;
|
|
|
|
|
qbs::GroupData newGroupData;
|
|
|
|
|
foreach (const qbs::GroupData &g, newProductData.groups()) {
|
|
|
|
|
if (g.name() == groupData.name()) {
|
|
|
|
|
newGroupData = g;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!newGroupData.isValid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return addFilesToProduct(node, QStringList() << newPath, newProductData, newGroupData, &dummy);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
void QbsProject::invalidate()
|
|
|
|
|
{
|
|
|
|
|
prepareForParsing();
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-17 16:26:23 +01:00
|
|
|
qbs::BuildJob *QbsProject::build(const qbs::BuildOptions &opts, QStringList productNames,
|
|
|
|
|
QString &error)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-11-17 16:26:23 +01:00
|
|
|
QTC_ASSERT(qbsProject().isValid(), return 0);
|
|
|
|
|
QTC_ASSERT(!isParsing(), return 0);
|
|
|
|
|
|
|
|
|
|
if (productNames.isEmpty())
|
2013-09-06 18:02:46 +02:00
|
|
|
return qbsProject().buildAllProducts(opts);
|
2014-11-17 16:26:23 +01:00
|
|
|
|
|
|
|
|
QList<qbs::ProductData> products;
|
|
|
|
|
foreach (const QString &productName, productNames) {
|
|
|
|
|
bool found = false;
|
|
|
|
|
foreach (const qbs::ProductData &data, qbsProjectData().allProducts()) {
|
|
|
|
|
if (uniqueProductName(data) == productName) {
|
|
|
|
|
found = true;
|
|
|
|
|
products.append(data);
|
|
|
|
|
break;
|
2013-06-10 15:40:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2014-11-17 16:26:23 +01:00
|
|
|
if (!found) {
|
2014-11-26 14:11:12 +01:00
|
|
|
error = tr("Cannot build: Selected products do not exist anymore.");
|
2014-11-17 16:26:23 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
2013-06-10 15:40:18 +02:00
|
|
|
}
|
2014-11-17 16:26:23 +01:00
|
|
|
|
|
|
|
|
return qbsProject().buildSomeProducts(products, opts);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-02-28 13:06:15 +01:00
|
|
|
qbs::CleanJob *QbsProject::clean(const qbs::CleanOptions &opts)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2013-09-06 18:02:46 +02:00
|
|
|
if (!qbsProject().isValid())
|
2013-01-30 18:19:31 +01:00
|
|
|
return 0;
|
2013-09-06 18:02:46 +02:00
|
|
|
return qbsProject().cleanAllProducts(opts);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-12 16:19:52 +02:00
|
|
|
qbs::InstallJob *QbsProject::install(const qbs::InstallOptions &opts)
|
|
|
|
|
{
|
2013-09-06 18:02:46 +02:00
|
|
|
if (!qbsProject().isValid())
|
2013-04-12 16:19:52 +02:00
|
|
|
return 0;
|
2013-09-06 18:02:46 +02:00
|
|
|
return qbsProject().installAllProducts(opts);
|
2013-04-12 16:19:52 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-29 18:25:59 +02:00
|
|
|
QString QbsProject::profileForTarget(const Target *t) const
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2016-01-08 11:31:06 +01:00
|
|
|
return projectManager()->profileForKit(t->kit());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsProject::isParsing() const
|
|
|
|
|
{
|
|
|
|
|
return m_qbsUpdateFutureInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsProject::hasParseResult() const
|
|
|
|
|
{
|
2013-09-06 18:02:46 +02:00
|
|
|
return qbsProject().isValid();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-06 18:02:46 +02:00
|
|
|
qbs::Project QbsProject::qbsProject() const
|
2013-04-16 13:14:07 +02:00
|
|
|
{
|
2014-07-10 17:01:54 +02:00
|
|
|
return m_qbsProject;
|
2013-04-16 13:14:07 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-22 09:49:51 +02:00
|
|
|
qbs::ProjectData QbsProject::qbsProjectData() const
|
2013-04-16 13:14:07 +02:00
|
|
|
{
|
2014-07-22 09:49:51 +02:00
|
|
|
return m_projectData;
|
2013-04-16 13:14:07 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-06 11:16:41 +02:00
|
|
|
bool QbsProject::needsSpecialDeployment() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-11 11:21:11 +01:00
|
|
|
bool QbsProject::checkCancelStatus()
|
|
|
|
|
{
|
|
|
|
|
const CancelStatus cancelStatus = m_cancelStatus;
|
|
|
|
|
m_cancelStatus = CancelStatusNone;
|
|
|
|
|
if (cancelStatus != CancelStatusCancelingForReparse)
|
|
|
|
|
return false;
|
|
|
|
|
qCDebug(qbsPmLog) << "Cancel request while parsing, starting re-parse";
|
|
|
|
|
m_qbsProjectParser->deleteLater();
|
|
|
|
|
m_qbsProjectParser = 0;
|
|
|
|
|
parseCurrentBuildConfiguration();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-11 17:53:26 +01:00
|
|
|
void QbsProject::updateAfterParse()
|
2016-03-08 14:00:56 +01:00
|
|
|
{
|
2016-03-11 17:53:26 +01:00
|
|
|
qCDebug(qbsPmLog) << "Updating data after parse";
|
2016-03-11 11:21:11 +01:00
|
|
|
rootProjectNode()->update();
|
2016-04-25 14:45:52 +02:00
|
|
|
updateDocuments(m_qbsProject.buildSystemFiles());
|
2016-03-11 17:53:26 +01:00
|
|
|
updateBuildTargetData();
|
2016-03-11 11:21:11 +01:00
|
|
|
updateCppCodeModel();
|
|
|
|
|
updateQmlJsCodeModel();
|
|
|
|
|
emit fileListChanged();
|
2016-03-08 14:00:56 +01:00
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
void QbsProject::handleQbsParsingDone(bool success)
|
|
|
|
|
{
|
2014-06-16 14:42:21 +02:00
|
|
|
QTC_ASSERT(m_qbsProjectParser, return);
|
2016-03-11 11:21:11 +01:00
|
|
|
QTC_ASSERT(m_qbsUpdateFutureInterface, return);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-03-11 17:53:26 +01:00
|
|
|
qCDebug(qbsPmLog) << "Parsing done, success:" << success;
|
2014-07-14 14:22:27 +02:00
|
|
|
|
2016-03-11 11:21:11 +01:00
|
|
|
if (checkCancelStatus())
|
2014-07-14 10:22:37 +02:00
|
|
|
return;
|
|
|
|
|
|
2014-06-16 14:42:21 +02:00
|
|
|
generateErrors(m_qbsProjectParser->error());
|
|
|
|
|
|
2016-03-11 17:53:26 +01:00
|
|
|
m_qbsProject = m_qbsProjectParser->qbsProject();
|
2016-07-15 11:02:10 +02:00
|
|
|
m_qbsProjects.insert(activeTarget(), m_qbsProject);
|
2016-03-11 17:53:26 +01:00
|
|
|
bool dataChanged = false;
|
2014-07-10 17:01:54 +02:00
|
|
|
if (success) {
|
2016-03-08 14:00:56 +01:00
|
|
|
QTC_ASSERT(m_qbsProject.isValid(), return);
|
2016-03-11 17:53:26 +01:00
|
|
|
const qbs::ProjectData &projectData = m_qbsProject.projectData();
|
|
|
|
|
if (projectData != m_projectData) {
|
|
|
|
|
m_projectData = projectData;
|
|
|
|
|
dataChanged = true;
|
|
|
|
|
}
|
2014-07-14 10:22:37 +02:00
|
|
|
} else {
|
|
|
|
|
m_qbsUpdateFutureInterface->reportCanceled();
|
2014-07-10 17:01:54 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-16 14:42:21 +02:00
|
|
|
m_qbsProjectParser->deleteLater();
|
|
|
|
|
m_qbsProjectParser = 0;
|
2016-03-11 11:21:11 +01:00
|
|
|
m_qbsUpdateFutureInterface->reportFinished();
|
|
|
|
|
delete m_qbsUpdateFutureInterface;
|
|
|
|
|
m_qbsUpdateFutureInterface = 0;
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-03-11 17:53:26 +01:00
|
|
|
if (dataChanged)
|
|
|
|
|
updateAfterParse();
|
2013-01-30 18:19:31 +01:00
|
|
|
emit projectParsingDone(success);
|
2016-10-20 13:18:54 +02:00
|
|
|
emit parsingFinished();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-11 17:53:26 +01:00
|
|
|
void QbsProject::handleRuleExecutionDone()
|
|
|
|
|
{
|
|
|
|
|
qCDebug(qbsPmLog) << "Rule execution done";
|
|
|
|
|
|
|
|
|
|
if (checkCancelStatus())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_qbsProjectParser->deleteLater();
|
|
|
|
|
m_qbsProjectParser = 0;
|
|
|
|
|
m_qbsUpdateFutureInterface->reportFinished();
|
|
|
|
|
delete m_qbsUpdateFutureInterface;
|
|
|
|
|
m_qbsUpdateFutureInterface = 0;
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(m_qbsProject.isValid(), return);
|
|
|
|
|
m_projectData = m_qbsProject.projectData();
|
|
|
|
|
updateAfterParse();
|
|
|
|
|
emit projectParsingDone(true);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 18:25:59 +02:00
|
|
|
void QbsProject::targetWasAdded(Target *t)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2016-07-15 11:02:10 +02:00
|
|
|
m_qbsProjects.insert(t, qbs::Project());
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(t, &Target::activeBuildConfigurationChanged, this, &QbsProject::delayParsing);
|
|
|
|
|
connect(t, &Target::buildDirectoryChanged, this, &QbsProject::delayParsing);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-15 11:02:10 +02:00
|
|
|
void QbsProject::targetWasRemoved(Target *t)
|
|
|
|
|
{
|
|
|
|
|
m_qbsProjects.remove(t);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 18:25:59 +02:00
|
|
|
void QbsProject::changeActiveTarget(Target *t)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2013-08-29 18:25:59 +02:00
|
|
|
BuildConfiguration *bc = 0;
|
2016-07-15 11:02:10 +02:00
|
|
|
if (t) {
|
|
|
|
|
m_qbsProject = m_qbsProjects.value(t);
|
|
|
|
|
if (t->kit())
|
|
|
|
|
bc = t->activeBuildConfiguration();
|
|
|
|
|
}
|
2013-01-30 18:19:31 +01:00
|
|
|
buildConfigurationChanged(bc);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 18:25:59 +02:00
|
|
|
void QbsProject::buildConfigurationChanged(BuildConfiguration *bc)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
|
|
|
|
if (m_currentBc)
|
2016-06-28 23:29:21 +03:00
|
|
|
disconnect(m_currentBc, &QbsBuildConfiguration::qbsConfigurationChanged,
|
|
|
|
|
this, &QbsProject::delayParsing);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
m_currentBc = qobject_cast<QbsBuildConfiguration *>(bc);
|
|
|
|
|
if (m_currentBc) {
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_currentBc, &QbsBuildConfiguration::qbsConfigurationChanged,
|
|
|
|
|
this, &QbsProject::delayParsing);
|
2013-06-06 18:45:53 +02:00
|
|
|
delayParsing();
|
2013-01-30 18:19:31 +01:00
|
|
|
} else {
|
|
|
|
|
invalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-26 16:19:43 +01:00
|
|
|
void QbsProject::startParsing()
|
|
|
|
|
{
|
2014-03-03 14:15:46 +01:00
|
|
|
// Qbs does update the build graph during the build. So we cannot
|
|
|
|
|
// start to parse while a build is running or we will lose information.
|
2015-02-03 23:56:02 +02:00
|
|
|
if (BuildManager::isBuilding(this)) {
|
2014-07-14 14:22:27 +02:00
|
|
|
scheduleParsing();
|
2014-03-03 14:15:46 +01:00
|
|
|
return;
|
2014-07-14 14:22:27 +02:00
|
|
|
}
|
2014-03-03 14:15:46 +01:00
|
|
|
|
2014-07-17 12:02:56 +02:00
|
|
|
parseCurrentBuildConfiguration();
|
2013-11-26 16:19:43 +01:00
|
|
|
}
|
|
|
|
|
|
2013-06-06 18:45:53 +02:00
|
|
|
void QbsProject::delayParsing()
|
|
|
|
|
{
|
|
|
|
|
m_parsingDelay.start();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-17 12:02:56 +02:00
|
|
|
void QbsProject::parseCurrentBuildConfiguration()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-07-11 12:44:12 +02:00
|
|
|
m_parsingScheduled = false;
|
2014-07-14 14:22:27 +02:00
|
|
|
if (m_cancelStatus == CancelStatusCancelingForReparse)
|
2014-07-14 10:22:37 +02:00
|
|
|
return;
|
2013-11-26 16:19:43 +01:00
|
|
|
|
2014-07-14 14:22:27 +02:00
|
|
|
// The CancelStatusCancelingAltoghether type can only be set by a build job, during
|
|
|
|
|
// which no other parse requests come through to this point (except by the build job itself,
|
|
|
|
|
// but of course not while canceling is in progress).
|
|
|
|
|
QTC_ASSERT(m_cancelStatus == CancelStatusNone, return);
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
if (!activeTarget())
|
|
|
|
|
return;
|
|
|
|
|
QbsBuildConfiguration *bc = qobject_cast<QbsBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
|
|
|
|
|
if (!bc)
|
|
|
|
|
return;
|
2014-07-14 10:22:37 +02:00
|
|
|
|
|
|
|
|
// New parse requests override old ones.
|
|
|
|
|
// NOTE: We need to wait for the current operation to finish, since otherwise there could
|
|
|
|
|
// be a conflict. Consider the case where the old qbs::ProjectSetupJob is writing
|
|
|
|
|
// to the build graph file when the cancel request comes in. If we don't wait for
|
|
|
|
|
// acknowledgment, it might still be doing that when the new one already reads from the
|
|
|
|
|
// same file.
|
|
|
|
|
if (m_qbsProjectParser) {
|
2014-07-14 14:22:27 +02:00
|
|
|
m_cancelStatus = CancelStatusCancelingForReparse;
|
2014-07-14 10:22:37 +02:00
|
|
|
m_qbsProjectParser->cancel();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-16 17:45:16 +02:00
|
|
|
parse(bc->qbsConfiguration(), bc->environment(), bc->buildDirectory().toString());
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-14 14:22:27 +02:00
|
|
|
void QbsProject::cancelParsing()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_qbsProjectParser, return);
|
|
|
|
|
m_cancelStatus = CancelStatusCancelingAltoghether;
|
|
|
|
|
m_qbsProjectParser->cancel();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 12:44:12 +02:00
|
|
|
void QbsProject::updateAfterBuild()
|
|
|
|
|
{
|
2014-07-28 09:53:06 +02:00
|
|
|
QTC_ASSERT(m_qbsProject.isValid(), return);
|
2016-10-06 15:59:23 +02:00
|
|
|
const qbs::ProjectData &projectData = m_qbsProject.projectData();
|
|
|
|
|
if (projectData == m_projectData)
|
|
|
|
|
return;
|
|
|
|
|
qCDebug(qbsPmLog) << "Updating data after build";
|
|
|
|
|
m_projectData = projectData;
|
|
|
|
|
rootProjectNode()->update();
|
2014-07-11 12:44:12 +02:00
|
|
|
updateBuildTargetData();
|
2014-10-30 16:17:18 +01:00
|
|
|
updateCppCompilerCallData();
|
2016-03-02 13:04:48 +01:00
|
|
|
if (m_extraCompilersPending) {
|
|
|
|
|
m_extraCompilersPending = false;
|
|
|
|
|
updateCppCodeModel();
|
|
|
|
|
}
|
2014-07-11 12:44:12 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-16 14:42:21 +02:00
|
|
|
void QbsProject::registerQbsProjectParser(QbsProjectParser *p)
|
|
|
|
|
{
|
|
|
|
|
m_parsingDelay.stop();
|
|
|
|
|
|
|
|
|
|
if (m_qbsProjectParser) {
|
|
|
|
|
m_qbsProjectParser->disconnect(this);
|
|
|
|
|
m_qbsProjectParser->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_qbsProjectParser = p;
|
|
|
|
|
|
2016-03-08 14:00:56 +01:00
|
|
|
if (p) {
|
2016-03-11 17:53:26 +01:00
|
|
|
connect(m_qbsProjectParser, &QbsProjectParser::ruleExecutionDone,
|
|
|
|
|
this, &QbsProject::handleRuleExecutionDone);
|
2016-06-28 23:29:21 +03:00
|
|
|
connect(m_qbsProjectParser, &QbsProjectParser::done,
|
|
|
|
|
this, &QbsProject::handleQbsParsingDone);
|
2016-03-08 14:00:56 +01:00
|
|
|
}
|
2014-06-16 14:42:21 +02:00
|
|
|
}
|
|
|
|
|
|
2015-05-18 16:57:29 +02:00
|
|
|
Project::RestoreResult QbsProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2015-05-18 16:57:29 +02:00
|
|
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
|
|
|
|
if (result != RestoreResult::Ok)
|
|
|
|
|
return result;
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-08-29 18:25:59 +02:00
|
|
|
Kit *defaultKit = KitManager::defaultKit();
|
2015-11-16 17:10:55 +01:00
|
|
|
if (!activeTarget() && defaultKit)
|
|
|
|
|
addTarget(createTarget(defaultKit));
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2015-05-18 16:57:29 +02:00
|
|
|
return RestoreResult::Ok;
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-06-18 12:06:11 +02:00
|
|
|
void QbsProject::generateErrors(const qbs::ErrorInfo &e)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2013-06-18 12:06:11 +02:00
|
|
|
foreach (const qbs::ErrorItem &item, e.items())
|
2013-08-29 18:25:59 +02:00
|
|
|
TaskHub::addTask(Task::Error, item.description(),
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM,
|
2014-11-07 13:40:49 +01:00
|
|
|
FileName::fromString(item.codeLocation().filePath()),
|
2013-08-29 18:25:59 +02:00
|
|
|
item.codeLocation().line());
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
QString QbsProject::productDisplayName(const qbs::Project &project,
|
|
|
|
|
const qbs::ProductData &product)
|
|
|
|
|
{
|
|
|
|
|
QString displayName = product.name();
|
|
|
|
|
if (product.profile() != project.profile())
|
|
|
|
|
displayName.append(QLatin1String(" [")).append(product.profile()).append(QLatin1Char(']'));
|
|
|
|
|
return displayName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsProject::uniqueProductName(const qbs::ProductData &product)
|
|
|
|
|
{
|
|
|
|
|
return product.name() + QLatin1Char('.') + product.profile();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 18:25:59 +02:00
|
|
|
void QbsProject::parse(const QVariantMap &config, const Environment &env, const QString &dir)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2013-06-11 18:10:42 +02:00
|
|
|
prepareForParsing();
|
2014-06-16 14:42:21 +02:00
|
|
|
QTC_ASSERT(!m_qbsProjectParser, return);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-06-16 14:42:21 +02:00
|
|
|
registerQbsProjectParser(new QbsProjectParser(this, m_qbsUpdateFutureInterface));
|
2013-05-30 14:14:42 +02:00
|
|
|
|
2014-11-24 17:21:21 +01:00
|
|
|
QbsManager::instance()->updateProfileIfNecessary(activeTarget()->kit());
|
2014-07-17 12:02:56 +02:00
|
|
|
m_qbsProjectParser->parse(config, env, dir);
|
|
|
|
|
emit projectParsingStarted();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::prepareForParsing()
|
|
|
|
|
{
|
2013-08-29 18:25:59 +02:00
|
|
|
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
2013-11-15 15:24:11 +01:00
|
|
|
if (m_qbsUpdateFutureInterface) {
|
2013-01-30 18:19:31 +01:00
|
|
|
m_qbsUpdateFutureInterface->reportCanceled();
|
2013-11-15 15:24:11 +01:00
|
|
|
m_qbsUpdateFutureInterface->reportFinished();
|
|
|
|
|
}
|
2013-01-30 18:19:31 +01:00
|
|
|
delete m_qbsUpdateFutureInterface;
|
|
|
|
|
m_qbsUpdateFutureInterface = 0;
|
|
|
|
|
|
2014-06-16 14:42:21 +02:00
|
|
|
m_qbsUpdateFutureInterface = new QFutureInterface<bool>();
|
2013-01-30 18:19:31 +01:00
|
|
|
m_qbsUpdateFutureInterface->setProgressRange(0, 0);
|
2013-09-03 15:18:37 +02:00
|
|
|
ProgressManager::addTask(m_qbsUpdateFutureInterface->future(),
|
2014-04-17 15:14:14 +02:00
|
|
|
tr("Reading Project \"%1\"").arg(displayName()), "Qbs.QbsEvaluate");
|
2013-01-30 18:19:31 +01:00
|
|
|
m_qbsUpdateFutureInterface->reportStarted();
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-18 15:52:29 +02:00
|
|
|
void QbsProject::updateDocuments(const QSet<QString> &files)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
|
|
|
|
// Update documents:
|
2013-06-18 15:52:29 +02:00
|
|
|
QSet<QString> newFiles = files;
|
2016-01-08 12:12:27 +01:00
|
|
|
QTC_ASSERT(!newFiles.isEmpty(), newFiles << projectFilePath().toString());
|
2013-01-30 18:19:31 +01:00
|
|
|
QSet<QString> oldFiles;
|
2013-08-29 17:56:28 +02:00
|
|
|
foreach (IDocument *doc, m_qbsDocuments)
|
2014-12-21 21:54:30 +02:00
|
|
|
oldFiles.insert(doc->filePath().toString());
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
QSet<QString> filesToAdd = newFiles;
|
|
|
|
|
filesToAdd.subtract(oldFiles);
|
|
|
|
|
QSet<QString> filesToRemove = oldFiles;
|
|
|
|
|
filesToRemove.subtract(newFiles);
|
|
|
|
|
|
2013-08-29 17:56:28 +02:00
|
|
|
QSet<IDocument *> currentDocuments = m_qbsDocuments;
|
|
|
|
|
foreach (IDocument *doc, currentDocuments) {
|
2014-12-21 21:54:30 +02:00
|
|
|
if (filesToRemove.contains(doc->filePath().toString())) {
|
2013-01-30 18:19:31 +01:00
|
|
|
m_qbsDocuments.remove(doc);
|
|
|
|
|
delete doc;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-29 17:56:28 +02:00
|
|
|
QSet<IDocument *> toAdd;
|
2013-01-30 18:19:31 +01:00
|
|
|
foreach (const QString &f, filesToAdd)
|
|
|
|
|
toAdd.insert(new QbsProjectFile(this, f));
|
|
|
|
|
|
2013-08-29 17:56:28 +02:00
|
|
|
DocumentManager::addDocuments(toAdd.toList());
|
2013-01-30 18:19:31 +01:00
|
|
|
m_qbsDocuments.unite(toAdd);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-10 10:54:15 +02:00
|
|
|
static CppTools::ProjectFile::Kind cppFileType(const qbs::ArtifactData &sourceFile)
|
2016-02-22 15:47:39 +01:00
|
|
|
{
|
|
|
|
|
if (sourceFile.fileTags().contains(QLatin1String("hpp")))
|
|
|
|
|
return CppTools::ProjectFile::CXXHeader;
|
|
|
|
|
if (sourceFile.fileTags().contains(QLatin1String("cpp")))
|
|
|
|
|
return CppTools::ProjectFile::CXXSource;
|
|
|
|
|
if (sourceFile.fileTags().contains(QLatin1String("c")))
|
|
|
|
|
return CppTools::ProjectFile::CSource;
|
|
|
|
|
if (sourceFile.fileTags().contains(QLatin1String("objc")))
|
|
|
|
|
return CppTools::ProjectFile::ObjCSource;
|
|
|
|
|
if (sourceFile.fileTags().contains(QLatin1String("objcpp")))
|
|
|
|
|
return CppTools::ProjectFile::ObjCXXSource;
|
|
|
|
|
return CppTools::ProjectFile::Unclassified;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-11 13:13:07 +02:00
|
|
|
static QString groupLocationToProjectFile(const qbs::CodeLocation &location)
|
|
|
|
|
{
|
|
|
|
|
return QString::fromLatin1("%1:%2:%3")
|
|
|
|
|
.arg(location.filePath())
|
|
|
|
|
.arg(location.line())
|
|
|
|
|
.arg(location.column());
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 15:49:34 +01:00
|
|
|
// TODO: Receive the values from qbs when QBS-1030 is resolved.
|
|
|
|
|
static void getExpandedCompilerFlags(QStringList &cFlags, QStringList &cxxFlags,
|
|
|
|
|
const qbs::PropertyMap &properties)
|
|
|
|
|
{
|
|
|
|
|
const auto getCppProp = [properties](const char *propertyName) {
|
|
|
|
|
return properties.getModuleProperty("cpp", QLatin1String(propertyName));
|
|
|
|
|
};
|
|
|
|
|
const QVariant &enableExceptions = getCppProp("enableExceptions");
|
|
|
|
|
const QVariant &enableRtti = getCppProp("enableRtti");
|
|
|
|
|
QStringList commonFlags = getCppProp("platformCommonCompilerFlags").toStringList();
|
|
|
|
|
commonFlags << getCppProp("commonCompilerFlags").toStringList()
|
|
|
|
|
<< getCppProp("platformDriverFlags").toStringList()
|
|
|
|
|
<< getCppProp("driverFlags").toStringList();
|
|
|
|
|
const QStringList toolchain = properties.getModulePropertiesAsStringList("qbs", "toolchain");
|
|
|
|
|
if (toolchain.contains("gcc")) {
|
|
|
|
|
bool hasTargetOption = false;
|
|
|
|
|
if (toolchain.contains("clang")) {
|
|
|
|
|
const int majorVersion = getCppProp("compilerVersionMajor").toInt();
|
|
|
|
|
const int minorVersion = getCppProp("compilerVersionMinor").toInt();
|
|
|
|
|
if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 1))
|
|
|
|
|
hasTargetOption = true;
|
|
|
|
|
}
|
|
|
|
|
if (hasTargetOption) {
|
|
|
|
|
commonFlags << "-target" << getCppProp("target").toString();
|
|
|
|
|
} else {
|
|
|
|
|
const QString targetArch = getCppProp("targetArch").toString();
|
|
|
|
|
if (targetArch == "x86_64")
|
|
|
|
|
commonFlags << "-m64";
|
|
|
|
|
else if (targetArch == "i386")
|
|
|
|
|
commonFlags << "-m32";
|
|
|
|
|
const QString machineType = getCppProp("machineType").toString();
|
|
|
|
|
if (!machineType.isEmpty())
|
|
|
|
|
commonFlags << ("-march=" + machineType);
|
|
|
|
|
}
|
|
|
|
|
const QStringList targetOS = properties.getModulePropertiesAsStringList(
|
|
|
|
|
"qbs", "targetOS");
|
|
|
|
|
if (targetOS.contains("unix")) {
|
|
|
|
|
const QVariant positionIndependentCode = getCppProp("positionIndependentCode");
|
|
|
|
|
if (!positionIndependentCode.isValid() || positionIndependentCode.toBool())
|
|
|
|
|
commonFlags << "-fPIC";
|
|
|
|
|
}
|
|
|
|
|
cFlags = cxxFlags = commonFlags;
|
|
|
|
|
|
|
|
|
|
const QString cxxLanguageVersion = getCppProp("cxxLanguageVersion").toString();
|
|
|
|
|
if (cxxLanguageVersion == "c++11")
|
|
|
|
|
cxxFlags << "-std=c++0x";
|
|
|
|
|
else if (cxxLanguageVersion == "c++14")
|
|
|
|
|
cxxFlags << "-std=c++1y";
|
|
|
|
|
else if (!cxxLanguageVersion.isEmpty())
|
|
|
|
|
cxxFlags << ("-std=" + cxxLanguageVersion);
|
|
|
|
|
const QString cxxStandardLibrary = getCppProp("cxxStandardLibrary").toString();
|
|
|
|
|
if (!cxxStandardLibrary.isEmpty() && toolchain.contains("clang"))
|
|
|
|
|
cxxFlags << ("-stdlib=" + cxxStandardLibrary);
|
|
|
|
|
if (enableExceptions.isValid()) {
|
|
|
|
|
cxxFlags << QLatin1String(enableExceptions.toBool()
|
|
|
|
|
? "-fexceptions" : "-fno-exceptions");
|
|
|
|
|
}
|
|
|
|
|
if (enableRtti.isValid())
|
|
|
|
|
cxxFlags << QLatin1String(enableRtti.toBool() ? "-frtti" : "-fno-rtti");
|
|
|
|
|
|
|
|
|
|
const QString cLanguageVersion = getCppProp("cLanguageVersion").toString();
|
|
|
|
|
if (cLanguageVersion == "c11")
|
|
|
|
|
cFlags << "-std=c1x";
|
|
|
|
|
else if (!cLanguageVersion.isEmpty())
|
|
|
|
|
cFlags << ("-std=" + cLanguageVersion);
|
|
|
|
|
} else if (toolchain.contains("msvc")) {
|
|
|
|
|
if (enableExceptions.toBool()) {
|
|
|
|
|
const QString exceptionModel = getCppProp("exceptionHandlingModel").toString();
|
|
|
|
|
if (exceptionModel == "default")
|
|
|
|
|
commonFlags << "/EHsc";
|
|
|
|
|
else if (exceptionModel == "seh")
|
|
|
|
|
commonFlags << "/EHa";
|
|
|
|
|
else if (exceptionModel == "externc")
|
|
|
|
|
commonFlags << "/EHs";
|
|
|
|
|
}
|
|
|
|
|
cFlags = cxxFlags = commonFlags;
|
|
|
|
|
cFlags << "/TC";
|
|
|
|
|
cxxFlags << "/TP";
|
|
|
|
|
if (enableRtti.isValid())
|
|
|
|
|
cxxFlags << QLatin1String(enableRtti.toBool() ? "/GR" : "/GR-");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 13:58:47 +02:00
|
|
|
void QbsProject::updateCppCodeModel()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-09-11 13:58:47 +02:00
|
|
|
if (!m_projectData.isValid())
|
2013-01-30 18:19:31 +01:00
|
|
|
return;
|
|
|
|
|
|
2014-08-19 12:01:47 +02:00
|
|
|
QtSupport::BaseQtVersion *qtVersion =
|
|
|
|
|
QtSupport::QtKitInformation::qtVersion(activeTarget()->kit());
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-10-30 16:17:18 +01:00
|
|
|
CppTools::CppModelManager *modelmanager = CppTools::CppModelManager::instance();
|
2015-02-15 23:13:28 +02:00
|
|
|
CppTools::ProjectInfo pinfo(this);
|
2014-08-19 12:01:47 +02:00
|
|
|
CppTools::ProjectPartBuilder ppBuilder(pinfo);
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
if (qtVersion) {
|
|
|
|
|
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
2014-08-19 12:01:47 +02:00
|
|
|
ppBuilder.setQtVersion(CppTools::ProjectPart::Qt4);
|
2013-01-30 18:19:31 +01:00
|
|
|
else
|
2014-08-19 12:01:47 +02:00
|
|
|
ppBuilder.setQtVersion(CppTools::ProjectPart::Qt5);
|
|
|
|
|
} else {
|
|
|
|
|
ppBuilder.setQtVersion(CppTools::ProjectPart::NoQt);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 16:12:54 +01:00
|
|
|
QList<ProjectExplorer::ExtraCompilerFactory *> factories =
|
|
|
|
|
ProjectExplorer::ExtraCompilerFactory::extraCompilerFactories();
|
|
|
|
|
const auto factoriesBegin = factories.constBegin();
|
|
|
|
|
const auto factoriesEnd = factories.constEnd();
|
|
|
|
|
|
|
|
|
|
qDeleteAll(m_extraCompilers);
|
|
|
|
|
m_extraCompilers.clear();
|
2014-09-11 13:58:47 +02:00
|
|
|
foreach (const qbs::ProductData &prd, m_projectData.allProducts()) {
|
2013-01-30 18:19:31 +01:00
|
|
|
foreach (const qbs::GroupData &grp, prd.groups()) {
|
2013-02-20 17:40:52 +01:00
|
|
|
const qbs::PropertyMap &props = grp.properties();
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-11-04 15:49:34 +01:00
|
|
|
QStringList cFlags;
|
|
|
|
|
QStringList cxxFlags;
|
|
|
|
|
getExpandedCompilerFlags(cFlags, cxxFlags, props);
|
|
|
|
|
ppBuilder.setCxxFlags(cxxFlags);
|
|
|
|
|
ppBuilder.setCFlags(cFlags);
|
2013-04-28 17:18:50 +04:00
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
QStringList list = props.getModulePropertiesAsStringList(
|
|
|
|
|
QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_DEFINES));
|
2013-04-28 17:15:51 +04:00
|
|
|
QByteArray grpDefines;
|
2013-03-21 13:17:51 +01:00
|
|
|
foreach (const QString &def, list) {
|
|
|
|
|
QByteArray data = def.toUtf8();
|
|
|
|
|
int pos = data.indexOf('=');
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
data[pos] = ' ';
|
2014-11-13 12:16:25 +01:00
|
|
|
else
|
|
|
|
|
data.append(" 1"); // cpp.defines: [ "FOO" ] is considered to be "FOO=1"
|
2013-03-21 13:17:51 +01:00
|
|
|
grpDefines += (QByteArray("#define ") + data + '\n');
|
|
|
|
|
}
|
2014-08-19 12:01:47 +02:00
|
|
|
ppBuilder.setDefines(grpDefines);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_INCLUDEPATHS));
|
2014-07-23 10:48:29 +02:00
|
|
|
list.append(props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_SYSTEM_INCLUDEPATHS)));
|
2016-01-13 14:12:15 +01:00
|
|
|
CppTools::ProjectPartHeaderPaths grpHeaderPaths;
|
2014-06-25 17:23:19 +02:00
|
|
|
foreach (const QString &p, list)
|
2016-01-13 14:12:15 +01:00
|
|
|
grpHeaderPaths += CppTools::ProjectPartHeaderPath(
|
2014-06-25 17:23:19 +02:00
|
|
|
FileName::fromUserInput(p).toString(),
|
2016-01-13 14:12:15 +01:00
|
|
|
CppTools::ProjectPartHeaderPath::IncludePath);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_FRAMEWORKPATHS));
|
2014-07-23 10:48:29 +02:00
|
|
|
list.append(props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_SYSTEM_FRAMEWORKPATHS)));
|
2014-06-25 17:23:19 +02:00
|
|
|
foreach (const QString &p, list)
|
2016-01-13 14:12:15 +01:00
|
|
|
grpHeaderPaths += CppTools::ProjectPartHeaderPath(
|
2014-06-25 17:23:19 +02:00
|
|
|
FileName::fromUserInput(p).toString(),
|
2016-01-13 14:12:15 +01:00
|
|
|
CppTools::ProjectPartHeaderPath::FrameworkPath);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-08-19 12:01:47 +02:00
|
|
|
ppBuilder.setHeaderPaths(grpHeaderPaths);
|
|
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
const QString pch = props.getModuleProperty(QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_PRECOMPILEDHEADER)).toString();
|
2014-08-19 12:01:47 +02:00
|
|
|
ppBuilder.setPreCompiledHeaders(QStringList() << pch);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-08-19 12:01:47 +02:00
|
|
|
ppBuilder.setDisplayName(grp.name());
|
2016-04-11 13:13:07 +02:00
|
|
|
ppBuilder.setProjectFile(groupLocationToProjectFile(grp.location()));
|
2016-02-22 15:47:39 +01:00
|
|
|
|
2016-08-10 10:54:15 +02:00
|
|
|
QHash<QString, qbs::ArtifactData> filePathToSourceArtifact;
|
|
|
|
|
foreach (const qbs::ArtifactData &source, grp.allSourceArtifacts()) {
|
2016-02-22 15:47:39 +01:00
|
|
|
filePathToSourceArtifact.insert(source.filePath(), source);
|
|
|
|
|
|
2016-01-15 16:12:54 +01:00
|
|
|
foreach (const QString &tag, source.fileTags()) {
|
|
|
|
|
for (auto i = factoriesBegin; i != factoriesEnd; ++i) {
|
|
|
|
|
if ((*i)->sourceTag() != tag)
|
|
|
|
|
continue;
|
2016-03-01 16:03:58 +01:00
|
|
|
QStringList generated = m_qbsProject.generatedFiles(prd, source.filePath(),
|
|
|
|
|
false);
|
2016-03-02 13:04:48 +01:00
|
|
|
if (generated.isEmpty()) {
|
|
|
|
|
// We don't know the target files until we build for the first time.
|
|
|
|
|
m_extraCompilersPending = true;
|
2016-01-15 16:12:54 +01:00
|
|
|
continue;
|
2016-03-02 13:04:48 +01:00
|
|
|
}
|
2016-01-15 16:12:54 +01:00
|
|
|
|
|
|
|
|
const FileNameList fileNames = Utils::transform(generated,
|
|
|
|
|
[](const QString &s) {
|
|
|
|
|
return Utils::FileName::fromString(s);
|
|
|
|
|
});
|
|
|
|
|
m_extraCompilers.append((*i)->create(
|
|
|
|
|
this, FileName::fromString(source.filePath()), fileNames));
|
|
|
|
|
}
|
2013-08-07 12:29:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
2014-08-19 12:01:47 +02:00
|
|
|
|
2016-02-22 15:47:39 +01:00
|
|
|
const QList<Id> languages = ppBuilder.createProjectPartsForFiles(
|
|
|
|
|
grp.allFilePaths(),
|
|
|
|
|
[filePathToSourceArtifact](const QString &filePath) {
|
|
|
|
|
return cppFileType(filePathToSourceArtifact.value(filePath));
|
|
|
|
|
});
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
foreach (Id language, languages)
|
2014-08-19 12:01:47 +02:00
|
|
|
setProjectLanguage(language, true);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-12 14:14:18 +02:00
|
|
|
pinfo.finish();
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2016-01-15 16:12:54 +01:00
|
|
|
CppTools::GeneratedCodeModelSupport::update(m_extraCompilers);
|
2013-08-07 12:29:52 +02:00
|
|
|
|
2014-10-30 16:17:18 +01:00
|
|
|
// Update the code model
|
2014-11-06 15:45:16 +01:00
|
|
|
m_codeModelFuture.cancel();
|
2013-07-16 12:08:39 +02:00
|
|
|
m_codeModelFuture = modelmanager->updateProjectInfo(pinfo);
|
2014-10-30 16:17:18 +01:00
|
|
|
m_codeModelProjectInfo = modelmanager->projectInfo(this);
|
2014-11-20 12:50:37 +01:00
|
|
|
QTC_CHECK(m_codeModelProjectInfo == pinfo);
|
2014-10-30 16:17:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::updateCppCompilerCallData()
|
|
|
|
|
{
|
|
|
|
|
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
|
|
|
|
QTC_ASSERT(m_codeModelProjectInfo == modelManager->projectInfo(this), return);
|
|
|
|
|
|
|
|
|
|
CppTools::ProjectInfo::CompilerCallData data;
|
|
|
|
|
foreach (const qbs::ProductData &product, m_projectData.allProducts()) {
|
|
|
|
|
if (!product.isEnabled())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (const qbs::GroupData &group, product.groups()) {
|
|
|
|
|
if (!group.isEnabled())
|
|
|
|
|
continue;
|
|
|
|
|
|
2016-04-11 13:13:07 +02:00
|
|
|
CppTools::ProjectInfo::CompilerCallGroup compilerCallGroup;
|
|
|
|
|
compilerCallGroup.groupId = groupLocationToProjectFile(group.location());
|
|
|
|
|
|
2016-08-10 10:54:15 +02:00
|
|
|
foreach (const qbs::ArtifactData &file, group.allSourceArtifacts()) {
|
2016-02-22 15:47:39 +01:00
|
|
|
const QString &filePath = file.filePath();
|
|
|
|
|
if (!CppTools::ProjectFile::isSource(cppFileType(file)))
|
2014-10-30 16:17:18 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
qbs::ErrorInfo errorInfo;
|
2016-02-22 15:47:39 +01:00
|
|
|
const qbs::RuleCommandList ruleCommands = m_qbsProject.ruleCommands(product,
|
|
|
|
|
filePath, QLatin1String("obj"), &errorInfo);
|
2014-10-30 16:17:18 +01:00
|
|
|
if (errorInfo.hasError())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
QList<QStringList> calls;
|
|
|
|
|
foreach (const qbs::RuleCommand &ruleCommand, ruleCommands) {
|
|
|
|
|
if (ruleCommand.type() == qbs::RuleCommand::ProcessCommandType)
|
|
|
|
|
calls << ruleCommand.arguments();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!calls.isEmpty())
|
2016-04-11 13:13:07 +02:00
|
|
|
compilerCallGroup.callsPerSourceFile.insert(filePath, calls);
|
2014-10-30 16:17:18 +01:00
|
|
|
}
|
2016-04-11 13:13:07 +02:00
|
|
|
|
|
|
|
|
if (!compilerCallGroup.callsPerSourceFile.isEmpty())
|
|
|
|
|
data.append(compilerCallGroup);
|
2014-10-30 16:17:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-02 12:57:30 +02:00
|
|
|
m_codeModelProjectInfo = modelManager->updateCompilerCallDataForProject(this, data);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-11 13:58:47 +02:00
|
|
|
void QbsProject::updateQmlJsCodeModel()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2013-02-22 11:20:33 +01:00
|
|
|
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
|
|
|
|
|
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);
|
2015-08-04 15:52:22 +02:00
|
|
|
foreach (const qbs::ProductData &product, m_projectData.allProducts()) {
|
|
|
|
|
static const QString propertyName = QLatin1String("qmlImportPaths");
|
|
|
|
|
foreach (const QString &path, product.properties().value(propertyName).toStringList()) {
|
|
|
|
|
projectInfo.importPaths.maybeInsert(Utils::FileName::fromString(path),
|
|
|
|
|
QmlJS::Dialect::Qml);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-10 14:45:47 +02:00
|
|
|
|
|
|
|
|
setProjectLanguage(ProjectExplorer::Constants::LANG_QMLJS, !projectInfo.sourceFiles.isEmpty());
|
2014-01-23 14:28:31 +01:00
|
|
|
modelManager->updateProjectInfo(projectInfo, this);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
void QbsProject::updateApplicationTargets()
|
2013-09-02 10:12:37 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
BuildTargetInfoList applications;
|
2014-09-05 12:08:15 +02:00
|
|
|
foreach (const qbs::ProductData &productData, m_projectData.allProducts()) {
|
2014-08-07 15:38:38 +02:00
|
|
|
if (!productData.isEnabled() || !productData.isRunnable())
|
|
|
|
|
continue;
|
2014-09-05 12:08:15 +02:00
|
|
|
const QString displayName = productDisplayName(m_qbsProject, productData);
|
2014-08-07 15:38:38 +02:00
|
|
|
if (productData.targetArtifacts().isEmpty()) { // No build yet.
|
2015-02-03 23:56:02 +02:00
|
|
|
applications.list << BuildTargetInfo(displayName,
|
|
|
|
|
FileName(),
|
|
|
|
|
FileName::fromString(productData.location().filePath()));
|
2014-08-07 15:38:38 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
2016-08-10 10:54:15 +02:00
|
|
|
foreach (const qbs::ArtifactData &ta, productData.targetArtifacts()) {
|
2013-09-02 10:12:37 +02:00
|
|
|
QTC_ASSERT(ta.isValid(), continue);
|
|
|
|
|
if (!ta.isExecutable())
|
|
|
|
|
continue;
|
2015-02-03 23:56:02 +02:00
|
|
|
applications.list << BuildTargetInfo(displayName,
|
|
|
|
|
FileName::fromString(ta.filePath()),
|
|
|
|
|
FileName::fromString(productData.location().filePath()));
|
2013-09-02 10:12:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
activeTarget()->setApplicationTargets(applications);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
void QbsProject::updateDeploymentInfo()
|
2013-09-02 10:12:37 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
DeploymentData deploymentData;
|
2014-09-05 12:08:15 +02:00
|
|
|
if (m_qbsProject.isValid()) {
|
2016-08-10 10:54:15 +02:00
|
|
|
foreach (const qbs::ArtifactData &f, m_projectData.installableArtifacts()) {
|
|
|
|
|
deploymentData.addFile(f.filePath(), f.installData().installDir(),
|
2015-08-28 10:51:33 +02:00
|
|
|
f.isExecutable() ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal);
|
2013-09-02 10:12:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
activeTarget()->setDeploymentData(deploymentData);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 12:44:12 +02:00
|
|
|
void QbsProject::updateBuildTargetData()
|
|
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
updateApplicationTargets();
|
|
|
|
|
updateDeploymentInfo();
|
2016-02-09 12:03:37 +01:00
|
|
|
if (activeTarget())
|
|
|
|
|
activeTarget()->updateDefaultRunConfigurations();
|
2014-07-11 12:44:12 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|