Skip to content

Commit

Permalink
audio/audacity: Fix build in 12 and 13
Browse files Browse the repository at this point in the history
Conditional workaround for the problem with old libc++ and the buggy
implementation of std::conjunction

Patch by tatsuki_makino@hotmail.com

PR:		275192
  • Loading branch information
tatsuki-makino authored and fernape committed Nov 24, 2023
1 parent 4e2c038 commit 01b1ed5
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 3 deletions.
10 changes: 7 additions & 3 deletions audio/audacity/Makefile
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions 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>);
39 changes: 39 additions & 0 deletions 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;
20 changes: 20 additions & 0 deletions 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&&...>
> {

0 comments on commit 01b1ed5

Please sign in to comment.