From 28b2eb482612313eacbcb991c16f6c1c3f861ebc Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Thu, 7 Mar 2024 00:53:29 -0500 Subject: [PATCH] Build libretro core for tvOS --- .gitlab-ci.yml | 18 ++++++++++++++++-- Source/ee/EeExecutor.cpp | 10 +++++----- Source/ee/EeExecutor.h | 4 +++- Source/ui_libretro/CMakeLists.txt | 6 +++++- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e017c1707e..55e71a5a07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,8 @@ GIT_SUBMODULE_STRATEGY: recursive CORENAME: play API_LEVEL: 19 - CORE_ARGS: -DBUILD_LIBRETRO_CORE=ON -DBUILD_PLAY=OFF -DENABLE_AMAZON_S3=off -DBUILD_TESTS=OFF + BASE_CORE_ARGS: -DBUILD_LIBRETRO_CORE=ON -DBUILD_PLAY=OFF -DENABLE_AMAZON_S3=off -DBUILD_TESTS=OFF + CORE_ARGS: $BASE_CORE_ARGS EXTRA_PATH: Source/ui_libretro .core-defs-win: @@ -48,6 +49,10 @@ include: - project: 'libretro-infrastructure/ci-templates' file: '/ios-cmake.yml' + # tvOS + - project: 'libretro-infrastructure/ci-templates' + file: '/tvos-cmake.yml' + # Stages for building stages: - build-prepare @@ -126,7 +131,16 @@ libretro-build-ios-arm64: - .libretro-ios-cmake-arm64 - .core-defs variables: - CORE_ARGS: -DBUILD_LIBRETRO_CORE=ON -DBUILD_PLAY=OFF -DENABLE_AMAZON_S3=off -DBUILD_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=deps/Dependencies/cmake-ios/ios.cmake -DTARGET_IOS=ON + CORE_ARGS: $BASE_CORE_ARGS -DCMAKE_TOOLCHAIN_FILE=deps/Dependencies/cmake-ios/ios.cmake -DTARGET_IOS=ON LIBNAME: ${CORENAME}_libretro_ios.dylib +# tvOS +libretro-build-tvos-arm64: + extends: + - .libretro-tvos-cmake-arm64 + - .core-defs + variables: + CORE_ARGS: $BASE_CORE_ARGS -DIOS_PLATFORM=TVOS -DCMAKE_TOOLCHAIN_FILE=deps/Dependencies/cmake-ios/ios.cmake -DTARGET_IOS=ON + LIBNAME: ${CORENAME}_libretro_tvos.dylib + ################################### CONSOLES ################################# diff --git a/Source/ee/EeExecutor.cpp b/Source/ee/EeExecutor.cpp index 534313a99c..96c95ad611 100644 --- a/Source/ee/EeExecutor.cpp +++ b/Source/ee/EeExecutor.cpp @@ -52,7 +52,7 @@ void CEeExecutor::AddExceptionHandler() #if defined(_WIN32) m_handler = AddVectoredExceptionHandler(TRUE, &CEeExecutor::HandleException); assert(m_handler != NULL); -#elif defined(__unix__) || defined(__ANDROID__) +#elif defined(__unix__) || defined(__ANDROID__) || TARGET_OS_TV struct sigaction sigAction; sigAction.sa_handler = nullptr; sigAction.sa_sigaction = &HandleException; @@ -60,7 +60,7 @@ void CEeExecutor::AddExceptionHandler() sigemptyset(&sigAction.sa_mask); int result = sigaction(SIGSEGV, &sigAction, nullptr); assert(result >= 0); -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !TARGET_OS_TV if(!m_running) { kern_return_t result = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_port); @@ -80,7 +80,7 @@ void CEeExecutor::RemoveExceptionHandler() #if defined(_WIN32) RemoveVectoredExceptionHandler(m_handler); -#elif defined(__APPLE__) +#elif defined(__APPLE__) && !TARGET_OS_TV m_running = false; m_handlerThread.join(); #endif @@ -93,7 +93,7 @@ void CEeExecutor::RemoveExceptionHandler() void CEeExecutor::AttachExceptionHandlerToThread() { //Only necessary for macOS and iOS since the handler is set on a thread basis -#if defined(__APPLE__) +#if defined(__APPLE__) && !TARGET_OS_TV assert(m_running); auto result = mach_port_insert_right(mach_task_self(), m_port, m_port, MACH_MSG_TYPE_MAKE_SEND); @@ -233,7 +233,7 @@ LONG CEeExecutor::HandleExceptionInternal(_EXCEPTION_POINTERS* exceptionInfo) return EXCEPTION_CONTINUE_SEARCH; } -#elif defined(__unix__) || defined(__ANDROID__) +#elif defined(__unix__) || defined(__ANDROID__) || TARGET_OS_TV void CEeExecutor::HandleException(int sigId, siginfo_t* sigInfo, void* baseContext) { diff --git a/Source/ee/EeExecutor.h b/Source/ee/EeExecutor.h index 258e48464b..b0aa7c3aea 100644 --- a/Source/ee/EeExecutor.h +++ b/Source/ee/EeExecutor.h @@ -3,8 +3,10 @@ #ifdef _WIN32 #include #elif defined(__APPLE__) +#include #include #include +#include #elif defined(__unix__) #include #endif @@ -43,7 +45,7 @@ class CEeExecutor : public CGenericMipsExecutor LONG HandleExceptionInternal(_EXCEPTION_POINTERS*); LPVOID m_handler = NULL; -#elif defined(__unix__) || defined(__ANDROID__) +#elif defined(__unix__) || defined(__ANDROID__) || TARGET_OS_TV static void HandleException(int, siginfo_t*, void*); void HandleExceptionInternal(int, siginfo_t*, void*); #elif defined(__APPLE__) diff --git a/Source/ui_libretro/CMakeLists.txt b/Source/ui_libretro/CMakeLists.txt index b84b0c402d..388a80d58e 100644 --- a/Source/ui_libretro/CMakeLists.txt +++ b/Source/ui_libretro/CMakeLists.txt @@ -61,7 +61,11 @@ if(TARGET_PLATFORM_ANDROID) set_target_properties(play_libretro PROPERTIES SUFFIX "_android.so") endif() if(TARGET_PLATFORM_IOS) - set_target_properties(play_libretro PROPERTIES SUFFIX "_ios.dylib") + if(IOS_PLATFORM STREQUAL "TVOS") + set_target_properties(play_libretro PROPERTIES SUFFIX "_tvos.dylib") + else() + set_target_properties(play_libretro PROPERTIES SUFFIX "_ios.dylib") + endif() endif() target_link_libraries(play_libretro ${PROJECT_LIBS})