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 "nimconstants.h"
|
||||
#include "nimbleproject.h"
|
||||
#include "nimbuildsystem.h"
|
||||
@@ -34,6 +35,7 @@
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
@@ -107,14 +109,12 @@ NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
||||
m_arguments->setArguments(defaultArguments());
|
||||
|
||||
setCommandLineProvider([this] {
|
||||
auto bs = static_cast<NimBuildSystem *>(buildSystem());
|
||||
return CommandLine(bs->defaultNimble(),
|
||||
return CommandLine(Nim::nimblePathFromKit(target()->kit()),
|
||||
{"build", m_arguments->arguments(macroExpander())});
|
||||
});
|
||||
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
||||
setEnvironmentModifier([this](Environment &env) {
|
||||
auto bs = static_cast<NimBuildSystem *>(buildSystem());
|
||||
env.appendOrSetPath(bs->nimPathFromKit().toUserOutput());
|
||||
env.appendOrSetPath(Nim::nimPathFromKit(target()->kit()).toUserOutput());
|
||||
});
|
||||
|
||||
QTC_ASSERT(buildConfiguration(), return);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "nimblebuildsystem.h"
|
||||
|
||||
#include "nimbuildsystem.h"
|
||||
#include "nimbleproject.h"
|
||||
#include "nimproject.h"
|
||||
|
||||
@@ -46,7 +48,7 @@ static std::vector<NimbleTask> parseTasks(const QString &nimblePath, const QStri
|
||||
{
|
||||
QProcess process;
|
||||
process.setWorkingDirectory(workingDirectory);
|
||||
process.start(QStandardPaths::findExecutable(nimblePath), {"tasks"});
|
||||
process.start(nimblePath, {"tasks"});
|
||||
process.waitForFinished();
|
||||
|
||||
std::vector<NimbleTask> result;
|
||||
@@ -145,8 +147,9 @@ void NimbleBuildSystem::triggerParsing()
|
||||
void NimbleBuildSystem::updateProject()
|
||||
{
|
||||
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 srcDir = projectDir.pathAppended("src");
|
||||
|
||||
@@ -162,7 +165,7 @@ void NimbleBuildSystem::updateProject()
|
||||
|
||||
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) {
|
||||
m_tasks = std::move(tasks);
|
||||
emit tasksChanged();
|
||||
|
||||
@@ -25,12 +25,10 @@
|
||||
|
||||
#include "nimblerunconfiguration.h"
|
||||
|
||||
#include "nimbuildsystem.h"
|
||||
#include "nimblebuildsystem.h"
|
||||
#include "nimconstants.h"
|
||||
#include "nimbleproject.h"
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/localenvironmentaspect.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
@@ -91,14 +89,7 @@ public:
|
||||
NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
QString nimble;
|
||||
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<ExecutableAspect>()->setExecutable(Nim::nimblePathFromKit(target->kit()));
|
||||
addAspect<ArgumentsAspect>()->setArguments("test");
|
||||
addAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(project()->projectDirectory());
|
||||
addAspect<TerminalAspect>();
|
||||
|
||||
@@ -196,20 +196,21 @@ void NimBuildSystem::triggerParsing()
|
||||
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 {});
|
||||
const FilePath command = tc->compilerCommand();
|
||||
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 FilePath nimPath = nimPathFromKit();
|
||||
const FilePath nimPath = nimPathFromKit(kit);
|
||||
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()
|
||||
|
||||
@@ -30,8 +30,13 @@
|
||||
|
||||
#include <utils/filesystemwatcher.h>
|
||||
|
||||
namespace ProjectExplorer { class Kit; }
|
||||
|
||||
namespace Nim {
|
||||
|
||||
Utils::FilePath nimPathFromKit(ProjectExplorer::Kit *kit);
|
||||
Utils::FilePath nimblePathFromKit(ProjectExplorer::Kit *kit);
|
||||
|
||||
class NimProjectScanner : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -86,9 +91,6 @@ public:
|
||||
|
||||
void triggerParsing() override;
|
||||
|
||||
Utils::FilePath nimPathFromKit() const;
|
||||
QString defaultNimble() const;
|
||||
|
||||
protected:
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
Reference in New Issue
Block a user