commit:     063b3e0e3d31acd88f453831f71d74d976d66359
Author:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 28 15:42:23 2022 +0000
Commit:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
CommitDate: Mon Oct  3 13:27:11 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=063b3e0e

www-client/firefox: enable wayland+pgo build on rapid

 - virtwl() function copied from
   https://cgit.alxu.ca/gentoo-overlay.git/tree/eclass/virtualwl.eclass

Closes: https://bugs.gentoo.org/848858
Closes: https://bugs.gentoo.org/767997
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/27512

 www-client/firefox/firefox-105.0.1.ebuild | 39 ++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/www-client/firefox/firefox-105.0.1.ebuild 
b/www-client/firefox/firefox-105.0.1.ebuild
index a44bccfac2a9..1b8da3f2d869 100644
--- a/www-client/firefox/firefox-105.0.1.ebuild
+++ b/www-client/firefox/firefox-105.0.1.ebuild
@@ -76,7 +76,6 @@ REQUIRED_USE="debug? ( !system-av1 )
 
 # Firefox-only REQUIRED_USE flags
 REQUIRED_USE+=" || ( X wayland )"
-REQUIRED_USE+=" pgo? ( X )"
 REQUIRED_USE+=" screencast? ( wayland )"
 
 FF_ONLY_DEPEND="!www-client/firefox:0
@@ -109,7 +108,10 @@ BDEPEND="${PYTHON_DEPS}
                )
        )
        amd64? ( >=dev-lang/nasm-2.14 )
-       x86? ( >=dev-lang/nasm-2.14 )"
+       x86? ( >=dev-lang/nasm-2.14 )
+       pgo? (
+               wayland? ( >=gui-libs/wlroots-0.15.1-r1[tinywl] )
+       )"
 COMMON_DEPEND="${FF_ONLY_DEPEND}
        dev-libs/atk
        dev-libs/expat
@@ -408,6 +410,27 @@ mozconfig_use_with() {
        mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" 
"${flag}"
 }
 
+virtwl() {
+       debug-print-function ${FUNCNAME} "$@"
+
+       [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument"
+       [[ -n $XDG_RUNTIME_DIR ]] || die "${FUNCNAME} needs XDG_RUNTIME_DIR to 
be set; try xdg_environment_reset"
+       tinywl -h >/dev/null || die 'tinywl -h failed'
+
+       # TODO: don't run addpredict in utility function. WLR_RENDERER=pixman 
doesn't work
+       addpredict /dev/dri
+       local VIRTWL VIRTWL_PID
+       coproc VIRTWL { WLR_BACKENDS=headless exec tinywl -s 'echo 
$WAYLAND_DISPLAY; read _; kill $PPID'; }
+       local -x WAYLAND_DISPLAY
+       read WAYLAND_DISPLAY <&${VIRTWL[0]}
+
+       debug-print "${FUNCNAME}: $@"
+       "$@"
+
+       [[ -n $VIRTWL_PID ]] || die "tinywl exited unexpectedly"
+       exec {VIRTWL[0]}<&- {VIRTWL[1]}>&-
+}
+
 pkg_pretend() {
        if [[ ${MERGE_TYPE} != binary ]] ; then
                if use pgo ; then
@@ -1011,16 +1034,20 @@ src_configure() {
 src_compile() {
        local virtx_cmd=
 
-       if use pgo ; then
-               virtx_cmd=virtx
-
+       if use pgo; then
                # Reset and cleanup environment variables used by GNOME/XDG
                gnome2_environment_reset
 
                addpredict /root
+
+               if ! use X; then
+                       virtx_cmd=virtwl
+               else
+                       virtx_cmd=virtx
+               fi
        fi
 
-       if ! use X && use wayland; then
+       if ! use X; then
                local -x GDK_BACKEND=wayland
        else
                local -x GDK_BACKEND=x11

Reply via email to