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
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:
extends: .build-retroarch-macos-xcode
variables:

View file

@ -33,12 +33,13 @@
#include "../audio_driver.h"
#include "../../verbosity.h"
#include "defines/cocoa_defines.h"
typedef struct coreaudio
{
slock_t *lock;
scond_t *cond;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#if !HAS_MACOSX_10_12
ComponentInstance dev;
#else
AudioComponentInstance dev;
@ -64,7 +65,7 @@ static void coreaudio_free(void *data)
if (dev->dev_alive)
{
AudioOutputUnitStop(dev->dev);
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#if !HAS_MACOSX_10_12
CloseComponent(dev->dev);
#else
AudioComponentInstanceDispose(dev->dev);
@ -139,7 +140,7 @@ static void choose_output_device(coreaudio_t *dev, const char* device)
UInt32 size = 0;
propaddr.mSelector = kAudioHardwarePropertyDevices;
#if MAC_OS_X_VERSION_10_12
#if HAS_MACOSX_10_12
propaddr.mScope = kAudioObjectPropertyScopeOutput;
#else
propaddr.mScope = kAudioObjectPropertyScopeGlobal;
@ -157,7 +158,7 @@ static void choose_output_device(coreaudio_t *dev, const char* device)
&propaddr, 0, 0, &size, devices) != noErr)
goto done;
#if MAC_OS_X_VERSION_10_12
#if HAS_MACOSX_10_12
#else
propaddr.mScope = kAudioDevicePropertyScopeOutput;
#endif
@ -192,7 +193,7 @@ static void *coreaudio_init(const char *device,
size_t fifo_size;
UInt32 i_size;
AudioStreamBasicDescription real_desc;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#if !HAS_MACOSX_10_12
Component comp;
#else
AudioComponent comp;
@ -204,7 +205,7 @@ static void *coreaudio_init(const char *device,
AudioStreamBasicDescription stream_desc = {0};
bool component_unavailable = false;
static bool session_initialized = false;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#if !HAS_MACOSX_10_12
ComponentDescription desc = {0};
#else
AudioComponentDescription desc = {0};
@ -238,7 +239,7 @@ static void *coreaudio_init(const char *device,
#endif
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#if !HAS_MACOSX_10_12
comp = FindNextComponent(NULL, &desc);
#else
comp = AudioComponentFindNext(NULL, &desc);
@ -246,7 +247,7 @@ static void *coreaudio_init(const char *device,
if (!comp)
goto error;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#if !HAS_MACOSX_10_12
component_unavailable = (OpenAComponent(comp, &dev->dev) != noErr);
#else
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;
#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
#else
#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 */
} CFDomainMask;
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
#if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
static int speak_pid = 0;
#endif
@ -128,14 +128,19 @@ static void CFSearchPathForDirectoriesInDomains(
#else
NSSearchPathDirectory dir = NSDocumentDirectory;
#endif
CFStringRef array_val;
#if __has_feature(objc_arc)
CFStringRef array_val = (__bridge CFStringRef)[
array_val = (__bridge CFStringRef)[
NSSearchPathForDirectoriesInDomains(dir,
NSUserDomainMask, YES) firstObject];
#else
CFStringRef array_val = (CFStringRef)[
NSSearchPathForDirectoriesInDomains(dir,
NSUserDomainMask, YES) firstObject];
NSArray *arr = NSSearchPathForDirectoriesInDomains(dir,
NSUserDomainMask, YES);
if ([arr count] == 0) {
array_val = nil;
} else{
array_val = (CFStringRef)[arr objectAtIndex:0];
}
#endif
if (array_val)
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)
{
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
#if (defined(OSX) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200))
vm_size_t page_size;
vm_statistics64_data_t vm_stats;
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;
}
#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)
{
if (string_is_equal(language,"en"))
@ -995,13 +1000,9 @@ frontend_ctx_driver_t frontend_ctx_darwin = {
NULL, /* watch_path_for_changes */
NULL, /* check_for_path_changes */
NULL, /* set_sustained_performance_mode */
#if (defined(OSX) && !(defined(__ppc__) || defined(__ppc64__)))
frontend_darwin_get_cpu_model_name, /* get_cpu_model_name */
#else
NULL, /* get_cpu_model_name */
#endif
frontend_darwin_get_cpu_model_name, /* get_cpu_model_name */
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 */
accessibility_speak_macos, /* accessibility_speak */
#else

View file

@ -40,7 +40,7 @@ RETRO_BEGIN_DECLS
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
#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_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
@ -59,7 +59,7 @@ RETRO_BEGIN_DECLS
#endif
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_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_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_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
#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
#elif defined(HAVE_PSGL)
#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_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_check_fb_status(target) glCheckFramebufferStatusEXT(target)
#define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids)
@ -1221,7 +1221,7 @@ static bool gl2_renderchain_init_hw_render(
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.
* There's no GL_DEPTH_STENCIL_ATTACHMENT like in desktop GL. */
gl2_fb_rb(RARCH_GL_FRAMEBUFFER,

View file

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

View file

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

View file

@ -634,6 +634,14 @@ if [ "$HAVE_GLSLANG" != no ]; then
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 SPIRV_CROSS SPIRV-Cross '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_CHECK=no # check support for unit tests
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

View file

@ -61,7 +61,7 @@ UINavigationControllerDelegate> {
#else
#if defined(HAVE_COCOA_METAL)
@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 {
#else
@interface RetroArch_OSX : NSObject<NSApplicationDelegate> {