git: 33b9f9f8c931 - main - x11-wm/hyprland: drop GCC dependency via bundled libc++

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Tue, 31 Jan 2023 00:57:30 UTC
The branch main has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=33b9f9f8c931bd07f5f963b606ff3ca4bf425124

commit 33b9f9f8c931bd07f5f963b606ff3ca4bf425124
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2023-01-30 21:28:56 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-01-31 00:56:46 +0000

    x11-wm/hyprland: drop GCC dependency via bundled libc++
    
    libc++ 15 needs a workaround but libc++ < 14 is C++23-hopeless.
---
 x11-wm/hyprland/Makefile | 35 ++++++++++++++++++++++++++++++++---
 x11-wm/hyprland/distinfo |  4 ++++
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/x11-wm/hyprland/Makefile b/x11-wm/hyprland/Makefile
index 83073cac7f2e..dbdda4dfebad 100644
--- a/x11-wm/hyprland/Makefile
+++ b/x11-wm/hyprland/Makefile
@@ -1,11 +1,12 @@
 PORTNAME=	hyprland
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.21.0beta
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	x11-wm wayland
 
 PATCH_SITES=	https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
 PATCHFILES+=	c3adc9ec5602.patch:-p1 # https://github.com/hyprwm/Hyprland/pull/1448
+PATCHFILES+=	f90ff8303b4f.patch:-p1 # https://github.com/hyprwm/Hyprland/pull/1457
 
 MAINTAINER=	jbeich@FreeBSD.org
 COMMENT=	Dynamic tiling Wayland compositor that doesn't sacrifice on its looks #'
@@ -23,7 +24,6 @@ LIB_DEPENDS=	libwayland-server.so:graphics/wayland \
 		libxkbcommon.so:x11/libxkbcommon
 
 USES=		compiler:c++11-lib gl gnome meson pkgconfig xorg
-USE_GCC=	yes:build
 USE_GITHUB=	yes
 USE_GL=		egl opengl
 USE_GNOME=	cairo
@@ -31,7 +31,6 @@ USE_XORG=	pixman
 GH_ACCOUNT=	hyprwm
 GH_PROJECT=	Hyprland
 GH_TUPLE=	hyprwm:hyprland-protocols:301733a:hyprland_protocols/subprojects/hyprland-protocols
-LDFLAGS+=	-static-libstdc++ -static-libgcc # avoid libc++ conflict
 
 OPTIONS_DEFINE=	X11
 OPTIONS_DEFAULT=X11
@@ -58,4 +57,34 @@ post-install:
 	@${RM} -r ${STAGEDIR}${PREFIX}/share/protocols
 .endif
 
+# XXX Drop after FreeBSD 13.2 EOL around 2024-05-01 (don't forget distinfo)
+.if !exists(/usr/include/c++/v1/__ranges/as_rvalue_view.h) || make(makesum) || make(fetch)
+. if exists(/usr/include/c++/v1/__algorithm/ranges_all_of.h) && !make(makesum) && !make(fetch)
+CXXFLAGS+=	-fexperimental-library # std::ranges::all_of
+. else
+BUILD_DEPENDS+=	${CMAKE_BIN}:devel/cmake-core
+USES+=		llvm:min=14,build
+CC=		clang${LLVM_VERSION}
+CXX=		clang++${LLVM_VERSION}
+CPP=		clang-cpp${LLVM_VERSION}
+CONFIGURE_ENV+=	CC="${CC}" CXX="${CXX}" CPP="${CPP}"
+CMAKE_BIN=	${LOCALBASE}/bin/cmake
+CMAKE_ARGS+=	-GNinja
+
+# XXX Move into separate port and standardize via USES
+GH_TUPLE+=	llvm:llvm-project:llvmorg-16.0.0-rc1:libcxx
+CXXFLAGS+=	-nostdinc++ -isystem${WRKDIR}/libcxx_prefix/include/c++/v1
+# Don't link against new libc++ as it's not necessary
+#LDFLAGS+=	-nostdlib++ -L${WRKDIR}/libcxx_prefix/lib -l:libc++.a -lcxxrt
+
+pre-configure:	bundled-libcxx
+bundled-libcxx:
+	@${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS:M*Ninja*} \
+		-DLIBCXX_INCLUDE_BENCHMARKS:BOOL=OFF \
+		-DCMAKE_INSTALL_PREFIX:PATH=${WRKDIR}/libcxx_prefix \
+		-B ${WRKDIR}/libcxx_build -S ${WRKSRC_libcxx}/libcxx
+	@${DO_MAKE_BUILD:NDESTDIR*} install -C ${WRKDIR}/libcxx_build
+. endif
+.endif
+
 .include <bsd.port.mk>
diff --git a/x11-wm/hyprland/distinfo b/x11-wm/hyprland/distinfo
index 9914c517e0b3..4a64c3189146 100644
--- a/x11-wm/hyprland/distinfo
+++ b/x11-wm/hyprland/distinfo
@@ -3,5 +3,9 @@ SHA256 (hyprwm-Hyprland-v0.21.0beta_GH0.tar.gz) = 7fb3ba09011c991fcdfbba825cc69a
 SIZE (hyprwm-Hyprland-v0.21.0beta_GH0.tar.gz) = 714570
 SHA256 (hyprwm-hyprland-protocols-301733a_GH0.tar.gz) = 3b3b4e948525f1d823313390b2551ea8969d0cbf82bd72e2a4a2ce2750552330
 SIZE (hyprwm-hyprland-protocols-301733a_GH0.tar.gz) = 4852
+SHA256 (llvm-llvm-project-llvmorg-16.0.0-rc1_GH0.tar.gz) = e1b8d991921c8e9564359b17955878716dc68201ded4699c6b175b14fe3085aa
+SIZE (llvm-llvm-project-llvmorg-16.0.0-rc1_GH0.tar.gz) = 180127224
 SHA256 (c3adc9ec5602.patch) = 71e502ca9b18a7e3b29d19ff72493dc511b2b8937ca032db085a273fdd6a8d26
 SIZE (c3adc9ec5602.patch) = 1759
+SHA256 (f90ff8303b4f.patch) = 6b0b3664b44d804bc0a4c686cb44ba0b3fb5612d3f075e3a030a1ed81e34a56a
+SIZE (f90ff8303b4f.patch) = 8448