Skip to content

Commit

Permalink
Build libretro core for tvOS
Browse files Browse the repository at this point in the history
  • Loading branch information
warmenhoven committed Mar 8, 2024
1 parent b66f306 commit 28b2eb4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
18 changes: 16 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 #################################
10 changes: 5 additions & 5 deletions Source/ee/EeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ 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;
sigAction.sa_flags = SA_SIGINFO;
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);
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 3 additions & 1 deletion Source/ee/EeExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#ifdef _WIN32
#include <Windows.h>
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#include <mach/mach.h>
#include <thread>
#include <signal.h>
#elif defined(__unix__)
#include <signal.h>
#endif
Expand Down Expand Up @@ -43,7 +45,7 @@ class CEeExecutor : public CGenericMipsExecutor<BlockLookupTwoWay>
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__)
Expand Down
6 changes: 5 additions & 1 deletion Source/ui_libretro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 28b2eb4

Please sign in to comment.