Ports: Add a ClassiCube port

This commit is contained in:
cflip 2022-10-15 10:24:29 -06:00 committed by Linus Groh
parent fea43a647f
commit 75d46e0e96
Notes: sideshowbarker 2024-07-17 05:20:20 +09:00
5 changed files with 225 additions and 0 deletions

View File

@ -29,6 +29,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n
| [`cfunge`](cfunge/) | cfunge | 2bc4fb2 | https://github.com/VorpalBlade/cfunge/ |
| [`chester`](chester/) | Chester Gameboy Emulator | | https://github.com/veikkos/chester |
| [`citron`](citron/) | Citron Programming Language | 0.0.9.3 | https://github.com/alimpfard/citron |
| [`ClassiCube`](ClassiCube/) | ClassiCube | 1.3.3 | https://github.com/UnknownShadow200/ClassiCube |
| [`cmake`](cmake/) | CMake | 3.23.2 | https://cmake.org/ |
| [`cmatrix`](cmatrix/) | cmatrix | 3112b12 | https://github.com/abishekvashok/cmatrix |
| [`composer`](composer/) | Composer | 2.3.5 | https://getcomposer.org/ |

26
Ports/ClassiCube/package.sh Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env -S bash ../.port_include.sh
port='ClassiCube'
version='1.3.3'
files="https://github.com/UnknownShadow200/ClassiCube/archive/refs/tags/${version}.tar.gz ClassiCube-${version}.tar.gz f90acfeb82fd440ead6e086694d99bd1583b0174da1801687c4c3d0fcb21d83d"
auth_type='sha256'
workdir="${port}-${version}/src/"
depends=(
'SDL2'
'curl'
'libopenal'
)
launcher_name='ClassiCube'
launcher_category='Games'
launcher_workdir='/home/anon/Games/ClassiCube'
launcher_command='/usr/local/bin/ClassiCube'
makeopts+=(
'ClassiCube'
'PLAT=serenity'
)
install() {
run mkdir -p ${SERENITY_INSTALL_ROOT}/home/anon/Games/ClassiCube
run cp ClassiCube ${SERENITY_INSTALL_ROOT}/usr/local/bin
}

View File

@ -0,0 +1,161 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: cflip <cflip@cflip.net>
Date: Fri, 14 Oct 2022 21:28:37 -0600
Subject: [PATCH] Add support for SerenityOS
---
Core.h | 8 ++++++++
Drawer2D.c | 1 +
Http_Worker.c | 3 +++
Logger.c | 19 ++++++++++++++++++-
Makefile | 9 ++++++++-
Platform_Posix.c | 6 +++++-
6 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/Core.h b/Core.h
index bdefce2fb420bc1d30ab7d1448d2501d6ba247ee..29eb2973727cb4b98bb01fdf02c65240017f86f5 100644
--- a/Core.h
+++ b/Core.h
@@ -239,6 +239,14 @@ Thus it is **NOT SAFE** to allocate a string on the stack. */
#define CC_BUILD_CURL
#define CC_BUILD_OPENAL
#define CC_BUILD_SDL
+#elif defined __serenity__
+#define CC_BUILD_SERENITY
+#define CC_BUILD_POSIX
+#define CC_BUILD_GL
+#define CC_BUILD_GL11
+#define CC_BUILD_CURL
+#define CC_BUILD_OPENAL
+#define CC_BUILD_SDL
#elif defined __EMSCRIPTEN__
#define CC_BUILD_WEB
#define CC_BUILD_GL
diff --git a/Drawer2D.c b/Drawer2D.c
index f66b9024aa2b27ea87cf332873d9156fccdc63fe..5bfbdd030c72f2ee9471c7b5444f6499b91ca64b 100644
--- a/Drawer2D.c
+++ b/Drawer2D.c
@@ -811,6 +811,7 @@ static cc_string font_candidates[] = {
String_FromConst(""), /* replaced with font_default */
String_FromConst("Arial"), /* preferred font on all platforms */
String_FromConst("Liberation Sans"), /* ice looking fallbacks for linux */
+ String_FromConst("Liberation Serif"),
String_FromConst("Nimbus Sans"),
String_FromConst("Bitstream Charter"),
String_FromConst("Cantarell"),
diff --git a/Http_Worker.c b/Http_Worker.c
index 936361eb04a8a5e56820ca827a8e72020da17451..514494fc516960fc17824406a2c49d72cf31f7f4 100644
--- a/Http_Worker.c
+++ b/Http_Worker.c
@@ -254,6 +254,9 @@ static const cc_string curlAlt = String_FromConst("/usr/pkg/lib/libcurl.so");
#elif defined CC_BUILD_BSD
static const cc_string curlLib = String_FromConst("libcurl.so");
static const cc_string curlAlt = String_FromConst("libcurl.so");
+#elif defined CC_BUILD_SERENITY
+static const cc_string curlLib = String_FromConst("/usr/local/lib/libcurl.so");
+static const cc_string curlAlt = String_FromConst("/usr/local/lib/libcurl.so");
#else
static const cc_string curlLib = String_FromConst("libcurl.so.4");
static const cc_string curlAlt = String_FromConst("libcurl.so.3");
diff --git a/Logger.c b/Logger.c
index 14ff7d6ab8455294b83bb36fb29ea6994a883c25..4eb3d1d4ad63a24d9030a98c1fc02816369ef728 100644
--- a/Logger.c
+++ b/Logger.c
@@ -16,7 +16,7 @@
#define NOIME
#include <windows.h>
#include <imagehlp.h>
-#elif defined CC_BUILD_OPENBSD || defined CC_BUILD_HAIKU
+#elif defined CC_BUILD_OPENBSD || defined CC_BUILD_HAIKU || defined CC_BUILD_SERENITY
#include <signal.h>
/* OpenBSD doesn't provide sys/ucontext.h */
#elif defined CC_BUILD_LINUX || defined CC_BUILD_ANDROID
@@ -343,6 +343,10 @@ void Logger_Backtrace(cc_string* trace, void* ctx) {
}
String_AppendConst(trace, _NL);
}
+#elif defined CC_BUILD_SERENITY
+void Logger_Backtrace(cc_string* trace, void* ctx) {
+ /* FIXME: Implement */
+}
#elif defined CC_BUILD_POSIX
#include <execinfo.h>
void Logger_Backtrace(cc_string* trace, void* ctx) {
@@ -667,6 +671,19 @@ static void PrintRegisters(cc_string* str, void* ctx) {
#error "Unknown CPU architecture"
#endif
}
+#elif defined CC_BUILD_SERENITY
+static void PrintRegisters(cc_string* str, void* ctx) {
+ mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
+#if defined __i386__
+ #define REG_GET(reg, ign) &r.e##reg
+ Dump_X86()
+#elif defined __x86_64__
+ #define REG_GET(reg, ign) &r.r##reg
+ Dump_X64()
+#else
+ #error "Unknown CPU architecture"
+#endif
+}
#endif
static void DumpRegisters(void* ctx) {
cc_string str; char strBuffer[768];
diff --git a/Makefile b/Makefile
index 6c7152071c94116b4cf3d175fa8bd0c0652b77ff..73d6e386dedd38b9ffd558aa13ce3f0390bd601e 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,6 @@ OBJECTS:=$(C_OBJECTS)
ENAME=ClassiCube
DEL=rm
JOBS=1
-CC=cc
CFLAGS=-g -pipe -fno-math-errno
LDFLAGS=-g -rdynamic
@@ -92,6 +91,12 @@ LDFLAGS=-g
LIBS=-lm -lexecinfo -lGL -lnetwork -lstdc++ -lbe -lgame -ltracker
endif
+ifeq ($(PLAT),serenity)
+CFLAGS=-g -pipe -fno-math-errno
+LDFLAGS=-g
+LIBS=-lgl -lSDL2
+endif
+
ifeq ($(OS),Windows_NT)
DEL=del
endif
@@ -120,6 +125,8 @@ dragonfly:
$(MAKE) $(ENAME) PLAT=dragonfly -j$(JOBS)
haiku:
$(MAKE) $(ENAME) PLAT=haiku -j$(JOBS)
+serenity:
+ $(MAKE) $(ENAME) PLAT=serenity -j$(JOBS)
clean:
$(DEL) $(OBJECTS)
diff --git a/Platform_Posix.c b/Platform_Posix.c
index 2a410f00d96460decb16bd703caa5163d4e2ff63..31f9cc7e3e60a31e336e025bfefa0865984dc7b8 100644
--- a/Platform_Posix.c
+++ b/Platform_Posix.c
@@ -445,6 +445,10 @@ void Platform_LoadSysFonts(void) {
static const cc_string dirs[] = {
String_FromConst("/system/data/fonts")
};
+#elif defined CC_BUILD_SERENITY
+ static const cc_string dirs[] = {
+ String_FromConst("/res/fonts")
+ };
#elif defined CC_BUILD_DARWIN
static const cc_string dirs[] = {
String_FromConst("/System/Library/Fonts"),
@@ -700,7 +704,7 @@ static cc_result Process_RawGetExePath(char* path, int* len) {
*len = String_CalcLen(path, NATIVE_STR_LEN);
return 0;
}
-#elif defined CC_BUILD_LINUX
+#elif defined CC_BUILD_LINUX || defined CC_BUILD_SERENITY
static cc_result Process_RawGetExePath(char* path, int* len) {
*len = readlink("/proc/self/exe", path, NATIVE_STR_LEN);
return *len == -1 ? errno : 0;

View File

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: cflip <cflip@cflip.net>
Date: Sat, 15 Oct 2022 15:29:44 -0600
Subject: [PATCH] HACK: Disable interrupt hooks
This allows crashes to be handled by Serenity's crash handler, which
automatically displays debugging information such as the backtrace.
---
Program.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/Program.c b/Program.c
index 3b210522036a51a8f4a9fece8b5b2e20be79a7aa..f3c9fd895ef163cad75dce4b566676bc83546767 100644
--- a/Program.c
+++ b/Program.c
@@ -55,7 +55,6 @@ CC_NOINLINE static void WarnMissingArgs(int argsCount, const cc_string* args) {
static void SetupProgram(int argc, char** argv) {
static char ipBuffer[STRING_SIZE];
cc_result res;
- Logger_Hook();
Platform_Init();
res = Platform_SetDefaultCurrentDirectory(argc, argv);

View File

@ -0,0 +1,14 @@
# Patches for ClassiCube on SerenityOS
## `0001-Add-support-for-SerenityOS.patch`
Add support for SerenityOS
## `0002-HACK-Disable-interrupt-hooks.patch`
HACK: Disable interrupt hooks
This allows crashes to be handled by Serenity's crash handler, which
automatically displays debugging information such as the backtrace.