From 6b102c1772d9de3a6e47e53a72a7c8ff7f0decd7 Mon Sep 17 00:00:00 2001 From: Inori Date: Sat, 10 Aug 2019 04:35:37 -0400 Subject: [PATCH] Silence stderr if built without console --- binding/binding-mri.cpp | 10 ++++++++++ meson.build | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/binding/binding-mri.cpp b/binding/binding-mri.cpp index 274a33bd..1195a30a 100644 --- a/binding/binding-mri.cpp +++ b/binding/binding-mri.cpp @@ -43,6 +43,12 @@ #include +#ifdef __WIN32__ +#define NULL_IO "NUL" +#else +#define NULL_IO "/dev/null" +#endif + extern const char module_rpg1[]; extern const char module_rpg2[]; extern const char module_rpg3[]; @@ -616,6 +622,10 @@ static void mriBindingExecute() #else ruby_init(); rb_eval_string("$KCODE='U'"); +#ifdef NO_CONSOLE + // Sysinit isn't a thing yet, so send stderr to /dev/null instead + rb_funcall(rb_gv_get("$stderr"), rb_intern("reopen"), 1, rb_str_new2(NULL_IO)); +#endif #endif Config &conf = shState->rtData().config; diff --git a/meson.build b/meson.build index 39e85570..27981a26 100644 --- a/meson.build +++ b/meson.build @@ -4,14 +4,18 @@ xxd = find_program('xxd', native: true) host_system = host_machine.system() compiler = meson.get_compiler('cpp') -if get_option('workdir_current') == true +if get_option('workdir_current') add_project_arguments('-DWORKDIR_CURRENT', language: 'cpp') endif -if get_option('fix_essentials') == true +if get_option('fix_essentials') add_project_arguments('-DUSE_ESSENTIALS_FIXES', language: 'cpp') endif +if not get_option('console') + add_project_arguments('-DNO_CONSOLE', language: 'cpp') +endif + subdir('src') subdir('binding') subdir('shader')