From a772bbb905b7458ab8c08adc6bee2edcc539dcbf Mon Sep 17 00:00:00 2001 From: Violet Purcell Date: Tue, 5 Sep 2023 09:18:58 -0400 Subject: [PATCH] JUCE: Fix build on musl From https://github.com/juce-framework/JUCE/pull/1239. Signed-off-by: Violet Purcell --- source/modules/juce_core/juce_core.cpp | 2 +- .../juce_core/native/juce_linux_SystemStats.cpp | 12 ++++++------ .../modules/juce_core/native/juce_posix_SharedCode.h | 2 +- source/modules/juce_core/system/juce_SystemStats.cpp | 2 +- .../modules/juce_core/system/juce_TargetPlatform.h | 9 +++++++++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/source/modules/juce_core/juce_core.cpp b/source/modules/juce_core/juce_core.cpp index f528a9535..29fa4fb69 100644 --- a/source/modules/juce_core/juce_core.cpp +++ b/source/modules/juce_core/juce_core.cpp @@ -103,7 +103,7 @@ #include #include - #if ! (JUCE_ANDROID || JUCE_WASM) + #if ! (JUCE_ANDROID || JUCE_WASM || JUCE_MUSL) #include #endif #endif diff --git a/source/modules/juce_core/native/juce_linux_SystemStats.cpp b/source/modules/juce_core/native/juce_linux_SystemStats.cpp index 84abf88ea..60d8047b7 100644 --- a/source/modules/juce_core/native/juce_linux_SystemStats.cpp +++ b/source/modules/juce_core/native/juce_linux_SystemStats.cpp @@ -198,22 +198,22 @@ String SystemStats::getComputerName() String SystemStats::getUserLanguage() { - #if JUCE_BSD + #if JUCE_GLIBC + return getLocaleValue (_NL_IDENTIFICATION_LANGUAGE); + #else if (auto langEnv = getenv ("LANG")) return String::fromUTF8 (langEnv).upToLastOccurrenceOf (".UTF-8", false, true); return {}; - #else - return getLocaleValue (_NL_IDENTIFICATION_LANGUAGE); #endif } String SystemStats::getUserRegion() { - #if JUCE_BSD - return {}; - #else + #if JUCE_GLIBC return getLocaleValue (_NL_IDENTIFICATION_TERRITORY); + #else + return {}; #endif } diff --git a/source/modules/juce_core/native/juce_posix_SharedCode.h b/source/modules/juce_core/native/juce_posix_SharedCode.h index efe1bda73..67a49d03a 100644 --- a/source/modules/juce_core/native/juce_posix_SharedCode.h +++ b/source/modules/juce_core/native/juce_posix_SharedCode.h @@ -167,7 +167,7 @@ int juce_siginterrupt (int sig, int flag) //============================================================================== namespace { - #if JUCE_LINUX || (JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T) // (this iOS stuff is to avoid a simulator bug) + #if JUCE_GLIBC || (JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T) // (this iOS stuff is to avoid a simulator bug) using juce_statStruct = struct stat64; #define JUCE_STAT stat64 #else diff --git a/source/modules/juce_core/system/juce_SystemStats.cpp b/source/modules/juce_core/system/juce_SystemStats.cpp index 59707c9d1..b0aec6903 100644 --- a/source/modules/juce_core/system/juce_SystemStats.cpp +++ b/source/modules/juce_core/system/juce_SystemStats.cpp @@ -133,7 +133,7 @@ String SystemStats::getStackBacktrace() { String result; - #if JUCE_ANDROID || JUCE_MINGW || JUCE_WASM + #if JUCE_ANDROID || JUCE_MINGW || JUCE_WASM || JUCE_MUSL jassertfalse; // sorry, not implemented yet! #elif JUCE_WINDOWS diff --git a/source/modules/juce_core/system/juce_TargetPlatform.h b/source/modules/juce_core/system/juce_TargetPlatform.h index 7be92aa83..186012361 100644 --- a/source/modules/juce_core/system/juce_TargetPlatform.h +++ b/source/modules/juce_core/system/juce_TargetPlatform.h @@ -33,6 +33,7 @@ - Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. - Either JUCE_INTEL or JUCE_ARM - Either JUCE_GCC or JUCE_CLANG or JUCE_MSVC + - Either JUCE_GLIBC or JUCE_MUSL will be defined on Linux depending on the system's libc implementation. */ //============================================================================== @@ -161,6 +162,14 @@ #elif __MMX__ || __SSE__ || __amd64__ #define JUCE_INTEL 1 #endif + + #if JUCE_LINUX + #ifdef __GLIBC__ + #define JUCE_GLIBC 1 + #else + #define JUCE_MUSL 1 + #endif + #endif #endif //==============================================================================