[Amiga] Migrate from SDL1 to SDL2

This commit is contained in:
staphen
2026-09-26 14:36:46 +02:00
committed by Anders Jenbo
parent bd1ee963f7
commit 130aae0e8a
7 changed files with 8 additions and 89 deletions
-3
View File
@@ -31,9 +31,6 @@ jobs:
with:
fetch-depth: 0
- name: Run prep.sh script
run: ./Packaging/amiga/prep.sh
- name: Configure CMake
run: |
cmake \
+5
View File
@@ -22,6 +22,11 @@ if(TARGET_PLATFORM STREQUAL "dos")
URL https://github.com/diasurgical/SDL/archive/20b47a62a12f0c7be4052fb5b32eb21d709d6f06.tar.gz
URL_HASH MD5=6e77a1d1a79d7f0dd6231b39515a341f
)
elseif(AMIGA)
FetchContent_Declare(SDL2
URL https://github.com/diasurgical/SDL/archive/11b221d7309208b8a4724b1ae2c1c53cfb4513c3.tar.gz
URL_HASH MD5=9aeaa9f187d6b20c6927838f26fc6baf
)
else()
FetchContent_Declare(SDL2
URL https://github.com/libsdl-org/SDL/releases/download/release-2.32.8/SDL2-2.32.8.tar.gz
-32
View File
@@ -1,32 +0,0 @@
# Wrapper around CMake's bundled FindSDL module.
#
# The bundled module runs its own `find_package(Threads)` and appends
# `CMAKE_THREAD_LIBS_INIT` to the SDL libraries. AmigaOS has no POSIX threads
# library — SDL 1.2 uses native AmigaOS tasks — and `m68k-amigaos-g++` rejects
# both `-pthread` and `-lpthreads`, so strip the thread flag back out.
#
# This has to live in a wrapper rather than at the call site because
# dependencies built from source (notably SDL_audiolib) call `find_package(SDL)`
# themselves and propagate the flag through their own link interface.
include("${CMAKE_ROOT}/Modules/FindSDL.cmake")
if(AMIGA)
foreach(_devilutionx_sdl_var SDL_LIBRARY SDL_LIBRARIES SDL_LIBRARY_TEMP)
if(${_devilutionx_sdl_var})
list(FILTER ${_devilutionx_sdl_var} EXCLUDE REGEX "pthread")
endif()
endforeach()
unset(_devilutionx_sdl_var)
# The module also bakes the thread flag into the imported target's link
# interface, which is what dependencies actually consume.
if(TARGET SDL::SDL)
get_target_property(_devilutionx_sdl_iface SDL::SDL INTERFACE_LINK_LIBRARIES)
if(_devilutionx_sdl_iface)
list(FILTER _devilutionx_sdl_iface EXCLUDE REGEX "pthread")
set_target_properties(SDL::SDL PROPERTIES INTERFACE_LINK_LIBRARIES "${_devilutionx_sdl_iface}")
endif()
unset(_devilutionx_sdl_iface)
endif()
endif()
+2 -2
View File
@@ -4,10 +4,10 @@ set(BUILD_TESTING OFF)
set(ASAN OFF)
set(UBSAN OFF)
set(NONET ON)
set(USE_SDL1 ON)
set(SDL1_VIDEO_MODE_BPP 8)
set(DEVILUTIONX_DISPLAY_PIXELFORMAT SDL_PIXELFORMAT_INDEX8)
set(DEVILUTIONX_SYSTEM_BZIP2 OFF)
set(DEVILUTIONX_SYSTEM_SDL2 OFF)
set(DEVILUTIONX_SYSTEM_ZLIB OFF)
list(APPEND DEVILUTIONX_PLATFORM_LINK_LIBRARIES ZLIB::ZLIB)
-3
View File
@@ -1,9 +1,6 @@
FROM amigadev/crosstools:m68k-amigaos-gcc10
RUN apt-get update && apt-get install --no-install-recommends -y smpq
RUN mkdir /devilutionx-deps-build
COPY Packaging/amiga/prep.sh /devilutionx-deps-build/prep.sh
RUN cd /devilutionx-deps-build && ./prep.sh
CMD cmake -S. -Bbuild-amiga -DCPACK=ON \
-DCMAKE_BUILD_TYPE=Release \
-48
View File
@@ -1,48 +0,0 @@
#!/usr/bin/env bash
# exit when any command fails
set -euo pipefail
PARALLELISM="$(getconf _NPROCESSORS_ONLN)"
mkdir -p deps
cd deps
# SDL1.2
wget https://github.com/AmigaPorts/SDL-1.2/archive/AmigaOS3.tar.gz -O SDL-1.2.tar.gz
tar -xvf SDL-1.2.tar.gz
cd SDL-1.2-AmigaOS3
# GCC 14+ promotes several legacy-C conformance warnings to hard errors by
# default (implicit-function-declaration, implicit-int, int-conversion,
# incompatible-pointer-types, return-mismatch, etc). This codebase predates
# that change and trips all of them; downgrade back to warnings so it still
# builds on newer GCC. Some of these warning names don't exist before GCC 14
# at all, so -Wno-error=<name> is a hard "unrecognized option" error on
# older GCC rather than a no-op -- gate this on the actual compiler version
# rather than applying it unconditionally.
# Appended at end-of-file rather than a specific line, since this Makefile
# is fetched from the upstream master branch and its exact contents can
# change; Make variable assignments apply regardless of where they appear.
GCC_MAJOR_VERSION="$(m68k-amigaos-gcc -dumpversion | cut -d. -f1)"
if [ "$GCC_MAJOR_VERSION" -ge 14 ]; then
export CFLAGS="-Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=int-conversion -Wno-error=incompatible-pointer-types -Wno-error=return-mismatch -Wno-error=return-type -Wno-error=pointer-sign -Wno-error=pointer-to-int-cast -Wno-error=int-to-pointer-cast"
fi
cmake \
-S . \
-B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DM68K_COMMON="-s -ffast-math -fomit-frame-pointer -fbbb=-" \
-DM68K_CPU=68040 \
-DM68K_FPU=hard \
-DAPOLLOBLIT=OFF \
-DGIT_TAG=1.2.15
cmake --build build -j"$PARALLELISM"
# cmake --install is broken on amigadev/crosstools
cmake -P build/cmake_install.cmake
cd ..
+1 -1
View File
@@ -702,7 +702,7 @@ extern "C" char *SDL_GetPrefPath(const char *org, const char *app)
#elif !defined(__APPLE__)
namespace {
#if !defined(__QNXNTO__) && !defined(__amigaos__) && !(defined(WINVER) && WINVER <= 0x0500 && (!defined(_WIN32_WINNT) || _WIN32_WINNT == 0))
#if !defined(__QNXNTO__) && !(defined(WINVER) && WINVER <= 0x0500 && (!defined(_WIN32_WINNT) || _WIN32_WINNT == 0))
char *readSymLink(const char *path)
{
// From sdl2-2.0.9/src/filesystem/unix/SDL_sysfilesystem.c