# kfilemetadata 6.27.0 — KDE Frameworks 6 (Capa 3, ADR 0011). Extracción de metadatos de archivos.
# Patrón KF6: dynamic, wrapper zig que filtra -Wl,--fatal-warnings, CMAKE_PREFIX_PATH=/usr, ECM + qttools + dbus.
# Deps del CMakeLists:
#   REQUIRED: Qt6 Xml, KF6 CoreAddons, KF6 I18n, KF6 Codecs.
#   OPTIONAL (se activan si están sellados): Qt6 Gui, KF6 Archive, KF6 Config.
#   OPTIONAL externas TODAS (no forzadas, ausentes = OK): Poppler, Taglib, LibExiv2, FFmpeg, EPub, CatDoc,
#     QMobipocket6, libappimage. Ninguna tiene receta → se quedan sin encontrar (extractores concretos deshabilitados).
# ki18n → gettext-tiny. kconfig se construyó con QML ⇒ qtdeclarative en el cierre.
# BLOCKER SORTEADO — Xattr TYPE REQUIRED en Linux (FindXattr.cmake busca sys/xattr.h + libattr; en musl NO hay libattr,
#   los syscalls xattr viven en libc). NO existe receta `attr`/`libattr` en el catálogo. Las vars XATTR_* SÓLO se usan
#   dentro de FindXattr.cmake (jamás se linkean en src/), así que se satisface la rama "already in cache" pasando
#   -DXATTR_INCLUDE_DIRS=/usr/include -DXATTR_LIBRARIES=c ⇒ XATTR_FOUND=TRUE, evita el ecm_feature_summary FATAL. Inocuo.
# Sin option(WITH_X11); sin código X11 → sin -DWITH_X11=OFF.
name    = "kfilemetadata"
version = "6.27.0"

[source]
tarball = "https://download.kde.org/stable/frameworks/6.27/kfilemetadata-6.27.0.tar.xz"
sha256  = "27f68558259394ad84d357aa316821672ee66481fa851ddf2a6109f668a6c6a3"

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "dynamic"
flags    = []

[build.phases]
configure = '''
ZW="$PWD/.zwrap"; mkdir -p "$ZW"
cat > "$ZW/cc"  <<'W'
#!/bin/sh
a=""; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; a="$a $x"; done
exec /opt/zig/zig cc -mcpu=baseline $a
W
cat > "$ZW/cxx" <<'W'
#!/bin/sh
a=""; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; a="$a $x"; done
exec /opt/zig/zig c++ -mcpu=baseline $a
W
chmod +x "$ZW/cc" "$ZW/cxx"
cmake -B build -G Ninja -Wno-dev \
  -DCMAKE_C_COMPILER="$ZW/cc" -DCMAKE_CXX_COMPILER="$ZW/cxx" -DCMAKE_ASM_COMPILER="$ZW/cc" \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr \
  -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
  -DXATTR_INCLUDE_DIRS=/usr/include -DXATTR_LIBRARIES=c \
  -DBUILD_TESTING=OFF -DBUILD_PYTHON_BINDINGS=OFF -DBUILD_DESIGNERPLUGIN=OFF
'''
compile = "cmake --build build"
install = "DESTDIR=/out cmake --install build"

[deps]
build = ["cmake", "samurai", "python3", "pkgconf", "qtbase", "dbus", "extra-cmake-modules", "qttools", "mesa", "libdrm", "libxkbcommon", "wayland", "gettext-tiny", "kcoreaddons", "ki18n", "kcodecs", "karchive", "kconfig", "kcolorscheme", "kguiaddons", "kwidgetsaddons", "qtdeclarative"]
