forked from qt-creator/qt-creator
Nim: Fix building with nimble
Do not expect nimble to be in PATH, but assume it is located where nim resides. Use kit's information of nim to construct the nimble path and add the path of nim explicitly to the build environment as nimble uses it. Also fixes running nimble test. Change-Id: If7be425f7b811486afe39fc1618709dbb2f75ac9 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -26,6 +26,8 @@
|
|||||||
#include "nimblebuildstep.h"
|
#include "nimblebuildstep.h"
|
||||||
#include "nimconstants.h"
|
#include "nimconstants.h"
|
||||||
#include "nimbleproject.h"
|
#include "nimbleproject.h"
|
||||||
|
#include "nimbuildsystem.h"
|
||||||
|
#include "nimtoolchain.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/ioutputparser.h>
|
#include <projectexplorer/ioutputparser.h>
|
||||||
@@ -105,10 +107,15 @@ NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
|||||||
m_arguments->setArguments(defaultArguments());
|
m_arguments->setArguments(defaultArguments());
|
||||||
|
|
||||||
setCommandLineProvider([this] {
|
setCommandLineProvider([this] {
|
||||||
return CommandLine(QStandardPaths::findExecutable("nimble"),
|
auto bs = static_cast<NimBuildSystem *>(buildSystem());
|
||||||
|
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) {
|
||||||
|
auto bs = static_cast<NimBuildSystem *>(buildSystem());
|
||||||
|
env.appendOrSetPath(bs->nimPathFromKit().toUserOutput());
|
||||||
|
});
|
||||||
|
|
||||||
QTC_ASSERT(buildConfiguration(), return);
|
QTC_ASSERT(buildConfiguration(), return);
|
||||||
QObject::connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged,
|
QObject::connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged,
|
||||||
|
@@ -24,9 +24,13 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "nimblerunconfiguration.h"
|
#include "nimblerunconfiguration.h"
|
||||||
|
|
||||||
|
#include "nimbuildsystem.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>
|
||||||
@@ -35,8 +39,6 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace Nim {
|
namespace Nim {
|
||||||
@@ -89,7 +91,14 @@ public:
|
|||||||
NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id)
|
NimbleTestConfiguration(ProjectExplorer::Target *target, Utils::Id id)
|
||||||
: RunConfiguration(target, 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<ArgumentsAspect>()->setArguments("test");
|
||||||
addAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(project()->projectDirectory());
|
addAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(project()->projectDirectory());
|
||||||
addAspect<TerminalAspect>();
|
addAspect<TerminalAspect>();
|
||||||
|
@@ -25,16 +25,21 @@
|
|||||||
|
|
||||||
#include "nimbuildsystem.h"
|
#include "nimbuildsystem.h"
|
||||||
|
|
||||||
|
#include "nimconstants.h"
|
||||||
#include "nimproject.h"
|
#include "nimproject.h"
|
||||||
#include "nimbleproject.h"
|
#include "nimbleproject.h"
|
||||||
#include "nimprojectnode.h"
|
#include "nimprojectnode.h"
|
||||||
|
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
#include <projectexplorer/toolchain.h>
|
||||||
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -191,6 +196,22 @@ void NimBuildSystem::triggerParsing()
|
|||||||
m_projectScanner.startScan();
|
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()
|
void NimBuildSystem::loadSettings()
|
||||||
{
|
{
|
||||||
QVariantMap settings = project()->namedSettings(SETTINGS_KEY).toMap();
|
QVariantMap settings = project()->namedSettings(SETTINGS_KEY).toMap();
|
||||||
|
@@ -86,6 +86,9 @@ 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