mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
Ports: Add OpenRCT2
This commit is contained in:
parent
839c23417d
commit
b1793868b0
Notes:
sideshowbarker
2024-07-17 00:47:29 +09:00
Author: https://github.com/janso3 Commit: https://github.com/SerenityOS/serenity/commit/b1793868b0 Pull-request: https://github.com/SerenityOS/serenity/pull/17371 Reviewed-by: https://github.com/timschumi ✅
11 changed files with 327 additions and 0 deletions
|
@ -187,6 +187,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
|
|||
| [`nyancat`](nyancat/) | Nyancat | | https://github.com/klange/nyancat |
|
||||
| [`oksh`](oksh/) | oksh | 7.1 | https://github.com/ibara/oksh |
|
||||
| [`OpenJDK`](OpenJDK/) | OpenJDK | 17.0.2 | https://openjdk.java.net/ |
|
||||
| [`openrct2`](openrct2/) | OpenRCT2 | 0.4.3 | https://openrct2.org/ |
|
||||
| [`openssh`](openssh/) | OpenSSH | 9.0-94eb685 | https://github.com/openssh/openssh-portable |
|
||||
| [`openssl`](openssl/) | OpenSSL | 1.1.1s | https://www.openssl.org/ |
|
||||
| [`openttd`](openttd/) | OpenTTD | 12.2 | https://www.openttd.org/ |
|
||||
|
|
53
Ports/openrct2/package.sh
Executable file
53
Ports/openrct2/package.sh
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env -S bash ../.port_include.sh
|
||||
port='openrct2'
|
||||
version='0.4.3'
|
||||
auth_type='sha256'
|
||||
depends=(
|
||||
'curl'
|
||||
'flac'
|
||||
'fontconfig'
|
||||
'freetype'
|
||||
'libicu'
|
||||
'libogg'
|
||||
'libpng'
|
||||
'libvorbis'
|
||||
'libzip'
|
||||
'nlohmann-json'
|
||||
'openssl'
|
||||
'SDL2'
|
||||
'speexdsp'
|
||||
'zlib'
|
||||
)
|
||||
files="https://github.com/OpenRCT2/OpenRCT2/archive/refs/tags/v${version}.tar.gz ${port}-${version}.tar.gz 1269759b3a90717f379cd375f30629e3f24d3fdeb0c54cc1dca03676e64731ef
|
||||
https://github.com/OpenRCT2/OpenRCT2/releases/download/v${version}/OpenRCT2-${version}-linux-x86_64.tar.gz OpenRCT2-${version}-linux-x86_64.tar.gz 3691aa42e0b2eff80609688930d87b8cb8b97fb57f2ed624d3ed57e2eefb4fcf"
|
||||
useconfigure='true'
|
||||
workdir="OpenRCT2-${version}"
|
||||
configopts=(
|
||||
"-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt"
|
||||
"-DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local/"
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
"-DDISABLE_DISCORD_RPC=ON"
|
||||
"-DDISABLE_GOOGLE_BENCHMARK=ON"
|
||||
"-DWITH_TESTS=OFF"
|
||||
"-DDISABLE_OPENGL=ON")
|
||||
icon_file='resources/logo/icon_x16.png'
|
||||
launcher_name='OpenRCT2'
|
||||
launcher_category='Games'
|
||||
launcher_command='/usr/local/bin/openrct2'
|
||||
|
||||
configure() {
|
||||
mkdir -p "${PORT_BUILD_DIR}/OpenRCT2-${version}-build"
|
||||
cd "${PORT_BUILD_DIR}/OpenRCT2-${version}-build"
|
||||
cmake -G Ninja "${configopts[@]}" "${PORT_BUILD_DIR}/OpenRCT2-${version}"
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${PORT_BUILD_DIR}/OpenRCT2-${version}-build"
|
||||
mv "${PORT_BUILD_DIR}/OpenRCT2/data/g2.dat" .
|
||||
ninja
|
||||
}
|
||||
|
||||
install() {
|
||||
cd "${PORT_BUILD_DIR}/OpenRCT2-${version}-build"
|
||||
ninja install
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Tue, 7 Feb 2023 21:10:21 +0100
|
||||
Subject: [PATCH] Add SerenityOS platform detection
|
||||
|
||||
We teach OpenRCT2 about the name of our platform.
|
||||
---
|
||||
src/openrct2/Version.h | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/openrct2/Version.h b/src/openrct2/Version.h
|
||||
index 0e5d83aaf2cf0b0e2562065cab6c7b1526a0f1e9..428552a4f78cc9d21a15f4641144fe65b6c751e4 100644
|
||||
--- a/src/openrct2/Version.h
|
||||
+++ b/src/openrct2/Version.h
|
||||
@@ -70,6 +70,9 @@
|
||||
#ifdef __EMSCRIPTEN__
|
||||
# define OPENRCT2_PLATFORM "Emscripten"
|
||||
#endif
|
||||
+#ifdef __serenity__
|
||||
+# define OPENRCT2_PLATFORM "SerenityOS"
|
||||
+#endif
|
||||
#ifndef OPENRCT2_PLATFORM
|
||||
# error Unknown platform!
|
||||
#endif
|
36
Ports/openrct2/patches/0002-Add-missing-includes.patch
Normal file
36
Ports/openrct2/patches/0002-Add-missing-includes.patch
Normal file
|
@ -0,0 +1,36 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Tue, 7 Feb 2023 21:21:46 +0100
|
||||
Subject: [PATCH] Add missing includes
|
||||
|
||||
These are missing when compiling the release build.
|
||||
---
|
||||
src/openrct2/core/String.cpp | 1 +
|
||||
src/openrct2/network/Socket.cpp | 2 ++
|
||||
2 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/openrct2/core/String.cpp b/src/openrct2/core/String.cpp
|
||||
index 76c4574ed6e060dc7032b0a8c346bdbc3a435a2d..fbe23e4af894e3dbf4bc57ba3370e3f9e2ed24e7 100644
|
||||
--- a/src/openrct2/core/String.cpp
|
||||
+++ b/src/openrct2/core/String.cpp
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
+#include <alloca.h>
|
||||
#ifndef _WIN32
|
||||
# include <unicode/ucnv.h>
|
||||
# include <unicode/unistr.h>
|
||||
diff --git a/src/openrct2/network/Socket.cpp b/src/openrct2/network/Socket.cpp
|
||||
index 89803e28568efd38dd82845f89af97e47366f5b6..e166ed45d158d0cf516ff83b7992e04780f28edb 100644
|
||||
--- a/src/openrct2/network/Socket.cpp
|
||||
+++ b/src/openrct2/network/Socket.cpp
|
||||
@@ -51,6 +51,8 @@
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
+ #include <sys/time.h>
|
||||
+ #include <sys/select.h>
|
||||
#include "../common.h"
|
||||
using SOCKET = int32_t;
|
||||
#define SOCKET_ERROR -1
|
|
@ -0,0 +1,23 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Tue, 7 Feb 2023 21:25:16 +0100
|
||||
Subject: [PATCH] Read the executable path from /proc/self/exe
|
||||
|
||||
When looking for the executable path, we behave exactly like Linux.
|
||||
---
|
||||
src/openrct2/platform/Platform.Linux.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp
|
||||
index fb1f1e58d92a9e8823f1c8ff82bcf1efc448a8fd..eea10444874fced76027421350c7a4402bbbbfe0 100644
|
||||
--- a/src/openrct2/platform/Platform.Linux.cpp
|
||||
+++ b/src/openrct2/platform/Platform.Linux.cpp
|
||||
@@ -129,7 +129,7 @@ namespace Platform
|
||||
std::string GetCurrentExecutablePath()
|
||||
{
|
||||
char exePath[PATH_MAX] = { 0 };
|
||||
-# ifdef __linux__
|
||||
+# if defined(__linux__) || defined(__serenity__)
|
||||
auto bytesRead = readlink("/proc/self/exe", exePath, sizeof(exePath));
|
||||
if (bytesRead == -1)
|
||||
{
|
32
Ports/openrct2/patches/0004-Remove-use-of-strptime.patch
Normal file
32
Ports/openrct2/patches/0004-Remove-use-of-strptime.patch
Normal file
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Tue, 7 Feb 2023 21:36:54 +0100
|
||||
Subject: [PATCH] Remove use of strptime()
|
||||
|
||||
This is a hack to patch out strptime() from duktape, which is not being used by this project.
|
||||
---
|
||||
src/thirdparty/duktape/duk_config.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/thirdparty/duktape/duk_config.h b/src/thirdparty/duktape/duk_config.h
|
||||
index 4ac2e1d54dfc5da74136effbcb0e569c6ddea50a..b676781634c55ecb6c45f6cf01c0e9d1ee2afc75 100644
|
||||
--- a/src/thirdparty/duktape/duk_config.h
|
||||
+++ b/src/thirdparty/duktape/duk_config.h
|
||||
@@ -221,7 +221,7 @@
|
||||
|
||||
/* Generic Unix (includes Cygwin) */
|
||||
#if defined(__unix) || defined(__unix__) || defined(unix) || \
|
||||
- defined(DUK_F_LINUX) || defined(DUK_F_BSD)
|
||||
+ defined(DUK_F_LINUX) || defined(DUK_F_BSD) || defined(__serenity__)
|
||||
#define DUK_F_UNIX
|
||||
#endif
|
||||
|
||||
@@ -840,7 +840,7 @@
|
||||
/* --- Generic UNIX --- */
|
||||
#define DUK_USE_DATE_NOW_GETTIMEOFDAY
|
||||
#define DUK_USE_DATE_TZO_GMTIME_R
|
||||
-#define DUK_USE_DATE_PRS_STRPTIME
|
||||
+#undef DUK_USE_DATE_PRS_STRPTIME
|
||||
#define DUK_USE_DATE_FMT_STRFTIME
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
|
@ -0,0 +1,23 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Tue, 7 Feb 2023 22:16:32 +0100
|
||||
Subject: [PATCH] Don't try linking to stdc++fs
|
||||
|
||||
This code tried to link to stdc++fs for std::filesystem features, which are already included in our toolchain.
|
||||
---
|
||||
src/openrct2/CMakeLists.txt | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt
|
||||
index 6a1a1f081a0131d0cd93b558802989804ba4df67..377c62dbd70fe359bf58f7dddd5c302c8f1a15a4 100644
|
||||
--- a/src/openrct2/CMakeLists.txt
|
||||
+++ b/src/openrct2/CMakeLists.txt
|
||||
@@ -38,7 +38,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
||||
SET_CHECK_CXX_FLAGS(${PROJECT_NAME})
|
||||
|
||||
# GCC / Clang likes us to pass the -lstdc++fs flag to link C++17 filesystem implementation.
|
||||
-if (NOT MINGW AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
||||
+if (NOT MINGW AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SerenityOS")
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_libraries(${PROJECT_NAME} stdc++fs)
|
||||
endif()
|
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Wed, 8 Feb 2023 10:45:25 +0100
|
||||
Subject: [PATCH] Add compile options to CMakeLists.txt
|
||||
|
||||
This irons out some compiler warnings that turned into errors when compiling a release build.
|
||||
---
|
||||
CMakeLists.txt | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 76a17f24386dce3e364b292ac23867231123ebe5..687b2361b02ae1c82fc4de8320bdb28487872eec 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -298,6 +298,8 @@ else ()
|
||||
# unused-const-variable[=2] would check for unused values from headers as well
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_UNUSED_CONST_VARIABLE -Wunused-const-variable=1)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WNO_CLOBBERED -Wno-clobbered)
|
||||
+ ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WNO_MAYBE_UNINITIALIZED -Wno-maybe-uninitialized)
|
||||
+ ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WNO_NULL_DEREFERENCE -Wno-null-dereference)
|
||||
# Disabled due to problems compiling OpenSSL on macOS.
|
||||
# ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_DOCUMENTATION -Wdocumentation)
|
||||
|
||||
@@ -307,7 +309,7 @@ else ()
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
|
||||
|
||||
# Currently used MinGW w/GCC 7.2 doesn't provide sane error messages for this
|
||||
- ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NULL_DEREFERENCE -Wnull-dereference)
|
||||
+ # ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS CXX_WARN_NULL_DEREFERENCE -Wnull-dereference)
|
||||
endif ()
|
||||
# These have no workarounds available when building with LTO
|
||||
if (NOT IPO_BUILD_ENABLED)
|
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Wed, 8 Feb 2023 11:32:30 +0100
|
||||
Subject: [PATCH] Disable locale detection for writing the default config.ini
|
||||
|
||||
At the time of writing, locale support in Serenity is not great. We always returned the "C" locale, which this code interpreted wrong. Since this is just used for writing a default value to the game config (which can be changed later), we just default to English.
|
||||
---
|
||||
src/openrct2/platform/Platform.Linux.cpp | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp
|
||||
index eea10444874fced76027421350c7a4402bbbbfe0..ecd97d9a708c61ff8ba3f5e3096f41a47bc7a34d 100644
|
||||
--- a/src/openrct2/platform/Platform.Linux.cpp
|
||||
+++ b/src/openrct2/platform/Platform.Linux.cpp
|
||||
@@ -178,6 +178,7 @@ namespace Platform
|
||||
|
||||
uint16_t GetLocaleLanguage()
|
||||
{
|
||||
+#if !defined(__serenity__)
|
||||
const char* langString = setlocale(LC_MESSAGES, "");
|
||||
if (langString != nullptr)
|
||||
{
|
||||
@@ -238,6 +239,7 @@ namespace Platform
|
||||
}
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
return LANGUAGE_ENGLISH_UK;
|
||||
}
|
||||
|
23
Ports/openrct2/patches/0008-Disable-g2.dat-target.patch
Normal file
23
Ports/openrct2/patches/0008-Disable-g2.dat-target.patch
Normal file
|
@ -0,0 +1,23 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= <offenhaeuser@protonmail.com>
|
||||
Date: Wed, 8 Feb 2023 12:27:59 +0100
|
||||
Subject: [PATCH] Disable g2.dat target
|
||||
|
||||
Normally, the build system uses one of the compiled binaries to pack assets into `g2.dat`. However, since we cross-compile this binary for Serenity, we can't do this on the host system. Instead, we download the latest Linux build of OpenRCT2 and copy its `g2.dat` into the disk image.
|
||||
---
|
||||
CMakeLists.txt | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 687b2361b02ae1c82fc4de8320bdb28487872eec..bb2cf3395d40c773dbb432ac81473358a3bb71cb 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -386,7 +386,7 @@ endif ()
|
||||
|
||||
|
||||
# g2
|
||||
-if (NOT (MACOS_BUNDLE AND (NOT CMAKE_OSX_ARCHITECTURES MATCHES "${SYSTEM_MACOS_ARCH}")))
|
||||
+if (NOT (MACOS_BUNDLE AND (NOT CMAKE_OSX_ARCHITECTURES MATCHES "${SYSTEM_MACOS_ARCH}")) AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SerenityOS")
|
||||
add_custom_command(
|
||||
OUTPUT g2.dat
|
||||
COMMAND ./openrct2-cli sprite build ${CMAKE_BINARY_DIR}/g2.dat ${ROOT_DIR}/resources/g2/sprites.json
|
50
Ports/openrct2/patches/ReadMe.md
Normal file
50
Ports/openrct2/patches/ReadMe.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Patches for openrct2 on SerenityOS
|
||||
|
||||
## `0001-Add-SerenityOS-platform-detection.patch`
|
||||
|
||||
Add SerenityOS platform detection
|
||||
|
||||
We teach OpenRCT2 about the name of our platform.
|
||||
|
||||
## `0002-Add-missing-includes.patch`
|
||||
|
||||
Add missing includes
|
||||
|
||||
These are missing when compiling the release build.
|
||||
|
||||
## `0003-Read-the-executable-path-from-proc-self-exe.patch`
|
||||
|
||||
Read the executable path from /proc/self/exe
|
||||
|
||||
When looking for the executable path, we behave exactly like Linux.
|
||||
|
||||
## `0004-Remove-use-of-strptime.patch`
|
||||
|
||||
Remove use of strptime()
|
||||
|
||||
This is a hack to patch out strptime() from duktape, which is not being used by this project.
|
||||
|
||||
## `0005-Don-t-try-linking-to-stdc-fs.patch`
|
||||
|
||||
Don't try linking to stdc++fs
|
||||
|
||||
This code tried to link to stdc++fs for std::filesystem features, which are already included in our toolchain.
|
||||
|
||||
## `0006-Add-compile-options-to-CMakeLists.txt.patch`
|
||||
|
||||
Add compile options to CMakeLists.txt
|
||||
|
||||
This irons out some compiler warnings that turned into errors when compiling a release build.
|
||||
|
||||
## `0007-Disable-locale-detection-for-writing-the-default-con.patch`
|
||||
|
||||
Disable locale detection for writing the default config.ini
|
||||
|
||||
At the time of writing, locale support in Serenity is not great. We always returned the "C" locale, which this code interpreted wrong. Since this is just used for writing a default value to the game config (which can be changed later), we just default to English.
|
||||
|
||||
## `0008-Disable-g2.dat-target.patch`
|
||||
|
||||
Disable g2.dat target
|
||||
|
||||
Normally, the build system uses one of the compiled binaries to pack assets into `g2.dat`. However, since we cross-compile this binary for Serenity, we can't do this on the host system. Instead, we download the latest Linux build of OpenRCT2 and copy its `g2.dat` into the disk image.
|
||||
|
Loading…
Reference in a new issue