2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-03-10 14:20:07 +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.
|
2009-03-10 14:20:07 +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
|
|
|
****************************************************************************/
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
#include "genericproject.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2009-11-23 12:11:48 +01:00
|
|
|
#include "genericbuildconfiguration.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "genericmakestep.h"
|
2012-08-14 15:37:38 +02:00
|
|
|
#include "genericprojectconstants.h"
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
#include <coreplugin/documentmanager.h>
|
|
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2013-01-08 16:08:38 +01:00
|
|
|
#include <cpptools/cpptoolsconstants.h>
|
2014-09-15 00:12:27 +02:00
|
|
|
#include <cpptools/cppmodelmanager.h>
|
2016-01-12 12:51:33 +01:00
|
|
|
#include <cpptools/projectinfo.h>
|
|
|
|
|
#include <cpptools/projectpartbuilder.h>
|
2012-08-14 15:37:38 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-08-18 13:46:52 +02:00
|
|
|
#include <projectexplorer/abi.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2016-05-12 17:42:36 +02:00
|
|
|
#include <projectexplorer/customexecutablerunconfiguration.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
#include <projectexplorer/headerpath.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
|
#include <projectexplorer/kitmanager.h>
|
2009-03-10 14:20:07 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2015-04-21 09:08:07 +03:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2015-12-22 13:27:22 +01:00
|
|
|
#include <utils/algorithm.h>
|
2011-03-30 15:15:15 +02:00
|
|
|
#include <utils/fileutils.h>
|
2012-08-14 15:37:38 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QProcessEnvironment>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
using namespace Core;
|
2009-09-24 16:02:02 +02:00
|
|
|
using namespace ProjectExplorer;
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
namespace GenericProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-03-18 13:33:00 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
2012-08-14 15:37:38 +02:00
|
|
|
//
|
2009-03-18 13:33:00 +01:00
|
|
|
// GenericProject
|
2012-08-14 15:37:38 +02:00
|
|
|
//
|
2009-03-18 13:33:00 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2016-01-08 12:12:27 +01:00
|
|
|
GenericProject::GenericProject(Manager *manager, const QString &fileName)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2013-09-27 16:30:20 +02:00
|
|
|
setId(Constants::GENERICPROJECT_ID);
|
2016-01-08 11:31:06 +01:00
|
|
|
setProjectManager(manager);
|
2016-01-08 12:12:27 +01:00
|
|
|
setDocument(new GenericProjectFile(this, fileName, GenericProject::Everything));
|
2016-01-08 12:49:00 +01:00
|
|
|
setRootProjectNode(new GenericProjectNode(this));
|
2012-08-14 15:37:38 +02:00
|
|
|
setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT));
|
2013-05-28 13:19:32 +02:00
|
|
|
setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX));
|
2011-04-12 12:17:19 +02:00
|
|
|
|
2016-01-08 12:12:27 +01:00
|
|
|
QFileInfo fileInfo = projectFilePath().toFileInfo();
|
2009-03-16 11:49:57 +01:00
|
|
|
QDir dir = fileInfo.dir();
|
|
|
|
|
|
2009-03-20 16:13:46 +01:00
|
|
|
m_projectName = fileInfo.completeBaseName();
|
2009-03-19 16:33:44 +01:00
|
|
|
m_filesFileName = QFileInfo(dir, m_projectName + QLatin1String(".files")).absoluteFilePath();
|
|
|
|
|
m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath();
|
|
|
|
|
m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath();
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
m_filesIDocument = new GenericProjectFile(this, m_filesFileName, GenericProject::Files);
|
|
|
|
|
m_includesIDocument = new GenericProjectFile(this, m_includesFileName, GenericProject::Configuration);
|
|
|
|
|
m_configIDocument = new GenericProjectFile(this, m_configFileName, GenericProject::Configuration);
|
2011-11-07 17:03:10 +01:00
|
|
|
|
2016-01-08 11:09:37 +01:00
|
|
|
DocumentManager::addDocument(document());
|
2012-08-14 15:37:38 +02:00
|
|
|
DocumentManager::addDocument(m_filesIDocument);
|
|
|
|
|
DocumentManager::addDocument(m_includesIDocument);
|
|
|
|
|
DocumentManager::addDocument(m_configIDocument);
|
2011-11-07 17:03:10 +01:00
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
FileNode *projectFilesNode = new FileNode(Utils::FileName::fromString(m_filesFileName),
|
2016-10-31 13:47:42 +01:00
|
|
|
FileType::Project,
|
2014-10-02 16:15:18 +02:00
|
|
|
/* generated = */ false);
|
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
FileNode *projectIncludesNode = new FileNode(Utils::FileName::fromString(m_includesFileName),
|
2016-10-31 13:47:42 +01:00
|
|
|
FileType::Project,
|
2014-10-02 16:15:18 +02:00
|
|
|
/* generated = */ false);
|
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
FileNode *projectConfigNode = new FileNode(Utils::FileName::fromString(m_configFileName),
|
2016-10-31 13:47:42 +01:00
|
|
|
FileType::Project,
|
2014-10-02 16:15:18 +02:00
|
|
|
/* generated = */ false);
|
|
|
|
|
|
2016-01-08 12:49:00 +01:00
|
|
|
rootProjectNode()->addFileNodes(QList<FileNode *>() << projectFilesNode
|
|
|
|
|
<< projectIncludesNode << projectConfigNode);
|
2014-10-02 16:15:18 +02:00
|
|
|
|
2016-01-08 11:31:06 +01:00
|
|
|
projectManager()->registerProject(this);
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GenericProject::~GenericProject()
|
|
|
|
|
{
|
2010-04-22 18:57:43 +02:00
|
|
|
m_codeModelFuture.cancel();
|
2016-01-08 11:31:06 +01:00
|
|
|
projectManager()->unregisterProject(this);
|
2009-09-24 16:02:02 +02:00
|
|
|
}
|
|
|
|
|
|
2009-03-16 11:49:57 +01:00
|
|
|
QString GenericProject::filesFileName() const
|
2011-04-12 08:20:54 +02:00
|
|
|
{
|
|
|
|
|
return m_filesFileName;
|
|
|
|
|
}
|
2009-03-16 11:49:57 +01:00
|
|
|
|
|
|
|
|
QString GenericProject::includesFileName() const
|
2011-04-12 08:20:54 +02:00
|
|
|
{
|
|
|
|
|
return m_includesFileName;
|
|
|
|
|
}
|
2009-03-16 11:49:57 +01:00
|
|
|
|
|
|
|
|
QString GenericProject::configFileName() const
|
2011-04-12 08:20:54 +02:00
|
|
|
{
|
|
|
|
|
return m_configFileName;
|
|
|
|
|
}
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2009-03-19 17:58:56 +01:00
|
|
|
static QStringList readLines(const QString &absoluteFileName)
|
2009-03-16 11:08:07 +01:00
|
|
|
{
|
|
|
|
|
QStringList lines;
|
|
|
|
|
|
|
|
|
|
QFile file(absoluteFileName);
|
|
|
|
|
if (file.open(QFile::ReadOnly)) {
|
|
|
|
|
QTextStream stream(&file);
|
|
|
|
|
|
|
|
|
|
forever {
|
2015-12-22 15:09:12 +01:00
|
|
|
const QString line = stream.readLine();
|
2009-03-16 11:08:07 +01:00
|
|
|
if (line.isNull())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
lines.append(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lines;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-10 16:38:50 +01:00
|
|
|
bool GenericProject::saveRawFileList(const QStringList &rawFileList)
|
2014-07-28 14:41:55 +02:00
|
|
|
{
|
|
|
|
|
bool result = saveRawList(rawFileList, filesFileName());
|
|
|
|
|
refresh(GenericProject::Files);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GenericProject::saveRawList(const QStringList &rawList, const QString &fileName)
|
2009-06-29 18:04:29 +02:00
|
|
|
{
|
2016-07-18 10:04:42 +02:00
|
|
|
FileChangeBlocker changeGuard(fileName);
|
2009-06-29 18:42:59 +02:00
|
|
|
// Make sure we can open the file for writing
|
2014-07-28 14:41:55 +02:00
|
|
|
Utils::FileSaver saver(fileName, QIODevice::Text);
|
2011-03-30 15:15:15 +02:00
|
|
|
if (!saver.hasError()) {
|
|
|
|
|
QTextStream stream(saver.file());
|
2014-07-28 14:41:55 +02:00
|
|
|
foreach (const QString &filePath, rawList)
|
2011-03-30 15:15:15 +02:00
|
|
|
stream << filePath << QLatin1Char('\n');
|
|
|
|
|
saver.setResult(&stream);
|
|
|
|
|
}
|
2014-07-28 14:43:43 +02:00
|
|
|
bool result = saver.finalize(ICore::mainWindow());
|
|
|
|
|
return result;
|
2009-06-29 18:04:29 +02:00
|
|
|
}
|
2009-03-16 11:08:07 +01:00
|
|
|
|
2015-12-22 13:27:22 +01:00
|
|
|
static void insertSorted(QStringList *list, const QString &value)
|
|
|
|
|
{
|
|
|
|
|
int pos = Utils::indexOf(*list, [value](const QString &s) { return s > value; });
|
|
|
|
|
list->insert(pos, value);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-30 14:07:07 +02:00
|
|
|
bool GenericProject::addFiles(const QStringList &filePaths)
|
|
|
|
|
{
|
2010-02-10 16:38:50 +01:00
|
|
|
QStringList newList = m_rawFileList;
|
|
|
|
|
|
2016-01-08 12:12:27 +01:00
|
|
|
QDir baseDir(projectDirectory().toString());
|
2010-02-10 16:38:50 +01:00
|
|
|
foreach (const QString &filePath, filePaths)
|
2015-12-22 13:27:22 +01:00
|
|
|
insertSorted(&newList, baseDir.relativeFilePath(filePath));
|
2014-07-28 14:41:55 +02:00
|
|
|
|
|
|
|
|
QSet<QString> includes = projectIncludePaths().toSet();
|
|
|
|
|
QSet<QString> toAdd;
|
|
|
|
|
|
2014-09-27 08:01:54 +02:00
|
|
|
foreach (const QString &filePath, filePaths) {
|
2015-12-22 15:09:12 +01:00
|
|
|
const QString directory = QFileInfo(filePath).absolutePath();
|
2015-12-22 13:20:45 +01:00
|
|
|
if (!includes.contains(directory) && !toAdd.contains(directory))
|
2014-07-28 14:41:55 +02:00
|
|
|
toAdd << directory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QDir dir(projectDirectory().toString());
|
|
|
|
|
foreach (const QString &path, toAdd) {
|
|
|
|
|
QString relative = dir.relativeFilePath(path);
|
|
|
|
|
if (relative.isEmpty())
|
2014-08-29 14:00:18 +02:00
|
|
|
relative = QLatin1Char('.');
|
2014-07-28 14:41:55 +02:00
|
|
|
m_rawProjectIncludePaths.append(relative);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool result = saveRawList(newList, filesFileName());
|
|
|
|
|
result &= saveRawList(m_rawProjectIncludePaths, includesFileName());
|
|
|
|
|
refresh(GenericProject::Everything);
|
|
|
|
|
|
|
|
|
|
return result;
|
2009-06-30 14:07:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GenericProject::removeFiles(const QStringList &filePaths)
|
|
|
|
|
{
|
2010-02-10 16:38:50 +01:00
|
|
|
QStringList newList = m_rawFileList;
|
2009-06-30 15:00:30 +02:00
|
|
|
|
2010-02-10 16:38:50 +01:00
|
|
|
foreach (const QString &filePath, filePaths) {
|
|
|
|
|
QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
|
|
|
|
|
if (i != m_rawListEntries.end())
|
|
|
|
|
newList.removeOne(i.value());
|
2009-06-30 15:00:30 +02:00
|
|
|
}
|
2009-06-30 14:07:07 +02:00
|
|
|
|
2010-02-10 16:38:50 +01:00
|
|
|
return saveRawFileList(newList);
|
2009-06-30 14:07:07 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-20 11:57:20 +02:00
|
|
|
bool GenericProject::setFiles(const QStringList &filePaths)
|
|
|
|
|
{
|
|
|
|
|
QStringList newList;
|
2016-01-08 12:12:27 +01:00
|
|
|
QDir baseDir(projectDirectory().toString());
|
2011-06-20 11:57:20 +02:00
|
|
|
foreach (const QString &filePath, filePaths)
|
|
|
|
|
newList.append(baseDir.relativeFilePath(filePath));
|
2015-12-22 13:27:22 +01:00
|
|
|
Utils::sort(newList);
|
2011-06-20 11:57:20 +02:00
|
|
|
|
|
|
|
|
return saveRawFileList(newList);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-24 21:42:11 +02:00
|
|
|
bool GenericProject::renameFile(const QString &filePath, const QString &newFilePath)
|
|
|
|
|
{
|
|
|
|
|
QStringList newList = m_rawFileList;
|
|
|
|
|
|
|
|
|
|
QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
|
|
|
|
|
if (i != m_rawListEntries.end()) {
|
|
|
|
|
int index = newList.indexOf(i.value());
|
|
|
|
|
if (index != -1) {
|
2016-01-08 12:12:27 +01:00
|
|
|
QDir baseDir(projectDirectory().toString());
|
2015-12-22 13:27:22 +01:00
|
|
|
newList.removeAt(index);
|
|
|
|
|
insertSorted(&newList, baseDir.relativeFilePath(newFilePath));
|
2011-10-24 21:42:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return saveRawFileList(newList);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-19 17:58:56 +01:00
|
|
|
void GenericProject::parseProject(RefreshOptions options)
|
2009-03-12 15:07:54 +01:00
|
|
|
{
|
2010-02-10 16:38:50 +01:00
|
|
|
if (options & Files) {
|
|
|
|
|
m_rawListEntries.clear();
|
|
|
|
|
m_rawFileList = readLines(filesFileName());
|
2010-02-11 16:42:23 +01:00
|
|
|
m_files = processEntries(m_rawFileList, &m_rawListEntries);
|
2010-02-10 16:38:50 +01:00
|
|
|
}
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2009-03-19 17:58:56 +01:00
|
|
|
if (options & Configuration) {
|
2014-07-28 14:41:55 +02:00
|
|
|
m_rawProjectIncludePaths = readLines(includesFileName());
|
|
|
|
|
m_projectIncludePaths = processEntries(m_rawProjectIncludePaths);
|
2009-03-16 11:08:07 +01:00
|
|
|
|
2010-02-10 17:28:53 +01:00
|
|
|
// TODO: Possibly load some configuration from the project file
|
|
|
|
|
//QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
2009-03-19 17:58:56 +01:00
|
|
|
}
|
2009-03-16 11:08:07 +01:00
|
|
|
|
2009-03-19 17:58:56 +01:00
|
|
|
if (options & Files)
|
|
|
|
|
emit fileListChanged();
|
2009-03-12 15:07:54 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-19 17:58:56 +01:00
|
|
|
void GenericProject::refresh(RefreshOptions options)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2009-03-19 17:58:56 +01:00
|
|
|
parseProject(options);
|
|
|
|
|
|
2016-10-06 11:31:00 +02:00
|
|
|
if (options & Files) {
|
|
|
|
|
QList<FileNode *> fileNodes = Utils::transform(files(), [](const QString &f) {
|
2016-10-31 13:47:42 +01:00
|
|
|
FileType fileType = FileType::Source; // ### FIXME
|
2016-10-06 11:31:00 +02:00
|
|
|
if (f.endsWith(QLatin1String(".qrc")))
|
2016-10-31 13:47:42 +01:00
|
|
|
fileType = FileType::Resource;
|
2016-10-06 11:31:00 +02:00
|
|
|
return new FileNode(Utils::FileName::fromString(f), fileType, false);
|
|
|
|
|
});
|
|
|
|
|
rootProjectNode()->buildTree(fileNodes);
|
|
|
|
|
}
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2014-06-18 16:16:55 +02:00
|
|
|
refreshCppCodeModel();
|
2016-10-20 13:18:54 +02:00
|
|
|
emit parsingFinished();
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-10 16:38:50 +01:00
|
|
|
/**
|
2010-02-11 16:42:23 +01:00
|
|
|
* Expands environment variables in the given \a string when they are written
|
|
|
|
|
* like $$(VARIABLE).
|
|
|
|
|
*/
|
|
|
|
|
static void expandEnvironmentVariables(const QProcessEnvironment &env, QString &string)
|
|
|
|
|
{
|
2012-04-30 12:01:15 +02:00
|
|
|
static QRegExp candidate(QLatin1String("\\$\\$\\((.+)\\)"));
|
2010-02-11 16:42:23 +01:00
|
|
|
|
|
|
|
|
int index = candidate.indexIn(string);
|
|
|
|
|
while (index != -1) {
|
|
|
|
|
const QString value = env.value(candidate.cap(1));
|
|
|
|
|
|
|
|
|
|
string.replace(index, candidate.matchedLength(), value);
|
|
|
|
|
index += value.length();
|
|
|
|
|
|
|
|
|
|
index = candidate.indexIn(string, index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Expands environment variables and converts the path from relative to the
|
|
|
|
|
* project to an absolute path.
|
|
|
|
|
*
|
2010-02-10 16:38:50 +01:00
|
|
|
* The \a map variable is an optional argument that will map the returned
|
2010-02-11 16:42:23 +01:00
|
|
|
* absolute paths back to their original \a entries.
|
2010-02-10 16:38:50 +01:00
|
|
|
*/
|
2010-02-11 16:42:23 +01:00
|
|
|
QStringList GenericProject::processEntries(const QStringList &paths,
|
|
|
|
|
QHash<QString, QString> *map) const
|
2009-03-12 15:07:54 +01:00
|
|
|
{
|
2010-02-11 16:42:23 +01:00
|
|
|
const QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
2016-01-08 12:12:27 +01:00
|
|
|
const QDir projectDir(projectDirectory().toString());
|
2010-02-11 16:42:23 +01:00
|
|
|
|
2013-03-26 18:06:38 +01:00
|
|
|
QFileInfo fileInfo;
|
2009-03-12 15:07:54 +01:00
|
|
|
QStringList absolutePaths;
|
2010-02-10 16:38:50 +01:00
|
|
|
foreach (const QString &path, paths) {
|
2010-02-11 16:42:23 +01:00
|
|
|
QString trimmedPath = path.trimmed();
|
|
|
|
|
if (trimmedPath.isEmpty())
|
2010-02-10 16:38:50 +01:00
|
|
|
continue;
|
|
|
|
|
|
2010-02-11 16:42:23 +01:00
|
|
|
expandEnvironmentVariables(env, trimmedPath);
|
|
|
|
|
|
2012-12-13 12:11:31 +01:00
|
|
|
trimmedPath = Utils::FileName::fromUserInput(trimmedPath).toString();
|
|
|
|
|
|
2013-03-26 18:06:38 +01:00
|
|
|
fileInfo.setFile(projectDir, trimmedPath);
|
|
|
|
|
if (fileInfo.exists()) {
|
|
|
|
|
const QString absPath = fileInfo.absoluteFilePath();
|
|
|
|
|
absolutePaths.append(absPath);
|
|
|
|
|
if (map)
|
|
|
|
|
map->insert(absPath, trimmedPath);
|
|
|
|
|
}
|
2009-03-12 15:07:54 +01:00
|
|
|
}
|
|
|
|
|
absolutePaths.removeDuplicates();
|
|
|
|
|
return absolutePaths;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-18 16:16:55 +02:00
|
|
|
void GenericProject::refreshCppCodeModel()
|
|
|
|
|
{
|
2015-02-15 23:13:28 +02:00
|
|
|
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
2014-06-18 16:16:55 +02:00
|
|
|
|
|
|
|
|
m_codeModelFuture.cancel();
|
|
|
|
|
|
2015-02-15 23:13:28 +02:00
|
|
|
CppTools::ProjectInfo pInfo(this);
|
2014-06-18 16:16:55 +02:00
|
|
|
CppTools::ProjectPartBuilder ppBuilder(pInfo);
|
2015-04-21 09:08:07 +03:00
|
|
|
|
|
|
|
|
CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt;
|
|
|
|
|
if (QtSupport::BaseQtVersion *qtVersion =
|
|
|
|
|
QtSupport::QtKitInformation::qtVersion(activeTarget()->kit())) {
|
|
|
|
|
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
|
|
|
|
|
activeQtVersion = CppTools::ProjectPart::Qt4;
|
|
|
|
|
else
|
|
|
|
|
activeQtVersion = CppTools::ProjectPart::Qt5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ppBuilder.setQtVersion(activeQtVersion);
|
2014-06-18 16:16:55 +02:00
|
|
|
ppBuilder.setIncludePaths(projectIncludePaths());
|
|
|
|
|
ppBuilder.setConfigFileName(configFileName());
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
const QList<Id> languages = ppBuilder.createProjectPartsForFiles(files());
|
|
|
|
|
foreach (Id language, languages)
|
2014-06-18 16:16:55 +02:00
|
|
|
setProjectLanguage(language, true);
|
|
|
|
|
|
|
|
|
|
m_codeModelFuture = modelManager->updateProjectInfo(pInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-13 15:12:54 +01:00
|
|
|
QStringList GenericProject::projectIncludePaths() const
|
2011-04-12 08:20:54 +02:00
|
|
|
{
|
|
|
|
|
return m_projectIncludePaths;
|
|
|
|
|
}
|
2009-03-13 15:12:54 +01:00
|
|
|
|
2009-03-12 15:07:54 +01:00
|
|
|
QStringList GenericProject::files() const
|
2011-04-12 08:20:54 +02:00
|
|
|
{
|
|
|
|
|
return m_files;
|
|
|
|
|
}
|
2009-03-12 15:07:54 +01:00
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString GenericProject::displayName() const
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2009-03-18 12:18:59 +01:00
|
|
|
return m_projectName;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-08 11:31:06 +01:00
|
|
|
Manager *GenericProject::projectManager() const
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2016-01-08 11:31:06 +01:00
|
|
|
return static_cast<Manager *>(Project::projectManager());
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList GenericProject::files(FilesMode fileMode) const
|
|
|
|
|
{
|
2015-11-26 12:37:17 +01:00
|
|
|
Q_UNUSED(fileMode);
|
2013-01-08 16:08:38 +01:00
|
|
|
return m_files;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QStringList GenericProject::buildTargets() const
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
|
|
|
|
QStringList targets;
|
|
|
|
|
targets.append(QLatin1String("all"));
|
|
|
|
|
targets.append(QLatin1String("clean"));
|
|
|
|
|
return targets;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-18 16:57:29 +02:00
|
|
|
Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
2010-01-19 16:33:44 +01:00
|
|
|
{
|
2015-05-18 16:57:29 +02:00
|
|
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
|
|
|
|
if (result != RestoreResult::Ok)
|
|
|
|
|
return result;
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
Kit *defaultKit = KitManager::defaultKit();
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!activeTarget() && defaultKit)
|
|
|
|
|
addTarget(createTarget(defaultKit));
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2010-04-27 10:58:36 +02:00
|
|
|
// Sanity check: We need both a buildconfiguration and a runconfiguration!
|
|
|
|
|
QList<Target *> targetList = targets();
|
2015-09-04 14:59:40 +02:00
|
|
|
if (targetList.isEmpty())
|
|
|
|
|
return RestoreResult::Error;
|
|
|
|
|
|
2010-04-27 10:58:36 +02:00
|
|
|
foreach (Target *t, targetList) {
|
|
|
|
|
if (!t->activeBuildConfiguration()) {
|
|
|
|
|
removeTarget(t);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!t->activeRunConfiguration())
|
2016-05-12 17:42:36 +02:00
|
|
|
t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
|
2010-04-27 10:58:36 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
refresh(Everything);
|
2015-05-18 16:57:29 +02:00
|
|
|
return RestoreResult::Ok;
|
2009-08-21 15:59:17 +02:00
|
|
|
}
|
|
|
|
|
|
2009-03-10 14:20:07 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
2012-08-14 15:37:38 +02:00
|
|
|
//
|
2009-03-10 14:20:07 +01:00
|
|
|
// GenericProjectFile
|
2012-08-14 15:37:38 +02:00
|
|
|
//
|
2009-03-10 14:20:07 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
2009-03-18 13:33:00 +01:00
|
|
|
|
2016-01-08 11:09:37 +01:00
|
|
|
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName,
|
|
|
|
|
GenericProject::RefreshOptions options) :
|
2009-03-18 12:18:59 +01:00
|
|
|
m_project(parent),
|
2011-11-07 17:03:10 +01:00
|
|
|
m_options(options)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2014-03-05 15:58:12 +01:00
|
|
|
setId("Generic.ProjectFile");
|
2014-06-26 02:15:34 +02:00
|
|
|
setMimeType(QLatin1String(Constants::GENERICMIMETYPE));
|
2014-12-21 21:54:30 +02:00
|
|
|
setFilePath(Utils::FileName::fromString(fileName));
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2015-11-26 12:37:17 +01:00
|
|
|
Q_UNUSED(state);
|
|
|
|
|
Q_UNUSED(type);
|
2010-03-19 10:28:05 +01:00
|
|
|
return BehaviorSilent;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-04 15:24:13 +02:00
|
|
|
bool GenericProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
|
2010-03-19 10:28:05 +01:00
|
|
|
{
|
2015-11-26 12:37:17 +01:00
|
|
|
Q_UNUSED(errorString);
|
|
|
|
|
Q_UNUSED(flag);
|
2011-11-07 17:03:10 +01:00
|
|
|
if (type == TypePermissions)
|
|
|
|
|
return true;
|
|
|
|
|
m_project->refresh(m_options);
|
2011-04-04 15:24:13 +02:00
|
|
|
return true;
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
2012-08-14 15:37:38 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace GenericProjectManager
|