forked from qt-creator/qt-creator
GenericProject: Move parts of GenericProject to GenericBuildSystem
Change-Id: I27b7ccb6a1382dd59c339fbcd3f0275c6b2cc291 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -47,7 +47,9 @@
|
|||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
|
#include <projectexplorer/selectablefilesmodel.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
#include <projectexplorer/taskhub.h>
|
||||||
|
|
||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
#include <qtsupport/qtcppkitinfo.h>
|
#include <qtsupport/qtcppkitinfo.h>
|
||||||
@@ -73,6 +75,12 @@ using namespace Utils;
|
|||||||
namespace GenericProjectManager {
|
namespace GenericProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
enum RefreshOptions {
|
||||||
|
Files = 0x01,
|
||||||
|
Configuration = 0x02,
|
||||||
|
Everything = Files | Configuration
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// GenericProjectFile
|
// GenericProjectFile
|
||||||
@@ -82,10 +90,8 @@ namespace Internal {
|
|||||||
class GenericProjectFile : public Core::IDocument
|
class GenericProjectFile : public Core::IDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GenericProjectFile(GenericProject *parent, const FilePath &fileName,
|
GenericProjectFile(GenericProject *parent, const FilePath &fileName, RefreshOptions options)
|
||||||
GenericProject::RefreshOptions options) :
|
: m_project(parent), m_options(options)
|
||||||
m_project(parent),
|
|
||||||
m_options(options)
|
|
||||||
{
|
{
|
||||||
setId("Generic.ProjectFile");
|
setId("Generic.ProjectFile");
|
||||||
setMimeType(Constants::GENERICMIMETYPE);
|
setMimeType(Constants::GENERICMIMETYPE);
|
||||||
@@ -97,19 +103,11 @@ public:
|
|||||||
return BehaviorSilent;
|
return BehaviorSilent;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override
|
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
|
||||||
{
|
|
||||||
Q_UNUSED(errorString)
|
|
||||||
Q_UNUSED(flag)
|
|
||||||
if (type == TypePermissions)
|
|
||||||
return true;
|
|
||||||
m_project->refresh(m_options);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GenericProject *m_project = nullptr;
|
GenericProject *m_project = nullptr;
|
||||||
GenericProject::RefreshOptions m_options;
|
RefreshOptions m_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -119,14 +117,13 @@ private:
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class GenericBuildSytem : public BuildSystem
|
class GenericBuildSystem : public BuildSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit GenericBuildSytem(Project *project)
|
explicit GenericBuildSystem(Project *project);
|
||||||
: BuildSystem(project)
|
~GenericBuildSystem();
|
||||||
{}
|
|
||||||
|
|
||||||
bool supportsAction(Node *, ProjectAction action, const Node *) const override
|
bool supportsAction(Node *, ProjectAction action, const Node *) const final
|
||||||
{
|
{
|
||||||
return action == AddNewFile
|
return action == AddNewFile
|
||||||
|| action == AddExistingFile
|
|| action == AddExistingFile
|
||||||
@@ -135,25 +132,47 @@ public:
|
|||||||
|| action == Rename;
|
|| action == Rename;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addFiles(Node *, const QStringList &filePaths, QStringList *) override
|
RemovedFilesFromProject removeFiles(Node *, const QStringList &filePaths, QStringList *) final;
|
||||||
{
|
bool renameFile(Node *, const QString &filePath, const QString &newFilePath) final;
|
||||||
return project()->addFiles(filePaths);
|
bool addFiles(Node *, const QStringList &filePaths, QStringList *) final;
|
||||||
}
|
|
||||||
|
|
||||||
RemovedFilesFromProject removeFiles(Node *, const QStringList &filePaths,
|
GenericProject *project() const { return static_cast<GenericProject *>(BuildSystem::project()); }
|
||||||
QStringList * = nullptr) override
|
|
||||||
{
|
|
||||||
return project()->removeFiles(filePaths) ? RemovedFilesFromProject::Ok
|
|
||||||
: RemovedFilesFromProject::Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool renameFile(Node *, const QString &filePath, const QString &newFilePath) override
|
FilePath filesFilePath() const { return ::FilePath::fromString(m_filesFileName); }
|
||||||
{
|
|
||||||
return project()->renameFile(filePath, newFilePath);
|
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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GenericProject *project() { return static_cast<GenericProject *>(BuildSystem::project()); }
|
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;
|
||||||
|
|
||||||
|
Utils::FileSystemWatcher * const m_deployFileWatcher = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -171,13 +190,16 @@ static bool writeFile(const QString &filePath, const QString &contents)
|
|||||||
|
|
||||||
GenericProject::GenericProject(const Utils::FilePath &fileName)
|
GenericProject::GenericProject(const Utils::FilePath &fileName)
|
||||||
: Project(Constants::GENERICMIMETYPE, fileName)
|
: Project(Constants::GENERICMIMETYPE, fileName)
|
||||||
, m_deployFileWatcher(new FileSystemWatcher(this))
|
|
||||||
{
|
{
|
||||||
setId(Constants::GENERICPROJECT_ID);
|
setId(Constants::GENERICPROJECT_ID);
|
||||||
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
setProjectLanguages(Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||||
setDisplayName(fileName.toFileInfo().completeBaseName());
|
setDisplayName(fileName.toFileInfo().completeBaseName());
|
||||||
setBuildSystemCreator([](Project *p) { return new GenericBuildSytem(p); });
|
setBuildSystemCreator([](Project *p) { return new GenericBuildSystem(p); });
|
||||||
|
}
|
||||||
|
|
||||||
|
GenericBuildSystem::GenericBuildSystem(Project *project)
|
||||||
|
: BuildSystem(project)
|
||||||
|
{
|
||||||
QObject *projectUpdaterFactory = ExtensionSystem::PluginManager::getObjectByName(
|
QObject *projectUpdaterFactory = ExtensionSystem::PluginManager::getObjectByName(
|
||||||
"CppProjectUpdaterFactory");
|
"CppProjectUpdaterFactory");
|
||||||
if (projectUpdaterFactory) {
|
if (projectUpdaterFactory) {
|
||||||
@@ -189,7 +211,7 @@ GenericProject::GenericProject(const Utils::FilePath &fileName)
|
|||||||
QTC_CHECK(successFullyCreatedProjectUpdater);
|
QTC_CHECK(successFullyCreatedProjectUpdater);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this, &GenericProject::projectFileIsDirty, this, [this](const FilePath &p) {
|
connect(project, &Project::projectFileIsDirty, this, [this](const FilePath &p) {
|
||||||
if (p.endsWith(".files"))
|
if (p.endsWith(".files"))
|
||||||
refresh(Files);
|
refresh(Files);
|
||||||
else if (p.endsWith(".includes") || p.endsWith(".config") || p.endsWith(".cxxflags")
|
else if (p.endsWith(".includes") || p.endsWith(".config") || p.endsWith(".cxxflags")
|
||||||
@@ -220,23 +242,21 @@ GenericProject::GenericProject(const Utils::FilePath &fileName)
|
|||||||
QTC_CHECK(writeFile(m_cflagsFileName, Constants::GENERICPROJECT_CFLAGS_FILE_TEMPLATE));
|
QTC_CHECK(writeFile(m_cflagsFileName, Constants::GENERICPROJECT_CFLAGS_FILE_TEMPLATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
setExtraProjectFiles({FilePath::fromString(m_filesFileName),
|
project->setExtraProjectFiles({FilePath::fromString(m_filesFileName),
|
||||||
FilePath::fromString(m_includesFileName),
|
FilePath::fromString(m_includesFileName),
|
||||||
FilePath::fromString(m_configFileName),
|
FilePath::fromString(m_configFileName),
|
||||||
FilePath::fromString(m_cxxflagsFileName),
|
FilePath::fromString(m_cxxflagsFileName),
|
||||||
FilePath::fromString(m_cflagsFileName)});
|
FilePath::fromString(m_cflagsFileName)});
|
||||||
|
|
||||||
connect(m_deployFileWatcher,
|
connect(m_deployFileWatcher, &FileSystemWatcher::fileChanged,
|
||||||
&FileSystemWatcher::fileChanged,
|
this, &GenericBuildSystem::updateDeploymentData);
|
||||||
this,
|
|
||||||
&GenericProject::updateDeploymentData);
|
|
||||||
|
|
||||||
connect(this, &Project::activeTargetChanged, this, [this] { refresh(Everything); });
|
connect(project, &Project::activeTargetChanged, this, [this] { refresh(Everything); });
|
||||||
|
|
||||||
connect(this, &Project::activeBuildConfigurationChanged, this, [this] { refresh(Everything); });
|
connect(project, &Project::activeBuildConfigurationChanged, this, [this] { refresh(Everything); });
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericProject::~GenericProject()
|
GenericBuildSystem::~GenericBuildSystem()
|
||||||
{
|
{
|
||||||
delete m_cppCodeModelUpdater;
|
delete m_cppCodeModelUpdater;
|
||||||
}
|
}
|
||||||
@@ -261,14 +281,14 @@ static QStringList readLines(const QString &absoluteFileName)
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericProject::saveRawFileList(const QStringList &rawFileList)
|
bool GenericBuildSystem::saveRawFileList(const QStringList &rawFileList)
|
||||||
{
|
{
|
||||||
bool result = saveRawList(rawFileList, m_filesFileName);
|
bool result = saveRawList(rawFileList, m_filesFileName);
|
||||||
refresh(GenericProject::Files);
|
refresh(Files);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericProject::saveRawList(const QStringList &rawList, const QString &fileName)
|
bool GenericBuildSystem::saveRawList(const QStringList &rawList, const QString &fileName)
|
||||||
{
|
{
|
||||||
FileChangeBlocker changeGuard(fileName);
|
FileChangeBlocker changeGuard(fileName);
|
||||||
// Make sure we can open the file for writing
|
// Make sure we can open the file for writing
|
||||||
@@ -292,7 +312,7 @@ static void insertSorted(QStringList *list, const QString &value)
|
|||||||
list->insert(pos, value);
|
list->insert(pos, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericProject::addFiles(const QStringList &filePaths)
|
bool GenericBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringList *)
|
||||||
{
|
{
|
||||||
QStringList newList = m_rawFileList;
|
QStringList newList = m_rawFileList;
|
||||||
|
|
||||||
@@ -321,12 +341,12 @@ bool GenericProject::addFiles(const QStringList &filePaths)
|
|||||||
|
|
||||||
bool result = saveRawList(newList, m_filesFileName);
|
bool result = saveRawList(newList, m_filesFileName);
|
||||||
result &= saveRawList(m_rawProjectIncludePaths, m_includesFileName);
|
result &= saveRawList(m_rawProjectIncludePaths, m_includesFileName);
|
||||||
refresh(GenericProject::Everything);
|
refresh(Everything);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericProject::removeFiles(const QStringList &filePaths)
|
RemovedFilesFromProject GenericBuildSystem::removeFiles(Node *, const QStringList &filePaths, QStringList *)
|
||||||
{
|
{
|
||||||
QStringList newList = m_rawFileList;
|
QStringList newList = m_rawFileList;
|
||||||
|
|
||||||
@@ -336,10 +356,11 @@ bool GenericProject::removeFiles(const QStringList &filePaths)
|
|||||||
newList.removeOne(i.value());
|
newList.removeOne(i.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
return saveRawFileList(newList);
|
return saveRawFileList(newList) ? RemovedFilesFromProject::Ok
|
||||||
|
: RemovedFilesFromProject::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericProject::setFiles(const QStringList &filePaths)
|
bool GenericBuildSystem::setFiles(const QStringList &filePaths)
|
||||||
{
|
{
|
||||||
QStringList newList;
|
QStringList newList;
|
||||||
QDir baseDir(projectDirectory().toString());
|
QDir baseDir(projectDirectory().toString());
|
||||||
@@ -350,7 +371,7 @@ bool GenericProject::setFiles(const QStringList &filePaths)
|
|||||||
return saveRawFileList(newList);
|
return saveRawFileList(newList);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericProject::renameFile(const QString &filePath, const QString &newFilePath)
|
bool GenericBuildSystem::renameFile(Node *, const QString &filePath, const QString &newFilePath)
|
||||||
{
|
{
|
||||||
QStringList newList = m_rawFileList;
|
QStringList newList = m_rawFileList;
|
||||||
|
|
||||||
@@ -375,7 +396,7 @@ static QStringList readFlags(const QString &filePath)
|
|||||||
return QtcProcess::splitArgs(lines.first());
|
return QtcProcess::splitArgs(lines.first());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericProject::parseProject(RefreshOptions options)
|
void GenericBuildSystem::parse(RefreshOptions options)
|
||||||
{
|
{
|
||||||
if (options & Files) {
|
if (options & Files) {
|
||||||
m_rawListEntries.clear();
|
m_rawListEntries.clear();
|
||||||
@@ -405,7 +426,7 @@ void GenericProject::parseProject(RefreshOptions options)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath GenericProject::findCommonSourceRoot()
|
FilePath GenericBuildSystem::findCommonSourceRoot()
|
||||||
{
|
{
|
||||||
if (m_files.isEmpty())
|
if (m_files.isEmpty())
|
||||||
return FilePath::fromFileInfo(QFileInfo(m_filesFileName).absolutePath());
|
return FilePath::fromFileInfo(QFileInfo(m_filesFileName).absolutePath());
|
||||||
@@ -425,17 +446,17 @@ FilePath GenericProject::findCommonSourceRoot()
|
|||||||
return FilePath::fromString(QFileInfo(root).absolutePath());
|
return FilePath::fromString(QFileInfo(root).absolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericProject::refresh(RefreshOptions options)
|
void GenericBuildSystem::refresh(RefreshOptions options)
|
||||||
{
|
{
|
||||||
ParseGuard guard = guardParsingRun();
|
Project::ParseGuard guard = project()->guardParsingRun();
|
||||||
parseProject(options);
|
parse(options);
|
||||||
|
|
||||||
if (options & Files) {
|
if (options & Files) {
|
||||||
auto newRoot = std::make_unique<ProjectNode>(projectDirectory());
|
auto newRoot = std::make_unique<ProjectNode>(projectDirectory());
|
||||||
newRoot->setDisplayName(projectFilePath().toFileInfo().completeBaseName());
|
newRoot->setDisplayName(projectFilePath().toFileInfo().completeBaseName());
|
||||||
|
|
||||||
// find the common base directory of all source files
|
// find the common base directory of all source files
|
||||||
Utils::FilePath baseDir = findCommonSourceRoot();
|
FilePath baseDir = findCommonSourceRoot();
|
||||||
|
|
||||||
for (const QString &f : qAsConst(m_files)) {
|
for (const QString &f : qAsConst(m_files)) {
|
||||||
FileType fileType = FileType::Source; // ### FIXME
|
FileType fileType = FileType::Source; // ### FIXME
|
||||||
@@ -456,7 +477,7 @@ void GenericProject::refresh(RefreshOptions options)
|
|||||||
FileType::Project));
|
FileType::Project));
|
||||||
|
|
||||||
newRoot->compress();
|
newRoot->compress();
|
||||||
setRootProjectNode(std::move(newRoot));
|
project()->setRootProjectNode(std::move(newRoot));
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshCppCodeModel();
|
refreshCppCodeModel();
|
||||||
@@ -471,20 +492,21 @@ void GenericProject::refresh(RefreshOptions options)
|
|||||||
* The \a map variable is an optional argument that will map the returned
|
* The \a map variable is an optional argument that will map the returned
|
||||||
* absolute paths back to their original \a entries.
|
* absolute paths back to their original \a entries.
|
||||||
*/
|
*/
|
||||||
QStringList GenericProject::processEntries(const QStringList &paths,
|
QStringList GenericBuildSystem::processEntries(const QStringList &paths,
|
||||||
QHash<QString, QString> *map) const
|
QHash<QString, QString> *map) const
|
||||||
{
|
{
|
||||||
const BuildConfiguration *const buildConfig = activeTarget() ? activeTarget()->activeBuildConfiguration()
|
Target *target = project()->activeTarget();
|
||||||
|
const BuildConfiguration *const buildConfig = target ? target->activeBuildConfiguration()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
const Utils::Environment buildEnv = buildConfig ? buildConfig->environment()
|
const Utils::Environment buildEnv = buildConfig ? buildConfig->environment()
|
||||||
: Utils::Environment::systemEnvironment();
|
: Utils::Environment::systemEnvironment();
|
||||||
|
|
||||||
const Utils::MacroExpander *expander = macroExpander();
|
const Utils::MacroExpander *expander = project()->macroExpander();
|
||||||
if (buildConfig)
|
if (buildConfig)
|
||||||
expander = buildConfig->macroExpander();
|
expander = buildConfig->macroExpander();
|
||||||
else if (activeTarget())
|
else if (target)
|
||||||
expander = activeTarget()->macroExpander();
|
expander = target->macroExpander();
|
||||||
|
|
||||||
const QDir projectDir(projectDirectory().toString());
|
const QDir projectDir(projectDirectory().toString());
|
||||||
|
|
||||||
@@ -512,15 +534,15 @@ QStringList GenericProject::processEntries(const QStringList &paths,
|
|||||||
return absolutePaths;
|
return absolutePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericProject::refreshCppCodeModel()
|
void GenericBuildSystem::refreshCppCodeModel()
|
||||||
{
|
{
|
||||||
if (!m_cppCodeModelUpdater)
|
if (!m_cppCodeModelUpdater)
|
||||||
return;
|
return;
|
||||||
QtSupport::CppKitInfo kitInfo(this);
|
QtSupport::CppKitInfo kitInfo(project());
|
||||||
QTC_ASSERT(kitInfo.isValid(), return);
|
QTC_ASSERT(kitInfo.isValid(), return);
|
||||||
|
|
||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setDisplayName(displayName());
|
rpp.setDisplayName(project()->displayName());
|
||||||
rpp.setProjectFileLocation(projectFilePath().toString());
|
rpp.setProjectFileLocation(projectFilePath().toString());
|
||||||
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
||||||
rpp.setHeaderPaths(m_projectIncludePaths);
|
rpp.setHeaderPaths(m_projectIncludePaths);
|
||||||
@@ -529,15 +551,16 @@ void GenericProject::refreshCppCodeModel()
|
|||||||
rpp.setFlagsForC({nullptr, m_cflags});
|
rpp.setFlagsForC({nullptr, m_cflags});
|
||||||
rpp.setFiles(m_files);
|
rpp.setFiles(m_files);
|
||||||
|
|
||||||
m_cppCodeModelUpdater->update({this, kitInfo, activeParseEnvironment(), {rpp}});
|
m_cppCodeModelUpdater->update({project(), kitInfo, project()->activeParseEnvironment(), {rpp}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericProject::updateDeploymentData()
|
void GenericBuildSystem::updateDeploymentData()
|
||||||
{
|
{
|
||||||
static const QString fileName("QtCreatorDeployment.txt");
|
static const QString fileName("QtCreatorDeployment.txt");
|
||||||
Utils::FilePath deploymentFilePath;
|
Utils::FilePath deploymentFilePath;
|
||||||
if (activeTarget() && activeTarget()->activeBuildConfiguration()) {
|
Target *target = project()->activeTarget();
|
||||||
deploymentFilePath = activeTarget()->activeBuildConfiguration()->buildDirectory()
|
if (target && target->activeBuildConfiguration()) {
|
||||||
|
deploymentFilePath = target->activeBuildConfiguration()->buildDirectory()
|
||||||
.pathAppended(fileName);
|
.pathAppended(fileName);
|
||||||
}
|
}
|
||||||
bool hasDeploymentData = QFileInfo::exists(deploymentFilePath.toString());
|
bool hasDeploymentData = QFileInfo::exists(deploymentFilePath.toString());
|
||||||
@@ -549,7 +572,7 @@ void GenericProject::updateDeploymentData()
|
|||||||
DeploymentData deploymentData;
|
DeploymentData deploymentData;
|
||||||
deploymentData.addFilesFromDeploymentFile(deploymentFilePath.toString(),
|
deploymentData.addFilesFromDeploymentFile(deploymentFilePath.toString(),
|
||||||
projectDirectory().toString());
|
projectDirectory().toString());
|
||||||
activeTarget()->setDeploymentData(deploymentData);
|
project()->activeTarget()->setDeploymentData(deploymentData);
|
||||||
if (m_deployFileWatcher->files() != QStringList(deploymentFilePath.toString())) {
|
if (m_deployFileWatcher->files() != QStringList(deploymentFilePath.toString())) {
|
||||||
m_deployFileWatcher->removeFiles(m_deployFileWatcher->files());
|
m_deployFileWatcher->removeFiles(m_deployFileWatcher->files());
|
||||||
m_deployFileWatcher->addFile(deploymentFilePath.toString(),
|
m_deployFileWatcher->addFile(deploymentFilePath.toString(),
|
||||||
@@ -558,6 +581,15 @@ void GenericProject::updateDeploymentData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericBuildSystem::removeFiles(const QStringList &filesToRemove)
|
||||||
|
{
|
||||||
|
if (removeFiles(nullptr, filesToRemove, nullptr) == RemovedFilesFromProject::Error) {
|
||||||
|
TaskHub::addTask(Task::Error, tr("Project files list update failed."),
|
||||||
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM,
|
||||||
|
filesFilePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||||
{
|
{
|
||||||
const RestoreResult result = Project::fromMap(map, errorMessage);
|
const RestoreResult result = Project::fromMap(map, errorMessage);
|
||||||
@@ -581,7 +613,7 @@ Project::RestoreResult GenericProject::fromMap(const QVariantMap &map, QString *
|
|||||||
t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
|
t->addRunConfiguration(new CustomExecutableRunConfiguration(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh(Everything);
|
static_cast<GenericBuildSystem *>(buildSystem())->refresh(Everything);
|
||||||
return RestoreResult::Ok;
|
return RestoreResult::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,5 +622,30 @@ ProjectExplorer::DeploymentKnowledge GenericProject::deploymentKnowledge() const
|
|||||||
return DeploymentKnowledge::Approximative;
|
return DeploymentKnowledge::Approximative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GenericProjectFile::reload(QString *errorString, IDocument::ReloadFlag flag, IDocument::ChangeType type)
|
||||||
|
{
|
||||||
|
Q_UNUSED(errorString)
|
||||||
|
Q_UNUSED(flag)
|
||||||
|
if (type == TypePermissions)
|
||||||
|
return true;
|
||||||
|
static_cast<GenericBuildSystem *>(m_project->buildSystem())->refresh(m_options);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenericProject::editFilesTriggered()
|
||||||
|
{
|
||||||
|
SelectableFilesDialogEditFiles sfd(projectDirectory(),
|
||||||
|
files(Project::AllFiles),
|
||||||
|
ICore::mainWindow());
|
||||||
|
if (sfd.exec() == QDialog::Accepted)
|
||||||
|
static_cast<GenericBuildSystem *>(buildSystem())
|
||||||
|
->setFiles(transform(sfd.selectedFiles(), &FilePath::toString));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenericProject::removeFilesTriggered(const QStringList &filesToRemove)
|
||||||
|
{
|
||||||
|
static_cast<GenericBuildSystem *>(buildSystem())->removeFiles(filesToRemove);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace GenericProjectManager
|
} // namespace GenericProjectManager
|
||||||
|
|||||||
@@ -25,14 +25,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/headerpath.h>
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
namespace CppTools {
|
|
||||||
class CppProjectUpdaterInterface;
|
|
||||||
}
|
|
||||||
namespace Utils { class FileSystemWatcher; }
|
|
||||||
|
|
||||||
namespace GenericProjectManager {
|
namespace GenericProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -43,55 +36,13 @@ class GenericProject : public ProjectExplorer::Project
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GenericProject(const Utils::FilePath &filename);
|
explicit GenericProject(const Utils::FilePath &filename);
|
||||||
~GenericProject() override;
|
|
||||||
|
|
||||||
bool addFiles(const QStringList &filePaths);
|
void editFilesTriggered();
|
||||||
bool removeFiles(const QStringList &filePaths);
|
void removeFilesTriggered(const QStringList &filesToRemove);
|
||||||
bool setFiles(const QStringList &filePaths);
|
|
||||||
bool renameFile(const QString &filePath, const QString &newFilePath);
|
|
||||||
|
|
||||||
Utils::FilePath filesFilePath() const { return Utils::FilePath::fromString(m_filesFileName); }
|
|
||||||
|
|
||||||
enum RefreshOptions {
|
|
||||||
Files = 0x01,
|
|
||||||
Configuration = 0x02,
|
|
||||||
Everything = Files | Configuration
|
|
||||||
};
|
|
||||||
|
|
||||||
void refresh(RefreshOptions options);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
|
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) final;
|
||||||
|
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const final;
|
||||||
bool saveRawFileList(const QStringList &rawFileList);
|
|
||||||
bool saveRawList(const QStringList &rawList, const QString &fileName);
|
|
||||||
void parseProject(RefreshOptions options);
|
|
||||||
QStringList processEntries(const QStringList &paths,
|
|
||||||
QHash<QString, QString> *map = nullptr) const;
|
|
||||||
|
|
||||||
Utils::FilePath findCommonSourceRoot();
|
|
||||||
void refreshCppCodeModel();
|
|
||||||
void updateDeploymentData();
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
Utils::FileSystemWatcher * const m_deployFileWatcher = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -95,14 +95,8 @@ GenericProjectPluginPrivate::GenericProjectPluginPrivate()
|
|||||||
mproject->addAction(command, PEC::G_PROJECT_FILES);
|
mproject->addAction(command, PEC::G_PROJECT_FILES);
|
||||||
|
|
||||||
connect(&editFilesAction, &QAction::triggered, this, [] {
|
connect(&editFilesAction, &QAction::triggered, this, [] {
|
||||||
auto genericProject = qobject_cast<GenericProject *>(ProjectTree::currentProject());
|
if (auto genericProject = qobject_cast<GenericProject *>(ProjectTree::currentProject()))
|
||||||
if (!genericProject)
|
genericProject->editFilesTriggered();
|
||||||
return;
|
|
||||||
SelectableFilesDialogEditFiles sfd(genericProject->projectDirectory(),
|
|
||||||
genericProject->files(Project::AllFiles),
|
|
||||||
ICore::mainWindow());
|
|
||||||
if (sfd.exec() == QDialog::Accepted)
|
|
||||||
genericProject->setFiles(transform(sfd.selectedFiles(), &FilePath::toString));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -118,10 +112,7 @@ GenericProjectPluginPrivate::GenericProjectPluginPrivate()
|
|||||||
const QStringList filesToRemove = transform<QStringList>(
|
const QStringList filesToRemove = transform<QStringList>(
|
||||||
folderNode->findNodes([](const Node *node) { return node->asFileNode(); }),
|
folderNode->findNodes([](const Node *node) { return node->asFileNode(); }),
|
||||||
[](const Node *node) { return node->filePath().toString();});
|
[](const Node *node) { return node->filePath().toString();});
|
||||||
if (!project->removeFiles(filesToRemove)) {
|
project->removeFilesTriggered(filesToRemove);
|
||||||
TaskHub::addTask(Task::Error, tr("Project files list update failed."),
|
|
||||||
PEC::TASK_CATEGORY_BUILDSYSTEM, project->filesFilePath());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user