diff --git a/binding/binding-mri.cpp b/binding/binding-mri.cpp index 50f00ab5..9e1cbdfb 100644 --- a/binding/binding-mri.cpp +++ b/binding/binding-mri.cpp @@ -59,12 +59,6 @@ extern "C" { #include #include -#ifdef __WIN32__ -#define NULL_IO "NUL" -#else -#define NULL_IO "/dev/null" -#endif - #define MACRO_STRINGIFY(x) #x extern const char module_rpg1[]; @@ -226,8 +220,10 @@ static void mriBindingInit() { rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest)); // Set $stdout and its ilk accordingly on Windows +#ifdef __WIN32__ if (shState->config().editor.debug) configureWindowsStreams(); +#endif // Load zlib, if it's present. Requires --with-static-linked-ext or zlib.so. // It's okay if it fails, normally it wouldn't be defined anyway. @@ -684,18 +680,7 @@ static void runRMXPScripts(BacktraceData &btData) { if (exc != Qnil) return; -#ifdef MKXPZ_ESSENTIALS_DEBUG - // Used to try and fix Essentials garbage later if it's detected - int minimonsters = 0; -#endif - while (true) { -#if RAPI_FULL < 200 && defined(MKXPZ_DISABLE_CONSOLE) - VALUE iostr = rb_str_new2(NULL_IO); - // Sysinit isn't a thing yet, so send io to /dev/null instead - rb_funcall(rb_gv_get("$stderr"), rb_intern("reopen"), 1, iostr); - rb_funcall(rb_gv_get("$stdout"), rb_intern("reopen"), 1, iostr); -#endif for (long i = 0; i < scriptCount; ++i) { VALUE script = rb_ary_entry(scriptArray, i); VALUE scriptDecoded = rb_ary_entry(script, 3); @@ -758,8 +743,8 @@ static void runRMXPScripts(BacktraceData &btData) { // Attempts to set $stdout and $stdin accordingly on Windows. Only // called when debug mode is on, since that's when the console // should be active. +#ifdef __WIN32__ static void configureWindowsStreams() { -#ifdef __WINDOWS__ #define HANDLE_VALID(handle) handle && handle != INVALID_HANDLE_VALUE const HANDLE outputHandle = GetStdHandle(STD_OUTPUT_HANDLE); @@ -787,8 +772,8 @@ static void configureWindowsStreams() { } #undef HANDLE_VALID -#endif // #ifdef __WINDOWS__ } +#endif // #ifdef __WINDOWS__ static void showExc(VALUE exc, const BacktraceData &btData) { VALUE bt = rb_funcall2(exc, rb_intern("backtrace"), 0, NULL); @@ -919,6 +904,14 @@ static void mriBindingExecute() { #else ruby_init(); rb_eval_string("$KCODE='U'"); +#ifdef __WIN32__ + if (!conf.editor.debug) { + VALUE iostr = rb_str_new2("NUL"); + // Sysinit isn't a thing yet, so send io to /dev/null instead + rb_funcall(rb_gv_get("$stderr"), rb_intern("reopen"), 1, iostr); + rb_funcall(rb_gv_get("$stdout"), rb_intern("reopen"), 1, iostr); + } +#endif #endif #if defined(MKXPZ_ESSENTIALS_DEBUG) && !defined(__WIN32__) diff --git a/meson.build b/meson.build index c6ccc115..a0787ef0 100644 --- a/meson.build +++ b/meson.build @@ -107,10 +107,6 @@ if get_option('cxx11_experimental') == true global_args += '-DMKXPZ_EXP_FS' endif -if not get_option('console') - global_args += '-DMKXPZ_DISABLE_CONSOLE' -endif - if get_option('force32') == true global_args += '-m32' endif @@ -159,7 +155,7 @@ if steamworks == true shim_args += '-DSTEAM_APPID=' + get_option('steam_appid') endif - if get_option('console') == true + if get_option('steamshim_debug') == true shim_args += '-DSTEAMSHIM_DEBUG' endif @@ -169,7 +165,7 @@ if steamworks == true include_directories: (steamworks_path + '/public'), cpp_args: shim_args, link_args: la.split(), - gui_app: (get_option('console') == false), + gui_app: (get_option('steamshim_debug') == false), install: (host_system != 'windows')) endif @@ -186,6 +182,6 @@ executable(exe_name, cpp_args: global_args, objc_args: global_args, objcpp_args: global_args, - gui_app: (get_option('console') == false), + gui_app: true, install: (host_system != 'windows') ) diff --git a/meson_options.txt b/meson_options.txt index a699ddde..d209e613 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,8 +2,6 @@ option('mri_version', type: 'string', value: '3.0', description: 'Version of MRI option('mri_includes', type: 'string', value: '', description: 'Ruby manual include path') option('mri_libpath', type: 'string', value: '', description: 'Ruby manual lib path') option('mri_library', type: 'string', value: '', description: 'Ruby manual link name') - -option('console', type: 'boolean', value: false, description: 'Whether to debug information in the console') option('macos_min_version', type: 'string', value: '', description: 'Minimum macOS system version to support (does not affect dependencies)') option('force32', type: 'boolean', value: false, description: 'Force compiler to build a 32-bit executable') @@ -22,5 +20,6 @@ option('appimagekit_path', type: 'string', value: '', description: 'Path to AppI option('appimage', type: 'boolean', value: false, description: 'Whether to install to an AppImage or just copy everything') option('steamworks_path', type: 'string', value: '', description: 'Path to Steamshim') option('steam_appid', type: 'string', value: '', description: 'Steam AppID. Set this to use SteamAPI_RestartAppIfNecessary') +option('steamshim_debug', type: 'boolean', value: false, description: 'Whether to show Steamshim debug messages in the console') option('gfx_backend', type: 'combo', value: 'gl', choices: ['gl', 'gles'], description: 'Graphics rendering API to use.') \ No newline at end of file