commit:     b0dfc07d460383e694939048199ea032b7a2d31e
Author:     Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail <DOT> com>
AuthorDate: Mon Apr 29 14:31:00 2024 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May  8 20:42:50 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b0dfc07d

media-libs/mesa: Add VIDEO_CARDS=nvk

* Add VIDEO_CARDS=nvk to build the Vulkan driver for NVIDIA GPUs
* Add all Rust submodules required by NVK
* Fix rust submodules not compiling on multilib system (see
* https://gitlab.freedesktop.org/mesa/mesa/-/issues/10490)

* Limit meson to < 1.4.0, to avoid a regression building Rust submodules
* Mesa bug report: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10855
* Meson bug report: https://github.com/mesonbuild/meson/issues/12973

* Notes: since nouveau is also required make sure VIDEO_CARDS=nouveau is
  also set.

Closes: https://github.com/gentoo/gentoo/pull/35658
Signed-off-by: Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail.com>
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 media-libs/mesa/Manifest         |  5 +++
 media-libs/mesa/mesa-9999.ebuild | 74 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/media-libs/mesa/Manifest b/media-libs/mesa/Manifest
index 7ae411f2b90d..47794ae1af38 100644
--- a/media-libs/mesa/Manifest
+++ b/media-libs/mesa/Manifest
@@ -2,3 +2,8 @@ DIST mesa-24.0.4.tar.xz 20057744 BLAKE2B 
6de755081f7e9dd9303af791e1a405203388787
 DIST mesa-24.0.5.tar.xz 20096384 BLAKE2B 
c4c5f493206f761a7171f19c6549dc791559a1fdbcf49aea98016f98c10f9130081a16df6b780062621495a42dc49ef5f0800bda64058e8ba60106f6a046ccef
 SHA512 
9476af4b9ac8db5dce397084ef169927d10b28adea7e74aa5b3136810b499ac98ddf7ab564e7d1ff81c887208c8ebab3ad2d4e27e7f46136609b5c67527018eb
 DIST mesa-24.0.6.tar.xz 20115628 BLAKE2B 
531482c1a01ec4c0bd6b2f0857640c14fcc2ba70e85a14e4edf0f44ba466c12e39ad067690e6a571a0744ae06080943b1328a29263225cb7570f119464e17fbe
 SHA512 
60fcc77132c3cb0c98e650d97d3324bfd18abe7f8f8a3aa5209f71b2fddd94510f939bbf5272b2241749307184d5badde9da4842be57ce13f5760875885ea6fc
 DIST mesa-24.1.0-rc1.tar.xz 28863968 BLAKE2B 
6d1b72395c208fcc82838f42b79455ebde3474a5e0362f6ee0ca52031c5ea15e1419bd4c9768649eecdeea51806e3dd7584fc70941b36efc23eb39a1716ac425
 SHA512 
575252e76e9fd0266ca9cdb0acb8b12f2890dcecca904ff46b81d439d70520d58f719c90806a4a72d553fca4214cfa3333e1271a8831a1e6a68ca257affc84e3
+DIST paste-1.0.14.tar.gz 18429 BLAKE2B 
88f533fd336bbbe24872b100777703832ff46b52970b94981fea202726de35ac0d3466f96370fa89c966b33e0f13c75cbf7f5f88bba290dc490a63c9e08a0b16
 SHA512 
0ec40c228afe645cb027a99c8bd8f7c65158aab48655018a45736727906b05f7354df114405f2eae88c4eba73dec62e8228f8be9834afa0f22b5f31c18006d34
+DIST proc-macro2-1.0.70.tar.gz 46747 BLAKE2B 
808e3a30c89fd979663899124853d386cc53862621f4d872bba87fe91baccddbc6612bd658b4c18b44f8420fcb10700b2906cde9c9512a616ab800ebbfb0867d
 SHA512 
cd5c41ef6a410e310e90828a33fee42c1e2bf30dfc2b0a0cf429fcc60fa1262393c977b2cab5f8a50a35fd1394fd6cc7e7a482581f88dcde20d9ad030c7414a5
+DIST quote-1.0.33.tar.gz 32169 BLAKE2B 
2438915aebe30b79929ddc6ed8bad5282537b081c763a3d6b2b9483b63e7b5e99b9bba6f1f7deb725031b23384410b60c7cc4aef0b00bb1d94541cde54408ee3
 SHA512 
3c000577d0e9f82bc379570a4fa63283d73cfc6dee0475475ba201994491dece0110cdefc26fcf9a3b9d0bf50a3649ca5b68c8a0f6f2e620946b624ff8b8f38b
+DIST syn-2.0.39.tar.gz 286899 BLAKE2B 
8bf5e89cb961195b48896294dc876d4e5e81fe7ac1df5330b972e6fdcfa2cf89fd1467f315081f84c1f447d402850e0ab4c7dc2bd20271c5e2bc9a2e3008f70b
 SHA512 
2ee6bb196bef427a9b9aada38fb3a3a11e893c4e9e8808063f544f5c05cda58d554dfea24488dd60b4c299457852b52bf17e5de8595333ff4f2358441964c672
+DIST unicode-ident-1.0.12.tar.gz 50118 BLAKE2B 
04e2651e14251d68f4e7e70e1e7a6d5eded21aa4f684c6162a91608189f6dcabaca4aa22204c40e08c82d76773c679ff965f21836264885a3b4cb62d7aa762db
 SHA512 
0d0228bfd8eb6a94d8ae4a003511dd5ad52a58b08d98a8f0a8c5e3dc8b3e6b987ea5009255dc1e9c411f91aec16edc4aaff26ed7a9c48430272f970cd2a9510d

diff --git a/media-libs/mesa/mesa-9999.ebuild b/media-libs/mesa/mesa-9999.ebuild
index a25510a044f3..f9c4e1acfcbb 100644
--- a/media-libs/mesa/mesa-9999.ebuild
+++ b/media-libs/mesa/mesa-9999.ebuild
@@ -7,18 +7,36 @@ LLVM_COMPAT=( {15..17} )
 LLVM_OPTIONAL=1
 PYTHON_COMPAT=( python3_{10..12} )
 
-inherit llvm-r1 meson-multilib python-any-r1 linux-info
+inherit llvm-r1 meson-multilib python-any-r1 linux-info rust-toolchain
 
 MY_P="${P/_/-}"
 
+SYN_PV=2.0.39
+PROC_MACRO2_PV=1.0.70
+QUOTE_PV=1.0.33
+UNICODE_IDENT_PV=1.0.12
+PASTE_PV=1.0.14
+
+NAK_URI="
+       https://github.com/dtolnay/syn/archive/refs/tags/${SYN_PV}.tar.gz -> 
syn-${SYN_PV}.tar.gz
+       
https://github.com/dtolnay/proc-macro2/archive/refs/tags/${PROC_MACRO2_PV}.tar.gz
 -> proc-macro2-${PROC_MACRO2_PV}.tar.gz
+       https://github.com/dtolnay/quote/archive/refs/tags/${QUOTE_PV}.tar.gz 
-> quote-${QUOTE_PV}.tar.gz
+       
https://github.com/dtolnay/unicode-ident/archive/refs/tags/${UNICODE_IDENT_PV}.tar.gz
 -> unicode-ident-${UNICODE_IDENT_PV}.tar.gz
+       https://github.com/dtolnay/paste/archive/refs/tags/${PASTE_PV}.tar.gz 
-> paste-${PASTE_PV}.tar.gz
+"
+
 DESCRIPTION="OpenGL-like graphic library for Linux"
 HOMEPAGE="https://www.mesa3d.org/ https://mesa.freedesktop.org/";
 
 if [[ ${PV} == 9999 ]]; then
        EGIT_REPO_URI="https://gitlab.freedesktop.org/mesa/mesa.git";
+       SRC_URI="${NAK_URI}"
        inherit git-r3
 else
-       SRC_URI="https://archive.mesa3d.org/${MY_P}.tar.xz";
+       SRC_URI="
+               https://archive.mesa3d.org/${MY_P}.tar.xz
+               ${NAK_URI}
+       "
        KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc 
~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-solaris"
 fi
 S="${WORKDIR}/${MY_P}"
@@ -28,7 +46,7 @@ LICENSE="MIT SGI-B-2.0"
 SLOT="0"
 
 RADEON_CARDS="r300 r600 radeon radeonsi"
-VIDEO_CARDS="${RADEON_CARDS} d3d12 freedreno intel lavapipe lima nouveau 
panfrost v3d vc4 virgl vivante vmware"
+VIDEO_CARDS="${RADEON_CARDS} d3d12 freedreno intel lavapipe lima nouveau nvk 
panfrost v3d vc4 virgl vivante vmware"
 for card in ${VIDEO_CARDS}; do
        IUSE_VIDEO_CARDS+=" video_cards_${card}"
 done
@@ -55,6 +73,7 @@ REQUIRED_USE="
        video_cards_lavapipe? ( llvm vulkan )
        video_cards_radeon? ( x86? ( llvm ) amd64? ( llvm ) )
        video_cards_r300?   ( x86? ( llvm ) amd64? ( llvm ) )
+       video_cards_nvk? ( vulkan video_cards_nouveau )
        vdpau? ( X )
        xa? ( X )
        zink? ( opengl vulkan )
@@ -126,6 +145,8 @@ DEPEND="${RDEPEND}
                x11-base/xorg-proto
        )
 "
+# meson-1.4.0 contains a regression, so it fails to compile nouveau/NVK
+# see https://gitlab.freedesktop.org/mesa/mesa/-/issues/10855
 BDEPEND="
        ${PYTHON_DEPS}
        opencl? (
@@ -142,7 +163,15 @@ BDEPEND="
                dev-libs/libclc[spirv(-)]
                $(python_gen_any_dep "dev-python/ply[\${PYTHON_USEDEP}]")
        )
-       vulkan? ( dev-util/glslang )
+       vulkan? (
+               dev-util/glslang
+               video_cards_nvk? (
+                       >=dev-util/bindgen-0.68.1
+                       >=dev-util/cbindgen-0.26.0
+                       >=virtual/rust-1.74.1
+                       <dev-build/meson-1.4.0
+               )
+       )
        wayland? ( dev-util/wayland-scanner )
 "
 
@@ -153,14 +182,20 @@ x86? (
        usr/lib/libGLX_mesa.so.0.0.0
 )"
 
+src_unpack() {
+       [[ ${PV} == 9999 ]] && git-r3_src_unpack
+       unpack ${A}
+}
+
 pkg_pretend() {
        if use vulkan; then
                if ! use video_cards_d3d12 &&
                   ! use video_cards_freedreno &&
                   ! use video_cards_intel &&
                   ! use video_cards_radeonsi &&
-                  ! use video_cards_v3d; then
-                       ewarn "Ignoring USE=vulkan     since VIDEO_CARDS does 
not contain d3d12, freedreno, intel, radeonsi, or v3d"
+                  ! use video_cards_v3d &&
+                  ! use video_cards_nvk; then
+                       ewarn "Ignoring USE=vulkan     since VIDEO_CARDS does 
not contain d3d12, freedreno, intel, radeonsi, v3d, or nvk"
                fi
        fi
 
@@ -236,6 +271,20 @@ src_prepare() {
        default
        sed -i -e "/^PLATFORM_SYMBOLS/a '__gentoo_check_ldflags__'," \
                bin/symbols-check.py || die # bug #830728
+
+       if use video_cards_nvk; then
+               # NVK Subproject Handling
+               pushd "${S}" >/dev/null || die
+               for subpkg in proc-macro2-${PROC_MACRO2_PV} syn-${SYN_PV} 
quote-${QUOTE_PV} unicode-ident-${UNICODE_IDENT_PV} paste-${PASTE_PV}; do
+                       # copy subprojects folder
+                       cp -r ../${subpkg} subprojects || die
+                       # copy meson.build
+                       cp subprojects/packagefiles/${subpkg%-*}/meson.build 
subprojects/${subpkg} || die
+                       # ovewrite subpkg version when needed
+                       sed -i -e "s/directory = \S\+/directory = ${subpkg}/" 
subprojects/${subpkg%-*}.wrap || die
+               done
+               popd >/dev/null || die
+       fi
 }
 
 multilib_src_configure() {
@@ -336,6 +385,15 @@ multilib_src_configure() {
                vulkan_enable video_cards_d3d12 microsoft-experimental
                vulkan_enable video_cards_radeonsi amd
                vulkan_enable video_cards_v3d broadcom
+               if use video_cards_nvk; then
+                       vulkan_enable video_cards_nvk nouveau
+                       if ! multilib_is_native_abi; then
+                               echo -e "[binaries]\nrust = ['rustc', 
'--target=$(rust_abi $CBUILD)']" > "${T}/rust_fix.ini"
+                               emesonargs+=(
+                                       --native-file "${T}"/rust_fix.ini
+                               )
+                       fi
+               fi
        fi
 
        driver_list() {
@@ -383,6 +441,10 @@ multilib_src_configure() {
                -Db_ndebug=$(usex debug false true)
        )
        meson_src_configure
+
+       if ! multilib_is_native_abi && use video_cards_nvk; then
+               sed -i -E '{N; s/(rule rust_COMPILER_FOR_BUILD\n command = 
rustc) --target=[a-zA-Z0-9=:-]+ (.*) -C link-arg=-m[[:digit:]]+/\1 \2/g}' 
build.ninja || die
+       fi
 }
 
 multilib_src_test() {

Reply via email to