commit:     9c908753edf4523644b47779bc3d9894d247e69c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 15 22:15:10 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 15 22:17:33 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9c908753

sys-devel/bpf-toolchain: add USE=bin-symlinks

Note that unlike dev-util/mingw64-toolchain, we're enabling it by default
because it'll be pretty uncommon for anyone to have a crossdev-built
toolchain for it. This is needed to avoid conflicts if someone wants
to build a bpf-unknown-none toolchain via crossdev where an ebuild
depends on bpf-toolchain (wouldn't be possible before because of file
conflicts).

Also, with it off by default, we would have to add some hacks in e.g.
the systemd ebuild to make it work by mangling PATH and things get
tricky there especially given only a small part of the build would even use it.

May change mind on this later if needed though.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...n-14.2.0.ebuild => bpf-toolchain-14.2.0-r1.ebuild} | 19 ++++++++++++++++---
 sys-devel/bpf-toolchain/metadata.xml                  |  7 +++++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0.ebuild 
b/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r1.ebuild
similarity index 92%
rename from sys-devel/bpf-toolchain/bpf-toolchain-14.2.0.ebuild
rename to sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r1.ebuild
index aba05ad111a3..0c5a58f41988 100644
--- a/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0.ebuild
+++ b/sys-devel/bpf-toolchain/bpf-toolchain-14.2.0-r1.ebuild
@@ -41,8 +41,8 @@ LICENSE="
 "
 SLOT="0"
 KEYWORDS="-* ~amd64"
-# TODO: USE=strip, USE=bin-symlinks from dev-util/mingw64-toolchain
-IUSE="custom-cflags"
+# TODO: USE=strip from dev-util/mingw64-toolchain?
+IUSE="+bin-symlinks custom-cflags"
 
 RDEPEND="
        dev-libs/gmp:=
@@ -50,6 +50,10 @@ RDEPEND="
        dev-libs/mpfr:=
        sys-libs/zlib:=
        virtual/libiconv
+       bin-symlinks? (
+               !cross-bpf-unknown-none/binutils
+               !cross-bpf-unknown-none/gcc
+       )
 "
 DEPEND="${RDEPEND}"
 
@@ -81,7 +85,8 @@ src_compile() {
        CTARGET=bpf-unknown-none
 
        BPFT_D=${T}/root # moved to ${D} in src_install
-       local prefix=${EPREFIX}/usr
+       local bpftdir=/usr/lib/${PN}
+       local prefix=${EPREFIX}${bpftdir}
        local sysroot=${BPFT_D}${prefix}
        local -x PATH=${sysroot}/bin:${PATH}
 
@@ -177,6 +182,14 @@ src_compile() {
        bpft-build binutils
        bpft-build gcc
 
+       if use bin-symlinks; then
+               mkdir -p -- "${BPFT_D}${EPREFIX}"/usr/bin/ || die
+               local bin
+               for bin in "${sysroot}"/bin/*; do
+                       ln -rs -- "${bin}" "${BPFT_D}${EPREFIX}"/usr/bin/ || die
+               done
+       fi
+
        # Delete libdep.a, which has a colliding name and is useless for bpf,
        # which does not make use of cross-library dependencies: the libdep.a
        # for the native binutils will do.

diff --git a/sys-devel/bpf-toolchain/metadata.xml 
b/sys-devel/bpf-toolchain/metadata.xml
index 12065082990f..34b44dd721cd 100644
--- a/sys-devel/bpf-toolchain/metadata.xml
+++ b/sys-devel/bpf-toolchain/metadata.xml
@@ -5,6 +5,13 @@
                <email>toolch...@gentoo.org</email>
                <name>Gentoo Toolchain Project</name>
        </maintainer>
+       <use>
+               <flag name="bin-symlinks">
+                       Symlink executables to usr/bin to be in default
+                       PATH (conflicts with crossdev bpf, and crossdev
+                       is preferable for a fully featured toolchain)
+               </flag>
+       </use>
        <upstream>
                <remote-id type="cpe">cpe:/a:gnu:gcc</remote-id>
                <remote-id type="cpe">cpe:/a:gnu:binutils</remote-id>

Reply via email to