# gwenview 25.04.3 — el visor de imágenes de KDE. 7ma APP del escritorio.
# Patrón KF6 app (dynamic, wrapper zig, ECM). Deps nuevas: phonon (sonido slideshow, REQUIRED) + exiv2
# (metadatos EXIF, REQUIRED; localizado por el FindLibExiv2.cmake de ECM). Imagen: libjpeg-turbo-shared +
# libpng-shared (variantes .so/PIC; el .a canónico no enlaza en gwenviewlib.so) + lcms2 (color, REQUIRED).
# kImageAnnotator (anotación, ksnip) se degrada a OPTIONAL (el código guarda con KIMAGEANNOTATOR_FOUND).
name    = "gwenview"
version = "25.04.3"

[source]
tarball = "https://download.kde.org/stable/release-service/25.04.3/src/gwenview-25.04.3.tar.xz"
sha256  = "59bf9fc4a4be87260781ccb5872212484b697caa53fa0ee7e128bdb08eaf5e87"

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

[build.phases]
configure = '''
rm -rf po doc
sed -i '/add_subdirectory(doc)/d' CMakeLists.txt
sed -i '/kdoctools_install/d' CMakeLists.txt
# kImageAnnotator-Qt6: REQUIRED → OPTIONAL (no lo tenemos; anotación deshabilitada).
sed -i '/kImageAnnotator-Qt6 PROPERTIES/ s/TYPE REQUIRED/TYPE OPTIONAL/' CMakeLists.txt
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 -DBUILD_TESTING=OFF
'''
compile = "cmake --build build"
install = "DESTDIR=/out cmake --install build"

[deps]
build = ["cmake", "samurai", "python3", "pkgconf", "qtbase", "qtsvg", "qtwayland", "dbus",
  "extra-cmake-modules", "qttools", "gettext-tiny", "mesa", "libdrm", "libxkbcommon", "wayland",
  "wayland-protocols", "plasma-wayland-protocols", "qtdeclarative",
  "phonon", "exiv2", "libjpeg-turbo-shared", "libpng-shared", "zlib-shared", "lcms2",
  "kio", "kitemmodels", "ki18n", "kparts", "kwindowsystem", "kiconthemes", "knotifications",
  "kguiaddons", "kwidgetsaddons", "kcrash",
  "kcoreaddons", "kservice", "kbookmarks", "kjobwidgets", "kcompletion", "kcodecs", "kcolorscheme",
  "kconfig", "kconfigwidgets", "kxmlgui", "kitemviews", "solid", "sonnet", "karchive", "attica",
  "kglobalaccel", "kauth", "icu4c", "ktextwidgets", "kirigami",
  "libX11", "xorgproto", "libXau", "libXdmcp", "libXext", "libXrender", "libXfixes", "libXi",
  "libxcb", "xcb-util", "xcb-util-keysyms", "xcb-util-wm", "xcb-util-image", "xcb-util-renderutil"]
