1# QtWebEngine itself is a very thin layer of Qt code on top of a large part of 2# Chromium (everything up to the content/ layer). As such, most of the work in 3# this port revolves around taming Chromium and getting it to build on FreeBSD. 4# While it does build at the moment, there are several items that should be 5# investigated or improved: 6# - We are using several stub files, especially in Chromium's base/ and net/ 7# layers. We should look at implementing the missing bits instead. 8# - We are currently not using any sandboxing mechanism. 9# - The process of porting QtWebEngine needs to be documented so we can move to 10# newer releases more easily. 11# 12 13PORTNAME?= webengine 14DISTVERSION= ${QT6_VERSION} 15# This is the parent port of print/qt6-pdf. Please always keep 'PORTREVISION?=' 16# and reset the value to '0' only after increasing QT6_VERSION in Mk/Uses/qt.mk. 17PORTREVISION?= 3 18CATEGORIES?= www 19PKGNAMEPREFIX= qt6- 20 21MAINTAINER= ports@MidnightBSD.org 22COMMENT?= Qt 6 library to render web content 23 24# 32-bit platforms are not supported by upstream, but we're limping them along. 25ONLY_FOR_ARCHS= aarch64 amd64 armv7 i386 26 27.if ${ARCH:U:Mi386} 28MAKE_JOBS_NUMBER_LIMIT= 1 29.endif 30 31BUILD_DEPENDS= ${LOCALBASE}/include/vulkan/vulkan.h:graphics/vulkan-headers 32LIB_DEPENDS= libfreetype.so:print/freetype2 \ 33 libnss3.so:security/nss \ 34 libopenjp2.so:graphics/openjpeg \ 35 libxkbcommon.so:x11/libxkbcommon 36 37USES= cmake compiler:c++20-lang gl localbase:ldflags ninja:build \ 38 pkgconfig python:build qt-dist:6,webengine 39USE_GL= opengl 40USE_QT= base declarative tools 41USE_XORG= x11 xcb xcomposite xcursor xdamage xext xfixes xi xkbfile \ 42 xrandr xrender xscrnsaver xshmfence xtst 43 44CMAKE_ON= QT_FEATURE_webengine_system_ffmpeg \ 45 QT_FEATURE_webengine_proprietary_codecs 46 47USE_LDCONFIG= ${PREFIX}/${QT_LIBDIR_REL} 48 49.if defined(BUILD_QTPDF) 50CMAKE_ON+= QT_FEATURE_qtpdf_build 51CMAKE_OFF+= QT_FEATURE_qtwebengine_build 52 53SYS_LIBS= freetype 54CXXFLAGS+= -I${LOCALBASE}/include/freetype2 55.else 56BUILD_DEPENDS+= ${LOCALBASE}/include/linux/videodev2.h:multimedia/v4l_compat \ 57 ${PYTHON_PKGNAMEPREFIX}html5lib>0:www/py-html5lib@${PY_FLAVOR} 58LIB_DEPENDS+= libabsl_base.so:devel/abseil \ 59 libavcodec.so:multimedia/ffmpeg \ 60 libdbus-1.so:devel/dbus \ 61 libdrm.so:graphics/libdrm \ 62 libepoll-shim.so:devel/libepoll-shim \ 63 libexpat.so:textproc/expat2 \ 64 libfontconfig.so:x11-fonts/fontconfig \ 65 libharfbuzz.so:print/harfbuzz \ 66 liblcms2.so:graphics/lcms2 \ 67 libnspr4.so:devel/nspr \ 68 libopenh264.so:multimedia/openh264 \ 69 libopus.so:audio/opus \ 70 libpci.so:devel/libpci \ 71 libpng.so:graphics/png \ 72 libre2.so:devel/re2 \ 73 libsnappy.so:archivers/snappy \ 74 libtiff.so:graphics/tiff \ 75 libudev.so:devel/libudev-devd \ 76 libvpx.so:multimedia/libvpx \ 77 libwebp.so:graphics/webp 78 79USES+= bison gnome gperf jpeg minizip xorg 80USE_GL+= gbm 81USE_QT+= positioning quick3d:build webchannel 82USE_GNOME+= glib20 libxml2 libxslt 83USE_XORG+= x11 xcb xcomposite xcursor xdamage xext xfixes xi xkbfile \ 84 xrandr xrender xscrnsaver xshmfence xtst 85 86CMAKE_ON+= QT_FEATURE_qtwebengine_build 87CMAKE_OFF+= QT_FEATURE_qtpdf_build 88 89CXXFLAGS+= -I${LOCALBASE}/include/freetype2 \ 90 -I${LOCALBASE}/include/harfbuzz \ 91 -I${LOCALBASE}/include/libepoll-shim \ 92 -I${LOCALBASE}/include/libdrm \ 93 -I${LOCALBASE}/include/nss \ 94 -I${LOCALBASE}/include/nspr 95 96SYS_LIBS= freetype harfbuzz-ng libdrm libpng libxml libxslt openh264 opus 97.endif 98 99# The build system reads the environment variable $NINJA_PATH to decide whether 100# to boostrap ninja or not (and also to invoke it afterwards). CC and CXX are 101# read by some Chromium code to determine which compiler to invoke when running 102# some configuration tests. 103CONFIGURE_ENV+= NINJAFLAGS="-j${MAKE_JOBS_NUMBER}" \ 104 NINJA_PATH="${LOCALBASE}/bin/ninja" \ 105 PATH=${CONFIGURE_WRKSRC}/bin:${LOCALBASE}/bin:${PATH} 106MAKE_ENV+= CC="${CC}" CXX="${CXX}" \ 107 C_INCLUDE_PATH=${LOCALBASE}/include \ 108 CPLUS_INCLUDE_PATH=${LOCALBASE}/include \ 109 ${CONFIGURE_ENV} 110# Avoid running multiple make(1) jobs, but only those. Otherwise the build 111# fails intermittently due race conditions if multiple ninja instances are 112# running at the same time (mostly for the targets "WebEngineCore" and 113# "convert_dict"). 114# 115# MAKE_JOBS_UNSAFE is too invasive because it also affects the number of jobs 116# for ninja(1) and would slow everything down which we don't want. We pass the 117# real number of make jobs via MAKE_JOBS_NUMBER to ninja(1) to CONFIGURE_ENV. 118DO_MAKE_BUILD= ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} -j1 ${MAKE_ARGS:N${DESTDIRNAME}=*} 119 120BINARY_ALIAS= python3=${PYTHON_CMD} 121 122.if !defined(BUILD_QTPDF) 123OPTIONS_DEFINE= DRIVER PIPEWIRE 124OPTIONS_DEFAULT= ALSA DRIVER PIPEWIRE 125OPTIONS_SINGLE= AUDIO 126OPTIONS_SINGLE_AUDIO= ALSA PULSEAUDIO SNDIO 127OPTIONS_SUB= yes 128 129AUDIO_DESC= Audio backend 130 131# Need the alsa plugins to get sound at runtime, otherwise messages 132# that the pcm_oss plugin can't be opened. 133ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib 134ALSA_RUN_DEPENDS= alsa-plugins>=0:audio/alsa-plugins 135ALSA_CMAKE_ON= -DQT_FEATURE_webengine_system_alsa:BOOL=ON 136ALSA_CMAKE_OFF= -DQT_FEATURE_webengine_system_alsa:BOOL=OFF 137 138DRIVER_DESC= Install WebEngineDriver 139DRIVER_CMAKE_ON= -DQT_FEATURE_webenginedriver:BOOL=ON 140DRIVER_CMAKE_OFF= -DQT_FEATURE_webenginedriver:BOOL=OFF 141 142PIPEWIRE_LIB_DEPENDS= libpipewire-0.3.so:multimedia/pipewire 143PIPEWIRE_CMAKE_ON= -DQT_FEATURE_webengine_webrtc_pipewire:BOOL=ON 144PIPEWIRE_CMAKE_OFF= -DQT_FEATURE_webengine_webrtc_pipewire:BOOL=OFF 145 146PULSEAUDIO_LIB_DEPENDS= libpulse.so:audio/pulseaudio 147PULSEAUDIO_CMAKE_ON= -DQT_FEATURE_webengine_system_pulseaudio:BOOL=ON 148PULSEAUDIO_CMAKE_OFF= -DQT_FEATURE_webengine_system_pulseaudio:BOOL=OFF 149 150SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio 151SNDIO_CMAKE_ON= -DQT_FEATURE_webengine_system_sndio:BOOL=ON 152SNDIO_CMAKE_OFF= -DQT_FEATURE_webengine_system_sndio:BOOL=OFF 153.endif 154 155.include <bsd.mport.options.mk> 156 157.if !defined(BUILD_QTPDF) 158. if ${ARCH:Mi386} 159USES+= nodejs:build,20 160. else 161USES+= nodejs:build,lts 162. endif 163.endif 164 165post-extract: 166 @${MKDIR} ${WRKSRC}/src/3rdparty/chromium/media/audio/sndio \ 167 ${WRKSRC}/src/3rdparty/chromium/sandbox/policy/freebsd \ 168 ${WRKSRC}/src/3rdparty/chromium/sandbox/policy/openbsd 169 (cd ${WRKSRC}/src/3rdparty/chromium/third_party/libdrm/src/include && ${CP} drm/drm.h .) 170 171post-patch: 172 @${REINPLACE_CMD} -e 's|%%CPPFLAGS%%|${CPPFLAGS}|;s|%%CXXFLAGS%%|${CXXFLAGS}|;s|%%LDFLAGS%%|${LDFLAGS}|' \ 173 ${WRKSRC}/src/host/BUILD.toolchain.gn.in 174 @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' \ 175 ${WRKSRC}/src/3rdparty/chromium/third_party/pdfium/core/fxge/linux/fx_linux_impl.cpp \ 176 ${WRKSRC}/src/3rdparty/chromium/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc 177 178pre-configure: 179# We used to remove bundled libraries to be sure that webengine uses 180# system libraries and not shipped ones. 181# 182# Leads to missing header errors: icu, libvpx, libwebp, re2, snappy, zlib 183# No-Op: flac 184# 185# Don't attempt to unbundle libraries that the Pdf module doesn't use. It 186# causes configuration errors. 187# 188# cd ${WRKSRC} && ${PYTHON_CMD} \ 189# ./build/linux/unbundle/remove_bundled_libraries.py [list of preserved] 190 cd ${WRKSRC}/src/3rdparty/chromium && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} \ 191 ./build/linux/unbundle/replace_gn_files.py --system-libraries \ 192 ${SYS_LIBS} || ${FALSE} 193 194.if !defined(BUILD_QTPDF) 195post-install: 196# Fix for deskutils/calibre, perhaps others, where this empty directory 197# is created during build causing a fs-violation. 198 ${MKDIR} ${FAKE_DESTDIR}${QT_DATADIR}/resources/locales 199 200post-install-DRIVER-on: 201 ${STRIP_CMD} ${FAKE_DESTDIR}${QT_TOOLDIR}/webenginedriver 202 203.endif 204 205.include <bsd.port.mk> 206