forked from qt-creator/qt-creator
Nim: Fix running when building with nimble
Change-Id: I62b2eebf408119a19f0e98958e3132c16c9c6aa5 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "nimblebuildstep.h"
|
#include "nimblebuildstep.h"
|
||||||
|
|
||||||
#include "nimconstants.h"
|
#include "nimconstants.h"
|
||||||
#include "nimbleproject.h"
|
#include "nimbleproject.h"
|
||||||
#include "nimbuildsystem.h"
|
#include "nimbuildsystem.h"
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
#include <projectexplorer/processparameters.h>
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@@ -107,14 +109,12 @@ NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
|||||||
m_arguments->setArguments(defaultArguments());
|
m_arguments->setArguments(defaultArguments());
|
||||||
|
|
||||||
setCommandLineProvider([this] {
|
setCommandLineProvider([this] {
|
||||||
auto bs = static_cast<NimBuildSystem *>(buildSystem());
|
return CommandLine(Nim::nimblePathFromKit(target()->kit()),
|
||||||
return CommandLine(bs->defaultNimble(),
|
|
||||||
{"build", m_arguments->arguments(macroExpander())});
|
{"build", m_arguments->arguments(macroExpander())});
|
||||||
});
|
});
|
||||||
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
||||||
setEnvironmentModifier([this](Environment &env) {
|
setEnvironmentModifier([this](Environment &env) {
|
||||||
auto bs = static_cast<NimBuildSystem *>(buildSystem());
|
env.appendOrSetPath(Nim::nimPathFromKit(target()->kit()).toUserOutput());
|
||||||
env.appendOrSetPath(bs->nimPathFromKit().toUserOutput());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QTC_ASSERT(buildConfiguration(), return);
|
QTC_ASSERT(buildConfiguration(), return);
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "nimblebuildsystem.h"
|
#include "nimblebuildsystem.h"
|
||||||
|
|
||||||
|
#include "nimbuildsystem.h"
|
||||||
#include "nimbleproject.h"
|
#include "nimbleproject.h"
|
||||||
#include "nimproject.h"
|
#include "nimproject.h"
|
||||||
|
|
||||||
@@ -46,7 +48,7 @@ static std::vector<NimbleTask> parseTasks(const QString &nimblePath, const QStri
|
|||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setWorkingDirectory(workingDirectory);
|
process.setWorkingDirectory(workingDirectory);
|
||||||
process.start(QStandardPaths::findExecutable(nimblePath), {"tasks"});
|
process.start(nimblePath, {"tasks"});
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
|
||||||
std::vector<NimbleTask> result;
|
std::vector<NimbleTask> result;
|
||||||
@@ -145,8 +147,9 @@ void NimbleBuildSystem::triggerParsing()
|
|||||||
void NimbleBuildSystem::updateProject()
|
void NimbleBuildSystem::updateProject()
|
||||||
{
|
{
|
||||||
const FilePath projectDir = projectDirectory();
|
const FilePath projectDir = projectDirectory();
|
||||||
|
const FilePath nimble = Nim::nimblePathFromKit(kit());
|
||||||
|
|
||||||
m_metadata = parseMetadata(QStandardPaths::findExecutable("nimble"), projectDir.toString());
|
m_metadata = parseMetadata(nimble.toString(), projectDir.toString());
|
||||||
const FilePath binDir = projectDir.pathAppended(m_metadata.binDir);
|
const FilePath binDir = projectDir.pathAppended(m_metadata.binDir);
|
||||||
const FilePath srcDir = projectDir.pathAppended("src");
|
const FilePath srcDir = projectDir.pathAppended("src");
|
||||||
|
|
||||||
@@ -162,7 +165,7 @@ void NimbleBuildSystem::updateProject()
|
|||||||
|
|
||||||
setApplicationTargets(std::move(targets));
|
setApplicationTargets(std::move(targets));
|
||||||
|
|
||||||
std::vector<NimbleTask> tasks = parseTasks(QStandardPaths::findExecutable("nimble"), projectDir.toString());
|
std::vector<NimbleTask> tasks = parseTasks(nimble.toString(), projectDir.toString());
|
||||||
if (tasks != m_tasks) {
|
if (tasks != m_tasks) {
|
||||||
m_tasks = std::move(tasks);
|
m_tasks = std::move(tasks);
|
||||||
emit tasksChanged();
|
emit tasksChanged();
|
||||||
|
|||||||
@@ -25,12 +25,10 @@
|
|||||||
|
|
||||||
#include "nimblerunconfiguration.h"
|
#include "nimblerunconfiguration.h"
|
||||||
|
|
||||||
#include "nimbuildsystem.h"
|
#include "nimblebuildsystem.h"
|
||||||
#include "nimconstants.h"
|
#include "nimconstants.h"
|
||||||
#include "nimbleproject.h"
|
#include "nimbleproject.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildstep.h>
|
|
||||||
#include <projectexplorer/buildsteplist.h>
|
|
||||||
#include <projectexplorer/localenvironmentaspect.h>
|
#include <projectexplorer/localenvironmentaspect.h>
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
#include <projectexplorer/runcontrol.h>
|
#include <projectexplorer/runcontrol.h>
|
||||||
@@ -91,14 +89,7 @@ public:
|
|||||||
NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id)
|
NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id)
|
||||||
: RunConfiguration(target, id)
|
: RunConfiguration(target, id)
|
||||||
{
|
{
|
||||||
QString nimble;
|
addAspect<ExecutableAspect>()->setExecutable(Nim::nimblePathFromKit(target->kit()));
|
||||||
auto bc = this->target()->activeBuildConfiguration();
|
|
||||||
auto nimbleBuildStep = bc->buildSteps()->firstStepWithId(Constants::C_NIMBLEBUILDSTEP_ID);
|
|
||||||
if (nimbleBuildStep && nimbleBuildStep->buildSystem()) {
|
|
||||||
nimble = static_cast<NimBuildSystem *>(nimbleBuildStep->buildSystem())->defaultNimble();
|
|
||||||
}
|
|
||||||
|
|
||||||
addAspect<ExecutableAspect>()->setExecutable(Utils::FilePath::fromString(nimble));
|
|
||||||
addAspect<ArgumentsAspect>()->setArguments("test");
|
addAspect<ArgumentsAspect>()->setArguments("test");
|
||||||
addAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(project()->projectDirectory());
|
addAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(project()->projectDirectory());
|
||||||
addAspect<TerminalAspect>();
|
addAspect<TerminalAspect>();
|
||||||
|
|||||||
@@ -196,20 +196,21 @@ void NimBuildSystem::triggerParsing()
|
|||||||
m_projectScanner.startScan();
|
m_projectScanner.startScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath NimBuildSystem::nimPathFromKit() const
|
FilePath nimPathFromKit(Kit *kit)
|
||||||
{
|
{
|
||||||
auto tc = ToolChainKitAspect::toolChain(kit(), Constants::C_NIMLANGUAGE_ID);
|
auto tc = ToolChainKitAspect::toolChain(kit, Constants::C_NIMLANGUAGE_ID);
|
||||||
QTC_ASSERT(tc, return {});
|
QTC_ASSERT(tc, return {});
|
||||||
const FilePath command = tc->compilerCommand();
|
const FilePath command = tc->compilerCommand();
|
||||||
return command.isEmpty() ? FilePath() : command.absolutePath();
|
return command.isEmpty() ? FilePath() : command.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NimBuildSystem::defaultNimble() const
|
FilePath nimblePathFromKit(Kit *kit)
|
||||||
{
|
{
|
||||||
|
// There's no extra setting for "nimble", derive it from the "nim" path.
|
||||||
const QString nimbleFromPath = QStandardPaths::findExecutable("nimble");
|
const QString nimbleFromPath = QStandardPaths::findExecutable("nimble");
|
||||||
const FilePath nimPath = nimPathFromKit();
|
const FilePath nimPath = nimPathFromKit(kit);
|
||||||
const FilePath nimbleFromKit = nimPath.pathAppended(HostOsInfo::withExecutableSuffix("nimble"));
|
const FilePath nimbleFromKit = nimPath.pathAppended(HostOsInfo::withExecutableSuffix("nimble"));
|
||||||
return nimbleFromKit.exists() ? nimbleFromKit.canonicalPath().toUserOutput() : nimbleFromPath;
|
return nimbleFromKit.exists() ? nimbleFromKit.canonicalPath() : FilePath::fromString(nimbleFromPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimBuildSystem::loadSettings()
|
void NimBuildSystem::loadSettings()
|
||||||
|
|||||||
@@ -30,8 +30,13 @@
|
|||||||
|
|
||||||
#include <utils/filesystemwatcher.h>
|
#include <utils/filesystemwatcher.h>
|
||||||
|
|
||||||
|
namespace ProjectExplorer { class Kit; }
|
||||||
|
|
||||||
namespace Nim {
|
namespace Nim {
|
||||||
|
|
||||||
|
Utils::FilePath nimPathFromKit(ProjectExplorer::Kit *kit);
|
||||||
|
Utils::FilePath nimblePathFromKit(ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
class NimProjectScanner : public QObject
|
class NimProjectScanner : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -86,9 +91,6 @@ public:
|
|||||||
|
|
||||||
void triggerParsing() override;
|
void triggerParsing() override;
|
||||||
|
|
||||||
Utils::FilePath nimPathFromKit() const;
|
|
||||||
QString defaultNimble() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|||||||
Reference in New Issue
Block a user