Replaced --target-list-machine CLI command with a more generic --capabilities-machine command, so that I can include other info.

- Also moved the `insightAvailable` flag from the `--version-machine` command
This commit is contained in:
Nav
2024-02-12 23:22:19 +00:00
parent 09cea149d8
commit 46d75b3f4b
3 changed files with 16 additions and 15 deletions

View File

@@ -10,7 +10,7 @@ Commands:
--help, -h Displays this help text. --help, -h Displays this help text.
--version, -v Displays Bloom's version number. --version, -v Displays Bloom's version number.
--version-machine Outputs Bloom's version number in JSON format. --version-machine Outputs Bloom's version number in JSON format.
--target-list-machine Outputs all targets and their configuration values, supported by this build, in JSON format. --capabilities-machine Outputs the capabilities of this build, in JSON format.
init Creates a new Bloom project configuration file (bloom.yaml), in the working directory. init Creates a new Bloom project configuration file (bloom.yaml), in the working directory.
For more information on getting started with Bloom, please visit https://bloom.oscillate.io/docs/getting-started. For more information on getting started with Bloom, please visit https://bloom.oscillate.io/docs/getting-started.

View File

@@ -123,8 +123,8 @@ std::map<std::string, std::function<int()>> Application::getCommandHandlersByCom
std::bind(&Application::initProject, this) std::bind(&Application::initProject, this)
}, },
{ {
"--target-list-machine", "--capabilities-machine",
std::bind(&Application::presentTargetListMachine, this) std::bind(&Application::presentCapabilitiesMachine, this)
}, },
}; };
} }
@@ -375,11 +375,6 @@ int Application::presentVersionText() {
int Application::presentVersionMachineText() { int Application::presentVersionMachineText() {
Logger::silence(); Logger::silence();
auto insightAvailable = true;
#ifdef EXCLUDE_INSIGHT
insightAvailable = false;
#endif
std::cout << QJsonDocument(QJsonObject({ std::cout << QJsonDocument(QJsonObject({
{"version", QString::fromStdString(Application::VERSION.toString())}, {"version", QString::fromStdString(Application::VERSION.toString())},
{"components", QJsonObject({ {"components", QJsonObject({
@@ -387,13 +382,12 @@ int Application::presentVersionMachineText() {
{"minor", Application::VERSION.minor}, {"minor", Application::VERSION.minor},
{"patch", Application::VERSION.patch}, {"patch", Application::VERSION.patch},
})}, })},
{"insightAvailable", insightAvailable},
})).toJson().toStdString(); })).toJson().toStdString();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
int Application::presentTargetListMachine() { int Application::presentCapabilitiesMachine() {
using Targets::TargetFamily; using Targets::TargetFamily;
Logger::silence(); Logger::silence();
@@ -403,17 +397,24 @@ int Application::presentTargetListMachine() {
{TargetFamily::RISC_V, "RISC-V"}, {TargetFamily::RISC_V, "RISC-V"},
}); });
auto output = QJsonArray(); auto supportedTargets = QJsonArray();
for (const auto& [configValue, descriptor] : Targets::TargetDescription::TargetDescriptionFile::mapping()) { for (const auto& [configValue, descriptor] : Targets::TargetDescription::TargetDescriptionFile::mapping()) {
output.push_back(QJsonObject({ supportedTargets.push_back(QJsonObject({
{"name" , QString::fromStdString(descriptor.targetName)}, {"name" , QString::fromStdString(descriptor.targetName)},
{"family" , targetFamilyNames.at(descriptor.targetFamily)}, {"family" , targetFamilyNames.at(descriptor.targetFamily)},
{"configurationValue" , QString::fromStdString(configValue)}, {"configurationValue" , QString::fromStdString(configValue)},
})); }));
} }
std::cout << QJsonDocument(output).toJson().toStdString(); std::cout << QJsonDocument(QJsonObject({
{"supportedTargets", supportedTargets},
#ifndef EXCLUDE_INSIGHT
{"insight", true},
#else
{"insight", false},
#endif
})).toJson().toStdString();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@@ -217,11 +217,11 @@ private:
int presentVersionMachineText(); int presentVersionMachineText();
/** /**
* Lists all supported targets, in JSON format. * Presents Bloom's capabilities, in JSON format.
* *
* @return * @return
*/ */
int presentTargetListMachine(); int presentCapabilitiesMachine();
/** /**
* Initialises a project in the user's working directory. * Initialises a project in the user's working directory.