git: 01b1ed56de8d - main - audio/audacity: Fix build in 12 and 13

From: Fernando Apesteguía <fernape_at_FreeBSD.org>
Date: Fri, 24 Nov 2023 08:13:39 UTC
The branch main has been updated by fernape:

URL: https://cgit.FreeBSD.org/ports/commit/?id=01b1ed56de8dcd0622782b07ef6c4658e47ef071

commit 01b1ed56de8dcd0622782b07ef6c4658e47ef071
Author:     Tatsuki Makino <tatsuki_makino@hotmail.com>
AuthorDate: 2023-11-23 10:02:04 +0000
Commit:     Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2023-11-24 08:13:29 +0000

    audio/audacity: Fix build in 12 and 13
    
    Conditional workaround for the problem with old libc++ and the buggy
    implementation of std::conjunction
    
    Patch by tatsuki_makino@hotmail.com
    
    PR:             275192
---
 audio/audacity/Makefile                            | 10 ++++--
 .../files/extra-libraries_lib-utility_TypeList.cpp | 23 +++++++++++++
 .../files/extra-libraries_lib-utility_TypeList.h   | 39 ++++++++++++++++++++++
 .../files/extra-libraries_lib-utility_TypeSwitch.h | 20 +++++++++++
 4 files changed, 89 insertions(+), 3 deletions(-)

diff --git a/audio/audacity/Makefile b/audio/audacity/Makefile
index fd6239d386d4..5d441d67db12 100644
--- a/audio/audacity/Makefile
+++ b/audio/audacity/Makefile
@@ -8,9 +8,6 @@ MAINTAINER=	xxjack12xx@gmail.com
 COMMENT=	GUI editor for digital audio waveforms
 WWW=		https://www.audacityteam.org/
 
-BROKEN_FreeBSD_13=	compiler bug
-BROKEN_FreeBSD_12=	compiler bug
-
 LICENSE=	GPLv2+
 LICENSE_FILE=	${WRKSRC}/LICENSE.txt
 
@@ -153,6 +150,13 @@ CMAKE_ARGS+=	-DHAVE_MMX:BOOL=OFF \
 		-DHAVE_SSE2:BOOL=OFF
 .endif
 
+.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1302508
+# Workarounds for buggy libc++ std::conjunction
+EXTRA_PATCHES=	${PATCHDIR}/extra-libraries_lib-utility_TypeList.cpp \
+		${PATCHDIR}/extra-libraries_lib-utility_TypeList.h \
+		${PATCHDIR}/extra-libraries_lib-utility_TypeSwitch.h
+.endif
+
 post-install:
 	@${RM} ${STAGEDIR}${DOCSDIR}/LICENSE.txt
 	#delete empty directories: https://github.com/audacity/audacity/issues/808
diff --git a/audio/audacity/files/extra-libraries_lib-utility_TypeList.cpp b/audio/audacity/files/extra-libraries_lib-utility_TypeList.cpp
new file mode 100644
index 000000000000..2575d8f5f745
--- /dev/null
+++ b/audio/audacity/files/extra-libraries_lib-utility_TypeList.cpp
@@ -0,0 +1,23 @@
+--- libraries/lib-utility/TypeList.cpp.orig	2023-11-16 11:58:21 UTC
++++ libraries/lib-utility/TypeList.cpp
+@@ -118,16 +118,16 @@ static_assert(Is_v<NullOrStartsWithInt, Nil>);
+ static_assert(Is_v<NullOrStartsWithInt, Example>);
+ 
+ static_assert(Every_v<Fn<is_arithmetic>, Example>);
+-static_assert(is_base_of_v<true_type, Every<Fn<is_arithmetic>, Example>>);
++static_assert(TypeList::is_base_of_v<true_type, Every<Fn<is_arithmetic>, Example>>);
+ static_assert(!Every_v<Fn<is_integral>, Example>);
+-static_assert(is_base_of_v<is_integral<double>,
++static_assert(TypeList::is_base_of_v<is_integral<double>,
+    Every<Fn<is_integral>, Example>>);
+ 
+ static_assert(Some_v<Fn<is_integral>, Example>);
+-static_assert(is_base_of_v<is_integral<int>,
++static_assert(TypeList::is_base_of_v<is_integral<int>,
+    Some<Fn<is_integral>, Example>>);
+ static_assert(!Some_v<Fn<is_void>, Example>);
+-static_assert(is_base_of_v<false_type, Some<Fn<is_void>, Example>>);
++static_assert(TypeList::is_base_of_v<false_type, Some<Fn<is_void>, Example>>);
+ 
+ static_assert(NotEvery_v<Fn<is_floating_point>, Example>);
+ static_assert(NotAny_v<Fn<is_void>, Example>);
diff --git a/audio/audacity/files/extra-libraries_lib-utility_TypeList.h b/audio/audacity/files/extra-libraries_lib-utility_TypeList.h
new file mode 100644
index 000000000000..dfc77dc2be3d
--- /dev/null
+++ b/audio/audacity/files/extra-libraries_lib-utility_TypeList.h
@@ -0,0 +1,39 @@
+--- libraries/lib-utility/TypeList.h.orig	2023-11-16 11:58:21 UTC
++++ libraries/lib-utility/TypeList.h
+@@ -54,6 +54,18 @@ namespace TypeList {
+  can make compound predicates out of simpler ones.
+   */
+ 
++template <class...>
++struct conjunction : std::true_type {};
++
++template <class _Arg>
++struct conjunction<_Arg> : _Arg {};
++
++template <class _Arg, class... _Args>
++struct conjunction<_Arg, _Args...> : std::conditional_t<!bool(_Arg::value), _Arg, conjunction<_Args...>> {};
++
++template <class _Bp, class _Dp>
++inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp);
++
+ //! standard in C++20; add a level of indirection to a type
+ template<typename T> struct type_identity { using type = T; };
+ 
+@@ -429,7 +441,7 @@ struct And<Predicate, Predicates...> { (private)
+       static constexpr bool value = Is_v<And<Predicates...>, T>;
+    };
+ public:
+-   template<typename T> using typemap = typename std::conjunction<
++   template<typename T> using typemap = typename TypeList::conjunction<
+       typename Predicate::template typemap<T>, Rest<T>
+    >;
+ };
+@@ -437,7 +449,7 @@ struct And<Predicate, Predicates...> { (private)
+ //! Derived from the Predicate, applied to the first of the types (often boolean
+ //! constant types), for which the value is false; or std::true_type
+ template<typename Predicate, typename TypeList> struct Every
+-   : Apply_t<std::conjunction, Map_t<Predicate, TypeList>> {};
++   : Apply_t<conjunction, Map_t<Predicate, TypeList>> {};
+ //! The constant value in the corresponding type
+ template<typename Predicate, typename TypeList> constexpr auto Every_v =
+    Every<Predicate, TypeList>::value;
diff --git a/audio/audacity/files/extra-libraries_lib-utility_TypeSwitch.h b/audio/audacity/files/extra-libraries_lib-utility_TypeSwitch.h
new file mode 100644
index 000000000000..f0291a0356a8
--- /dev/null
+++ b/audio/audacity/files/extra-libraries_lib-utility_TypeSwitch.h
@@ -0,0 +1,20 @@
+--- libraries/lib-utility/TypeSwitch.h.orig	2023-11-16 11:58:21 UTC
++++ libraries/lib-utility/TypeSwitch.h
+@@ -127,7 +127,7 @@ struct Executor {
+          // Case 1: Compatible, and invocable on the next function, giving
+          // another function, that accepts BaseClass:
+          struct Case1_;
+-         using Case1 = std::conjunction<Compatible, curried, Case1_>;
++         using Case1 = TypeList::conjunction<Compatible, curried, Case1_>;
+          struct Case1_ {
+             static constexpr bool value = std::is_invocable_v<
+                std::invoke_result_t<F, Dummy &&>, BaseClass&, Args&&...>;
+@@ -135,7 +135,7 @@ struct Executor {
+          };
+ 
+          // Case 2: Invocable directly on the object
+-         struct Case2 : std::conjunction<
++         struct Case2 : TypeList::conjunction<
+             Compatible, std::negation<curried>,
+             std::is_invocable<F, BaseClass&, Args&&...>
+          > {