fix(freebsd): correct platform macros, missing includes, and

printf/variadic bugs
This commit is contained in:
AnmiTaliDev 2026-08-04 10:12:40 +05:00
parent 5f0d83410b
commit 42b87478c0
No known key found for this signature in database
GPG key ID: C15CE1C091FF3004
10 changed files with 44 additions and 24 deletions

View file

@ -153,7 +153,7 @@ elseif(LINUX)
list(APPEND MAIN_HEADERS src/xdg-user-dir-lookup.h)
elseif(BSD)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LINUXPKGS REQUIRED gtk+-3.0)
pkg_check_modules(LINUXPKGS REQUIRED gtk+-3.0 libxfconf-0)
include_directories(${LINUXPKGS_INCLUDE_DIRS})
add_compile_options(${LINUXPKGS_CFLAGS_OTHER})
list(APPEND PLATFORM_LIBRARIES ${LINUXPKGS_LDFLAGS})
@ -421,7 +421,7 @@ find_package(Ruby 3.0 REQUIRED COMPONENTS Development)
pkg_check_modules(VORBISFILE REQUIRED vorbisfile)
find_package_handle_standard_args(pixman-1 DEFAULT_MSG PIXMAN_LIBRARY PIXMAN_INCLUDE_DIR)
mark_as_advanced(PIXMAN_INCLUDE_DIR PIXMAN_LIBRARY)
find_package(OpenSSL CONFIG REQUIRED COMPONENTS Crypto)
find_package(OpenSSL REQUIRED COMPONENTS Crypto)
pkg_check_modules(SIGC2 REQUIRED sigc++-2.0)
target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFINES})

View file

@ -36,7 +36,6 @@
#include "sunshine.h"
#include "modloader.h"
#include <ruby-3.4.0/ruby/internal/gc.h>
#include <ruby.h>
#include <ruby/debug.h>
#include <ruby/encoding.h>
@ -380,7 +379,7 @@ static void runCustomScript(const std::string &filename){
std::string scriptData;
if (!readFileSDL(filename.c_str(), scriptData)){
crash(Exception::MEOW, "Unable to open %s", filename);
crash(Exception::MEOW, "Unable to open %s", filename.c_str());
return;
}
@ -412,7 +411,7 @@ static void runRMXPScripts(BacktraceData &btData){
try{
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
}catch (const Exception &e){
crash(Exception::MEOW, "Failed to read script data: %s", e.msg);
crash(Exception::MEOW, "Failed to read script data: %s", e.msg.c_str());
return;
}

View file

@ -26,6 +26,7 @@
//костыль ебаный сука
#undef snprintf
#undef inline
#undef close
#include "exception.h"

View file

@ -19,7 +19,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef OS_LINUX
#ifdef __linux__
#include <sys/inotify.h>
#endif
#include <unistd.h>
@ -164,7 +164,7 @@ void journalBindingInit(){
mutex = SDL_CreateMutex();
SDL_memset((char*)lang_buffer, 0, BUFFER_SIZE);
lang_buffer[0] = '_';
#if defined __linux
#ifdef unix_like
mkfifo(PIPE_PATH.c_str(), 0666);
atexit(cleanup_pipe);
#endif

View file

@ -19,7 +19,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef OS_LINUX
#ifdef __linux__
#include <sys/inotify.h>
#endif
#include <unistd.h>

View file

@ -6,6 +6,10 @@
#include "sharedstate.h"
#include "pipe.h"
#if defined __FreeBSD__ || defined __DragonFly__
#include <sys/sysctl.h>
#endif
static Pipe ipc;
static void start(){
@ -29,10 +33,19 @@ static void start(){
#else
#if defined unix_like
char path[PATH_MAX];
std::string exename;
#if defined __FreeBSD__ || defined __DragonFly__
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
size_t size = sizeof(path);
if (sysctl(mib, 4, path, &size, NULL, 0) != 0)
rb_raise(rb_eRuntimeError, "Cannot determine path of running executable");
exename = std::string(path);
#else
ssize_t len = readlink("/proc/self/exe", path, PATH_MAX);
if (len == -1)
rb_raise(rb_eRuntimeError, "Cannot determine path of running executable");
std::string exename = std::string(path, len);
exename = std::string(path, len);
#endif
#else
#endif

View file

@ -293,7 +293,7 @@ int main(int argc, char *argv[]){
if (!conf.gameFolder.empty()){
if (chdir(conf.gameFolder.c_str()) != 0){
crash(Exception::MEOW, "Unable to switch into gameFolder %s", conf.gameFolder);
crash(Exception::MEOW, "Unable to switch into gameFolder %s", conf.gameFolder.c_str());
return 0;
}
}

View file

@ -23,6 +23,9 @@
#include <physfs.h>
#include <pixman.h>
#include <SDL3/SDL_system.h>
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
#endif
#include <boost/stacktrace.hpp>
#include <SDL3/SDL_cpuinfo.h>
#include "sunshine.h"
@ -83,6 +86,7 @@ void crash(Exception::Type t, const char *fmt, ...){
o << "[BOOST stacktrace()]" << std::endl;
o << boost::stacktrace::stacktrace() << std::endl;
o << "[OpenGL]" << std::endl;
if (gl.GetString){
try{
o << "GL Vendor: " << glGetStringInt(GL_VENDOR) << std::endl;
o << "GL Renderer: " << glGetStringInt(GL_RENDERER) << std::endl;
@ -93,6 +97,9 @@ void crash(Exception::Type t, const char *fmt, ...){
}catch(const std::exception& e){
o << "Crashed before OpenGL initialization: " << e.what() << std::endl;
}
}else{
o << "OpenGL not initialized yet" << std::endl;
}
o << "[Versions of libs]" << std::endl;
const int sdlcompiled = SDL_VERSION;
const int sdllinked = SDL_GetVersion();
@ -146,7 +153,7 @@ void crash(Exception::Type t, const char *fmt, ...){
}
}
if(!t == Exception::MEOW)
if(t != Exception::MEOW)
throw Exception(t, msg);
}

View file

@ -17,7 +17,6 @@
#include <fstream>
#include <openssl/sha.h>
#include <SDL3/SDL_stdinc.h>
#include <zip.h>
#include <locale>
#include <filesystem>
#include <string>

View file

@ -27,6 +27,7 @@
#include "xdg-user-dir-lookup.h"
#include <stdio.h>
#include <SDL3/SDL_stdinc.h>
/**
* xdg_user_dir_lookup_with_fallback: