From deeed3dcd2c9b9abc9997c65cf4d664ece233c2e Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 5 Nov 2019 07:19:45 +0100 Subject: Nim: Fix compile Change-Id: I19753d929dc2ed9594f4d5f0e4daba18b12b868f Reviewed-by: David Schulz Reviewed-by: Christian Stenger --- src/plugins/nim/project/nimblebuildstep.cpp | 4 ++-- src/plugins/nim/project/nimblebuildsystem.cpp | 29 ++++++++++++--------------- src/plugins/nim/project/nimblebuildsystem.h | 2 -- src/plugins/nim/project/nimbleproject.cpp | 8 +++----- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/plugins/nim/project/nimblebuildstep.cpp b/src/plugins/nim/project/nimblebuildstep.cpp index 940c3e91eb..33b686bd4b 100644 --- a/src/plugins/nim/project/nimblebuildstep.cpp +++ b/src/plugins/nim/project/nimblebuildstep.cpp @@ -164,12 +164,12 @@ QString NimbleBuildStep::defaultArguments() const QTC_ASSERT(buildConfiguration(), return {}; ); switch (buildConfiguration()->buildType()) { case ProjectExplorer::BuildConfiguration::Debug: - return "--debugger:native"; + return {"--debugger:native"}; case ProjectExplorer::BuildConfiguration::Unknown: case ProjectExplorer::BuildConfiguration::Profile: case ProjectExplorer::BuildConfiguration::Release: default: - return ""; + return {}; } } diff --git a/src/plugins/nim/project/nimblebuildsystem.cpp b/src/plugins/nim/project/nimblebuildsystem.cpp index c8d0e81d9a..d968b50391 100644 --- a/src/plugins/nim/project/nimblebuildsystem.cpp +++ b/src/plugins/nim/project/nimblebuildsystem.cpp @@ -105,6 +105,19 @@ NimbleMetadata parseMetadata(const QString &nimblePath, const QString &workingDi NimbleBuildSystem::NimbleBuildSystem(Project *project) : NimBuildSystem(project) { + // Not called in parseProject due to nimble behavior to create temporary + // files in project directory. This creation in turn stimulate the fs watcher + // that in turn causes project parsing (thus a loop if invoke in parseProject). + // For this reason we call this function manually during project creation + // See https://github.com/nim-lang/nimble/issues/720 + m_directoryWatcher.addFile(this->project()->projectFilePath().toString(), + FileSystemWatcher::WatchModifiedDate); + connect(&m_directoryWatcher, &FileSystemWatcher::fileChanged, this, [this](const QString &path) { + if (path == this->project()->projectFilePath().toString()) { + updateProject(); + } + }); + updateProject(); } void NimbleBuildSystem::parseProject(BuildSystem::ParsingContext &&ctx) @@ -118,22 +131,6 @@ void NimbleBuildSystem::updateProject() updateProjectTasks(); } -void NimbleBuildSystem::init() -{ - // Not called in parseProject due to nimble behavior to create temporary - // files in project directory. This creation in turn stimulate the fs watcher - // that in turn causes project parsing (thus a loop if invoke in parseProject). - // For this reason we call this function manually during project creation - // See https://github.com/nim-lang/nimble/issues/720 - m_directoryWatcher.addFile(project()->projectFilePath().toString(), FileSystemWatcher::WatchModifiedDate); - connect(&m_directoryWatcher, &FileSystemWatcher::fileChanged, this, [this](const QString &path) { - if (path == project()->projectFilePath().toString()) { - updateProject(); - } - }); - updateProject(); -} - void NimbleBuildSystem::updateProjectTasks() { auto prj = dynamic_cast(project()); diff --git a/src/plugins/nim/project/nimblebuildsystem.h b/src/plugins/nim/project/nimblebuildsystem.h index 4ffd9185e7..45c540598e 100644 --- a/src/plugins/nim/project/nimblebuildsystem.h +++ b/src/plugins/nim/project/nimblebuildsystem.h @@ -36,8 +36,6 @@ class NimbleBuildSystem : public NimBuildSystem public: NimbleBuildSystem(ProjectExplorer::Project *project); - void init(); - protected: void parseProject(ParsingContext &&ctx) override; diff --git a/src/plugins/nim/project/nimbleproject.cpp b/src/plugins/nim/project/nimbleproject.cpp index 067c647e97..9003e55a93 100644 --- a/src/plugins/nim/project/nimbleproject.cpp +++ b/src/plugins/nim/project/nimbleproject.cpp @@ -41,9 +41,7 @@ NimbleProject::NimbleProject(const Utils::FilePath &fileName) setDisplayName(fileName.toFileInfo().completeBaseName()); // ensure debugging is enabled (Nim plugin translates nim code to C code) setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID)); - auto bs = std::make_unique(this); - bs->init(); - setBuildSystem(std::move(bs)); + setBuildSystemCreator([] (Project *p) { return new NimbleBuildSystem(p); }); } std::vector NimbleProject::tasks() const @@ -103,10 +101,10 @@ QStringList NimbleProject::toStringList(const std::vector &tasks) std::tuple> NimbleProject::fromStringList(const QStringList &list) { if (list.size() % 2 != 0) - return {Project::RestoreResult::Error, {}}; + return std::make_tuple(Project::RestoreResult::Error, std::vector()); std::vector result; for (int i = 0; i < list.size(); i += 2) result.push_back({list[i], list[i + 1]}); - return {Project::RestoreResult::Ok, std::move(result)}; + return std::make_tuple(Project::RestoreResult::Ok, result); } -- cgit v1.2.1