diff --git a/build.sh b/build.sh index 26097c6..6bdbe08 100755 --- a/build.sh +++ b/build.sh @@ -646,13 +646,16 @@ TOOLCHAIN mkdir -p "$RES" SAPLING_SPEND="" SAPLING_OUTPUT="" ASMAP_DAT="" - find_sapling_params || true - find_asmap || true - - if [[ -n "$SAPLING_SPEND" && -n "$SAPLING_OUTPUT" ]]; then - cp -f "$SAPLING_SPEND" "$RES/sapling-spend.params" - cp -f "$SAPLING_OUTPUT" "$RES/sapling-output.params" + local EMBED_NODE_DATA=false + should_bundle_full_node_assets && EMBED_NODE_DATA=true + if $EMBED_NODE_DATA; then + find_sapling_params || true + find_asmap || true + fi + # Lite needs no Sapling params/asmap (its backend embeds its own), so it always gets a header for + # images/themes/xmrig; the full node still requires the params to be found. + if ! $EMBED_NODE_DATA || [[ -n "$SAPLING_SPEND" && -n "$SAPLING_OUTPUT" ]]; then cat > "$GEN/embedded_data.h" < #include "incbin.h" +HDR + if $EMBED_NODE_DATA; then + cp -f "$SAPLING_SPEND" "$RES/sapling-spend.params" + cp -f "$SAPLING_OUTPUT" "$RES/sapling-output.params" + cat >> "$GEN/embedded_data.h" <> "$GEN/embedded_data.h" + if [[ -n "$ASMAP_DAT" ]]; then + cp -f "$ASMAP_DAT" "$RES/asmap.dat" + echo "INCBIN(asmap_dat, \"$RES/asmap.dat\");" >> "$GEN/embedded_data.h" + else + echo 'extern "C" { static const uint8_t* g_asmap_dat_data = nullptr; }' >> "$GEN/embedded_data.h" + echo 'static const unsigned int g_asmap_dat_size = 0;' >> "$GEN/embedded_data.h" + fi else - echo 'extern "C" { static const uint8_t* g_asmap_dat_data = nullptr; }' >> "$GEN/embedded_data.h" - echo 'static const unsigned int g_asmap_dat_size = 0;' >> "$GEN/embedded_data.h" + info "Lite mode: not embedding Sapling params/asmap (the SDXL backend embeds its own)" + for sym in sapling_spend_params sapling_output_params asmap_dat; do + echo "extern \"C\" { static const uint8_t* g_${sym}_data = nullptr; }" >> "$GEN/embedded_data.h" + echo "static const unsigned int g_${sym}_size = 0;" >> "$GEN/embedded_data.h" + done fi # ── Daemon binaries ────────────────────────────────────────────── @@ -809,6 +823,7 @@ HDR info "Embedded resources header generated" else warn "Building WITHOUT embedded resources (Sapling params not found)" + rm -f "$GEN/embedded_data.h" # never compile a stale header left by the other variant in this shared build dir fi # ── Fetch libsodium for Windows if needed ────────────────────────────── diff --git a/src/resources/embedded_resources.cpp b/src/resources/embedded_resources.cpp index eb4f157..b6bfdd1 100644 --- a/src/resources/embedded_resources.cpp +++ b/src/resources/embedded_resources.cpp @@ -89,8 +89,8 @@ bool hasEmbeddedResources() const EmbeddedResource* getEmbeddedResource(const std::string& name) { // Search static resource table (params, daemon binaries, etc.) - for (const auto* res = s_resources; res->data != nullptr; ++res) { - if (name == res->filename) { + for (const auto* res = s_resources; res->filename != nullptr; ++res) { + if (res->data && res->size && name == res->filename) { return res; } }