Module: Tebako::Packager::PatchMain

Defined in:
lib/tebako/packager/patch_main.rb

Overview

Ruby patching literals (main.c)

Constant Summary collapse

MAIN_C_SUBST_RB_MAIN =
<<~SUBST
  /* -- Start of tebako patch -- */
  #include <tebako/tebako-main.h>
  /* -- End of tebako patch -- */

  static int
  rb_main(int argc, char **argv)
SUBST
MAIN_C_SUBST_MAIN =
<<~SUBST
  /* -- Start of tebako patch -- */
  #include <tebako/tebako-main.h>
  /* -- End of tebako patch -- */

  int
  main(int argc, char **argv)
SUBST
MAIN_C_SUBST_RB_MAIN_INNER =
<<~SUBST
  ruby_init();
  /* -- Start of tebako patch -- */
      if (!tebako_is_running_miniruby())
      {
          VALUE cwd = rb_str_new_cstr(tebako_original_pwd());
          rb_gv_set("$tebako_original_pwd", cwd);
      }
  /* -- End of tebako patch -- */
SUBST
MAIN_C_SUBST_MAIN_INNER =
<<~SUBST
      ruby_sysinit(&argc, &argv);
  /* -- Start of tebako patch -- */
      if (tebako_main(&argc, &argv) != 0) {
          printf("Tebako intialization failed.");
          return -1;
      }
  /* -- End of tebako patch -- */
SUBST

Class Method Summary collapse

Class Method Details

.get_main_c_patch(ruby_ver) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/tebako/packager/patch_main.rb', line 73

def get_main_c_patch(ruby_ver)
  {
    get_main_c_main_pattern(ruby_ver) => get_main_c_main_subst(ruby_ver),
    "ruby_init();" => MAIN_C_SUBST_RB_MAIN_INNER,
    "    ruby_sysinit(&argc, &argv);" => MAIN_C_SUBST_MAIN_INNER
  }
end