Added EXCLUDE_INSIGHT build flag.

This commit is contained in:
Nav
2023-05-10 19:53:39 +01:00
parent 3f0326d9a3
commit 0012404a5d
7 changed files with 108 additions and 26 deletions

View File

@@ -47,8 +47,16 @@ namespace Bloom
Logger::warning("This is a debug build - some functions may not work as expected");
#endif
#ifdef EXCLUDE_INSIGHT
Logger::warning(
"The Insight component has been excluded from this build. All Insight related configuration parameters "
"will be ignored."
);
#endif
this->startup();
#ifndef EXCLUDE_INSIGHT
if (this->insightConfig->insightEnabled) {
this->insight = std::make_unique<Insight>(
*(this->applicationEventListener),
@@ -72,6 +80,7 @@ namespace Bloom
this->shutdown();
return EXIT_SUCCESS;
}
#endif
// Main event loop
while (Thread::getThreadState() == ThreadState::READY) {
@@ -165,9 +174,11 @@ namespace Bloom
Thread::setThreadState(ThreadState::SHUTDOWN_INITIATED);
Logger::info("Shutting down Bloom");
#ifndef EXCLUDE_INSIGHT
if (this->insight != nullptr) {
this->insight->shutdown();
}
#endif
this->stopDebugServer();
this->stopTargetController();
@@ -283,6 +294,7 @@ namespace Bloom
this->environmentConfig = selectedEnvironmentIt->second;
#ifndef EXCLUDE_INSIGHT
if (this->environmentConfig->insightConfig.has_value()) {
this->insightConfig = this->environmentConfig->insightConfig.value();
@@ -292,6 +304,7 @@ namespace Bloom
} else {
throw InvalidConfig("Insight configuration missing.");
}
#endif
if (this->environmentConfig->debugServerConfig.has_value()) {
this->debugServerConfig = this->environmentConfig->debugServerConfig.value();
@@ -332,6 +345,10 @@ namespace Bloom
std::cout << "Bloom v" << Application::VERSION.toString() << "\n";
#ifdef EXCLUDE_INSIGHT
std::cout << "Insight has been excluded from this build.\n";
#endif
#ifdef BLOOM_DEBUG_BUILD
std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n";
#endif
@@ -344,6 +361,11 @@ namespace Bloom
int Application::presentVersionMachineText() {
Logger::silence();
auto insightAvailable = true;
#ifdef EXCLUDE_INSIGHT
insightAvailable = false;
#endif
std::cout << QJsonDocument(QJsonObject({
{"version", QString::fromStdString(Application::VERSION.toString())},
{"components", QJsonObject({
@@ -351,6 +373,7 @@ namespace Bloom
{"minor", Application::VERSION.minor},
{"patch", Application::VERSION.patch},
})},
{"insightAvailable", insightAvailable},
})).toJson().toStdString();
return EXIT_SUCCESS;

View File

@@ -12,7 +12,11 @@
#include "src/TargetController/TargetControllerComponent.hpp"
#include "src/DebugServer/DebugServerComponent.hpp"
#ifndef EXCLUDE_INSIGHT
#include "src/Insight/Insight.hpp"
#endif
#include "src/SignalHandler/SignalHandler.hpp"
#include "src/ProjectConfig.hpp"
@@ -80,6 +84,7 @@ namespace Bloom
std::unique_ptr<DebugServer::DebugServerComponent> debugServer = nullptr;
std::thread debugServerThread;
#ifndef EXCLUDE_INSIGHT
/**
* Insight is, effectively, a small Qt application that serves a GUI to the user. It occupies the main thread,
* as well as a single worker thread, and possibly other threads created by Qt.
@@ -95,6 +100,7 @@ namespace Bloom
* as we want to manage the lifetime of the object here.
*/
std::unique_ptr<Insight> insight = nullptr;
#endif
/**
* Configuration extracted from the user's project configuration file.

View File

@@ -33,4 +33,7 @@ add_subdirectory(DebugToolDrivers)
add_subdirectory(Targets)
add_subdirectory(TargetController)
add_subdirectory(DebugServer)
add_subdirectory(Insight)
if (NOT ${EXCLUDE_INSIGHT})
add_subdirectory(Insight)
endif()

View File

@@ -9,19 +9,24 @@
namespace Bloom
{
ProjectSettings::ProjectSettings(const QJsonObject& jsonObject) {
#ifndef EXCLUDE_INSIGHT
if (jsonObject.contains("insight")) {
this->insightSettings = InsightProjectSettings(jsonObject.find("insight")->toObject());
}
#endif
}
QJsonObject ProjectSettings::toJson() const {
auto projectSettingsObj = QJsonObject();
#ifndef EXCLUDE_INSIGHT
projectSettingsObj.insert("insight", this->insightSettings.toJson());
#endif
return projectSettingsObj;
}
#ifndef EXCLUDE_INSIGHT
InsightProjectSettings::InsightProjectSettings(const QJsonObject& jsonObject) {
if (jsonObject.contains("mainWindowSize")) {
const auto mainWindowSizeObj = jsonObject.find("mainWindowSize")->toObject();
@@ -351,4 +356,5 @@ namespace Bloom
return json;
}
#endif
}

View File

@@ -8,14 +8,18 @@
#include <QJsonObject>
#include "src/Targets/TargetMemory.hpp"
#ifndef EXCLUDE_INSIGHT
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PanelState.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PaneState.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp"
#endif
#include "src/Helpers/BiMap.hpp"
namespace Bloom
{
#ifndef EXCLUDE_INSIGHT
struct InsightProjectSettings
{
public:
@@ -65,10 +69,13 @@ namespace Bloom
[[nodiscard]] QJsonObject paneStateToJson(const Widgets::PaneState& paneState) const;
};
#endif
struct ProjectSettings
{
#ifndef EXCLUDE_INSIGHT
InsightProjectSettings insightSettings;
#endif
ProjectSettings() = default;
explicit ProjectSettings(const QJsonObject& jsonObject);