#TODO runtime hangs
[source]
tar = "https://webkitgtk.org/releases/webkitgtk-2.49.1.tar.xz"
blake3 = "7f04acb2f909ad334fc623afb297ebca1d5a5005bda1682946fb37e044e45ecb"
patches = ["redox.patch"]

[build]
template = "custom"
dependencies = [
    "gtk3",
    "libatomic",
    "libgcrypt",
    "libsoup",
    "libtasn1",
    "libwebp",
    "sqlite3",
]
dev-dependencies = [
    "host:gperf",
    "libstdcxx",
]
script = """
DYNAMIC_INIT
export WEBKIT_USE_SCCACHE=1
export PYTHONDONTWRITEBYTECODE=1
#TODO: enable more features
COOKBOOK_CMAKE_FLAGS+=(
    -DENABLE_ASSERTS=ON
    -DENABLE_GAMEPAD=OFF
    -DENABLE_INTROSPECTION=OFF
    -DENABLE_MEDIA_STREAM=OFF
    -DENABLE_JOURNALD_LOG=OFF
    -DENABLE_RELEASE_LOG=ON
    -DENABLE_SPEECH_SYNTHESIS=OFF
    -DENABLE_SPELLCHECK=OFF
    -DENABLE_WEB_AUDIO=OFF
    -DENABLE_WEB_CODECS=OFF
    -DENABLE_VIDEO=OFF
    -DPORT=GTK
    -DUNIX=1
    -DUSE_AVIF=OFF
    -DUSE_GSTREAMER_GL=OFF
    -DUSE_GTK4=OFF
    -DUSE_JPEGXL=OFF
    -DUSE_LCMS=OFF
    -DUSE_LIBBACKTRACE=OFF
    -DUSE_LIBDRM=OFF
    -DUSE_LIBHYPHEN=OFF
    -DUSE_LIBSECRET=OFF
    -DUSE_SKIA=OFF
    -DUSE_SYSPROF_CAPTURE=OFF
    -DUSE_SYSTEM_MALLOC=ON
    -DUSE_SYSTEM_SYSPROF_CAPTURE=OFF
    -DUSE_WOFF2=OFF
    #TODO: remove these when runtime hangs solved
    -DENABLE_JIT=OFF
    -DENABLE_DFG_JIT=OFF
    -DENABLE_FTL_JIT=OFF
    -DENABLE_OPENGL=OFF
    -DENABLE_WEBGL=OFF
    -DENABLE_XSLT=OFF
    -DENABLE_GEOLOCATION=OFF
    -DENABLE_WEBDRIVER=OFF
    -DENABLE_BUBBLEWRAP_SANDBOX=OFF
    -DUSE_LCMS=OFF
)

cookbook_cmake

patchelf --replace-needed "${COOKBOOK_SYSROOT}/usr/lib/libsqlite3.so" "libsqlite3.so" "${COOKBOOK_STAGE}/usr/lib/libwebkit2gtk-4.1.so"
patchelf --replace-needed "${COOKBOOK_SYSROOT}/usr/lib/libsqlite3.so" "libsqlite3.so" "${COOKBOOK_STAGE}/usr/libexec/webkit2gtk-4.1/MiniBrowser"
mkdir -p "${COOKBOOK_STAGE}/usr/bin"
ln -sr "${COOKBOOK_STAGE}/usr/libexec/webkit2gtk-4.1/MiniBrowser" "${COOKBOOK_STAGE}/usr/bin/MiniBrowser"
"""

[package]
dependencies = ["glib-networking"]
