2013-01-30 18:19:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsproject.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsbuildconfiguration.h"
|
2013-02-06 11:28:33 +01:00
|
|
|
#include "qbslogsink.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
#include "qbsprojectfile.h"
|
|
|
|
|
#include "qbsprojectmanagerconstants.h"
|
|
|
|
|
#include "qbsnodes.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/documentmanager.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <language/language.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/id.h>
|
|
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
|
|
|
|
#include <coreplugin/mimedatabase.h>
|
|
|
|
|
#include <cpptools/cppmodelmanager.h>
|
|
|
|
|
#include <projectexplorer/buildenvironmentwidget.h>
|
|
|
|
|
#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>
|
2012-12-06 17:20:58 +01:00
|
|
|
#include <qmljstools/qmljsmodelmanager.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
|
|
|
|
|
|
|
|
|
#include <qbs.h>
|
|
|
|
|
#include <tools/scripttools.h> // qbs, remove once there is a expand method in Qbs itself!
|
|
|
|
|
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// Constants:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
static const char CONFIG_CPP_MODULE[] = "cpp";
|
|
|
|
|
static const char CONFIG_CXXFLAGS[] = "cxxflags";
|
|
|
|
|
static const char CONFIG_DEFINES[] = "defines";
|
|
|
|
|
static const char CONFIG_INCLUDEPATHS[] = "includePaths";
|
|
|
|
|
static const char CONFIG_FRAMEWORKPATHS[] = "frameworkPaths";
|
|
|
|
|
static const char CONFIG_PRECOMPILEDHEADER[] = "precompiledHeader";
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
static const char CONFIGURATION_PATH[] = "<configuration>";
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// HELPERS:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::TaskHub *taskHub()
|
|
|
|
|
{
|
|
|
|
|
return ProjectExplorer::ProjectExplorerPlugin::instance()->taskHub();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsProject:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QbsProject::QbsProject(QbsManager *manager, const QString &fileName) :
|
|
|
|
|
m_manager(manager), m_projectName(QFileInfo(fileName).completeBaseName()), m_fileName(fileName),
|
|
|
|
|
m_rootProjectNode(new QbsProjectNode(fileName)),
|
|
|
|
|
m_qbsSetupProjectJob(0),
|
|
|
|
|
m_qbsUpdateFutureInterface(0),
|
|
|
|
|
m_currentBc(0)
|
|
|
|
|
{
|
|
|
|
|
setProjectContext(Core::Context(Constants::PROJECT_ID));
|
2013-04-05 14:46:38 +02:00
|
|
|
Core::Context pl(ProjectExplorer::Constants::LANG_CXX);
|
|
|
|
|
pl.add(ProjectExplorer::Constants::LANG_QMLJS);
|
|
|
|
|
setProjectLanguages(pl);
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(changeActiveTarget(ProjectExplorer::Target*)));
|
|
|
|
|
connect(this, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(targetWasAdded(ProjectExplorer::Target*)));
|
|
|
|
|
|
|
|
|
|
updateDocuments(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsProject::~QbsProject()
|
|
|
|
|
{
|
|
|
|
|
m_codeModelFuture.cancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsProject::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_projectName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Id QbsProject::id() const
|
|
|
|
|
{
|
|
|
|
|
return Core::Id(Constants::PROJECT_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::IDocument *QbsProject::document() const
|
|
|
|
|
{
|
|
|
|
|
foreach (Core::IDocument *doc, m_qbsDocuments) {
|
|
|
|
|
if (doc->fileName() == m_fileName)
|
|
|
|
|
return doc;
|
|
|
|
|
}
|
|
|
|
|
QTC_ASSERT(false, return 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsManager *QbsProject::projectManager() const
|
|
|
|
|
{
|
|
|
|
|
return m_manager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ProjectNode *QbsProject::rootProjectNode() const
|
|
|
|
|
{
|
|
|
|
|
return m_rootProjectNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList QbsProject::files(ProjectExplorer::Project::FilesMode fileMode) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(fileMode);
|
2013-03-05 11:23:00 +01:00
|
|
|
QSet<QString> result;
|
2013-01-30 18:19:31 +01:00
|
|
|
if (m_rootProjectNode && m_rootProjectNode->projectData()) {
|
2013-03-05 11:23:00 +01:00
|
|
|
foreach (const qbs::ProductData &prd, m_rootProjectNode->projectData()->products()) {
|
|
|
|
|
foreach (const qbs::GroupData &grp, prd.groups()) {
|
|
|
|
|
foreach (const QString &file, grp.allFilePaths())
|
|
|
|
|
result.insert(file);
|
|
|
|
|
result.insert(grp.location().fileName);
|
|
|
|
|
}
|
|
|
|
|
result.insert(prd.location().fileName);
|
|
|
|
|
}
|
|
|
|
|
result.insert(m_rootProjectNode->projectData()->location().fileName);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
2013-03-05 11:23:00 +01:00
|
|
|
return result.toList();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::invalidate()
|
|
|
|
|
{
|
|
|
|
|
prepareForParsing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qbs::BuildJob *QbsProject::build(const qbs::BuildOptions &opts)
|
|
|
|
|
{
|
2013-04-16 13:14:07 +02:00
|
|
|
if (!qbsProject())
|
2013-01-30 18:19:31 +01:00
|
|
|
return 0;
|
|
|
|
|
if (!activeTarget() || !activeTarget()->kit())
|
|
|
|
|
return 0;
|
|
|
|
|
ProjectExplorer::BuildConfiguration *bc = 0;
|
|
|
|
|
bc = activeTarget()->activeBuildConfiguration();
|
|
|
|
|
if (!bc)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
QProcessEnvironment env = bc->environment().toProcessEnvironment();
|
2013-04-16 13:14:07 +02:00
|
|
|
return qbsProject()->buildAllProducts(opts, env);
|
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-04-16 13:14:07 +02:00
|
|
|
if (!qbsProject())
|
2013-01-30 18:19:31 +01:00
|
|
|
return 0;
|
2013-04-16 13:14:07 +02:00
|
|
|
return qbsProject()->cleanAllProducts(opts);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsProject::profileForTarget(const ProjectExplorer::Target *t) const
|
|
|
|
|
{
|
|
|
|
|
return m_manager->profileForKit(t->kit());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsProject::isParsing() const
|
|
|
|
|
{
|
|
|
|
|
return m_qbsUpdateFutureInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsProject::hasParseResult() const
|
|
|
|
|
{
|
2013-04-16 13:14:07 +02:00
|
|
|
return qbsProject();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::FileName QbsProject::defaultBuildDirectory() const
|
|
|
|
|
{
|
|
|
|
|
QFileInfo fi(m_fileName);
|
|
|
|
|
const QString buildDir = QDir(fi.canonicalPath()).absoluteFilePath(QString::fromLatin1("../%1-build").arg(fi.baseName()));
|
|
|
|
|
return Utils::FileName::fromString(buildDir);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-16 13:14:07 +02:00
|
|
|
const qbs::Project *QbsProject::qbsProject() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_rootProjectNode)
|
|
|
|
|
return 0;
|
|
|
|
|
return m_rootProjectNode->project();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const qbs::ProjectData *QbsProject::qbsProjectData() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_rootProjectNode)
|
|
|
|
|
return 0;
|
|
|
|
|
return m_rootProjectNode->projectData();
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
void QbsProject::handleQbsParsingDone(bool success)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_qbsSetupProjectJob, return);
|
|
|
|
|
QTC_ASSERT(m_qbsUpdateFutureInterface, return);
|
|
|
|
|
|
|
|
|
|
qbs::Project *project = 0;
|
|
|
|
|
if (success) {
|
|
|
|
|
project = new qbs::Project(m_qbsSetupProjectJob->project());
|
|
|
|
|
} else {
|
|
|
|
|
generateErrors(m_qbsSetupProjectJob->error());
|
|
|
|
|
m_qbsUpdateFutureInterface->reportCanceled();
|
|
|
|
|
}
|
|
|
|
|
m_qbsSetupProjectJob->deleteLater();
|
|
|
|
|
m_qbsSetupProjectJob = 0;
|
|
|
|
|
|
|
|
|
|
m_qbsUpdateFutureInterface->reportFinished();
|
|
|
|
|
delete m_qbsUpdateFutureInterface;
|
|
|
|
|
m_qbsUpdateFutureInterface = 0;
|
|
|
|
|
|
|
|
|
|
m_rootProjectNode->update(project);
|
|
|
|
|
|
|
|
|
|
updateDocuments(m_rootProjectNode->projectData());
|
|
|
|
|
|
|
|
|
|
updateCppCodeModel(m_rootProjectNode->projectData());
|
|
|
|
|
updateQmlJsCodeModel(m_rootProjectNode->projectData());
|
|
|
|
|
|
|
|
|
|
emit projectParsingDone(success);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::handleQbsParsingProgress(int progress)
|
|
|
|
|
{
|
|
|
|
|
if (m_qbsUpdateFutureInterface)
|
|
|
|
|
m_qbsUpdateFutureInterface->setProgressValue(m_currentProgressBase + progress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::handleQbsParsingTaskSetup(const QString &description, int maximumProgressValue)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(description);
|
|
|
|
|
if (m_qbsUpdateFutureInterface) {
|
|
|
|
|
m_currentProgressBase = m_qbsUpdateFutureInterface->progressValue();
|
|
|
|
|
m_qbsUpdateFutureInterface->setProgressRange(0, m_currentProgressBase + maximumProgressValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::targetWasAdded(ProjectExplorer::Target *t)
|
|
|
|
|
{
|
|
|
|
|
connect(t, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(parseCurrentBuildConfiguration()));
|
|
|
|
|
connect(t, SIGNAL(buildDirectoryChanged()),
|
|
|
|
|
this, SLOT(parseCurrentBuildConfiguration()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::changeActiveTarget(ProjectExplorer::Target *t)
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::BuildConfiguration *bc = 0;
|
|
|
|
|
if (t && t->kit())
|
|
|
|
|
bc = t->activeBuildConfiguration();
|
|
|
|
|
buildConfigurationChanged(bc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc)
|
|
|
|
|
{
|
|
|
|
|
if (m_currentBc)
|
|
|
|
|
disconnect(m_currentBc, SIGNAL(qbsConfigurationChanged()), this, SLOT(parseCurrentBuildConfiguration()));
|
|
|
|
|
|
|
|
|
|
m_currentBc = qobject_cast<QbsBuildConfiguration *>(bc);
|
|
|
|
|
if (m_currentBc) {
|
|
|
|
|
connect(m_currentBc, SIGNAL(qbsConfigurationChanged()), this, SLOT(parseCurrentBuildConfiguration()));
|
|
|
|
|
parseCurrentBuildConfiguration();
|
|
|
|
|
} else {
|
|
|
|
|
invalidate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::parseCurrentBuildConfiguration()
|
|
|
|
|
{
|
|
|
|
|
if (!activeTarget())
|
|
|
|
|
return;
|
|
|
|
|
QbsBuildConfiguration *bc = qobject_cast<QbsBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
|
|
|
|
|
if (!bc)
|
|
|
|
|
return;
|
|
|
|
|
parse(bc->qbsConfiguration(), bc->buildDirectory());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsProject::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!Project::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::KitManager *km = ProjectExplorer::KitManager::instance();
|
|
|
|
|
if (!activeTarget() && km->defaultKit()) {
|
|
|
|
|
ProjectExplorer::Target *t = new ProjectExplorer::Target(this, km->defaultKit());
|
|
|
|
|
t->updateDefaultBuildConfigurations();
|
|
|
|
|
t->updateDefaultDeployConfigurations();
|
|
|
|
|
t->updateDefaultRunConfigurations();
|
|
|
|
|
addTarget(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::generateErrors(const qbs::Error &e)
|
|
|
|
|
{
|
|
|
|
|
foreach (const qbs::ErrorData &data, e.entries())
|
|
|
|
|
taskHub()->addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error,
|
|
|
|
|
data.description(),
|
|
|
|
|
Utils::FileName::fromString(data.codeLocation().fileName),
|
|
|
|
|
data.codeLocation().line,
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::parse(const QVariantMap &config, const QString &dir)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(!dir.isNull(), return);
|
|
|
|
|
prepareForParsing();
|
|
|
|
|
m_qbsBuildConfig = config;
|
|
|
|
|
m_qbsBuildRoot = dir;
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(!m_qbsSetupProjectJob, return);
|
2013-02-01 13:41:29 +01:00
|
|
|
qbs::SetupProjectParameters params;
|
|
|
|
|
params.buildConfiguration = m_qbsBuildConfig;
|
|
|
|
|
params.buildRoot = m_qbsBuildRoot;
|
|
|
|
|
params.projectFilePath = m_fileName;
|
|
|
|
|
params.ignoreDifferentProjectFilePath = false;
|
2013-02-15 13:29:52 +01:00
|
|
|
qbs::Preferences *prefs = QbsManager::preferences();
|
2013-02-21 16:21:27 +01:00
|
|
|
const QString buildDir = qbsBuildDir();
|
|
|
|
|
params.searchPaths = prefs->searchPaths(buildDir);
|
|
|
|
|
params.pluginPaths = prefs->pluginPaths(buildDir);
|
2013-02-01 13:41:29 +01:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
m_qbsSetupProjectJob
|
2013-02-06 11:28:33 +01:00
|
|
|
= qbs::Project::setupProject(params, m_manager->settings(), m_manager->logSink(), 0);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
connect(m_qbsSetupProjectJob, SIGNAL(finished(bool,qbs::AbstractJob*)),
|
|
|
|
|
this, SLOT(handleQbsParsingDone(bool)));
|
|
|
|
|
connect(m_qbsSetupProjectJob, SIGNAL(taskStarted(QString,int,qbs::AbstractJob*)),
|
|
|
|
|
this, SLOT(handleQbsParsingTaskSetup(QString,int)));
|
|
|
|
|
connect(m_qbsSetupProjectJob, SIGNAL(taskProgress(int,qbs::AbstractJob*)),
|
|
|
|
|
this, SLOT(handleQbsParsingProgress(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::prepareForParsing()
|
|
|
|
|
{
|
|
|
|
|
taskHub()->clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
|
|
|
|
|
if (m_qbsUpdateFutureInterface)
|
|
|
|
|
m_qbsUpdateFutureInterface->reportCanceled();
|
|
|
|
|
delete m_qbsUpdateFutureInterface;
|
|
|
|
|
m_qbsUpdateFutureInterface = 0;
|
|
|
|
|
|
|
|
|
|
// FIXME: Christian claims this should work
|
|
|
|
|
delete m_qbsSetupProjectJob;
|
|
|
|
|
m_qbsSetupProjectJob = 0;
|
|
|
|
|
|
|
|
|
|
m_currentProgressBase = 0;
|
|
|
|
|
m_qbsUpdateFutureInterface = new QFutureInterface<void>();
|
|
|
|
|
m_qbsUpdateFutureInterface->setProgressRange(0, 0);
|
|
|
|
|
Core::ICore::progressManager()->addTask(m_qbsUpdateFutureInterface->future(), tr("Evaluating"),
|
|
|
|
|
QLatin1String(Constants::QBS_EVALUATE));
|
|
|
|
|
m_qbsUpdateFutureInterface->reportStarted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::updateDocuments(const qbs::ProjectData *prj)
|
|
|
|
|
{
|
|
|
|
|
// Update documents:
|
|
|
|
|
QSet<QString> newFiles;
|
|
|
|
|
newFiles.insert(m_fileName); // make sure we always have the project file...
|
|
|
|
|
|
|
|
|
|
if (prj) {
|
|
|
|
|
newFiles.insert(prj->location().fileName);
|
|
|
|
|
foreach (const qbs::ProductData &prd, prj->products())
|
|
|
|
|
newFiles.insert(prd.location().fileName);
|
|
|
|
|
}
|
|
|
|
|
QSet<QString> oldFiles;
|
|
|
|
|
foreach (Core::IDocument *doc, m_qbsDocuments)
|
|
|
|
|
oldFiles.insert(doc->fileName());
|
|
|
|
|
|
|
|
|
|
QSet<QString> filesToAdd = newFiles;
|
|
|
|
|
filesToAdd.subtract(oldFiles);
|
|
|
|
|
QSet<QString> filesToRemove = oldFiles;
|
|
|
|
|
filesToRemove.subtract(newFiles);
|
|
|
|
|
|
|
|
|
|
QSet<Core::IDocument *> currentDocuments = m_qbsDocuments;
|
|
|
|
|
foreach (Core::IDocument *doc, currentDocuments) {
|
|
|
|
|
if (filesToRemove.contains(doc->fileName())) {
|
|
|
|
|
m_qbsDocuments.remove(doc);
|
|
|
|
|
delete doc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
QSet<Core::IDocument *> toAdd;
|
|
|
|
|
foreach (const QString &f, filesToAdd)
|
|
|
|
|
toAdd.insert(new QbsProjectFile(this, f));
|
|
|
|
|
|
|
|
|
|
Core::DocumentManager::instance()->addDocuments(toAdd.toList());
|
|
|
|
|
m_qbsDocuments.unite(toAdd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::updateCppCodeModel(const qbs::ProjectData *prj)
|
|
|
|
|
{
|
|
|
|
|
if (!prj)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Kit *k = 0;
|
|
|
|
|
QtSupport::BaseQtVersion *qtVersion = 0;
|
|
|
|
|
ProjectExplorer::ToolChain *tc = 0;
|
|
|
|
|
if (ProjectExplorer::Target *target = activeTarget())
|
|
|
|
|
k = target->kit();
|
|
|
|
|
else
|
|
|
|
|
k = ProjectExplorer::KitManager::instance()->defaultKit();
|
|
|
|
|
qtVersion = QtSupport::QtKitInformation::qtVersion(k);
|
|
|
|
|
tc = ProjectExplorer::ToolChainKitInformation::toolChain(k);
|
|
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
CppTools::CppModelManagerInterface *modelmanager =
|
|
|
|
|
CppTools::CppModelManagerInterface::instance();
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
if (!modelmanager)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
|
2013-01-30 18:19:31 +01:00
|
|
|
pinfo.clearProjectParts();
|
2013-04-02 11:28:11 +02:00
|
|
|
CppTools::ProjectPart::QtVersion qtVersionForPart
|
|
|
|
|
= CppTools::ProjectPart::NoQt;
|
2013-01-30 18:19:31 +01:00
|
|
|
if (qtVersion) {
|
|
|
|
|
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
2013-04-02 11:28:11 +02:00
|
|
|
qtVersionForPart = CppTools::ProjectPart::Qt4;
|
2013-01-30 18:19:31 +01:00
|
|
|
else
|
2013-04-02 11:28:11 +02:00
|
|
|
qtVersionForPart = CppTools::ProjectPart::Qt5;
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList allFiles;
|
|
|
|
|
foreach (const qbs::ProductData &prd, prj->products()) {
|
|
|
|
|
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
|
|
|
|
|
|
|
|
QStringList grpIncludePaths;
|
|
|
|
|
QStringList grpFrameworkPaths;
|
|
|
|
|
QByteArray grpDefines;
|
|
|
|
|
bool isCxx11;
|
2013-02-20 17:40:52 +01:00
|
|
|
const QStringList cxxFlags = props.getModulePropertiesAsStringList(
|
|
|
|
|
QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_CXXFLAGS));
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
// Toolchain specific stuff:
|
|
|
|
|
QList<ProjectExplorer::HeaderPath> includePaths;
|
|
|
|
|
if (tc) {
|
|
|
|
|
includePaths = tc->systemHeaderPaths(cxxFlags, ProjectExplorer::SysRootKitInformation::sysRoot(k));
|
|
|
|
|
grpDefines += tc->predefinedMacros(cxxFlags);
|
|
|
|
|
if (tc->compilerFlags(cxxFlags) == ProjectExplorer::ToolChain::STD_CXX11)
|
|
|
|
|
isCxx11 = true;
|
|
|
|
|
}
|
|
|
|
|
foreach (const ProjectExplorer::HeaderPath &headerPath, includePaths) {
|
|
|
|
|
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
|
|
|
|
|
grpFrameworkPaths.append(headerPath.path());
|
|
|
|
|
else
|
|
|
|
|
grpIncludePaths.append(headerPath.path());
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
QStringList list = props.getModulePropertiesAsStringList(
|
|
|
|
|
QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_DEFINES));
|
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] = ' ';
|
|
|
|
|
grpDefines += (QByteArray("#define ") + data + '\n');
|
|
|
|
|
}
|
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));
|
2013-01-30 18:19:31 +01:00
|
|
|
foreach (const QString &p, list) {
|
|
|
|
|
const QString cp = Utils::FileName::fromUserInput(p).toString();
|
|
|
|
|
grpIncludePaths.append(cp);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_FRAMEWORKPATHS));
|
2013-01-30 18:19:31 +01:00
|
|
|
foreach (const QString &p, list) {
|
|
|
|
|
const QString cp = Utils::FileName::fromUserInput(p).toString();
|
|
|
|
|
grpFrameworkPaths.append(cp);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-20 17:40:52 +01:00
|
|
|
const QString pch = props.getModuleProperty(QLatin1String(CONFIG_CPP_MODULE),
|
|
|
|
|
QLatin1String(CONFIG_PRECOMPILEDHEADER)).toString();
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart);
|
|
|
|
|
CppTools::ProjectFileAdder adder(part->files);
|
2013-03-04 01:30:46 +04:00
|
|
|
foreach (const QString &file, grp.allFilePaths())
|
|
|
|
|
if (adder.maybeAdd(file))
|
|
|
|
|
allFiles.append(file);
|
2013-04-02 11:28:11 +02:00
|
|
|
part->files << CppTools::ProjectFile(QLatin1String(CONFIGURATION_PATH),
|
|
|
|
|
CppTools::ProjectFile::CXXHeader);
|
2013-03-04 01:30:46 +04:00
|
|
|
|
|
|
|
|
part->qtVersion = qtVersionForPart;
|
|
|
|
|
// TODO: qbs has separate variable for CFLAGS
|
2013-04-02 11:28:11 +02:00
|
|
|
part->cVersion = CppTools::ProjectPart::C99;
|
|
|
|
|
part->cxxVersion = isCxx11 ? CppTools::ProjectPart::CXX11 : CppTools::ProjectPart::CXX98;
|
2013-03-04 01:30:46 +04:00
|
|
|
// TODO: get the exact cxxExtensions from toolchain
|
|
|
|
|
part->includePaths = grpIncludePaths;
|
|
|
|
|
part->frameworkPaths = grpFrameworkPaths;
|
|
|
|
|
part->precompiledHeaders = QStringList(pch);
|
|
|
|
|
part->defines = grpDefines;
|
|
|
|
|
pinfo.appendProjectPart(part);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 14:45:47 +02:00
|
|
|
setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !allFiles.isEmpty());
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
if (pinfo.projectParts().isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Register update the code model:
|
|
|
|
|
modelmanager->updateProjectInfo(pinfo);
|
|
|
|
|
m_codeModelFuture = modelmanager->updateSourceFiles(allFiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsProject::updateQmlJsCodeModel(const qbs::ProjectData *prj)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(prj);
|
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 =
|
|
|
|
|
QmlJSTools::defaultProjectInfoForProject(this);
|
2013-04-10 14:45:47 +02:00
|
|
|
|
|
|
|
|
setProjectLanguage(ProjectExplorer::Constants::LANG_QMLJS, !projectInfo.sourceFiles.isEmpty());
|
2013-01-30 18:19:31 +01:00
|
|
|
modelManager->updateProjectInfo(projectInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 16:21:27 +01:00
|
|
|
QString QbsProject::qbsBuildDir() const
|
|
|
|
|
{
|
|
|
|
|
QString buildDir = Utils::Environment::systemEnvironment()
|
|
|
|
|
.value(QLatin1String("QBS_BUILD_DIR"));
|
|
|
|
|
if (buildDir.isEmpty())
|
2013-03-13 14:48:26 +01:00
|
|
|
buildDir = Core::ICore::resourcePath() + QLatin1String("/qbs");
|
2013-02-21 16:21:27 +01:00
|
|
|
return buildDir;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|