This commit is contained in:
DepressedTWM 2026-08-19 09:24:15 +04:00
parent 8da6b3d7d6
commit f96527d3e1
13 changed files with 50 additions and 52 deletions

View file

@ -3,6 +3,14 @@ project(oneshot)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CheckIPOSupported)
check_ipo_supported(
RESULT ipo_supported
OUTPUT ipo_error
LANGUAGES CXX C
)
# Helper for checking if options supported # Helper for checking if options supported
function(check_option var a) function(check_option var a)
set(all ${a}) set(all ${a})
@ -346,7 +354,8 @@ if(DEBUG)
-g3 -g3
-fno-omit-frame-pointer -fno-omit-frame-pointer
-Og -Og
-fcheck-new) -fcheck-new
-fstrict-flex-arrays=3)
add_compile_options(${OPTIONS_DEBUG}) add_compile_options(${OPTIONS_DEBUG})
if("${ARCH_DEBUG}" STREQUAL "") if("${ARCH_DEBUG}" STREQUAL "")
@ -369,7 +378,9 @@ else()
-frename-registers -frename-registers
-fuse-linker-plugin -fuse-linker-plugin
-fipa-pta -fipa-pta
-fext-dce) -fext-dce
-fstrict-enums
-fimplicit-constexpr)
add_compile_options(${OPTIONS_RELEASE}) add_compile_options(${OPTIONS_RELEASE})
add_link_options(-Wl,-O2 add_link_options(-Wl,-O2
@ -378,11 +389,7 @@ else()
-Wl,--no-undefined -Wl,--no-undefined
-Wl,--strip-all -Wl,--strip-all
-Wl,--no-copy-dt-needed-entries) -Wl,--no-copy-dt-needed-entries)
if(NOT WIN32)
check_option(OPTIONS_RELEASE_WIN32_FLTO -flto=thin)
add_compile_options(${OPTIONS_RELEASE_WIN32_FLTO})
add_link_options(${OPTIONS_RELEASE_WIN32_FLTO})
endif()
if("${ARCH_RELEASE}" STREQUAL "") if("${ARCH_RELEASE}" STREQUAL "")
message(STATUS "ARCH_RELEASE empty") message(STATUS "ARCH_RELEASE empty")
else() else()
@ -409,6 +416,17 @@ else()
) )
endif() endif()
if(NOT DEBUG)
if(ipo_supported)
set_property(
TARGET ${PROJECT_NAME}
PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
)
else()
message(WARNING "IPO/LTO is not supported: ${ipo_error}")
endif()
endif()
if(DEVBUILD) if(DEVBUILD)
target_compile_definitions(${PROJECT_NAME} PRIVATE DEVBUILD) target_compile_definitions(${PROJECT_NAME} PRIVATE DEVBUILD)
endif() endif()

View file

@ -108,7 +108,6 @@ RB_METHOD(audioReset) {
} }
void audioBindingInit(){ void audioBindingInit(){
printf("[audioBindingInit] Initialing Audio binding\n");
VALUE module = rb_define_module("Audio"); VALUE module = rb_define_module("Audio");
rb_define_singleton_method(module, "create_sound", RUBY_METHOD_FUNC(rb_audio_createAudioPlayback), -1); rb_define_singleton_method(module, "create_sound", RUBY_METHOD_FUNC(rb_audio_createAudioPlayback), -1);

View file

@ -423,9 +423,13 @@ static void runRMXPScripts(BacktraceData &btData){
} }
//Execute preloaded scripts //Execute preloaded scripts
for (std::set<std::string>::iterator i = preloadScripts.begin(); if(modloader_is_enabled){
i != preloadScripts.end(); ++i) for (std::set<std::string>::iterator i = preloadScripts.begin();
runCustomScript(*i); i != preloadScripts.end(); ++i){
runCustomScript(*i);
}
}
VALUE exc = rb_gv_get("$!"); VALUE exc = rb_gv_get("$!");
if (exc != Qnil) if (exc != Qnil)

View file

@ -139,9 +139,6 @@ RB_METHOD(kernelSaveData){
VALUE filename; VALUE filename;
rb_get_args(argc, argv, "oS", &obj, &filename); rb_get_args(argc, argv, "oS", &obj, &filename);
#ifdef DEBUG
printf("[kernelSaveData] Filename: %s\n", rb_str_to_str(filename));
#endif
VALUE file = rb_file_open_str(filename, "wb"); VALUE file = rb_file_open_str(filename, "wb");
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal")); VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));

View file

@ -343,7 +343,6 @@ static buttonCodes[] = {
static elementsN(buttonCodes); static elementsN(buttonCodes);
void inputBindingInit(){ void inputBindingInit(){
printf("[inputBindingInit] Initializing Input binding\n");
VALUE module = rb_define_module("Input"); VALUE module = rb_define_module("Input");
initGamepadBinding(module); initGamepadBinding(module);

View file

@ -29,7 +29,6 @@ VALUE meow(const std::vector<std::string> vec){
return ary; return ary;
} }
static VALUE hooks(int argc, VALUE *argv, VALUE self) { static VALUE hooks(int argc, VALUE *argv, VALUE self) {
VALUE v_path = Qnil; VALUE v_path = Qnil;
rb_scan_args(argc, argv, "01", &v_path); rb_scan_args(argc, argv, "01", &v_path);

View file

@ -55,7 +55,6 @@ RB_METHOD(steamUnlocked){
} }
void steamBindingInit(){ void steamBindingInit(){
printf("[steamBindingInit] Initializing Steam binding\n");
VALUE module = rb_define_module("Steam"); VALUE module = rb_define_module("Steam");
/* Constants */ /* Constants */

View file

@ -83,7 +83,6 @@
} }
void desktopEnvironmentInit(){ void desktopEnvironmentInit(){
printf("[desktopEnvironmentInit] desktopEnvironmentInit()\n");
if (desktop != "uninitialized") if (desktop != "uninitialized")
return; return;

View file

@ -67,3 +67,4 @@ GNOME support fixed
Fixed small defect on cg_wake5 Fixed small defect on cg_wake5
Added ModLoader loading screen Added ModLoader loading screen
Added [Function():string number] debug information in logs Added [Function():string number] debug information in logs
SecurityEngine now enabled only when Modloader is active

View file

@ -67,19 +67,19 @@ public:
~Debug(){ ~Debug(){
std::ostringstream result; std::ostringstream result;
result << "[" << location.line() << ":" << location.function_name() << "] " << buf.str(); result << "[" << location.line() << ":" << location.function_name() << "] " << buf.view();
#ifdef __ANDROID__ #ifdef __ANDROID__
__android_log_write(ANDROID_LOG_DEBUG, "sunshine", result.str().c_str()); __android_log_write(ANDROID_LOG_DEBUG, "sunshine", result.view().c_str());
#elif __EMSCRIPTEN__ #elif __EMSCRIPTEN__
emscripten_console_log(result.str().c_str()); emscripten_console_log(result.view().c_str());
#else #else
logs.push_back(result.str()); logs.emplace_back(result.view());
std::cout << result.str() << "\n"; std::cout << std::move(result).str() << '\n';
#endif #endif
} }
private: private:
std::stringstream buf; std::ostringstream buf;
std::source_location location; std::source_location location;
}; };

View file

@ -33,7 +33,6 @@
#else #else
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <assert.h>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@ -48,7 +47,6 @@
#include "exception.h" #include "exception.h"
#include "gl-fun.h" #include "gl-fun.h"
#include "i18n.h" #include "i18n.h"
#include "security.h"
#include "sunshine.h" #include "sunshine.h"
#include "modloader.h" #include "modloader.h"
@ -59,19 +57,12 @@
#include "binding.h" #include "binding.h"
#include "icon.png.xxd" #include "icon.png.xxd"
#include <SDL3/SDL_system.h>
#ifdef STEAM #ifdef STEAM
#include "steamshim/steamshim_child.h" #include "steamshim/steamshim_child.h"
#else #else
#include "gamecontrollerdb.txt.xxd" #include "gamecontrollerdb.txt.xxd"
#endif #endif
#ifdef ps2
#ifdef DEBUG
SDL_PS2_SKIP_IOP_RESET();
#endif
#endif
#ifndef VERSION_STRING #ifndef VERSION_STRING
#define VERSION_STRING ">w<" #define VERSION_STRING ">w<"
#endif #endif
@ -82,10 +73,6 @@ static void rgssThreadError(RGSSThreadData *rtData, const std::string &msg){
rtData->rqTermAck.set(); rtData->rqTermAck.set();
} }
static inline const char* glGetStringInt(GLenum name){
return (const char*) gl.GetString(name);
}
int rgssThreadFun(void *userdata){ int rgssThreadFun(void *userdata){
RGSSThreadData *threadData = static_cast<RGSSThreadData*>(userdata); RGSSThreadData *threadData = static_cast<RGSSThreadData*>(userdata);
const Config &conf = threadData->config; const Config &conf = threadData->config;
@ -123,10 +110,6 @@ int rgssThreadFun(void *userdata){
gl.Clear(GL_COLOR_BUFFER_BIT); gl.Clear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(win); SDL_GL_SwapWindow(win);
Debug() << "[main] GL Vendor :" << glGetStringInt(GL_VENDOR);
Debug() << "[main] GL Renderer :" << glGetStringInt(GL_RENDERER);
Debug() << "[main] GL Version :" << glGetStringInt(GL_VERSION);
Debug() << "[main] GLSL Version :" << glGetStringInt(GL_SHADING_LANGUAGE_VERSION);
#ifndef NDEBUG #ifndef NDEBUG
GLDebugLogger dLogger; GLDebugLogger dLogger;
#endif #endif
@ -168,10 +151,13 @@ static void setupWindowIcon(const Config &conf, SDL_Window *win){
} }
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
//I WANT FUCKING OPTIMIZE EVERYFING IN THIS BULLSHIT
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
startTime = boost::chrono::high_resolution_clock::now(); startTime = boost::chrono::high_resolution_clock::now();
loadLanguageMetadata(); //there will be a segfault on fclose if I don't move it here loadLanguageMetadata(); //there will be a segfault on fclose if I don't move it here
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
SDL_SetAppMetadata("Oneshot: Sunshine", "0.1.2", "meow.catwindowteam.sunshine"); SDL_SetAppMetadata("Oneshot: Sunshine", VERSION_STRING, "meow.catwindowteam.sunshine");
//X11 work on *BSD,Solaris too! //X11 work on *BSD,Solaris too!
#if unix_like #if unix_like
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
@ -184,8 +170,6 @@ int main(int argc, char *argv[]){
SDL_SetHint(SDL_HINT_ANDROID_ALLOW_PERSISTENT_FOLDER_ACCESS, "1"); SDL_SetHint(SDL_HINT_ANDROID_ALLOW_PERSISTENT_FOLDER_ACCESS, "1");
#elif vita #elif vita
SDL_SetHint(SDL_HINT_VITA_RESOLUTION, "1080"); SDL_SetHint(SDL_HINT_VITA_RESOLUTION, "1080");
#elif ps2
SFL_SetHint(SDL_HINT_PS2_GS_MODE, "NTSC");
#endif #endif
/* initialize SDL first */ /* initialize SDL first */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == false){ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == false){
@ -219,9 +203,6 @@ int main(int argc, char *argv[]){
/* now we load the config */ /* now we load the config */
Config conf; Config conf;
conf.read(argc, argv); conf.read(argc, argv);
if(conf.SecurityEngine){
SecurityManagerInit();
}
#if windows #if windows
if(conf.Windows_AllocConsole == true){ if(conf.Windows_AllocConsole == true){
AllocConsole(); AllocConsole();

View file

@ -163,7 +163,7 @@ void crash_screen(SDL_Window* win){
WarnMsg("Failed to create texture, please check if your device is too strong to run game or report bug.Error Message: ", SDL_GetError()); WarnMsg("Failed to create texture, please check if your device is too strong to run game or report bug.Error Message: ", SDL_GetError());
skip_crash_screen = true; skip_crash_screen = true;
}else{ }else{
SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST); SDL_SetTextureScaleMode(tex, SDL_SCALEMODE_NEAREST);
} }
//creating file and timestamp //creating file and timestamp
ofstream o; ofstream o;
@ -368,4 +368,3 @@ void WarnMsg(const char *fmt, ...) {
Debug() << "[WARNMSG]" << buf; Debug() << "[WARNMSG]" << buf;
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", buf, NULL); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Warning", buf, NULL);
} }

View file

@ -2,6 +2,7 @@
#include "debugwriter.h" #include "debugwriter.h"
#include "meow.h" #include "meow.h"
#include "config.h" #include "config.h"
#include "security.h"
#include <filesystem> #include <filesystem>
#include <string> #include <string>
@ -24,7 +25,7 @@ const static std::size_t N = 46;
static void modloader_add_to_log(const std::string data){ static void modloader_add_to_log(const std::string data){
Debug() << "[MODLOADER] " << data; Debug() << "[MODLOADER] " << data;
modloader_logs.push_back(data); modloader_logs.emplace_back(data);
} }
static int renderer_thread(void* data){ static int renderer_thread(void* data){
@ -74,7 +75,9 @@ void ModLoader(Config conf, SDL_Window* win){
Debug() << "[MODLOADER] Mods directory empty, skip."; Debug() << "[MODLOADER] Mods directory empty, skip.";
return; return;
} }
if(conf.SecurityEngine){
SecurityManagerInit();
}
SDL_Thread* render_thread_pointer = SDL_CreateThread(renderer_thread, "ModRenderer", win); SDL_Thread* render_thread_pointer = SDL_CreateThread(renderer_thread, "ModRenderer", win);
if (!render_thread_pointer) { if (!render_thread_pointer) {
//TODO: Error handling //TODO: Error handling
@ -92,7 +95,7 @@ void ModLoader(Config conf, SDL_Window* win){
if (ext == ".zip") { if (ext == ".zip") {
int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0); int ok = PHYSFS_mount(full.c_str(), "/mod-storage", 0);
mod_list.push_back(full); mod_list.emplace_back(full);
modloader_add_to_log("Added mod " + full); modloader_add_to_log("Added mod " + full);
mods_count++; mods_count++;
} else if (ext == ".rb") { } else if (ext == ".rb") {