Skip to content

Commit

Permalink
Build for PS2
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
AJenbo committed Aug 13, 2022
1 parent 4cf0053 commit 8981e82
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 3 deletions.
4 changes: 2 additions & 2 deletions 3rdParty/SDL2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 4 additions & 0 deletions CMake/Platforms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ if(VITA)
include(platforms/vita)
endif()

if(PS2)
include(platforms/ps2)
endif()

if(PS4)
include(platforms/ps4)
endif()
Expand Down
19 changes: 19 additions & 0 deletions CMake/platforms/ps2.cmake
Original file line number Diff line number Diff line change
@@ -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)

3 changes: 3 additions & 0 deletions CMake/platforms/ps2/modules/FindThreads.cmake
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions Source/encrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <memory>

#include <SDL.h>
#include <SDL_endian.h>
#include <pkware.h>

#include "encrypt.h"
Expand Down
1 change: 1 addition & 0 deletions Source/multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <config.h>

#include <fmt/format.h>
#include <ctime>

#include "DiabloUI/diabloui.h"
#include "diablo.h"
Expand Down
2 changes: 1 addition & 1 deletion Source/utils/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<off_t>(size)) == 0;
return true;
#else
static_assert(false, "truncate not implemented for the current platform");
#endif
Expand Down
1 change: 1 addition & 0 deletions Source/utils/pcx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <cstring>
#include <memory>
#include <SDL_endian.h>

#include "appfat.h"

Expand Down
1 change: 1 addition & 0 deletions Source/utils/sdl2_to_1_2_backports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <algorithm>
#include <cstddef>
#include <SDL_getenv.h>

#include "./console.h"

Expand Down
1 change: 1 addition & 0 deletions Source/utils/sdl2_to_1_2_backports.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <cstdio>
#include <sys/stat.h>
#include <sys/types.h>
#include <cstring>

#include <SDL.h>

Expand Down
1 change: 1 addition & 0 deletions Source/utils/sdl_thread.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <SDL.h>
#include <SDL_thread.h>
#include <memory>
#ifdef USE_SDL1
#include "utils/sdl2_to_1_2_backports.h"
Expand Down

0 comments on commit 8981e82

Please sign in to comment.