build: embed ui.toml and banlist with INCBIN instead of a configure loop
ui.toml and the default banlist were embedded by a CMake function that read each file and emitted a C array header one byte at a time in a configure-time loop. That is slow to configure, and because the result is a header, editing either resource recompiled every translation unit that included it. - Both files are now embedded with INCBIN from a small generated translation unit, the same pattern already used for the fonts. There is no generated header, so editing a resource re-assembles one tiny object file instead of triggering a wide recompile, and configure does no per-byte work. - Consumers include a hand-written header declaring the symbols and always use the embedded data (the __has_include fallback is gone). The data is not NUL-terminated, so every consumer passes an explicit size. - The old EmbedResources.cmake script is removed, and the generated unit is added to the app and test builds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+3
-21
@@ -15,13 +15,8 @@
|
||||
#include <system_error>
|
||||
#include <thread>
|
||||
|
||||
// Embedded ui.toml (generated at build time)
|
||||
#if __has_include("ui_toml_embedded.h")
|
||||
#include "ui_toml_embedded.h"
|
||||
#define HAS_EMBEDDED_UI_TOML 1
|
||||
#else
|
||||
#define HAS_EMBEDDED_UI_TOML 0
|
||||
#endif
|
||||
// Embedded ui.toml (INCBIN)
|
||||
#include "embedded/embedded_text.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -562,20 +557,7 @@ void Platform::ensureObsidianDragonSetup()
|
||||
// Use the build-time embedded copy first; fall back to the
|
||||
// bundled file on disk.
|
||||
std::string content;
|
||||
#if HAS_EMBEDDED_UI_TOML
|
||||
content.assign(reinterpret_cast<const char*>(embedded::ui_toml_data),
|
||||
embedded::ui_toml_size);
|
||||
#else
|
||||
{
|
||||
fs::path bundled = fs::path(getExecutableDirectory()) / "res" / "themes" / "ui.toml";
|
||||
std::ifstream src(bundled);
|
||||
if (src.is_open()) {
|
||||
std::ostringstream ss;
|
||||
ss << src.rdbuf();
|
||||
content = ss.str();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
content.assign(reinterpret_cast<const char*>(g_ui_toml_data), g_ui_toml_size);
|
||||
|
||||
if (!content.empty()) {
|
||||
// Patch the theme metadata so the example is clearly
|
||||
|
||||
Reference in New Issue
Block a user