ui : embed assets directly with CMake (#28445)

Remove the build-time C++ helper and external gzip dependency,
simplifying cross-compilation. Keep the generated C++ in templates for
readability and preserve fully embedded UI assets.

Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This commit is contained in:
Adrien Gallouët
2026-09-06 07:49:39 +02:00
committed by GitHub
parent 971595d669
commit c457e3bf7f
6 changed files with 281 additions and 408 deletions
+36
View File
@@ -0,0 +1,36 @@
// Generated by scripts/ui-assets.cmake - do not edit.
#include "ui.h"
@ASSET_ARRAYS@
#if defined(LLAMA_UI_HAS_ASSETS)
static const std::array<llama_ui_asset, @N_ASSETS@> g_assets = {{
@ASSET_TABLE@
}};
#endif
const llama_ui_asset * llama_ui_find_asset(const std::string & name) {
#if defined(LLAMA_UI_HAS_ASSETS)
for (const auto & a : g_assets) {
if (a.name == name) {
return &a;
}
}
#else
(void) name;
#endif
return nullptr;
}
const std::array<llama_ui_asset, @N_ASSETS@> & llama_ui_get_assets() {
#if defined(LLAMA_UI_HAS_ASSETS)
return g_assets;
#else
static const std::array<llama_ui_asset, 0> empty{};
return empty;
#endif
}
bool llama_ui_use_gzip() {
return @USE_GZIP@;
}