# kwindowsystem 6.27.0 — KDE Frameworks 6 (Capa 2, ADR 0011). Patrón KF6: dynamic, wrapper zig que filtra
# -Wl,--fatal-warnings (ECM lo agrega, zig lo rechaza), CMAKE_PREFIX_PATH=/usr, ECM + qttools + dbus.
#
# QML=ON (2026-07-18): construye el módulo QML org.kde.kwindowsystem (usr/lib/qt6/qml/org/kde/
# kwindowsystem/: qmldir + libKWindowSystem.so plugin). Ese módulo lo IMPORTA Desktop.qml de
# plasma-workspace ⇒ sin él plasmashell falla "module not installed" y no monta el containment del
# escritorio. Antes estaba OFF y se destrabó la sesión Plasma anidada INJERTANDO el módulo de un
# artefacto viejo (compat por soname libKF6WindowSystem.so.6); esto elimina ese injerto. qtdeclarative
# ya está en [deps].build. Rebuild en la granja (zig-skew: NO en el laptop).
name    = "kwindowsystem"
version = "6.27.0"
license = "LGPL-2.1-or-later OR LGPL-3.0-or-later"

[source]
tarball = "https://download.kde.org/stable/frameworks/6.27/kwindowsystem-6.27.0.tar.xz"
sha256  = "401e5700ab36530a605410464268bf726c898da42c6f7d7bf05a9db00ccfe172"

[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 \
  -DBUILD_TESTING=OFF -DBUILD_PYTHON_BINDINGS=OFF \
  -DKWINDOWSYSTEM_QML=ON -DKWINDOWSYSTEM_X11=ON -DKWINDOWSYSTEM_WAYLAND=ON
'''
compile = "cmake --build build"
install = "DESTDIR=/out cmake --install build"

[deps]
# X11+WAYLAND (Qt-xcb ya saldado): X11 provee KX11Extras (que libplasma/theme_p exige) vía XCB con
# KEYSYMS/RES/ICCCM + qtx11extras_p.h (Qt6::GuiPrivate, ahora con xcb=ON). Wayland: plasma-wayland-protocols
# + Qt6WaylandClient (bundleado en qtbase). Cadena X11: libxcb/libX11/xcb-util-keysyms/wm + libXau/libXdmcp.
build = ["cmake", "samurai", "python3", "pkgconf", "qtbase", "dbus", "extra-cmake-modules", "qttools", "qtdeclarative", "mesa", "libdrm", "libxkbcommon", "wayland", "wayland-protocols", "plasma-wayland-protocols", "libxcb", "libX11", "libXau", "libXdmcp", "xcb-util-keysyms", "xcb-util-wm", "xorgproto", "libXfixes", "libXext", "libXrender", "libXi"]
