Class: Tebako::Packager::Pass1Patch

Inherits:
RubygemsPatch show all
Defined in:
lib/tebako/packager/pass1_patch.rb

Overview

Ruby patching definitions (pass1 - common)

Direct Known Subclasses

Pass1DarwinPatch, Pass1MSysPatch

Constant Summary collapse

TOOL_RBINSTALL_RB_PATCH =

[TODO] looks like it does not exist in 3.1.4 May be obsolete

{
  "    next if files.empty?" => "# tebako patched    next if files.empty?"
}.freeze
EXT_SETUP_PATCH =
{
  "#option nodynamic" => "option nodynamic"
}.freeze
EXT_BIGDECIMAL_BIGDECIMAL_H_PATCH =

.................................................... This is something that I cannnot explain (this patch does not seem related to static compilation)

{
  "#include \"ruby/ruby.h\"" => <<~SUBST
    #include "ruby/ruby.h"

    /* -- Start of tebako patch -- */
    #ifndef HAVE_RB_SYM2STR
    #define HAVE_RB_SYM2STR  1
    #endif

    #ifndef HAVE_RB_ARRAY_CONST_PTR
    #define HAVE_RB_ARRAY_CONST_PTR 1
    #endif

    #ifndef HAVE_RB_RATIONAL_NUM
    #define HAVE_RB_RATIONAL_NUM 1
    #endif

    #ifndef HAVE_RB_RATIONAL_DEN
    #define HAVE_RB_RATIONAL_DEN 1
    #endif

    #ifndef HAVE_RB_COMPLEX_REAL
    #define HAVE_RB_COMPLEX_REAL
    #endif

    #ifndef HAVE_RB_COMPLEX_IMAG
    #define HAVE_RB_COMPLEX_IMAG
    #endif
    /* -- End of tebako patch -- */

  SUBST
}.freeze
OPENSSL_EXTCONF_RB_SUBST =

elif test "x$EXTSTATIC" = x then :

                       # When building exts as bundles, a mach-o bundle needs to know its loader
                       # program to bind symbols from the ruby executable
                       EXTDLDFLAGS="-bundle_loader '\$(BUILTRUBY)'"
<<~SUBST
  # Start of tebako patch
  $defs.push("-DRUBY_EXPORT=1")
  # End of tebako patch

  Logging::message "=== Checking done. ===\\n"
SUBST
OPENSSL_EXTCONF_RB_PATCH =
{
  "Logging::message \"=== Checking done. ===\\n\"" => OPENSSL_EXTCONF_RB_SUBST
}.freeze
ENC_JIS_PROPS_H_PATCH =
{
  "static const struct enc_property *onig_jis_property(/*const char *str, unsigned int len*/);" =>
    "/* tebako patched */ static const struct enc_property *onig_jis_property(const char *str, size_t len);"
}.freeze

Constants inherited from RubygemsPatch

RubygemsPatch::RUBYGEMS_OPENSSL_RB_PATCH, RubygemsPatch::RUBYGEMS_OPENSSL_RB_SUBST

Instance Method Summary collapse

Constructor Details

#initialize(mount_point, ruby_ver) ⇒ Pass1Patch

Returns a new instance of Pass1Patch.



129
130
131
132
# File 'lib/tebako/packager/pass1_patch.rb', line 129

def initialize(mount_point, ruby_ver)
  super(mount_point)
  @ruby_ver = ruby_ver
end

Instance Method Details

#base_patch_mapObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/tebako/packager/pass1_patch.rb', line 134

def base_patch_map
  {
    # ....................................................
    # It won't install gems with no files defined in spec
    # However if
    #   -- we are installing a default gem from extension
    #   -- extension is build statically
    #  there may be no files install in addition to spec
    # Example: io/wait extension (and others)
    # [TODO]  Check if it is still required
    # No match and patching on Ruby 3.1.4 but works wo issues
    "tool/rbinstall.rb" => TOOL_RBINSTALL_RB_PATCH,

    # ....................................................
    # Allow only packaged gems (from within memfs)
    "lib/rubygems/path_support.rb" => rubygems_path_support_patch(@mount_point),

    # ....................................................
    # Disable dynamic extensions
    "ext/Setup" => EXT_SETUP_PATCH
  }
end

#patch_mapObject



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/tebako/packager/pass1_patch.rb', line 157

def patch_map
  pm = base_patch_map
  pm.merge!(super)

  # ....................................................
  pm.store("ext/bigdecimal/bigdecimal.h", EXT_BIGDECIMAL_BIGDECIMAL_H_PATCH) unless @ruby_ver.ruby34?

  # ....................................................
  # autoload :OpenSSL, "openssl"
  # fails to deal with a default gem from statically linked extension
  pm.store("lib/rubygems/openssl.rb", RUBYGEMS_OPENSSL_RB_PATCH) if @ruby_ver.ruby3x?

  # ....................................................
  # fix onig_jis_property signature (gcc 15 compatibility issue)
  pm.store("enc/jis/props.h", ENC_JIS_PROPS_H_PATCH) unless @ruby_ver.ruby32?

  pm.freeze
end