description='Support for web applications using the Chromium browser project'
url='https://www.qt.io/'

license="FDL, GPL3, LGPL3, custom"

packager="spiky <spiky@nutyx.org>"
contributors="Tnut"

name=qt6-webengine
version=6.7.2
release=2

makedepends=(cmake ninja qt6-base qt6-declarative qt6-positioning qt6-webchannel
             qt6-tools qt6-websockets python-html5lib gzip icu
             alsa-lib dbus expat ffmpeg xorg-fontconfig freetype glib harfbuzz
             icu lcms2 xorg-libdrm libevent libjpeg-turbo libpng libtiff libwebp
             xorg-libx11 libxcb xorg-libxcomposite xorg-libxdamage xorg-libxext
             xorg-libxfixes libxkbcommon xorg-libxkbfile libxml2 xorg-libxrandr
             libxslt xorg-libxtst mesa minizip nspr nss openjpeg opus snappy
             pipewire gperf jsoncpp libepoxy node)

_name=${name/6-/}-everywhere-src

source=(ninja.patch ninja-1.12.patch
        https://download.qt.io/official_releases/qt/${version:0:3}/$version/submodules/${_name}-$version.tar.xz
        qtwebengine-6.7.2-ffmpeg7_fixes-1.patch)


prepare() {
cd ${_name}-$version

patch -Np1 -i ../ninja-1.12.patch
patch -Np1 -d src/3rdparty/chromium < ../qtwebengine-6.7.2-ffmpeg7_fixes-1.patch

sed -e '189 s/=/& false/' \
    -e '190 d'            \
    -i.orig src/3rdparty/chromium/third_party/webrtc/webrtc.gni
}
build() {
## Do not change ninja jobs ##
export NINJAJOBS=8

 cmake -D CMAKE_MESSAGE_LOG_LEVEL=STATUS       \
 -D QT_FEATURE_webengine_system_icu=ON         \
 -D QT_FEATURE_webengine_system_libevent=ON    \
 -D QT_FEATURE_webengine_proprietary_codecs=ON \
 -D QT_FEATURE_webengine_webrtc_pipewire=ON    \
 -D QT_BUILD_EXAMPLES_BY_DEFAULT=OFF           \
 -S ${_name}-$version -B build -G Ninja
 cmake --build build
 DESTDIR=$PKG cmake --install build
}
devel() {
  cd $PKG
  bsdtar -cf \
  $PKGMK_PACKAGE_DIR/$name.devel${PKGMK_BUILDVER}any.cards.tar \
  usr/include \
  usr/lib/qt6/mkspecs \
  usr/lib/cmake/
  
  rm -r usr/include usr/lib/qt6/mkspecs \
  usr/lib/cmake
}
