default_pre_build

patch -p1 < $SCRIPT_DIRECTORY/qtwebengine-5.15.14_p20240510-icu-75.patch
patch -p1 -d src/3rdparty -i $SCRIPT_DIRECTORY/qt5-webengine-ffmpeg5.patch
patch -p1 -d src/3rdparty -i $SCRIPT_DIRECTORY/qt5-webengine-pipewire-0.3.patch
patch -p2 -d src/3rdparty/chromium -i $SCRIPT_DIRECTORY/qt5-webengine-ninja-1.12.patch
patch -p1 -d src/3rdparty/chromium -i $SCRIPT_DIRECTORY/python3.12-imp.patch
patch -p1 -d src/3rdparty/chromium -i $SCRIPT_DIRECTORY/python3.12-six.patch
patch -p1 -d src/3rdparty/chromium -i $SCRIPT_DIRECTORY/qt5-webengine-ffmpeg7.patch

sed -e '/import pipes/d' -i src/3rdparty/chromium/build/android/gyp/util/build_utils.py

# So it doesn't link to the old version.
if [ -e /usr/lib/qt5/libQt5WebEngineCore.so ]; then
  mv -v /usr/lib/qt5/libQt5WebEngineCore.so{,.old}
fi

# Current python has removed this
sedit 's:import imp::' src/3rdparty/chromium/mojo/public/tools/mojom/mojom/fileutil.py
sedit 's:import imp::' src/3rdparty/chromium/mojo/public/tools/mojom/mojom/parse/lexer.py

#Jiggle with jumbo frames.
sed -i -e 's|use_jumbo_build=true|use_jumbo_build=false|' src/buildtools/config/common.pri 

# Fix string16 linking issues with GCC 13+
sed -i '1i #include <string>' src/3rdparty/chromium/base/strings/string16.h
sed -i '1i #include <string>' src/3rdparty/chromium/base/strings/string16_internals.h

# Current re2 version causes build failure, use internal
sedit 's:use_system_re2=true:use_system_re2=false:' src/core/config/linux.pri &&

#Quoting the LFS folks here;
#Although the patches used in this module ensures git is not invoked during the build, the build system has
#labyrinthine rules of byzantine complexity, and in particular trying to build without two .git directories
#will lead to it eventually falling into unexpected and unbuildable code which references a private header
#that has not been created. Avoid this by creating the required directories
mkdir -pv .git src/3rdparty/chromium/.git

