Add osx-ppc compilation for frontend (#13532)

* Fix old osx condition

Current code assumes that osx < 10.12 is equivalent to ppc osx. It's not
true as Leopard x86 is still < 10.12 but not ppc. As xcode compiles fat
binaries it includes osx x86 and compilation fails.

* Disable crtswitchres when no c++11 is available

Crtswitchres altually needs c++11. Since it's not that important to make
it compatible with lower c++, just disable if no c++11 is available

* Don't use firstObject on old Mac OS X.

It was introduced in 10.6, so on old ones just implement it ourselves

* Compile osx-ppc frontend

* osx-ppc: Build a fat binary

On 10.6 i386 xcode apparently refuses to build a pure ppc.
Settle for a fat binary.
This commit is contained in:
Vladimir Serbinenko 2022-01-24 16:22:07 +01:00 committed by GitHub
parent 948ad76b14
commit 4e24fb3d01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 72 additions and 30 deletions

View File

@ -363,6 +363,29 @@ build-retroarch-osx-opengl-x64:
XCPROJECT_NAME: RetroArch XCPROJECT_NAME: RetroArch
XCCONFIG: OpenGL_GitLabCI.xcconfig XCCONFIG: OpenGL_GitLabCI.xcconfig
build-retroarch-osx-ppc:
stage: build
artifacts:
paths:
- ${XCPROJECT_NAME}.zip
- retroarch-repo/
expire_in: 10 min
dependencies: []
variables:
XCPROJECT_NAME: RetroArch
XCCONFIG: OpenGL_GitLabCI.xcconfig
tags:
- macosx-legacy
script:
- xcodebuild -target RetroArch -configuration Release -project pkg/apple/RetroArch_PPC.xcodeproj ONLY_ACTIVE_ARCH=NO
- pushd pkg/apple/build/Release/
- ditto -c -k --sequesterRsrc --keepParent RetroArch.app ${XCPROJECT_NAME}.zip
- popd
- mv pkg/apple/build/Release/RetroArch.zip ${XCPROJECT_NAME}.zip
- mkdir .retroarch-repo
- "cp -r ./* .retroarch-repo"
- "mv .retroarch-repo/ retroarch-repo/"
build-retroarch-ios-arm64: build-retroarch-ios-arm64:
extends: .build-retroarch-macos-xcode extends: .build-retroarch-macos-xcode
variables: variables:

View File

@ -33,12 +33,13 @@
#include "../audio_driver.h" #include "../audio_driver.h"
#include "../../verbosity.h" #include "../../verbosity.h"
#include "defines/cocoa_defines.h"
typedef struct coreaudio typedef struct coreaudio
{ {
slock_t *lock; slock_t *lock;
scond_t *cond; scond_t *cond;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if !HAS_MACOSX_10_12
ComponentInstance dev; ComponentInstance dev;
#else #else
AudioComponentInstance dev; AudioComponentInstance dev;
@ -64,7 +65,7 @@ static void coreaudio_free(void *data)
if (dev->dev_alive) if (dev->dev_alive)
{ {
AudioOutputUnitStop(dev->dev); AudioOutputUnitStop(dev->dev);
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if !HAS_MACOSX_10_12
CloseComponent(dev->dev); CloseComponent(dev->dev);
#else #else
AudioComponentInstanceDispose(dev->dev); AudioComponentInstanceDispose(dev->dev);
@ -139,7 +140,7 @@ static void choose_output_device(coreaudio_t *dev, const char* device)
UInt32 size = 0; UInt32 size = 0;
propaddr.mSelector = kAudioHardwarePropertyDevices; propaddr.mSelector = kAudioHardwarePropertyDevices;
#if MAC_OS_X_VERSION_10_12 #if HAS_MACOSX_10_12
propaddr.mScope = kAudioObjectPropertyScopeOutput; propaddr.mScope = kAudioObjectPropertyScopeOutput;
#else #else
propaddr.mScope = kAudioObjectPropertyScopeGlobal; propaddr.mScope = kAudioObjectPropertyScopeGlobal;
@ -157,7 +158,7 @@ static void choose_output_device(coreaudio_t *dev, const char* device)
&propaddr, 0, 0, &size, devices) != noErr) &propaddr, 0, 0, &size, devices) != noErr)
goto done; goto done;
#if MAC_OS_X_VERSION_10_12 #if HAS_MACOSX_10_12
#else #else
propaddr.mScope = kAudioDevicePropertyScopeOutput; propaddr.mScope = kAudioDevicePropertyScopeOutput;
#endif #endif
@ -192,7 +193,7 @@ static void *coreaudio_init(const char *device,
size_t fifo_size; size_t fifo_size;
UInt32 i_size; UInt32 i_size;
AudioStreamBasicDescription real_desc; AudioStreamBasicDescription real_desc;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if !HAS_MACOSX_10_12
Component comp; Component comp;
#else #else
AudioComponent comp; AudioComponent comp;
@ -204,7 +205,7 @@ static void *coreaudio_init(const char *device,
AudioStreamBasicDescription stream_desc = {0}; AudioStreamBasicDescription stream_desc = {0};
bool component_unavailable = false; bool component_unavailable = false;
static bool session_initialized = false; static bool session_initialized = false;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if !HAS_MACOSX_10_12
ComponentDescription desc = {0}; ComponentDescription desc = {0};
#else #else
AudioComponentDescription desc = {0}; AudioComponentDescription desc = {0};
@ -238,7 +239,7 @@ static void *coreaudio_init(const char *device,
#endif #endif
desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentManufacturer = kAudioUnitManufacturer_Apple;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if !HAS_MACOSX_10_12
comp = FindNextComponent(NULL, &desc); comp = FindNextComponent(NULL, &desc);
#else #else
comp = AudioComponentFindNext(NULL, &desc); comp = AudioComponentFindNext(NULL, &desc);
@ -246,7 +247,7 @@ static void *coreaudio_init(const char *device,
if (!comp) if (!comp)
goto error; goto error;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if !HAS_MACOSX_10_12
component_unavailable = (OpenAComponent(comp, &dev->dev) != noErr); component_unavailable = (OpenAComponent(comp, &dev->dev) != noErr);
#else #else
component_unavailable = (AudioComponentInstanceNew(comp, &dev->dev) != noErr); component_unavailable = (AudioComponentInstanceNew(comp, &dev->dev) != noErr);

View File

@ -762,7 +762,7 @@ static const float menu_footer_opacity = 1.000;
static const float menu_header_opacity = 1.000; static const float menu_header_opacity = 1.000;
#if defined(HAVE_OPENGLES2) || (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if defined(HAVE_OPENGLES2) || (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
#define DEFAULT_MENU_SHADER_PIPELINE 1 #define DEFAULT_MENU_SHADER_PIPELINE 1
#else #else
#define DEFAULT_MENU_SHADER_PIPELINE 2 #define DEFAULT_MENU_SHADER_PIPELINE 2

View File

@ -114,7 +114,7 @@ typedef enum
CFAllDomainsMask = 0x0ffff /* All domains: all of the above and future items */ CFAllDomainsMask = 0x0ffff /* All domains: all of the above and future items */
} CFDomainMask; } CFDomainMask;
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__))) #if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
static int speak_pid = 0; static int speak_pid = 0;
#endif #endif
@ -128,14 +128,19 @@ static void CFSearchPathForDirectoriesInDomains(
#else #else
NSSearchPathDirectory dir = NSDocumentDirectory; NSSearchPathDirectory dir = NSDocumentDirectory;
#endif #endif
CFStringRef array_val;
#if __has_feature(objc_arc) #if __has_feature(objc_arc)
CFStringRef array_val = (__bridge CFStringRef)[ array_val = (__bridge CFStringRef)[
NSSearchPathForDirectoriesInDomains(dir, NSSearchPathForDirectoriesInDomains(dir,
NSUserDomainMask, YES) firstObject]; NSUserDomainMask, YES) firstObject];
#else #else
CFStringRef array_val = (CFStringRef)[ NSArray *arr = NSSearchPathForDirectoriesInDomains(dir,
NSSearchPathForDirectoriesInDomains(dir, NSUserDomainMask, YES);
NSUserDomainMask, YES) firstObject]; if ([arr count] == 0) {
array_val = nil;
} else{
array_val = (CFStringRef)[arr objectAtIndex:0];
}
#endif #endif
if (array_val) if (array_val)
CFStringGetCString(array_val, s, len, kCFStringEncodingUTF8); CFStringGetCString(array_val, s, len, kCFStringEncodingUTF8);
@ -805,7 +810,7 @@ static uint64_t frontend_darwin_get_total_mem(void)
static uint64_t frontend_darwin_get_free_mem(void) static uint64_t frontend_darwin_get_free_mem(void)
{ {
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__))) #if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
vm_size_t page_size; vm_size_t page_size;
vm_statistics64_data_t vm_stats; vm_statistics64_data_t vm_stats;
mach_port_t mach_port = mach_host_self(); mach_port_t mach_port = mach_host_self();
@ -831,7 +836,7 @@ static const char* frontend_darwin_get_cpu_model_name(void)
return darwin_cpu_model_name; return darwin_cpu_model_name;
} }
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__))) #if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
static char* accessibility_mac_language_code(const char* language) static char* accessibility_mac_language_code(const char* language)
{ {
if (string_is_equal(language,"en")) if (string_is_equal(language,"en"))
@ -995,13 +1000,9 @@ frontend_ctx_driver_t frontend_ctx_darwin = {
NULL, /* watch_path_for_changes */ NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */ NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */ NULL, /* set_sustained_performance_mode */
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
frontend_darwin_get_cpu_model_name, /* get_cpu_model_name */ frontend_darwin_get_cpu_model_name, /* get_cpu_model_name */
#else
NULL, /* get_cpu_model_name */
#endif
NULL, /* get_user_language */ NULL, /* get_user_language */
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__))) #if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
is_narrator_running_macos, /* is_narrator_running */ is_narrator_running_macos, /* is_narrator_running */
accessibility_speak_macos, /* accessibility_speak */ accessibility_speak_macos, /* accessibility_speak */
#else #else

View File

@ -40,7 +40,7 @@ RETRO_BEGIN_DECLS
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES #define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES #define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT #define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #elif (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT #define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT #define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT #define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
@ -59,7 +59,7 @@ RETRO_BEGIN_DECLS
#endif #endif
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT #define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT #define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #elif (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT #define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT #define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT #define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
@ -76,7 +76,7 @@ RETRO_BEGIN_DECLS
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT #define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
#endif #endif
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #if (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_EXT #define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_EXT
#elif defined(HAVE_PSGL) #elif defined(HAVE_PSGL)
#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_OES #define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_OES

View File

@ -200,7 +200,7 @@ typedef struct gl2_renderchain_data
#define gl2_rb_storage glRenderbufferStorageOES #define gl2_rb_storage glRenderbufferStorageOES
#define gl2_delete_rb glDeleteRenderbuffersOES #define gl2_delete_rb glDeleteRenderbuffersOES
#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #elif (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DEXT(a, b, c, d, e) #define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DEXT(a, b, c, d, e)
#define gl2_check_fb_status(target) glCheckFramebufferStatusEXT(target) #define gl2_check_fb_status(target) glCheckFramebufferStatusEXT(target)
#define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids) #define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids)
@ -1221,7 +1221,7 @@ static bool gl2_renderchain_init_hw_render(
if (stencil) if (stencil)
{ {
#if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES1) || ((defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))) #if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES1) || (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
/* GLES2 is a bit weird, as always. /* GLES2 is a bit weird, as always.
* There's no GL_DEPTH_STENCIL_ATTACHMENT like in desktop GL. */ * There's no GL_DEPTH_STENCIL_ATTACHMENT like in desktop GL. */
gl2_fb_rb(RARCH_GL_FRAMEBUFFER, gl2_fb_rb(RARCH_GL_FRAMEBUFFER,

View File

@ -30,6 +30,7 @@
#endif #endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
#define HAS_MACOSX_10_12 0
#define NSEventModifierFlagCommand NSCommandKeyMask #define NSEventModifierFlagCommand NSCommandKeyMask
#define NSEventModifierFlagControl NSControlKeyMask #define NSEventModifierFlagControl NSControlKeyMask
#define NSEventModifierFlagHelp NSHelpKeyMask #define NSEventModifierFlagHelp NSHelpKeyMask
@ -68,6 +69,8 @@
#define NSAlertStyleWarning NSWarningAlertStyle #define NSAlertStyleWarning NSWarningAlertStyle
#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
#define NSControlSizeRegular NSRegularControlSize #define NSControlSizeRegular NSRegularControlSize
#else
#define HAS_MACOSX_10_12 1
#endif #endif
#endif #endif

View File

@ -262,6 +262,12 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = (
i386,
x86_64,
ppc64,
ppc,
);
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default"; CLANG_CXX_LIBRARY = "compiler-default";
CLANG_ENABLE_OBJC_ARC = NO; CLANG_ENABLE_OBJC_ARC = NO;
@ -287,7 +293,7 @@
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "$(SRCROOT)/OSX/Info.plist"; INFOPLIST_FILE = "$(SRCROOT)/OSX/Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.4; MACOSX_DEPLOYMENT_TARGET = 10.4;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = ( OTHER_CFLAGS = (
"-DHAVE_RUNAHEAD", "-DHAVE_RUNAHEAD",
"-DHAVE_TRANSLATE", "-DHAVE_TRANSLATE",

View File

@ -634,6 +634,14 @@ if [ "$HAVE_GLSLANG" != no ]; then
fi fi
fi fi
if [ "$HAVE_CRTSWITCHRES" != no ]; then
if [ "$HAVE_CXX11" = 'no' ]; then
HAVE_CRTSWITCHRES=no
else
HAVE_CRTSWITCHRES=yes
fi
fi
check_enabled SLANG GLSLANG glslang 'slang is' false check_enabled SLANG GLSLANG glslang 'slang is' false
check_enabled SLANG SPIRV_CROSS SPIRV-Cross 'slang is' false check_enabled SLANG SPIRV_CROSS SPIRV-Cross 'slang is' false
check_enabled SLANG OPENGL_CORE 'OpenGL core' 'slang is' false check_enabled SLANG OPENGL_CORE 'OpenGL core' 'slang is' false

View File

@ -194,5 +194,5 @@ HAVE_ODROIDGO2=no # ODROID-GO Advance rotation support (requires librga
HAVE_LIBSHAKE=no # libShake haptic feedback support HAVE_LIBSHAKE=no # libShake haptic feedback support
HAVE_CHECK=no # check support for unit tests HAVE_CHECK=no # check support for unit tests
HAVE_WIFI=no # wifi driver support HAVE_WIFI=no # wifi driver support
HAVE_CRTSWITCHRES=yes # CRT mode switching support HAVE_CRTSWITCHRES=auto # CRT mode switching support (requires C++11)
C89_CRTSWITCHRES=no C89_CRTSWITCHRES=no

View File

@ -61,7 +61,7 @@ UINavigationControllerDelegate> {
#else #else
#if defined(HAVE_COCOA_METAL) #if defined(HAVE_COCOA_METAL)
@interface RetroArch_OSX : NSObject<ApplePlatform, NSApplicationDelegate> { @interface RetroArch_OSX : NSObject<ApplePlatform, NSApplicationDelegate> {
#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #elif (defined(__MACH__) && defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED < 101200))
@interface RetroArch_OSX : NSObject { @interface RetroArch_OSX : NSObject {
#else #else
@interface RetroArch_OSX : NSObject<NSApplicationDelegate> { @interface RetroArch_OSX : NSObject<NSApplicationDelegate> {