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_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
find_package(yaml-cpp 0.7.0 REQUIRED)
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)
option(EXCLUDE_INSIGHT "Exclude the Insight component from this build" OFF)
set(CMAKE_SKIP_BUILD_RPATH false)
set(CMAKE_BUILD_RPATH_USE_ORIGIN true)
@@ -52,6 +44,39 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
endif()
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(
Bloom
@@ -70,8 +95,6 @@ qt_add_resources(
)
add_subdirectory(src)
set_target_properties(Bloom PROPERTIES OUTPUT_NAME bloom)
target_include_directories(Bloom PUBLIC ./)
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)
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::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_definitions(
Bloom
PUBLIC $<$<BOOL:${EXCLUDE_INSIGHT}>:EXCLUDE_INSIGHT>
)
target_compile_options(
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/;`
- 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/;`
### 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");
#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);