Upgrade SDL for Mac

This removes the option to use system SDL, which seems like a trap.

Also simplifies the macbundle.sh script accordingly.

Buildfix

Buildfix fix

Moar buildfix
This commit is contained in:
Henrik Rydgård 2023-04-24 14:44:07 +02:00
parent 22314f8cc7
commit 5d028cb004
10 changed files with 71 additions and 47 deletions

View File

@ -107,10 +107,6 @@ if(NOT IOS)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl)
endif()
if(MACOSX AND NOT USE_SYSTEM_LIBSDL2)
set(SDL2_LIBRARY ${CMAKE_SOURCE_DIR}/SDL/macOS/SDL2.framework)
endif()
include(ccache)
include(GNUInstallDirs)
@ -161,7 +157,7 @@ option(USE_ARMIPS "Build with armips support in API/debugger" ON)
option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY})
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP})
option(USE_SYSTEM_LIBSDL2 "Dynamically link against system SDL2" ON)
option(USE_SYSTEM_LIBSDL2 "Dynamically link against system SDL2" ON) # Ignored on Mac
option(USE_SYSTEM_LIBPNG "Dynamically link against system libpng" ON)
option(USE_SYSTEM_ZSTD "Dynamically link against system zstd" ${USE_SYSTEM_ZSTD})
option(USE_SYSTEM_MINIUPNPC "Dynamically link against system miniUPnPc" ${USE_SYSTEM_MINIUPNPC})
@ -241,9 +237,16 @@ if(USING_EGL)
set(OPENGL_LIBRARIES ${OPENGL_LIBRARIES} ${EGL_LIBRARIES})
endif()
if(NOT LIBRETRO AND NOT IOS)
if(NOT LIBRETRO AND NOT IOS AND NOT MACOSX)
find_package(SDL2)
endif()
if(MACOSX AND NOT IOS)
find_library(SDL2Fwk SDL2 REQUIRED PATHS SDL/macOS)
message(STATUS "found SDL2Fwk=${SDL2Fwk}")
add_definitions(-DHAVE_SYSCTLBYNAME)
endif()
include(FindThreads)
if(APPLE)
@ -1252,7 +1255,8 @@ elseif(WIN32)
else()
link_directories(dx9sdk/Lib/x86)
endif()
elseif(TARGET SDL2::SDL2)
elseif(LIBRETRO)
else()
set(TargetBin PPSSPPSDL)
# Require SDL
add_definitions(-DSDL)
@ -1267,7 +1271,6 @@ elseif(TARGET SDL2::SDL2)
SDL/SDLVulkanGraphicsContext.cpp
)
endif()
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
if(APPLE)
set(nativeExtra ${nativeExtra}
SDL/SDLMain.h
@ -1290,11 +1293,12 @@ elseif(TARGET SDL2::SDL2)
set_source_files_properties(SDL/PPSSPPAboutViewController.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
set_source_files_properties(Common/Battery/AppleBatteryClient.m PROPERTIES COMPILE_FLAGS -fobjc-arc)
set(nativeExtraLibs ${nativeExtraLibs} ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY})
set(nativeExtraLibs ${nativeExtraLibs} ${SDL2Fwk})
elseif(USING_EGL)
set(nativeExtraLibs ${nativeExtraLibs} pthread)
set(nativeExtraLibs ${nativeExtraLibs} pthread SDL2::SDL2)
else()
set(nativeExtraLibs ${nativeExtraLibs} SDL2::SDL2)
endif()
elseif(NOT LIBRETRO)
message(FATAL_ERROR "Could not find SDL2. Failing.")
endif()
if(WIN32)
@ -2547,10 +2551,10 @@ if(TargetBin)
else()
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${BigFontAssets} ${SHADER_FILES} ${THEME_FILE} ${DEBUGGER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource})
file(INSTALL "${CMAKE_SOURCE_DIR}/ext/vulkan/macOS/Frameworks/libMoltenVK.dylib" DESTINATION "${CMAKE_BINARY_DIR}/PPSSPPSDL.app/Contents/Frameworks/")
if(TARGET SDL2::SDL2 AND NOT USING_QT_UI)
add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app")
elseif(USING_QT_UI)
if(USING_QT_UI)
add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/Qt/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPQt.app")
else()
add_custom_command(TARGET ${TargetBin} POST_BUILD COMMAND /bin/bash "${CMAKE_SOURCE_DIR}/SDL/macbundle.sh" "${CMAKE_BINARY_DIR}/PPSSPPSDL.app")
endif()
endif()
elseif(WIN32)

View File

@ -1,5 +1,11 @@
#include "SDL_syswm.h"
#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(MAC)
#include "SDL2/SDL.h"
#include "SDL2/SDL_syswm.h"
#else
#include "SDL.h"
#include "SDL_syswm.h"
#endif
#include "Common/GPU/OpenGL/GLRenderManager.h"
#include "Common/GPU/OpenGL/GLCommon.h"

View File

@ -1,10 +1,12 @@
#pragma once
#ifdef _MSC_VER
#include "SDL/SDL.h"
#include "SDL/SDL_thread.h"
#else
#if PPSSPP_PLATFORM(MAC)
#include "SDL2/SDL.h"
#else
#include "SDL.h"
#include "SDL_thread.h"
#endif
#endif
#include <map>

View File

@ -7,7 +7,13 @@
#include <pwd.h>
#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(MAC)
#include "SDL2/SDL.h"
#include "SDL2/SDL_syswm.h"
#else
#include "SDL.h"
#include "SDL_syswm.h"
#endif
#include "SDL/SDLJoystick.h"
SDLJoystick *joystick = NULL;
@ -35,8 +41,6 @@ SDLJoystick *joystick = NULL;
#include "Common/GPU/OpenGL/GLRenderManager.h"
#include "Common/Profiler/Profiler.h"
#include "SDL_syswm.h"
#if defined(VK_USE_PLATFORM_XLIB_KHR)
#include <X11/Xlib.h>
#include <X11/Xutil.h>

View File

@ -5,7 +5,12 @@
Feel free to customize this file to suit your needs
*/
#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(MAC)
#include "SDL2/SDL.h"
#else
#include "SDL.h"
#endif
#include "SDLMain.h"
#include "Common/Profiler/Profiler.h"
#include <signal.h>

View File

@ -10,7 +10,11 @@
#include "Common/Data/Text/Parsers.h"
#include "Core/System.h"
#if PPSSPP_PLATFORM(MAC)
#include "SDL2/SDL_vulkan.h"
#else
#include "SDL_vulkan.h"
#endif
#include "SDLVulkanGraphicsContext.h"
#if defined(VK_USE_PLATFORM_METAL_EXT)

View File

@ -1,5 +1,11 @@
#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(MAC)
#include "SDL2/SDL.h"
#include "SDL2/SDL_syswm.h"
#else
#include "SDL.h"
#include "SDL_syswm.h"
#endif
#include "Common/GraphicsContext.h"
#include "Common/GPU/Vulkan/VulkanContext.h"

@ -1 +1 @@
Subproject commit f19a1d54b8a5af6cc378ea307e0ec676922eb4cc
Subproject commit c387d93ab5910b5a6be78b4840a5bbbc452f3ac8

View File

@ -3,39 +3,25 @@
PPSSPP="${1}"
PPSSPPSDL="${PPSSPP}/Contents/MacOS/PPSSPPSDL"
ls ${PPSSPPSDL}
if [ ! -f "${PPSSPPSDL}" ]; then
echo "No such file: ${PPSSPPSDL}!"
exit 0
fi
SDL=$(otool -L "${PPSSPPSDL}" | grep -v @executable_path | grep -Eo /.+libSDL.+dylib)
if [ "${SDL}" != "" ]; then
if [ ! -f "${SDL}" ]; then
echo "Cannot locate SDL: ${SDL}!"
exit 0
fi
# We only support using the local SDL framework.
# All the old detection code has been eliminated.
SDL=../SDL/macOS/SDL2.framework
echo "Installing SDL from ${SDL}..."
echo "Copying SDL2.framework..."
SDLNAME=$(basename "${SDL}")
mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0
cp -r "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0
install_name_tool -change "${SDL}" "@executable_path/../Frameworks/${SDLNAME}" "${PPSSPPSDL}" || exit 0
elif [ "$(otool -L "${PPSSPPSDL}" | grep @rpath/SDL)" != "" ]; then
cd "$(dirname "$0")"
RPATH="$(pwd)/macOS"
cd -
SDL="${RPATH}/SDL2.framework"
if [ ! -d "${SDL}" ]; then
echo "Cannot locate SDL.framework: ${SDL}!"
exit 0
fi
mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0
cp -r "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0
rm -rf "${PPSSPP}/Contents/Frameworks/SDL2.framework" || exit 0
mkdir -p "${PPSSPP}/Contents/Frameworks" || exit 0
cp -a "$SDL" "${PPSSPP}/Contents/Frameworks" || exit 0
install_name_tool -rpath "${RPATH}" "@executable_path/../Frameworks" "${PPSSPPSDL}" || echo "Already patched."
fi
install_name_tool -change "${SDL}" "@executable_path/../Frameworks/${SDLNAME}" "${PPSSPPSDL}" || exit 0
echo "Done."
GIT_VERSION_LINE=$(grep "PPSSPP_GIT_VERSION = " "$(dirname "${0}")/../git-version.cpp")
echo "Setting version to '${GIT_VERSION_LINE}'..."
@ -50,4 +36,5 @@ else
fi
# AdHoc codesign is required for Apple Silicon.
codesign -fs - --deep "${PPSSPP}" || exit 1
echo "Signing..."
#codesign -fs - --deep "${PPSSPP}" || exit 1

View File

@ -18,7 +18,13 @@
#ifdef SDL
#include <cstdio>
#include <SDL.h>
#include "ppsspp_config.h"
#if PPSSPP_PLATFORM(MAC)
#include "SDL2/SDL.h"
#else
#include "SDL.h"
#endif
#include "headless/SDLHeadlessHost.h"
#include "Common/GPU/OpenGL/GLCommon.h"