Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build libretro core for tvOS #1360

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 #################################
12 changes: 8 additions & 4 deletions Source/ee/EeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#error Unsupported CPU architecture
#endif

#if TARGET_OS_TV
#define DISABLE_PROTECTION
#endif

#endif

static CEeExecutor* g_eeExecutor = nullptr;
Expand Down Expand Up @@ -70,7 +74,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
jpd002 marked this conversation as resolved.
Show resolved Hide resolved
if(!m_running)
{
kern_return_t result = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &m_port);
Expand All @@ -90,7 +94,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 @@ -103,7 +107,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 @@ -272,7 +276,7 @@ void CEeExecutor::HandleExceptionInternal(int sigId, siginfo_t* sigInfo, void* b
signal(SIGSEGV, SIG_DFL);
}

#elif defined(__APPLE__)
#elif defined(__APPLE__) && !TARGET_OS_TV

void CEeExecutor::HandlerThreadProc()
{
Expand Down
3 changes: 2 additions & 1 deletion Source/ee/EeExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define NOMINMAX
#include <Windows.h>
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#include <mach/mach.h>
#include <thread>
#elif defined(__unix__)
Expand Down Expand Up @@ -56,7 +57,7 @@ class CEeExecutor : public CGenericMipsExecutor<BlockLookupTwoWay>
#elif defined(__unix__) || defined(__ANDROID__)
static void HandleException(int, siginfo_t*, void*);
void HandleExceptionInternal(int, siginfo_t*, void*);
#elif defined(__APPLE__)
#elif defined(__APPLE__) && !TARGET_OS_TV
void HandlerThreadProc();

mach_port_t m_port = MACH_PORT_NULL;
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 @@ -69,7 +69,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
2 changes: 1 addition & 1 deletion deps/Dependencies
Loading