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

@@ -11,15 +11,7 @@ set(ENABLE_SANITIZERS off)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
find_package(yaml-cpp 0.7.0 REQUIRED) option(EXCLUDE_INSIGHT "Exclude the Insight component from this build" OFF)
find_package(Qt6Core REQUIRED)
find_package(Qt6Gui REQUIRED)
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Xml REQUIRED)
find_package(Qt6Svg REQUIRED)
find_package(Qt6UiTools REQUIRED)
find_package(Qt6SvgWidgets REQUIRED)
find_package(Qt6Network REQUIRED)
set(CMAKE_SKIP_BUILD_RPATH false) set(CMAKE_SKIP_BUILD_RPATH false)
set(CMAKE_BUILD_RPATH_USE_ORIGIN true) set(CMAKE_BUILD_RPATH_USE_ORIGIN true)
@@ -52,6 +44,39 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
endif() endif()
add_executable(Bloom) add_executable(Bloom)
set_target_properties(Bloom PROPERTIES OUTPUT_NAME bloom)
find_package(yaml-cpp 0.7.0 REQUIRED)
find_package(Qt6Core REQUIRED)
find_package(Qt6Xml REQUIRED)
if (NOT ${EXCLUDE_INSIGHT})
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Gui REQUIRED)
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Xml REQUIRED)
find_package(Qt6Svg REQUIRED)
find_package(Qt6UiTools REQUIRED)
find_package(Qt6SvgWidgets REQUIRED)
find_package(Qt6Network REQUIRED)
target_link_libraries(Bloom Qt6::Gui)
target_link_libraries(Bloom Qt6::UiTools)
target_link_libraries(Bloom Qt6::Widgets)
target_link_libraries(Bloom Qt6::Xml)
target_link_libraries(Bloom Qt6::Svg)
target_link_libraries(Bloom Qt6::SvgWidgets)
target_link_libraries(Bloom Qt6::Network)
endif()
target_link_libraries(Bloom -lstdc++fs)
target_link_libraries(Bloom -lpthread)
target_link_libraries(Bloom -lusb-1.0)
target_link_libraries(Bloom -lhidapi-libusb)
target_link_libraries(Bloom -lprocps)
target_link_libraries(Bloom ${YAML_CPP_LIBRARIES})
target_link_libraries(Bloom Qt6::Core)
target_link_libraries(Bloom Qt6::Xml)
target_sources( target_sources(
Bloom Bloom
@@ -70,8 +95,6 @@ qt_add_resources(
) )
add_subdirectory(src) add_subdirectory(src)
set_target_properties(Bloom PROPERTIES OUTPUT_NAME bloom)
target_include_directories(Bloom PUBLIC ./) target_include_directories(Bloom PUBLIC ./)
target_include_directories(Bloom PUBLIC ${YAML_CPP_INCLUDE_DIR}) target_include_directories(Bloom PUBLIC ${YAML_CPP_INCLUDE_DIR})
@@ -83,20 +106,10 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
target_include_directories(Bloom PUBLIC /opt/Qt/6.2.4/Src) target_include_directories(Bloom PUBLIC /opt/Qt/6.2.4/Src)
endif() endif()
target_link_libraries(Bloom -lstdc++fs) target_compile_definitions(
target_link_libraries(Bloom -lpthread) Bloom
target_link_libraries(Bloom -lusb-1.0) PUBLIC $<$<BOOL:${EXCLUDE_INSIGHT}>:EXCLUDE_INSIGHT>
target_link_libraries(Bloom -lhidapi-libusb) )
target_link_libraries(Bloom -lprocps)
target_link_libraries(Bloom ${YAML_CPP_LIBRARIES})
target_link_libraries(Bloom Qt6::Core)
target_link_libraries(Bloom Qt6::Gui)
target_link_libraries(Bloom Qt6::UiTools)
target_link_libraries(Bloom Qt6::Widgets)
target_link_libraries(Bloom Qt6::Xml)
target_link_libraries(Bloom Qt6::Svg)
target_link_libraries(Bloom Qt6::SvgWidgets)
target_link_libraries(Bloom Qt6::Network)
target_compile_options( target_compile_options(
Bloom Bloom

View File

@@ -124,3 +124,27 @@ sudo cmake --install ./ --prefix [SOME_OTHER_INSTALLATION_DIR];
having to supply the full path: `sudo ln -s /opt/bloom/bin/bloom /usr/bin/;` having to supply the full path: `sudo ln -s /opt/bloom/bin/bloom /usr/bin/;`
- If you're installing on Ubuntu 20.04 or older, you may need to move the installed udev rules, as they're expected - If you're installing on Ubuntu 20.04 or older, you may need to move the installed udev rules, as they're expected
to reside in `/lib/udev/rules.d` on those systems. Move them via: `sudo mv /usr/lib/udev/rules.d/99-bloom.rules /lib/udev/rules.d/;` to reside in `/lib/udev/rules.d` on those systems. Move them via: `sudo mv /usr/lib/udev/rules.d/99-bloom.rules /lib/udev/rules.d/;`
### Excluding Insight at build time
The Insight component can be excluded at build time, via the `EXCLUDE_INSIGHT` flag.
You'll still need to satisfy the Qt dependency on the build machine, as other parts of Bloom use Qt, but you'll no
longer need to install GUI dependencies on every machine you intend to run Bloom on. Just build it once and distribute
the binary, along with the necessary shared objects.
To identify the necessary shared objects, copy the binary to one of those machines and run `ldd [PATH_TO_BLOOM_BINARY]`.
That will output a list of all the dependencies that `ld` couldn't satisfy - those will be what you need to distribute
(or manually install on each machine).
#### Example build excluding Insight
```shell
# Build Bloom in [SOME_BUILD_DIR]
mkdir [SOME_BUILD_DIR];
cd [SOME_BUILD_DIR];
cmake [PATH_TO_BLOOM_SOURCE] -DEXCLUDE_INSIGHT=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=[PATH_TO_QT_INSTALLATION]/gcc_64/;
cmake --build ./;
...
```

View File

@@ -47,8 +47,16 @@ namespace Bloom
Logger::warning("This is a debug build - some functions may not work as expected"); Logger::warning("This is a debug build - some functions may not work as expected");
#endif #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(); this->startup();
#ifndef EXCLUDE_INSIGHT
if (this->insightConfig->insightEnabled) { if (this->insightConfig->insightEnabled) {
this->insight = std::make_unique<Insight>( this->insight = std::make_unique<Insight>(
*(this->applicationEventListener), *(this->applicationEventListener),
@@ -72,6 +80,7 @@ namespace Bloom
this->shutdown(); this->shutdown();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#endif
// Main event loop // Main event loop
while (Thread::getThreadState() == ThreadState::READY) { while (Thread::getThreadState() == ThreadState::READY) {
@@ -165,9 +174,11 @@ namespace Bloom
Thread::setThreadState(ThreadState::SHUTDOWN_INITIATED); Thread::setThreadState(ThreadState::SHUTDOWN_INITIATED);
Logger::info("Shutting down Bloom"); Logger::info("Shutting down Bloom");
#ifndef EXCLUDE_INSIGHT
if (this->insight != nullptr) { if (this->insight != nullptr) {
this->insight->shutdown(); this->insight->shutdown();
} }
#endif
this->stopDebugServer(); this->stopDebugServer();
this->stopTargetController(); this->stopTargetController();
@@ -283,6 +294,7 @@ namespace Bloom
this->environmentConfig = selectedEnvironmentIt->second; this->environmentConfig = selectedEnvironmentIt->second;
#ifndef EXCLUDE_INSIGHT
if (this->environmentConfig->insightConfig.has_value()) { if (this->environmentConfig->insightConfig.has_value()) {
this->insightConfig = this->environmentConfig->insightConfig.value(); this->insightConfig = this->environmentConfig->insightConfig.value();
@@ -292,6 +304,7 @@ namespace Bloom
} else { } else {
throw InvalidConfig("Insight configuration missing."); throw InvalidConfig("Insight configuration missing.");
} }
#endif
if (this->environmentConfig->debugServerConfig.has_value()) { if (this->environmentConfig->debugServerConfig.has_value()) {
this->debugServerConfig = this->environmentConfig->debugServerConfig.value(); this->debugServerConfig = this->environmentConfig->debugServerConfig.value();
@@ -332,6 +345,10 @@ namespace Bloom
std::cout << "Bloom v" << Application::VERSION.toString() << "\n"; 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 #ifdef BLOOM_DEBUG_BUILD
std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n"; std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n";
#endif #endif
@@ -344,6 +361,11 @@ namespace Bloom
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({
@@ -351,6 +373,7 @@ namespace Bloom
{"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;

View File

@@ -12,7 +12,11 @@
#include "src/TargetController/TargetControllerComponent.hpp" #include "src/TargetController/TargetControllerComponent.hpp"
#include "src/DebugServer/DebugServerComponent.hpp" #include "src/DebugServer/DebugServerComponent.hpp"
#ifndef EXCLUDE_INSIGHT
#include "src/Insight/Insight.hpp" #include "src/Insight/Insight.hpp"
#endif
#include "src/SignalHandler/SignalHandler.hpp" #include "src/SignalHandler/SignalHandler.hpp"
#include "src/ProjectConfig.hpp" #include "src/ProjectConfig.hpp"
@@ -80,6 +84,7 @@ namespace Bloom
std::unique_ptr<DebugServer::DebugServerComponent> debugServer = nullptr; std::unique_ptr<DebugServer::DebugServerComponent> debugServer = nullptr;
std::thread debugServerThread; 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, * 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. * 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. * as we want to manage the lifetime of the object here.
*/ */
std::unique_ptr<Insight> insight = nullptr; std::unique_ptr<Insight> insight = nullptr;
#endif
/** /**
* Configuration extracted from the user's project configuration file. * Configuration extracted from the user's project configuration file.

View File

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

View File

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

View File

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