forked from qt-creator/qt-creator
Nim: Proliferate FilePath use in NimbleBuildSystem
Change-Id: I1c5d5a6fed96ba189cd5e9f4f45cf103f991df46 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Filippo Cucchetto <filippocucchetto@gmail.com>
This commit is contained in:
@@ -35,8 +35,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -45,7 +44,7 @@ namespace Nim {
|
|||||||
|
|
||||||
const char C_NIMBLEPROJECT_TASKS[] = "Nim.NimbleProject.Tasks";
|
const char C_NIMBLEPROJECT_TASKS[] = "Nim.NimbleProject.Tasks";
|
||||||
|
|
||||||
static QList<QByteArray> linesFromProcessOutput(QProcess *process)
|
static QList<QByteArray> linesFromProcessOutput(QtcProcess *process)
|
||||||
{
|
{
|
||||||
QList<QByteArray> lines = process->readAllStandardOutput().split('\n');
|
QList<QByteArray> lines = process->readAllStandardOutput().split('\n');
|
||||||
lines = Utils::transform(lines, [](const QByteArray &line){ return line.trimmed(); });
|
lines = Utils::transform(lines, [](const QByteArray &line){ return line.trimmed(); });
|
||||||
@@ -53,19 +52,18 @@ static QList<QByteArray> linesFromProcessOutput(QProcess *process)
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<NimbleTask> parseTasks(const QString &nimblePath, const QString &workingDirectory)
|
static std::vector<NimbleTask> parseTasks(const FilePath &nimblePath, const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
QProcess process;
|
QtcProcess process;
|
||||||
|
process.setCommand({nimblePath, {"tasks"}});
|
||||||
process.setWorkingDirectory(workingDirectory);
|
process.setWorkingDirectory(workingDirectory);
|
||||||
process.start(nimblePath, {"tasks"});
|
process.start();
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
|
||||||
std::vector<NimbleTask> result;
|
std::vector<NimbleTask> result;
|
||||||
|
|
||||||
if (process.exitCode() != 0) {
|
if (process.exitCode() != 0) {
|
||||||
TaskHub::addTask(Task(Task::Error,
|
TaskHub::addTask(Task(Task::Error, process.stdOut(), {}, -1, Constants::C_NIMPARSE_ID));
|
||||||
QString::fromUtf8(process.readAllStandardOutput()),
|
|
||||||
{}, -1, Constants::C_NIMPARSE_ID));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,19 +80,18 @@ static std::vector<NimbleTask> parseTasks(const QString &nimblePath, const QStri
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NimbleMetadata parseMetadata(const QString &nimblePath, const QString &workingDirectory)
|
static NimbleMetadata parseMetadata(const FilePath &nimblePath, const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
QProcess process;
|
QtcProcess process;
|
||||||
|
process.setCommand({nimblePath, {"dump"}});
|
||||||
process.setWorkingDirectory(workingDirectory);
|
process.setWorkingDirectory(workingDirectory);
|
||||||
process.start(nimblePath, {"dump"});
|
process.start();
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
|
||||||
NimbleMetadata result = {};
|
NimbleMetadata result = {};
|
||||||
|
|
||||||
if (process.exitCode() != 0) {
|
if (process.exitCode() != 0) {
|
||||||
TaskHub::addTask(Task(Task::Error,
|
TaskHub::addTask(Task(Task::Error, process.stdOut(), {}, -1, Constants::C_NIMPARSE_ID));
|
||||||
QString::fromUtf8(process.readAllStandardOutput()),
|
|
||||||
{}, -1, Constants::C_NIMPARSE_ID));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
const QList<QByteArray> &lines = linesFromProcessOutput(&process);
|
const QList<QByteArray> &lines = linesFromProcessOutput(&process);
|
||||||
@@ -172,7 +169,7 @@ void NimbleBuildSystem::updateProject()
|
|||||||
const FilePath projectDir = projectDirectory();
|
const FilePath projectDir = projectDirectory();
|
||||||
const FilePath nimble = Nim::nimblePathFromKit(kit());
|
const FilePath nimble = Nim::nimblePathFromKit(kit());
|
||||||
|
|
||||||
const NimbleMetadata metadata = parseMetadata(nimble.toString(), projectDir.toString());
|
const NimbleMetadata metadata = parseMetadata(nimble, projectDir);
|
||||||
const FilePath binDir = projectDir.pathAppended(metadata.binDir);
|
const FilePath binDir = projectDir.pathAppended(metadata.binDir);
|
||||||
const FilePath srcDir = projectDir.pathAppended("src");
|
const FilePath srcDir = projectDir.pathAppended("src");
|
||||||
|
|
||||||
@@ -188,7 +185,7 @@ void NimbleBuildSystem::updateProject()
|
|||||||
|
|
||||||
setApplicationTargets(std::move(targets));
|
setApplicationTargets(std::move(targets));
|
||||||
|
|
||||||
std::vector<NimbleTask> tasks = parseTasks(nimble.toString(), projectDir.toString());
|
std::vector<NimbleTask> tasks = parseTasks(nimble, projectDir);
|
||||||
if (tasks != m_tasks) {
|
if (tasks != m_tasks) {
|
||||||
m_tasks = std::move(tasks);
|
m_tasks = std::move(tasks);
|
||||||
emit tasksChanged();
|
emit tasksChanged();
|
||||||
|
Reference in New Issue
Block a user