forked from qt-creator/qt-creator
Nim: Fix compile
Change-Id: I19753d929dc2ed9594f4d5f0e4daba18b12b868f Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -164,12 +164,12 @@ QString NimbleBuildStep::defaultArguments() const
|
|||||||
QTC_ASSERT(buildConfiguration(), return {}; );
|
QTC_ASSERT(buildConfiguration(), return {}; );
|
||||||
switch (buildConfiguration()->buildType()) {
|
switch (buildConfiguration()->buildType()) {
|
||||||
case ProjectExplorer::BuildConfiguration::Debug:
|
case ProjectExplorer::BuildConfiguration::Debug:
|
||||||
return "--debugger:native";
|
return {"--debugger:native"};
|
||||||
case ProjectExplorer::BuildConfiguration::Unknown:
|
case ProjectExplorer::BuildConfiguration::Unknown:
|
||||||
case ProjectExplorer::BuildConfiguration::Profile:
|
case ProjectExplorer::BuildConfiguration::Profile:
|
||||||
case ProjectExplorer::BuildConfiguration::Release:
|
case ProjectExplorer::BuildConfiguration::Release:
|
||||||
default:
|
default:
|
||||||
return "";
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,19 @@ NimbleMetadata parseMetadata(const QString &nimblePath, const QString &workingDi
|
|||||||
NimbleBuildSystem::NimbleBuildSystem(Project *project)
|
NimbleBuildSystem::NimbleBuildSystem(Project *project)
|
||||||
: NimBuildSystem(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)
|
void NimbleBuildSystem::parseProject(BuildSystem::ParsingContext &&ctx)
|
||||||
@@ -118,22 +131,6 @@ void NimbleBuildSystem::updateProject()
|
|||||||
updateProjectTasks();
|
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()
|
void NimbleBuildSystem::updateProjectTasks()
|
||||||
{
|
{
|
||||||
auto prj = dynamic_cast<NimbleProject*>(project());
|
auto prj = dynamic_cast<NimbleProject*>(project());
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ class NimbleBuildSystem : public NimBuildSystem
|
|||||||
public:
|
public:
|
||||||
NimbleBuildSystem(ProjectExplorer::Project *project);
|
NimbleBuildSystem(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
void init();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void parseProject(ParsingContext &&ctx) override;
|
void parseProject(ParsingContext &&ctx) override;
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ NimbleProject::NimbleProject(const Utils::FilePath &fileName)
|
|||||||
setDisplayName(fileName.toFileInfo().completeBaseName());
|
setDisplayName(fileName.toFileInfo().completeBaseName());
|
||||||
// ensure debugging is enabled (Nim plugin translates nim code to C code)
|
// ensure debugging is enabled (Nim plugin translates nim code to C code)
|
||||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||||
auto bs = std::make_unique<NimbleBuildSystem>(this);
|
setBuildSystemCreator([] (Project *p) { return new NimbleBuildSystem(p); });
|
||||||
bs->init();
|
|
||||||
setBuildSystem(std::move(bs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<NimbleTask> NimbleProject::tasks() const
|
std::vector<NimbleTask> NimbleProject::tasks() const
|
||||||
@@ -103,10 +101,10 @@ QStringList NimbleProject::toStringList(const std::vector<NimbleTask> &tasks)
|
|||||||
std::tuple<Project::RestoreResult, std::vector<NimbleTask>> NimbleProject::fromStringList(const QStringList &list)
|
std::tuple<Project::RestoreResult, std::vector<NimbleTask>> NimbleProject::fromStringList(const QStringList &list)
|
||||||
{
|
{
|
||||||
if (list.size() % 2 != 0)
|
if (list.size() % 2 != 0)
|
||||||
return {Project::RestoreResult::Error, {}};
|
return std::make_tuple(Project::RestoreResult::Error, std::vector<NimbleTask>());
|
||||||
|
|
||||||
std::vector<NimbleTask> result;
|
std::vector<NimbleTask> result;
|
||||||
for (int i = 0; i < list.size(); i += 2)
|
for (int i = 0; i < list.size(); i += 2)
|
||||||
result.push_back({list[i], list[i + 1]});
|
result.push_back({list[i], list[i + 1]});
|
||||||
return {Project::RestoreResult::Ok, std::move(result)};
|
return std::make_tuple(Project::RestoreResult::Ok, result);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user