From 44b8d13ff8baebdb639a1d21b0b5683e4e460ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=9A=93?= Date: Wed, 15 Jan 2025 22:10:50 -0500 Subject: [PATCH] Add Nintendo consoles, PS2 and PSP to libretro CI I'll also add PlayStation Vita and Xbox once I figure out how. Other than that, I think that's all the game consoles RetroArch supports that aren't Linux-based! --- .github/workflows/autobuild.yml | 173 +++++++++++++++++++++++++ meson.build | 1 + subprojects/packagefiles/liblzma.patch | 36 ++++- subprojects/packagefiles/zlib.patch | 57 ++++++++ 4 files changed, 266 insertions(+), 1 deletion(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 4ac1336a..b9ea3511 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -758,3 +758,176 @@ jobs: with: name: libretro-mkxp-z.darwin.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: ${{ runner.temp }}/retro-phase2 + + build-retro-phase2-nintendo: + needs: build-retro-phase1 + name: LR Nintendo ${{ matrix.arch_mkxpz }} + runs-on: ubuntu-latest + container: devkitpro/devkit${{ matrix.arch_devkitpro }}:latest + strategy: + fail-fast: false + matrix: + include: + - arch_mkxpz: armv6 + arch_gcc: arm-none-eabi + arch_devkitpro: arm + cpu_family: arm + cpu: generic-armv6k + endian: little + - arch_mkxpz: arm64 + arch_gcc: aarch64-none-elf + arch_devkitpro: a64 + cpu_family: aarch64 + cpu: generic-armv8-a + endian: little + - arch_mkxpz: power + arch_gcc: powerpc-eabi + arch_devkitpro: ppc + cpu_family: ppc + cpu: ppc + endian: big + steps: + - id: short-sha + uses: benjlevesque/short-sha@v2.2 + with: + length: 7 + + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: retro-phase1.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: retro/build/retro-phase1 + + - name: Install dependencies + run: | + apt update + apt install -y git python pip ninja-build cmake + pip install meson + + - name: Build phase 2 + run: | + echo "[binaries]" | tee -a ~/cross.ini + echo "c = '/opt/devkitpro/devkit$(echo ${{ matrix.arch_devkitpro }} | tr a-z A-Z)/bin/${{ matrix.arch_gcc }}-gcc'" | tee -a ~/cross.ini + echo "cpp = '/opt/devkitpro/devkit$(echo ${{ matrix.arch_devkitpro }} | tr a-z A-Z)/bin/${{ matrix.arch_gcc }}-g++'" | tee -a ~/cross.ini + echo "ar = '/opt/devkitpro/devkit$(echo ${{ matrix.arch_devkitpro }} | tr a-z A-Z)/bin/${{ matrix.arch_gcc }}-ar'" | tee -a ~/cross.ini + echo "strip = '/opt/devkitpro/devkit$(echo ${{ matrix.arch_devkitpro }} | tr a-z A-Z)/bin/${{ matrix.arch_gcc }}-strip'" | tee -a ~/cross.ini + echo "[host_machine]" | tee -a ~/cross.ini + echo "system = 'none'" | tee -a ~/cross.ini + echo "cpu_family = '${{ matrix.cpu_family }}'" | tee -a ~/cross.ini + echo "cpu = '${{ matrix.cpu }}'" | tee -a ~/cross.ini + echo "endian = '${{ matrix.endian }}'" | tee -a ~/cross.ini + + mkdir ~/retro-phase2 + cp retro/core.info ~/retro-phase2/libretro-mkxp-z.info + meson setup build --cross-file ~/cross.ini -Ddefault_library=static --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 + cd build + ninja -v + /opt/devkitpro/devkit$(echo ${{ matrix.arch_devkitpro }} | tr a-z A-Z)/bin/${{ matrix.arch_gcc }}-strip libretro-mkxp-z.a + mv libretro-mkxp-z.a ~/retro-phase2 + + - uses: actions/upload-artifact@v4 + with: + name: libretro-mkxp-z.nintendo.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: ~/retro-phase2 + + build-retro-phase2-ps2: + needs: build-retro-phase1 + name: LR PlayStation 2 + runs-on: ubuntu-latest + container: ps2dev/ps2dev:latest + steps: + - id: short-sha + uses: benjlevesque/short-sha@v2.2 + with: + length: 7 + + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: retro-phase1.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: retro/build/retro-phase1 + + - name: Install dependencies + run: | + apk update + apk add git meson cmake + + - name: Build phase 2 + run: | + echo "[binaries]" | tee -a ~/cross.ini + echo "c = 'mips64r5900el-ps2-elf-gcc'" | tee -a ~/cross.ini + echo "cpp = 'mips64r5900el-ps2-elf-g++'" | tee -a ~/cross.ini + echo "ar = 'mips64r5900el-ps2-elf-ar'" | tee -a ~/cross.ini + echo "strip = 'mips64r5900el-ps2-elf-strip'" | tee -a ~/cross.ini + echo "[host_machine]" | tee -a ~/cross.ini + echo "system = 'none'" | tee -a ~/cross.ini + echo "cpu_family = 'mips64'" | tee -a ~/cross.ini + echo "cpu = 'mips64el'" | tee -a ~/cross.ini + echo "endian = 'little'" | tee -a ~/cross.ini + + mkdir ~/retro-phase2 + cp retro/core.info ~/retro-phase2/libretro-mkxp-z.info + meson setup build --cross-file ~/cross.ini -Ddefault_library=static --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 + cd build + ninja -v + mips64r5900el-ps2-elf-strip libretro-mkxp-z.a + mv libretro-mkxp-z.a ~/retro-phase2 + + - uses: actions/upload-artifact@v4 + with: + name: libretro-mkxp-z.ps2.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: ~/retro-phase2 + + build-retro-phase2-psp: + needs: build-retro-phase1 + name: LR PlayStation Portable + runs-on: ubuntu-latest + container: pspdev/pspdev:latest + steps: + - id: short-sha + uses: benjlevesque/short-sha@v2.2 + with: + length: 7 + + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: retro-phase1.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: retro/build/retro-phase1 + + - name: Install dependencies + run: | + apk update + apk add git meson cmake + + - name: Build phase 2 + run: | + echo "[binaries]" | tee -a ~/cross.ini + echo "c = 'psp-gcc'" | tee -a ~/cross.ini + echo "cpp = 'psp-g++'" | tee -a ~/cross.ini + echo "ar = 'psp-ar'" | tee -a ~/cross.ini + echo "strip = 'psp-strip'" | tee -a ~/cross.ini + echo "[host_machine]" | tee -a ~/cross.ini + echo "system = 'none'" | tee -a ~/cross.ini + echo "cpu_family = 'mips64'" | tee -a ~/cross.ini + echo "cpu = 'mips64el'" | tee -a ~/cross.ini + echo "endian = 'little'" | tee -a ~/cross.ini + + mkdir ~/retro-phase2 + cp retro/core.info ~/retro-phase2/libretro-mkxp-z.info + meson setup build --cross-file ~/cross.ini -Ddefault_library=static --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 + cd build + ninja -v + psp-strip libretro-mkxp-z.a + mv libretro-mkxp-z.a ~/retro-phase2 + + - uses: actions/upload-artifact@v4 + with: + name: libretro-mkxp-z.psp.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: ~/retro-phase2 diff --git a/meson.build b/meson.build index b8ac9433..cf4122c9 100644 --- a/meson.build +++ b/meson.build @@ -53,6 +53,7 @@ if get_option('retro') == true 'CMAKE_POSITION_INDEPENDENT_CODE': true, 'CMAKE_BUILD_TYPE': 'None', 'ENABLE_STATIC_LIB': true, + 'ENABLE_SHARED_LIB': false, 'ENABLE_LIB_ONLY': true, }) diff --git a/subprojects/packagefiles/liblzma.patch b/subprojects/packagefiles/liblzma.patch index cdd318dc..1b729e0e 100644 --- a/subprojects/packagefiles/liblzma.patch +++ b/subprojects/packagefiles/liblzma.patch @@ -1,6 +1,7 @@ -# Fixes a compilation error when compiling liblzma in MSYS2. +# Fixes compilation errors when compiling liblzma in MSYS2 and for homebrew consoles. diff --git a/CMakeLists.txt b/CMakeLists.txt +index ea1674b..d700021 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,6 @@ if((MINGW OR CYGWIN) AND ( @@ -11,3 +12,36 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt string(REPLACE " " "\\x20" PACKAGE_NAME_DEFINITION "${PACKAGE_NAME}") # Use octal because "Program Files" would become \x20F. +@@ -1113,23 +1112,6 @@ target_compile_definitions(liblzma PRIVATE TUKLIB_SYMBOL_PREFIX=lzma_) + tuklib_cpucores(liblzma) + tuklib_physmem(liblzma) + +-# While liblzma can be built without tuklib_cpucores or tuklib_physmem +-# modules, the liblzma API functions lzma_cputhreads() and lzma_physmem() +-# will then be useless (which isn't too bad but still unfortunate). Since +-# I expect the CMake-based builds to be only used on systems that are +-# supported by these tuklib modules, problems with these tuklib modules +-# are considered a hard error for now. This hopefully helps to catch bugs +-# in the CMake versions of the tuklib checks. +-if(NOT TUKLIB_CPUCORES_FOUND OR NOT TUKLIB_PHYSMEM_FOUND) +- # Use SEND_ERROR instead of FATAL_ERROR. If someone reports a bug, +- # seeing the results of the remaining checks can be useful too. +- message(SEND_ERROR +- "tuklib_cpucores() or tuklib_physmem() failed. " +- "Unless you really are building for a system where these " +- "modules are not supported (unlikely), this is a bug in the " +- "included cmake/tuklib_*.cmake files that should be fixed. " +- "To build anyway, edit this CMakeLists.txt to ignore this error.") +-endif() + + # Check for __attribute__((__constructor__)) support. + # This needs -Werror because some compilers just warn +@@ -1747,7 +1729,7 @@ endif() + # xz + ############################################################################# + +-if(NOT MSVC OR MSVC_VERSION GREATER_EQUAL 1900) ++if(FALSE) + add_executable(xz + src/common/mythread.h + src/common/sysdefs.h diff --git a/subprojects/packagefiles/zlib.patch b/subprojects/packagefiles/zlib.patch index 371f663f..33794f9d 100644 --- a/subprojects/packagefiles/zlib.patch +++ b/subprojects/packagefiles/zlib.patch @@ -1,4 +1,6 @@ # This patch prevents zlib's build system from renaming zconf.h to zconf.h.included because libzip won't be able to find zconf.h otherwise. +# Also prevents the zlib shared library from being compiled to fix builds for homebrew consoles. +# Also includes unistd.h at the top of gzguts.h, again to fix builds for homebrew consoles. diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt @@ -21,3 +23,58 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein +@@ -149,41 +138,8 @@ if(MINGW) + set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) + endif(MINGW) + +-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +-target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) + target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) +-set_target_properties(zlib PROPERTIES SOVERSION 1) +- +-if(NOT CYGWIN) +- # This property causes shared libraries on Linux to have the full version +- # encoded into their final filename. We disable this on Cygwin because +- # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll +- # seems to be the default. +- # +- # This has no effect with MSVC, on that platform the version info for +- # the DLL comes from the resource file win32/zlib1.rc +- set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) +-endif() +- +-if(UNIX) +- # On unix-like platforms the library is almost always called libz +- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) +- if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX)) +- set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") +- endif() +-elseif(BUILD_SHARED_LIBS AND WIN32) +- # Creates zlib1.dll when building shared library version +- set_target_properties(zlib PROPERTIES SUFFIX "1.dll") +-endif() +- +-if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) +- install(TARGETS zlib zlibstatic +- RUNTIME DESTINATION "${INSTALL_BIN_DIR}" +- ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" +- LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) +-endif() + if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) + install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}") + endif() +diff --git a/gzguts.h b/gzguts.h +--- a/gzguts.h ++++ b/gzguts.h +@@ -2,6 +2,9 @@ + * Copyright (C) 2004-2024 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ ++#ifdef __unix__ ++# include ++#endif + + #ifdef _LARGEFILE64_SOURCE + # ifndef _LARGEFILE_SOURCE