Skip to content

Commit 41dd469

Browse files
committed
playlist_manager: replace HAVE_COCOATOUCH gate with SDK-version gate
In hindsight the HAVE_COCOATOUCH gate applied by cc1a131 and 345a2ef was too coarse. RetroArchPlaylistManager.m/.h is not iOS/tvOS-only - the file is portable to modern macOS, and the only reason it couldn't be built for macOS earlier was that its syntax requires Xcode 7 / SDK 10.11 (nullability macros NS_ASSUME_NONNULL_BEGIN/END, nullable, _Nonnull; Obj-C lightweight generics NSArray<...>). Pre-10.11 macOS (and PPC/Leopard in particular, where GCC 4.0 doesn't understand the syntax at all) should be excluded, but modern macOS should be able to use it. Introduce a new feature flag HAVE_RETROARCH_PLAYLIST_MANAGER and gate all the call sites on it instead: qb/config.params.sh - declare HAVE_RETROARCH_PLAYLIST_MANAGER=auto near HAVE_COCOA. qb.make.sh auto-plumbs this into config.mk via the existing CONFIG_OPTS iteration. qb/config.libs.sh - extend the existing Darwin probe to compute macos_target_pre_10_11 alongside macos_target_pre_10_7, then set HAVE_RETROARCH_PLAYLIST_MANAGER=yes if HAVE_COCOATOUCH=yes OR macos_target_pre_10_11=no; else no. Makefile.common - flip ifeq ($(HAVE_COCOATOUCH), 1) to ifeq ($(HAVE_RETROARCH_PLAYLIST_MANAGER), 1). griffin/griffin_objc.m - flip #ifdef HAVE_COCOATOUCH to #ifdef HAVE_RETROARCH_PLAYLIST_MANAGER around the .m include. ui/drivers/cocoa/cocoa_common.h - add a C-preprocessor synthesis block for non-qb builds (e.g. RetroArch.xcodeproj) that sets HAVE_RETROARCH_PLAYLIST_MANAGER based on HAVE_COCOATOUCH or MAC_OS_X_VERSION_MAX_ALLOWED >= 101100. Guarded with #ifndef so the qb-set value wins when present. Also flip the cocoa_launch_game_by_filename forward-decl gate. ui/drivers/cocoa/cocoa_common.m - flip the two existing gates (header include and function body open/close). Behavioral outcomes: - iOS/tvOS: HAVE_COCOATOUCH -> HAVE_RETROARCH_PLAYLIST_MANAGER. No change; file still built. - Modern macOS (10.11+): now builds the file. This is NEW - the previous HAVE_COCOATOUCH gate excluded it even though the file would have compiled fine there. - Pre-10.11 macOS (includes PPC/Leopard/Xcode 3.1): correctly excluded, same as before. - Non-Darwin: HAVE_RETROARCH_PLAYLIST_MANAGER stays 'auto', never emitted as 1 in config.mk; Makefile gate is false; nothing changes (and these builds never reached the file anyway, guarded further by HAVE_COCOA_COMMON). Supersedes the over-gating in cc1a131 (source-side) and 345a2ef (Makefile-side).
1 parent 3030b78 commit 41dd469

6 files changed

Lines changed: 58 additions & 14 deletions

File tree

Makefile.common

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,11 +2609,12 @@ ifeq ($(HAVE_COCOA_COMMON),1)
26092609
ui/drivers/ui_cocoa.o \
26102610
ui/drivers/cocoa/cocoa_common.o
26112611
# RetroArchPlaylistManager uses Obj-C lightweight generics and
2612-
# nullability macros (Xcode 7+, 2015). Its only consumer,
2613-
# cocoa_launch_game_by_filename(), is iOS/tvOS-only. Gate on
2614-
# HAVE_COCOATOUCH so desktop (macOS) make-builds don't try to
2615-
# compile it - GCC 4.0 on PPC can't parse the Xcode 7 syntax.
2616-
ifeq ($(HAVE_COCOATOUCH), 1)
2612+
# nullability macros (Xcode 7+, 2015). It's fine on iOS/tvOS and
2613+
# modern macOS (10.11+), but GCC 4.0 / old clang on pre-10.11
2614+
# macOS SDKs can't parse the syntax. HAVE_RETROARCH_PLAYLIST_MANAGER
2615+
# is set by qb/config.libs.sh based on the macOS target version
2616+
# (or HAVE_COCOATOUCH on iOS/tvOS).
2617+
ifeq ($(HAVE_RETROARCH_PLAYLIST_MANAGER), 1)
26172618
OBJ += ui/drivers/cocoa/RetroArchPlaylistManager.o
26182619
endif
26192620
LIBS += -framework Cocoa -framework AppKit -framework Foundation

griffin/griffin_objc.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232
#if defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
3333

3434
#include "../ui/drivers/cocoa/cocoa_common.m"
35-
#ifdef HAVE_COCOATOUCH
36-
/* RetroArchPlaylistManager is iOS/tvOS-only and uses Obj-C
37-
* lightweight generics + nullability macros (Xcode 7+, 2015).
38-
* Don't pull it into the macOS build - GCC 4.0 can't parse it. */
35+
#ifdef HAVE_RETROARCH_PLAYLIST_MANAGER
36+
/* RetroArchPlaylistManager uses Obj-C lightweight generics and
37+
* nullability macros (Xcode 7+, 2015). Usable on iOS/tvOS and
38+
* modern macOS, not on older macOS SDKs. Flag is synthesized
39+
* in cocoa_common.h for non-qb builds; set directly by qb. */
3940
#include "../ui/drivers/cocoa/RetroArchPlaylistManager.m"
4041
#endif
4142
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)

qb/config.libs.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,15 @@ if [ "$OS" = 'Darwin' ]; then
250250
# <stdatomic.h>, AVFoundation, @available). On Tiger/Leopard /
251251
# PowerPC / Xcode 3.1 those APIs are absent and builds fail.
252252
#
253+
# We also compute macos_target_pre_10_11 for code that requires
254+
# Xcode 7-era Obj-C features (nullability macros, lightweight
255+
# generics) - those need SDK 10.11 / Xcode 7 or newer.
256+
#
253257
# MACOSX_DEPLOYMENT_TARGET (set by the invoker or the toolchain)
254258
# takes priority over sw_vers, because on a cross-build the host
255259
# OS version may be newer than the target.
256260
macos_target_pre_10_7=no
261+
macos_target_pre_10_11=no
257262
macos_target_ver="${MACOSX_DEPLOYMENT_TARGET:-}"
258263
if [ -z "$macos_target_ver" ] && command -v sw_vers >/dev/null 2>&1; then
259264
macos_target_ver="$(sw_vers -productVersion 2>/dev/null)"
@@ -267,6 +272,10 @@ if [ "$OS" = 'Darwin' ]; then
267272
{ [ "$mt_major" -eq 10 ] && [ "$mt_minor" -lt 7 ]; }; then
268273
macos_target_pre_10_7=yes
269274
fi
275+
if [ "$mt_major" -lt 10 ] || \
276+
{ [ "$mt_major" -eq 10 ] && [ "$mt_minor" -lt 11 ]; }; then
277+
macos_target_pre_10_11=yes
278+
fi
270279
unset mt_major mt_minor
271280
fi
272281

@@ -307,7 +316,21 @@ if [ "$OS" = 'Darwin' ]; then
307316
HAVE_MICROPHONE=no
308317
die : "Notice: macOS target $macos_target_ver is pre-10.7; disabling microphone (requires C11 <stdatomic.h>). Override with --enable-microphone."
309318
fi
310-
unset macos_target_ver macos_target_pre_10_7
319+
320+
# RetroArchPlaylistManager.m/.h uses Obj-C nullability macros
321+
# (NS_ASSUME_NONNULL_BEGIN/END, nullable, _Nonnull) and
322+
# lightweight generics (NSArray<...>) - all Xcode 7+ (2015)
323+
# features requiring SDK 10.11 / iOS 9.0 or newer. Enable on
324+
# iOS/tvOS (any HAVE_COCOATOUCH build is modern enough in
325+
# practice) and on macOS 10.11+ targets. Disable on pre-10.11
326+
# macOS where GCC/old-clang can't parse the syntax.
327+
if [ "$HAVE_COCOATOUCH" = 'yes' ] || \
328+
[ "$macos_target_pre_10_11" = 'no' ]; then
329+
HAVE_RETROARCH_PLAYLIST_MANAGER=yes
330+
else
331+
HAVE_RETROARCH_PLAYLIST_MANAGER=no
332+
fi
333+
unset macos_target_ver macos_target_pre_10_7 macos_target_pre_10_11
311334

312335
if [ "$HAVE_METAL" = yes ] || [ "$HAVE_VULKAN" = yes ]; then
313336
check_lib '' COCOA_METAL "-framework AppKit" NSApplicationMain

qb/config.params.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,8 @@ HAVE_GAME_AI=no
215215
HAVE_SMBCLIENT=auto # SMB client support
216216
HAVE_BUILTINSMBCLIENT=no # Use builtin libsmb2
217217
HAVE_COCOA=auto # Cocoa support (Darwin/Apple)
218+
# RetroArchPlaylistManager (iOS/tvOS playlist helper, also fine on
219+
# modern macOS). Auto-disabled on pre-10.11 macOS targets by
220+
# config.libs.sh because the file uses Xcode 7-era Obj-C syntax.
221+
HAVE_RETROARCH_PLAYLIST_MANAGER=auto
218222
HAVE_MFI=auto # GameController.framework joypad support (Apple)

ui/drivers/cocoa/cocoa_common.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@
2929
#include <AppKit/AppKit.h>
3030
#endif
3131

32+
/* RetroArchPlaylistManager.m/.h uses Obj-C nullability macros
33+
* (NS_ASSUME_NONNULL_BEGIN/END, nullable, _Nonnull) and
34+
* lightweight generics (NSArray<...>) - all Xcode 7+ (2015)
35+
* features requiring SDK 10.11 / iOS 9.0 or newer. Synthesize
36+
* HAVE_RETROARCH_PLAYLIST_MANAGER here for build systems that
37+
* don't pass it in (e.g. the RetroArch_PPC.xcodeproj, non-qb
38+
* builds). qb/config.libs.sh sets the flag directly for make
39+
* builds and takes priority if already defined. */
40+
#ifndef HAVE_RETROARCH_PLAYLIST_MANAGER
41+
#if defined(HAVE_COCOATOUCH) || \
42+
(defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
43+
#define HAVE_RETROARCH_PLAYLIST_MANAGER 1
44+
#endif
45+
#endif
46+
3247
#include "../../../retroarch.h"
3348

3449
#if TARGET_OS_IPHONE && defined(HAVE_COCOATOUCH)
@@ -128,7 +143,7 @@ void cocoa_show_mouse(void *data, bool state);
128143

129144
void *cocoa_screen_get_chosen(void);
130145

131-
#ifdef HAVE_COCOATOUCH
146+
#ifdef HAVE_RETROARCH_PLAYLIST_MANAGER
132147
bool cocoa_launch_game_by_filename(NSString *filename);
133148
#endif
134149

ui/drivers/cocoa/cocoa_common.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "cocoa_common.h"
2424
#include "apple_platform.h"
2525
#include "../ui_cocoa.h"
26-
#ifdef HAVE_COCOATOUCH
26+
#ifdef HAVE_RETROARCH_PLAYLIST_MANAGER
2727
#include "RetroArchPlaylistManager.h"
2828
#endif
2929

@@ -1197,7 +1197,7 @@ void cocoa_file_load_with_detect_core(const char *filename)
11971197
}
11981198
}
11991199

1200-
#ifdef HAVE_COCOATOUCH
1200+
#ifdef HAVE_RETROARCH_PLAYLIST_MANAGER
12011201
bool cocoa_launch_game_by_filename(NSString *filename)
12021202
{
12031203
core_info_list_t *core_info_list = NULL;
@@ -1294,4 +1294,4 @@ bool cocoa_launch_game_by_filename(NSString *filename)
12941294
return task_push_load_content_with_new_core_from_companion_ui(
12951295
info->path, full_path, NULL, NULL, NULL, &content_info, NULL, NULL);
12961296
}
1297-
#endif /* HAVE_COCOATOUCH */
1297+
#endif /* HAVE_RETROARCH_PLAYLIST_MANAGER */

0 commit comments

Comments
 (0)