summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/nim/project/nimblebuildstep.cpp11
-rw-r--r--src/plugins/nim/project/nimblerunconfiguration.cpp15
-rw-r--r--src/plugins/nim/project/nimbuildsystem.cpp21
-rw-r--r--src/plugins/nim/project/nimbuildsystem.h3
4 files changed, 45 insertions, 5 deletions
diff --git a/src/plugins/nim/project/nimblebuildstep.cpp b/src/plugins/nim/project/nimblebuildstep.cpp
index 85e5bdfe9a..a8a84ff901 100644
--- a/src/plugins/nim/project/nimblebuildstep.cpp
+++ b/src/plugins/nim/project/nimblebuildstep.cpp
@@ -26,6 +26,8 @@
#include "nimblebuildstep.h"
#include "nimconstants.h"
#include "nimbleproject.h"
+#include "nimbuildsystem.h"
+#include "nimtoolchain.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/ioutputparser.h>
@@ -105,10 +107,15 @@ NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
m_arguments->setArguments(defaultArguments());
setCommandLineProvider([this] {
- return CommandLine(QStandardPaths::findExecutable("nimble"),
- {"build", m_arguments->arguments(macroExpander())});
+ auto bs = static_cast<NimBuildSystem *>(buildSystem());
+ return CommandLine(bs->defaultNimble(),
+ {"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());
+ });
QTC_ASSERT(buildConfiguration(), return);
QObject::connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged,
diff --git a/src/plugins/nim/project/nimblerunconfiguration.cpp b/src/plugins/nim/project/nimblerunconfiguration.cpp
index 53b7b6dd5e..6b01571c96 100644
--- a/src/plugins/nim/project/nimblerunconfiguration.cpp
+++ b/src/plugins/nim/project/nimblerunconfiguration.cpp
@@ -24,9 +24,13 @@
****************************************************************************/
#include "nimblerunconfiguration.h"
+
+#include "nimbuildsystem.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>
@@ -35,8 +39,6 @@
#include <utils/algorithm.h>
#include <utils/environment.h>
-#include <QStandardPaths>
-
using namespace ProjectExplorer;
namespace Nim {
@@ -89,7 +91,14 @@ public:
NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id)
: RunConfiguration(target, id)
{
- addAspect<ExecutableAspect>()->setExecutable(Utils::FilePath::fromString(QStandardPaths::findExecutable("nimble")));
+ 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<ArgumentsAspect>()->setArguments("test");
addAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(project()->projectDirectory());
addAspect<TerminalAspect>();
diff --git a/src/plugins/nim/project/nimbuildsystem.cpp b/src/plugins/nim/project/nimbuildsystem.cpp
index 74347691fa..01e37d5d85 100644
--- a/src/plugins/nim/project/nimbuildsystem.cpp
+++ b/src/plugins/nim/project/nimbuildsystem.cpp
@@ -25,16 +25,21 @@
#include "nimbuildsystem.h"
+#include "nimconstants.h"
#include "nimproject.h"
#include "nimbleproject.h"
#include "nimprojectnode.h"
#include <projectexplorer/target.h>
+#include <projectexplorer/toolchain.h>
+#include <projectexplorer/kitinformation.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
+#include <QStandardPaths>
+
using namespace ProjectExplorer;
using namespace Utils;
@@ -191,6 +196,22 @@ void NimBuildSystem::triggerParsing()
m_projectScanner.startScan();
}
+FilePath NimBuildSystem::nimPathFromKit() const
+{
+ 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
+{
+ const QString nimbleFromPath = QStandardPaths::findExecutable("nimble");
+ const FilePath nimPath = nimPathFromKit();
+ const FilePath nimbleFromKit = nimPath.pathAppended(HostOsInfo::withExecutableSuffix("nimble"));
+ return nimbleFromKit.exists() ? nimbleFromKit.canonicalPath().toUserOutput() : nimbleFromPath;
+}
+
void NimBuildSystem::loadSettings()
{
QVariantMap settings = project()->namedSettings(SETTINGS_KEY).toMap();
diff --git a/src/plugins/nim/project/nimbuildsystem.h b/src/plugins/nim/project/nimbuildsystem.h
index 91d2e931c9..6403d45430 100644
--- a/src/plugins/nim/project/nimbuildsystem.h
+++ b/src/plugins/nim/project/nimbuildsystem.h
@@ -86,6 +86,9 @@ public:
void triggerParsing() override;
+ Utils::FilePath nimPathFromKit() const;
+ QString defaultNimble() const;
+
protected:
void loadSettings();
void saveSettings();