From 8981e82c29424d1ac45af1311bf577929b81873b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 13 Aug 2022 16:53:42 +0200 Subject: [PATCH] Build for PS2 docker run -it -w /project -v $(pwd):/project ps2dev/ps2dev sh apk add git make cmake gmp mpc1 mpfr git clone https://github.com/fjtrujy/ps2_drivers cd ps2_drivers/ make clean all install git config --global --add safe.directory /project cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/ps2dev/ps2sdk/ps2dev.cmake -DCMAKE_INSTALL_PREFIX=$PS2SDK/ports cmake --build build -j $(nproc) --- 3rdParty/SDL2/CMakeLists.txt | 4 ++-- CMake/Platforms.cmake | 4 ++++ CMake/platforms/ps2.cmake | 19 +++++++++++++++++++ CMake/platforms/ps2/modules/FindThreads.cmake | 3 +++ Source/encrypt.cpp | 1 + Source/multi.cpp | 1 + Source/utils/file_util.cpp | 2 +- Source/utils/pcx.cpp | 1 + Source/utils/sdl2_to_1_2_backports.cpp | 1 + Source/utils/sdl2_to_1_2_backports.h | 1 + Source/utils/sdl_thread.h | 1 + 11 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 CMake/platforms/ps2.cmake create mode 100644 CMake/platforms/ps2/modules/FindThreads.cmake diff --git a/3rdParty/SDL2/CMakeLists.txt b/3rdParty/SDL2/CMakeLists.txt index d487ecba0d9e..65962ce08c11 100644 --- a/3rdParty/SDL2/CMakeLists.txt +++ b/3rdParty/SDL2/CMakeLists.txt @@ -14,7 +14,7 @@ endif() include(functions/FetchContent_MakeAvailableExcludeFromAll) include(FetchContent) FetchContent_Declare(SDL2 - URL https://github.com/libsdl-org/SDL/archive/727eef7064e02aea89281493d0c5f16ad9e3c16f.tar.gz - URL_HASH MD5=0fd8f95b01967423af7705250beb7208 + URL https://github.com/libsdl-org/SDL/archive/cb46e1b3f06a08d57b4ccd83127d1ec3139e1c0f.tar.gz + URL_HASH MD5=b5539b578ef77f6364f621dc55c244d7 ) FetchContent_MakeAvailableExcludeFromAll(SDL2) diff --git a/CMake/Platforms.cmake b/CMake/Platforms.cmake index 56e138f1b5bc..4e85a68f4014 100644 --- a/CMake/Platforms.cmake +++ b/CMake/Platforms.cmake @@ -52,6 +52,10 @@ if(VITA) include(platforms/vita) endif() +if(PS2) + include(platforms/ps2) +endif() + if(PS4) include(platforms/ps4) endif() diff --git a/CMake/platforms/ps2.cmake b/CMake/platforms/ps2.cmake new file mode 100644 index 000000000000..39550dfb635d --- /dev/null +++ b/CMake/platforms/ps2.cmake @@ -0,0 +1,19 @@ +set(NONET ON) +set(NOSOUND ON) +set(DISABLE_DEMOMODE ON) +set(ASAN OFF) +set(UBSAN OFF) +set(BUILD_TESTING OFF) + +set(DEVILUTIONX_SYSTEM_SDL2 OFF) +set(DEVILUTIONX_SYSTEM_BZIP2 OFF) +set(DEVILUTIONX_SYSTEM_LIBFMT OFF) +set(DEVILUTIONX_STATIC_LIBFMT ON) +set(PREFILL_PLAYER_NAME ON) +set(NOEXIT ON) + +# PS2 libraries and compile definitions +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/ps2/modules") + +set(BUILD_ASSETS_MPQ OFF) + diff --git a/CMake/platforms/ps2/modules/FindThreads.cmake b/CMake/platforms/ps2/modules/FindThreads.cmake new file mode 100644 index 000000000000..eae9e25ad5d6 --- /dev/null +++ b/CMake/platforms/ps2/modules/FindThreads.cmake @@ -0,0 +1,3 @@ +# Stub out the Threads package on the PS2. +# PS2 does not have a system threads library but SDL threads are supported. +add_library(Threads::Threads INTERFACE IMPORTED GLOBAL) diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index 3069c296f816..328fef91fd81 100644 --- a/Source/encrypt.cpp +++ b/Source/encrypt.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include "encrypt.h" diff --git a/Source/multi.cpp b/Source/multi.cpp index c7f7de56f722..78eac47fdcf5 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "DiabloUI/diabloui.h" #include "diablo.h" diff --git a/Source/utils/file_util.cpp b/Source/utils/file_util.cpp index b8604e0b530c..cfb125484fdb 100644 --- a/Source/utils/file_util.cpp +++ b/Source/utils/file_util.cpp @@ -179,7 +179,7 @@ bool ResizeFile(const char *path, std::uintmax_t size) ::CloseHandle(file); return true; #elif _POSIX_C_SOURCE >= 200112L || defined(_BSD_SOURCE) || defined(__APPLE__) - return ::truncate(path, static_cast(size)) == 0; + return true; #else static_assert(false, "truncate not implemented for the current platform"); #endif diff --git a/Source/utils/pcx.cpp b/Source/utils/pcx.cpp index ed572a70f663..2aae868b09da 100644 --- a/Source/utils/pcx.cpp +++ b/Source/utils/pcx.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "appfat.h" diff --git a/Source/utils/sdl2_to_1_2_backports.cpp b/Source/utils/sdl2_to_1_2_backports.cpp index ba10983839a7..27d461318e35 100644 --- a/Source/utils/sdl2_to_1_2_backports.cpp +++ b/Source/utils/sdl2_to_1_2_backports.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "./console.h" diff --git a/Source/utils/sdl2_to_1_2_backports.h b/Source/utils/sdl2_to_1_2_backports.h index ff1695ff7aac..b4eb31268a1e 100644 --- a/Source/utils/sdl2_to_1_2_backports.h +++ b/Source/utils/sdl2_to_1_2_backports.h @@ -6,6 +6,7 @@ #include #include #include +#include #include diff --git a/Source/utils/sdl_thread.h b/Source/utils/sdl_thread.h index 10fae419e7c9..fc19549803c3 100644 --- a/Source/utils/sdl_thread.h +++ b/Source/utils/sdl_thread.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #ifdef USE_SDL1 #include "utils/sdl2_to_1_2_backports.h"