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>
|
2017-03-15 13:40:21 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
|
|
|
|
|
2019-08-29 11:34:13 +02:00
|
|
|
#include <cpptools/cppprojectupdaterinterface.h>
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2017-03-15 13:40:21 +01:00
|
|
|
|
2011-08-18 13:46:52 +02:00
|
|
|
#include <projectexplorer/abi.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2019-10-22 14:55:51 +02:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2016-05-12 17:42:36 +02:00
|
|
|
#include <projectexplorer/customexecutablerunconfiguration.h>
|
2018-11-14 10:23:47 +01:00
|
|
|
#include <projectexplorer/deploymentdata.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>
|
2009-03-10 14:20:07 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2017-03-15 13:40:21 +01:00
|
|
|
#include <projectexplorer/projectnodes.h>
|
2019-10-23 09:49:27 +02:00
|
|
|
#include <projectexplorer/selectablefilesmodel.h>
|
2017-03-15 13:40:21 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2019-10-23 09:49:27 +02:00
|
|
|
#include <projectexplorer/taskhub.h>
|
2017-03-15 13:40:21 +01:00
|
|
|
|
2015-04-21 09:08:07 +03:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
2019-01-04 12:35:28 +01:00
|
|
|
#include <qtsupport/qtcppkitinfo.h>
|
2015-04-21 09:08:07 +03:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2017-03-15 13:40:21 +01:00
|
|
|
|
2015-12-22 13:27:22 +01:00
|
|
|
#include <utils/algorithm.h>
|
2018-11-14 10:23:47 +01:00
|
|
|
#include <utils/filesystemwatcher.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>
|
2019-01-11 14:10:09 +01:00
|
|
|
#include <utils/qtcprocess.h>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
2018-11-14 10:23:47 +01:00
|
|
|
#include <QFileInfo>
|
2017-03-15 13:40:21 +01:00
|
|
|
#include <QHash>
|
2019-08-29 11:34:13 +02:00
|
|
|
#include <QMetaObject>
|
2017-03-15 13:40:21 +01:00
|
|
|
#include <QSet>
|
|
|
|
|
#include <QStringList>
|
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;
|
2017-03-03 18:16:34 +01:00
|
|
|
using namespace Utils;
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
namespace GenericProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
enum RefreshOptions {
|
|
|
|
|
Files = 0x01,
|
|
|
|
|
Configuration = 0x02,
|
|
|
|
|
Everything = Files | Configuration
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-15 13:40:21 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// GenericProjectFile
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class GenericProjectFile : public Core::IDocument
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-10-23 09:49:27 +02:00
|
|
|
GenericProjectFile(GenericProject *parent, const FilePath &fileName, RefreshOptions options)
|
|
|
|
|
: m_project(parent), m_options(options)
|
2017-03-15 13:40:21 +01:00
|
|
|
{
|
|
|
|
|
setId("Generic.ProjectFile");
|
|
|
|
|
setMimeType(Constants::GENERICMIMETYPE);
|
|
|
|
|
setFilePath(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReloadBehavior reloadBehavior(ChangeTrigger, ChangeType) const final
|
|
|
|
|
{
|
|
|
|
|
return BehaviorSilent;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
2017-03-15 13:40:21 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
GenericProject *m_project = nullptr;
|
2019-10-23 09:49:27 +02:00
|
|
|
RefreshOptions m_options;
|
2017-03-15 13:40:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// GenericProjectNode
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
class GenericBuildSystem : public BuildSystem
|
2017-03-15 13:40:21 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2019-10-25 09:55:32 +02:00
|
|
|
explicit GenericBuildSystem(Target *target);
|
2019-10-23 09:49:27 +02:00
|
|
|
~GenericBuildSystem();
|
2017-03-15 13:40:21 +01:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void triggerParsing() final;
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool supportsAction(Node *, ProjectAction action, const Node *) const final
|
2017-03-15 13:40:21 +01:00
|
|
|
{
|
2017-04-19 09:56:14 +02:00
|
|
|
return action == AddNewFile
|
|
|
|
|
|| action == AddExistingFile
|
|
|
|
|
|| action == AddExistingDirectory
|
|
|
|
|
|| action == RemoveFile
|
|
|
|
|
|| action == Rename;
|
2017-03-15 13:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
RemovedFilesFromProject removeFiles(Node *, const QStringList &filePaths, QStringList *) final;
|
|
|
|
|
bool renameFile(Node *, const QString &filePath, const QString &newFilePath) final;
|
|
|
|
|
bool addFiles(Node *, const QStringList &filePaths, QStringList *) final;
|
2017-03-15 13:40:21 +01:00
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
FilePath filesFilePath() const { return ::FilePath::fromString(m_filesFileName); }
|
|
|
|
|
|
|
|
|
|
void refresh(RefreshOptions options);
|
|
|
|
|
|
|
|
|
|
bool saveRawFileList(const QStringList &rawFileList);
|
|
|
|
|
bool saveRawList(const QStringList &rawList, const QString &fileName);
|
|
|
|
|
void parse(RefreshOptions options);
|
|
|
|
|
|
|
|
|
|
QStringList processEntries(const QStringList &paths,
|
|
|
|
|
QHash<QString, QString> *map = nullptr) const;
|
|
|
|
|
|
|
|
|
|
Utils::FilePath findCommonSourceRoot();
|
|
|
|
|
void refreshCppCodeModel();
|
|
|
|
|
void updateDeploymentData();
|
|
|
|
|
|
|
|
|
|
bool setFiles(const QStringList &filePaths);
|
|
|
|
|
void removeFiles(const QStringList &filesToRemove);
|
2017-03-15 13:40:21 +01:00
|
|
|
|
|
|
|
|
private:
|
2019-10-23 09:49:27 +02:00
|
|
|
QString m_filesFileName;
|
|
|
|
|
QString m_includesFileName;
|
|
|
|
|
QString m_configFileName;
|
|
|
|
|
QString m_cxxflagsFileName;
|
|
|
|
|
QString m_cflagsFileName;
|
|
|
|
|
QStringList m_rawFileList;
|
|
|
|
|
QStringList m_files;
|
|
|
|
|
QHash<QString, QString> m_rawListEntries;
|
|
|
|
|
QStringList m_rawProjectIncludePaths;
|
|
|
|
|
ProjectExplorer::HeaderPaths m_projectIncludePaths;
|
|
|
|
|
QStringList m_cxxflags;
|
|
|
|
|
QStringList m_cflags;
|
|
|
|
|
|
|
|
|
|
CppTools::CppProjectUpdaterInterface *m_cppCodeModelUpdater = nullptr;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
Utils::FileSystemWatcher m_deployFileWatcher;
|
2017-03-15 13:40:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2019-01-11 14:10:09 +01:00
|
|
|
static bool writeFile(const QString &filePath, const QString &contents)
|
|
|
|
|
{
|
|
|
|
|
Utils::FileSaver saver(filePath, QIODevice::Text | QIODevice::WriteOnly);
|
|
|
|
|
return saver.write(contents.toUtf8()) && saver.finalize();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 12:24:08 +02:00
|
|
|
GenericProject::GenericProject(const Utils::FilePath &fileName)
|
|
|
|
|
: Project(Constants::GENERICMIMETYPE, fileName)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2013-09-27 16:30:20 +02:00
|
|
|
setId(Constants::GENERICPROJECT_ID);
|
2017-01-30 14:59:10 +01:00
|
|
|
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
2017-04-07 14:35:49 +02:00
|
|
|
setDisplayName(fileName.toFileInfo().completeBaseName());
|
2019-10-25 09:55:32 +02:00
|
|
|
setBuildSystemCreator([](Target *t) { return new GenericBuildSystem(t); });
|
2019-10-23 09:49:27 +02:00
|
|
|
}
|
2011-04-12 12:17:19 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
GenericBuildSystem::GenericBuildSystem(Target *target)
|
|
|
|
|
: BuildSystem(target)
|
2019-10-23 09:49:27 +02:00
|
|
|
{
|
2019-08-29 11:34:13 +02:00
|
|
|
QObject *projectUpdaterFactory = ExtensionSystem::PluginManager::getObjectByName(
|
|
|
|
|
"CppProjectUpdaterFactory");
|
|
|
|
|
if (projectUpdaterFactory) {
|
|
|
|
|
const bool successFullyCreatedProjectUpdater
|
|
|
|
|
= QMetaObject::invokeMethod(projectUpdaterFactory,
|
|
|
|
|
"create",
|
|
|
|
|
Q_RETURN_ARG(CppTools::CppProjectUpdaterInterface *,
|
|
|
|
|
m_cppCodeModelUpdater));
|
|
|
|
|
QTC_CHECK(successFullyCreatedProjectUpdater);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(target->project(), &Project::projectFileIsDirty, this, [this](const FilePath &p) {
|
2019-08-15 12:24:08 +02:00
|
|
|
if (p.endsWith(".files"))
|
|
|
|
|
refresh(Files);
|
|
|
|
|
else if (p.endsWith(".includes") || p.endsWith(".config") || p.endsWith(".cxxflags")
|
|
|
|
|
|| p.endsWith(".cflags"))
|
|
|
|
|
refresh(Configuration);
|
|
|
|
|
else
|
|
|
|
|
refresh(Everything);
|
|
|
|
|
});
|
|
|
|
|
|
2016-12-25 17:59:17 +01:00
|
|
|
const QFileInfo fileInfo = projectFilePath().toFileInfo();
|
|
|
|
|
const QDir dir = fileInfo.dir();
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2017-03-03 17:10:00 +01:00
|
|
|
const QString projectName = fileInfo.completeBaseName();
|
|
|
|
|
|
|
|
|
|
m_filesFileName = QFileInfo(dir, projectName + ".files").absoluteFilePath();
|
|
|
|
|
m_includesFileName = QFileInfo(dir, projectName + ".includes").absoluteFilePath();
|
2019-08-15 12:24:08 +02:00
|
|
|
m_configFileName = QFileInfo(dir, projectName + ".config").absoluteFilePath();
|
2009-03-16 11:49:57 +01:00
|
|
|
|
2019-01-11 14:10:09 +01:00
|
|
|
const QFileInfo cxxflagsFileInfo(dir, projectName + ".cxxflags");
|
|
|
|
|
m_cxxflagsFileName = cxxflagsFileInfo.absoluteFilePath();
|
|
|
|
|
if (!cxxflagsFileInfo.exists()) {
|
|
|
|
|
QTC_CHECK(writeFile(m_cxxflagsFileName, Constants::GENERICPROJECT_CXXFLAGS_FILE_TEMPLATE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QFileInfo cflagsFileInfo(dir, projectName + ".cflags");
|
|
|
|
|
m_cflagsFileName = cflagsFileInfo.absoluteFilePath();
|
|
|
|
|
if (!cflagsFileInfo.exists()) {
|
|
|
|
|
QTC_CHECK(writeFile(m_cflagsFileName, Constants::GENERICPROJECT_CFLAGS_FILE_TEMPLATE));
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
project()->setExtraProjectFiles({FilePath::fromString(m_filesFileName),
|
|
|
|
|
FilePath::fromString(m_includesFileName),
|
|
|
|
|
FilePath::fromString(m_configFileName),
|
|
|
|
|
FilePath::fromString(m_cxxflagsFileName),
|
|
|
|
|
FilePath::fromString(m_cflagsFileName)});
|
2019-08-15 12:24:08 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(&m_deployFileWatcher, &FileSystemWatcher::fileChanged,
|
2019-10-23 09:49:27 +02:00
|
|
|
this, &GenericBuildSystem::updateDeploymentData);
|
2019-08-02 13:59:21 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(target, &Target::activeBuildConfigurationChanged, this, [this] { refresh(Everything); });
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
GenericBuildSystem::~GenericBuildSystem()
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2017-02-06 16:59:53 +01:00
|
|
|
delete m_cppCodeModelUpdater;
|
2009-09-24 16:02:02 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void GenericBuildSystem::triggerParsing()
|
|
|
|
|
{
|
|
|
|
|
refresh(Everything);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
|
2016-12-25 17:59:17 +01:00
|
|
|
for (;;) {
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool GenericBuildSystem::saveRawFileList(const QStringList &rawFileList)
|
2014-07-28 14:41:55 +02:00
|
|
|
{
|
2017-03-15 13:40:21 +01:00
|
|
|
bool result = saveRawList(rawFileList, m_filesFileName);
|
2019-10-23 09:49:27 +02:00
|
|
|
refresh(Files);
|
2014-07-28 14:41:55 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool GenericBuildSystem::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());
|
2016-12-25 17:59:17 +01:00
|
|
|
for (const QString &filePath : rawList)
|
|
|
|
|
stream << filePath << '\n';
|
2011-03-30 15:15:15 +02:00
|
|
|
saver.setResult(&stream);
|
|
|
|
|
}
|
2020-06-02 09:10:40 +02:00
|
|
|
bool result = saver.finalize(ICore::dialogParent());
|
2014-07-28 14:43:43 +02:00
|
|
|
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)
|
|
|
|
|
{
|
2019-11-14 09:49:12 +01:00
|
|
|
const auto it = std::lower_bound(list->begin(), list->end(), value);
|
|
|
|
|
if (it == list->end())
|
2018-10-01 20:41:50 +02:00
|
|
|
list->append(value);
|
2019-11-14 09:49:12 +01:00
|
|
|
else if (*it > value)
|
|
|
|
|
list->insert(it, value);
|
2015-12-22 13:27:22 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool GenericBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringList *)
|
2009-06-30 14:07:07 +02:00
|
|
|
{
|
2016-12-25 17:59:17 +01:00
|
|
|
const QDir baseDir(projectDirectory().toString());
|
2019-11-14 09:49:12 +01:00
|
|
|
QStringList newList = m_rawFileList;
|
|
|
|
|
if (filePaths.size() > m_rawFileList.size()) {
|
|
|
|
|
newList += transform(filePaths, [&baseDir](const QString &p) {
|
|
|
|
|
return baseDir.relativeFilePath(p);
|
|
|
|
|
});
|
|
|
|
|
sort(newList);
|
|
|
|
|
newList.erase(std::unique(newList.begin(), newList.end()), newList.end());
|
|
|
|
|
} else {
|
|
|
|
|
for (const QString &filePath : filePaths)
|
|
|
|
|
insertSorted(&newList, baseDir.relativeFilePath(filePath));
|
|
|
|
|
}
|
2014-07-28 14:41:55 +02:00
|
|
|
|
2019-08-16 13:04:41 +02:00
|
|
|
const auto includes = transform<QSet<QString>>(m_projectIncludePaths,
|
|
|
|
|
[](const HeaderPath &hp) { return hp.path; });
|
2014-07-28 14:41:55 +02:00
|
|
|
QSet<QString> toAdd;
|
|
|
|
|
|
2016-12-25 17:59:17 +01:00
|
|
|
for (const QString &filePath : filePaths) {
|
2015-12-22 15:09:12 +01:00
|
|
|
const QString directory = QFileInfo(filePath).absolutePath();
|
2017-01-02 11:40:16 +01:00
|
|
|
if (!includes.contains(directory))
|
2014-07-28 14:41:55 +02:00
|
|
|
toAdd << directory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QDir dir(projectDirectory().toString());
|
2016-12-25 17:59:17 +01:00
|
|
|
const auto candidates = toAdd;
|
|
|
|
|
for (const QString &path : candidates) {
|
2014-07-28 14:41:55 +02:00
|
|
|
QString relative = dir.relativeFilePath(path);
|
|
|
|
|
if (relative.isEmpty())
|
2016-12-25 17:59:17 +01:00
|
|
|
relative = '.';
|
2014-07-28 14:41:55 +02:00
|
|
|
m_rawProjectIncludePaths.append(relative);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 13:40:21 +01:00
|
|
|
bool result = saveRawList(newList, m_filesFileName);
|
|
|
|
|
result &= saveRawList(m_rawProjectIncludePaths, m_includesFileName);
|
2019-10-23 09:49:27 +02:00
|
|
|
refresh(Everything);
|
2014-07-28 14:41:55 +02:00
|
|
|
|
|
|
|
|
return result;
|
2009-06-30 14:07:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
RemovedFilesFromProject GenericBuildSystem::removeFiles(Node *, const QStringList &filePaths, QStringList *)
|
2009-06-30 14:07:07 +02:00
|
|
|
{
|
2010-02-10 16:38:50 +01:00
|
|
|
QStringList newList = m_rawFileList;
|
2009-06-30 15:00:30 +02:00
|
|
|
|
2016-12-25 17:59:17 +01:00
|
|
|
for (const QString &filePath : filePaths) {
|
2010-02-10 16:38:50 +01:00
|
|
|
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
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
return saveRawFileList(newList) ? RemovedFilesFromProject::Ok
|
|
|
|
|
: RemovedFilesFromProject::Error;
|
2009-06-30 14:07:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool GenericBuildSystem::setFiles(const QStringList &filePaths)
|
2011-06-20 11:57:20 +02:00
|
|
|
{
|
|
|
|
|
QStringList newList;
|
2016-01-08 12:12:27 +01:00
|
|
|
QDir baseDir(projectDirectory().toString());
|
2016-12-25 17:59:17 +01:00
|
|
|
for (const QString &filePath : filePaths)
|
2011-06-20 11:57:20 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool GenericBuildSystem::renameFile(Node *, const QString &filePath, const QString &newFilePath)
|
2011-10-24 21:42:11 +02:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 14:10:09 +01:00
|
|
|
static QStringList readFlags(const QString &filePath)
|
|
|
|
|
{
|
|
|
|
|
const QStringList lines = readLines(filePath);
|
|
|
|
|
if (lines.isEmpty())
|
|
|
|
|
return QStringList();
|
2019-10-24 19:32:48 +02:00
|
|
|
QStringList flags;
|
|
|
|
|
for (const auto &line : lines)
|
|
|
|
|
flags.append(QtcProcess::splitArgs(line));
|
|
|
|
|
return flags;
|
2019-01-11 14:10:09 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
void GenericBuildSystem::parse(RefreshOptions options)
|
2009-03-12 15:07:54 +01:00
|
|
|
{
|
2010-02-10 16:38:50 +01:00
|
|
|
if (options & Files) {
|
|
|
|
|
m_rawListEntries.clear();
|
2017-03-15 13:40:21 +01:00
|
|
|
m_rawFileList = readLines(m_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) {
|
2017-03-15 13:40:21 +01:00
|
|
|
m_rawProjectIncludePaths = readLines(m_includesFileName);
|
2019-08-16 13:04:41 +02:00
|
|
|
QStringList normalPaths;
|
|
|
|
|
QStringList frameworkPaths;
|
2019-08-29 09:20:16 +02:00
|
|
|
for (const QString &rawPath : qAsConst(m_rawProjectIncludePaths)) {
|
2019-08-16 13:04:41 +02:00
|
|
|
if (rawPath.startsWith("-F"))
|
|
|
|
|
frameworkPaths << rawPath.mid(2);
|
|
|
|
|
else
|
|
|
|
|
normalPaths << rawPath;
|
|
|
|
|
}
|
|
|
|
|
const auto stringsToHeaderPaths = [this](const QStringList &paths, HeaderPathType type) {
|
|
|
|
|
return transform<HeaderPaths>(processEntries(paths),
|
|
|
|
|
[type](const QString &p) { return HeaderPath(p, type);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
m_projectIncludePaths = stringsToHeaderPaths(normalPaths, HeaderPathType::User);
|
|
|
|
|
m_projectIncludePaths << stringsToHeaderPaths(frameworkPaths, HeaderPathType::Framework);
|
2019-01-11 14:10:09 +01:00
|
|
|
m_cxxflags = readFlags(m_cxxflagsFileName);
|
|
|
|
|
m_cflags = readFlags(m_cflagsFileName);
|
2009-03-19 17:58:56 +01:00
|
|
|
}
|
2009-03-12 15:07:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
FilePath GenericBuildSystem::findCommonSourceRoot()
|
2019-05-13 12:18:07 +02:00
|
|
|
{
|
2019-07-18 09:28:34 +02:00
|
|
|
if (m_files.isEmpty())
|
|
|
|
|
return FilePath::fromFileInfo(QFileInfo(m_filesFileName).absolutePath());
|
|
|
|
|
|
|
|
|
|
QString root = m_files.front();
|
2019-08-29 09:20:16 +02:00
|
|
|
for (const QString &item : qAsConst(m_files)) {
|
2019-05-13 12:18:07 +02:00
|
|
|
if (root.length() > item.length())
|
|
|
|
|
root.truncate(item.length());
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < root.length(); ++i) {
|
|
|
|
|
if (root[i] != item[i]) {
|
|
|
|
|
root.truncate(i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-18 09:28:34 +02:00
|
|
|
return FilePath::fromString(QFileInfo(root).absolutePath());
|
2019-05-13 12:18:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
void GenericBuildSystem::refresh(RefreshOptions options)
|
2009-03-10 14:20:07 +01:00
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
ParseGuard guard = guardParsingRun();
|
2019-10-23 09:49:27 +02:00
|
|
|
parse(options);
|
2009-03-19 17:58:56 +01:00
|
|
|
|
2016-10-06 11:31:00 +02:00
|
|
|
if (options & Files) {
|
2019-10-22 14:55:51 +02:00
|
|
|
auto newRoot = std::make_unique<ProjectNode>(projectDirectory());
|
|
|
|
|
newRoot->setDisplayName(projectFilePath().toFileInfo().completeBaseName());
|
2017-03-10 17:30:40 +01:00
|
|
|
|
2019-05-13 12:18:07 +02:00
|
|
|
// find the common base directory of all source files
|
2019-10-23 09:49:27 +02:00
|
|
|
FilePath baseDir = findCommonSourceRoot();
|
2019-05-13 12:18:07 +02:00
|
|
|
|
2019-11-14 10:52:37 +01:00
|
|
|
std::vector<std::unique_ptr<FileNode>> fileNodes;
|
2019-08-29 09:20:16 +02:00
|
|
|
for (const QString &f : qAsConst(m_files)) {
|
2016-10-31 13:47:42 +01:00
|
|
|
FileType fileType = FileType::Source; // ### FIXME
|
2016-12-25 17:59:17 +01:00
|
|
|
if (f.endsWith(".qrc"))
|
2016-10-31 13:47:42 +01:00
|
|
|
fileType = FileType::Resource;
|
2019-11-14 10:52:37 +01:00
|
|
|
fileNodes.emplace_back(std::make_unique<FileNode>(FilePath::fromString(f), fileType));
|
2017-03-10 17:30:40 +01:00
|
|
|
}
|
2019-11-14 10:52:37 +01:00
|
|
|
newRoot->addNestedNodes(std::move(fileNodes), baseDir);
|
2016-12-29 13:46:03 +01:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
newRoot->addNestedNode(std::make_unique<FileNode>(FilePath::fromString(m_filesFileName),
|
2019-02-25 12:08:58 +01:00
|
|
|
FileType::Project));
|
2019-05-28 13:49:26 +02:00
|
|
|
newRoot->addNestedNode(std::make_unique<FileNode>(FilePath::fromString(m_includesFileName),
|
2019-02-25 12:08:58 +01:00
|
|
|
FileType::Project));
|
2019-05-28 13:49:26 +02:00
|
|
|
newRoot->addNestedNode(std::make_unique<FileNode>(FilePath::fromString(m_configFileName),
|
2019-02-25 12:08:58 +01:00
|
|
|
FileType::Project));
|
2019-05-28 13:49:26 +02:00
|
|
|
newRoot->addNestedNode(std::make_unique<FileNode>(FilePath::fromString(m_cxxflagsFileName),
|
2019-02-25 12:08:58 +01:00
|
|
|
FileType::Project));
|
2019-05-28 13:49:26 +02:00
|
|
|
newRoot->addNestedNode(std::make_unique<FileNode>(FilePath::fromString(m_cflagsFileName),
|
2019-02-25 12:08:58 +01:00
|
|
|
FileType::Project));
|
2017-03-03 15:13:06 +01:00
|
|
|
|
2019-05-13 12:18:07 +02:00
|
|
|
newRoot->compress();
|
2019-11-20 15:21:54 +01:00
|
|
|
setRootProjectNode(std::move(newRoot));
|
2016-10-06 11:31:00 +02:00
|
|
|
}
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2014-06-18 16:16:55 +02:00
|
|
|
refreshCppCodeModel();
|
2018-11-14 10:23:47 +01:00
|
|
|
updateDeploymentData();
|
2019-08-06 14:46:37 +02:00
|
|
|
guard.markAsSuccess();
|
2019-11-15 15:44:45 +01:00
|
|
|
|
|
|
|
|
emitBuildSystemUpdated();
|
2009-03-10 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-11 16:42:23 +01:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
*/
|
2019-10-23 09:49:27 +02:00
|
|
|
QStringList GenericBuildSystem::processEntries(const QStringList &paths,
|
|
|
|
|
QHash<QString, QString> *map) const
|
2009-03-12 15:07:54 +01:00
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
const BuildConfiguration *const buildConfig = target()->activeBuildConfiguration();
|
2016-12-20 16:42:01 +01:00
|
|
|
|
2016-12-20 16:40:28 +01:00
|
|
|
const Utils::Environment buildEnv = buildConfig ? buildConfig->environment()
|
|
|
|
|
: Utils::Environment::systemEnvironment();
|
2016-12-20 16:42:01 +01:00
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
const Utils::MacroExpander *expander = project()->macroExpander();
|
2016-12-20 16:42:01 +01:00
|
|
|
if (buildConfig)
|
|
|
|
|
expander = buildConfig->macroExpander();
|
2019-10-25 09:55:32 +02:00
|
|
|
else
|
|
|
|
|
expander = target()->macroExpander();
|
2016-12-20 16:42:01 +01:00
|
|
|
|
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;
|
2016-12-25 17:59:17 +01:00
|
|
|
for (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;
|
|
|
|
|
|
2016-12-20 16:40:28 +01:00
|
|
|
trimmedPath = buildEnv.expandVariables(trimmedPath);
|
2016-12-20 16:42:01 +01:00
|
|
|
trimmedPath = expander->expand(trimmedPath);
|
2010-02-11 16:42:23 +01:00
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
trimmedPath = Utils::FilePath::fromUserInput(trimmedPath).toString();
|
2012-12-13 12:11:31 +01:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
void GenericBuildSystem::refreshCppCodeModel()
|
2014-06-18 16:16:55 +02:00
|
|
|
{
|
2019-08-29 11:34:13 +02:00
|
|
|
if (!m_cppCodeModelUpdater)
|
|
|
|
|
return;
|
2019-11-20 12:12:53 +01:00
|
|
|
QtSupport::CppKitInfo kitInfo(kit());
|
2019-01-04 12:35:28 +01:00
|
|
|
QTC_ASSERT(kitInfo.isValid(), return);
|
2015-04-21 09:08:07 +03:00
|
|
|
|
2019-08-28 18:22:45 +02:00
|
|
|
RawProjectPart rpp;
|
2019-10-23 09:49:27 +02:00
|
|
|
rpp.setDisplayName(project()->displayName());
|
2017-03-09 14:13:22 +01:00
|
|
|
rpp.setProjectFileLocation(projectFilePath().toString());
|
2019-01-04 12:35:28 +01:00
|
|
|
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
2019-08-16 13:04:41 +02:00
|
|
|
rpp.setHeaderPaths(m_projectIncludePaths);
|
2017-03-15 13:40:21 +01:00
|
|
|
rpp.setConfigFileName(m_configFileName);
|
2019-01-11 14:10:09 +01:00
|
|
|
rpp.setFlagsForCxx({nullptr, m_cxxflags});
|
|
|
|
|
rpp.setFlagsForC({nullptr, m_cflags});
|
2017-03-15 13:40:21 +01:00
|
|
|
rpp.setFiles(m_files);
|
2014-06-18 16:16:55 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
m_cppCodeModelUpdater->update({project(), kitInfo, activeParseEnvironment(), {rpp}});
|
2014-06-18 16:16:55 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
void GenericBuildSystem::updateDeploymentData()
|
2018-11-14 10:23:47 +01:00
|
|
|
{
|
|
|
|
|
static const QString fileName("QtCreatorDeployment.txt");
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath deploymentFilePath;
|
2020-02-05 12:32:44 +01:00
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
|
|
|
|
if (bc)
|
|
|
|
|
deploymentFilePath = bc->buildDirectory().pathAppended(fileName);
|
|
|
|
|
|
2018-11-14 10:23:47 +01:00
|
|
|
bool hasDeploymentData = QFileInfo::exists(deploymentFilePath.toString());
|
|
|
|
|
if (!hasDeploymentData) {
|
2019-05-16 14:49:56 +02:00
|
|
|
deploymentFilePath = projectDirectory().pathAppended(fileName);
|
2018-11-14 10:23:47 +01:00
|
|
|
hasDeploymentData = QFileInfo::exists(deploymentFilePath.toString());
|
|
|
|
|
}
|
|
|
|
|
if (hasDeploymentData) {
|
2020-02-05 12:32:44 +01:00
|
|
|
DeploymentData deploymentData;
|
|
|
|
|
deploymentData.addFilesFromDeploymentFile(deploymentFilePath.toString(),
|
|
|
|
|
projectDirectory().toString());
|
|
|
|
|
setDeploymentData(deploymentData);
|
2019-10-25 09:55:32 +02:00
|
|
|
if (m_deployFileWatcher.files() != QStringList(deploymentFilePath.toString())) {
|
|
|
|
|
m_deployFileWatcher.removeFiles(m_deployFileWatcher.files());
|
|
|
|
|
m_deployFileWatcher.addFile(deploymentFilePath.toString(),
|
|
|
|
|
FileSystemWatcher::WatchModifiedDate);
|
2018-11-14 10:23:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
void GenericBuildSystem::removeFiles(const QStringList &filesToRemove)
|
|
|
|
|
{
|
|
|
|
|
if (removeFiles(nullptr, filesToRemove, nullptr) == RemovedFilesFromProject::Error) {
|
2020-03-12 13:46:25 +01:00
|
|
|
TaskHub::addTask(BuildSystemTask(Task::Error,
|
|
|
|
|
GenericProject::tr("Project files list update failed."),
|
2020-01-15 08:56:11 +01:00
|
|
|
filesFilePath()));
|
2019-10-23 09:49:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2016-12-25 17:59:17 +01:00
|
|
|
const RestoreResult result = Project::fromMap(map, errorMessage);
|
2015-05-18 16:57:29 +02:00
|
|
|
if (result != RestoreResult::Ok)
|
|
|
|
|
return result;
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2019-08-01 14:58:00 +02:00
|
|
|
if (!activeTarget())
|
|
|
|
|
addTargetForDefaultKit();
|
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!
|
2016-12-25 17:59:17 +01:00
|
|
|
const QList<Target *> targetList = targets();
|
2015-09-04 14:59:40 +02:00
|
|
|
if (targetList.isEmpty())
|
|
|
|
|
return RestoreResult::Error;
|
|
|
|
|
|
2016-12-25 17:59:17 +01:00
|
|
|
for (Target *t : targetList) {
|
2010-04-27 10:58:36 +02:00
|
|
|
if (!t->activeBuildConfiguration()) {
|
|
|
|
|
removeTarget(t);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (!t->activeRunConfiguration())
|
2017-11-14 17:16:24 +01:00
|
|
|
t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
|
2010-04-27 10:58:36 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
if (Target *t = activeTarget())
|
|
|
|
|
static_cast<GenericBuildSystem *>(t->buildSystem())->refresh(Everything);
|
|
|
|
|
|
2015-05-18 16:57:29 +02:00
|
|
|
return RestoreResult::Ok;
|
2009-08-21 15:59:17 +02:00
|
|
|
}
|
|
|
|
|
|
2019-04-12 14:49:59 +02:00
|
|
|
ProjectExplorer::DeploymentKnowledge GenericProject::deploymentKnowledge() const
|
|
|
|
|
{
|
|
|
|
|
return DeploymentKnowledge::Approximative;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
bool GenericProjectFile::reload(QString *errorString, IDocument::ReloadFlag flag, IDocument::ChangeType type)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(errorString)
|
|
|
|
|
Q_UNUSED(flag)
|
|
|
|
|
if (type == TypePermissions)
|
|
|
|
|
return true;
|
2019-10-25 09:55:32 +02:00
|
|
|
|
|
|
|
|
if (Target *t = m_project->activeTarget())
|
|
|
|
|
static_cast<GenericBuildSystem *>(t->buildSystem())->refresh(m_options);
|
|
|
|
|
|
2019-10-23 09:49:27 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericProject::editFilesTriggered()
|
|
|
|
|
{
|
|
|
|
|
SelectableFilesDialogEditFiles sfd(projectDirectory(),
|
|
|
|
|
files(Project::AllFiles),
|
2020-06-02 09:10:40 +02:00
|
|
|
ICore::dialogParent());
|
2019-10-25 09:55:32 +02:00
|
|
|
if (sfd.exec() == QDialog::Accepted) {
|
|
|
|
|
if (Target *t = activeTarget()) {
|
|
|
|
|
auto bs = static_cast<GenericBuildSystem *>(t->buildSystem());
|
|
|
|
|
bs->setFiles(transform(sfd.selectedFiles(), &FilePath::toString));
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-23 09:49:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericProject::removeFilesTriggered(const QStringList &filesToRemove)
|
|
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
if (Target *t = activeTarget())
|
|
|
|
|
static_cast<GenericBuildSystem *>(t->buildSystem())->removeFiles(filesToRemove);
|
2019-10-23 09:49:27 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace GenericProjectManager
|