rbe-tebako 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.clang-format +4 -0
- data/Brewfile +23 -0
- data/CMakeLists.txt +464 -0
- data/CODE_OF_CONDUCT.adoc +128 -0
- data/CONTRIBUTING.adoc +294 -0
- data/Gemfile +31 -0
- data/INSTALLATION.adoc +233 -0
- data/LICENSE.md +33 -0
- data/README.adoc +1363 -0
- data/Rakefile +35 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/cmake/copy_dir.cmake +29 -0
- data/common.env +5 -0
- data/exe/rbe-tebako +32 -0
- data/exe/rbe-tebako-packager +77 -0
- data/include/tebako/tebako-fs.h +43 -0
- data/include/tebako/tebako-main.h +42 -0
- data/include/tebako/tebako-prism.h +51 -0
- data/lib/rbe-tebako.rb +6 -0
- data/lib/tebako/build_helpers.rb +77 -0
- data/lib/tebako/cache_manager.rb +112 -0
- data/lib/tebako/cli.rb +220 -0
- data/lib/tebako/cli_helpers.rb +165 -0
- data/lib/tebako/codegen.rb +252 -0
- data/lib/tebako/deploy_helper.rb +258 -0
- data/lib/tebako/error.rb +70 -0
- data/lib/tebako/options_manager.rb +338 -0
- data/lib/tebako/package_descriptor.rb +143 -0
- data/lib/tebako/packager/pass1_patch.rb +266 -0
- data/lib/tebako/packager/pass1a_patch.rb +55 -0
- data/lib/tebako/packager/pass2_patch.rb +140 -0
- data/lib/tebako/packager/pass2_patch_crt.rb +46 -0
- data/lib/tebako/packager/pass2msys_patch.rb +190 -0
- data/lib/tebako/packager/patch.rb +54 -0
- data/lib/tebako/packager/patch_buildsystem.rb +124 -0
- data/lib/tebako/packager/patch_helpers.rb +109 -0
- data/lib/tebako/packager/patch_libraries.rb +188 -0
- data/lib/tebako/packager/patch_literals.rb +275 -0
- data/lib/tebako/packager/patch_main.rb +93 -0
- data/lib/tebako/packager/rubygems_patch.rb +83 -0
- data/lib/tebako/packager.rb +210 -0
- data/lib/tebako/packager_lite.rb +78 -0
- data/lib/tebako/ruby_builder.rb +71 -0
- data/lib/tebako/ruby_version.rb +206 -0
- data/lib/tebako/scenario_manager.rb +251 -0
- data/lib/tebako/stripper.rb +135 -0
- data/lib/tebako/version.rb +30 -0
- data/lib/tebako.rb +34 -0
- data/src/tebako-main.cpp +168 -0
- data/tools/.gitattributes +4 -0
- data/tools/.github/workflows/build-containers.yml +190 -0
- data/tools/.github/workflows/lint.yml +41 -0
- data/tools/.github/workflows/test.yml +331 -0
- data/tools/.gitignore +1 -0
- data/tools/README.md +49 -0
- data/tools/ci-scripts/arm-brew-install.sh +43 -0
- data/tools/ci-scripts/arm-brew-setup.sh +33 -0
- data/tools/ci-scripts/level-up.sh +35 -0
- data/tools/ci-scripts/patch-fbthrift.sh +94 -0
- data/tools/ci-scripts/patch-folly.sh +551 -0
- data/tools/ci-scripts/patch-glog.sh +57 -0
- data/tools/ci-scripts/patch-zstd.sh +57 -0
- data/tools/ci-scripts/tools.sh +63 -0
- data/tools/ci-scripts/x86-brew-install.sh +43 -0
- data/tools/ci-scripts/x86-brew-setup.sh +33 -0
- data/tools/cmake-scripts/def-external-project.cmake +96 -0
- data/tools/cmake-scripts/macos-environment.cmake +91 -0
- data/tools/cmake-scripts/msys-environment.cmake +78 -0
- data/tools/cmake-scripts/setup-libarchive.cmake +93 -0
- data/tools/cmake-scripts/setup-libfmt.cmake +61 -0
- data/tools/cmake-scripts/setup-libhowardhinnerdate.cmake +55 -0
- data/tools/cmake-scripts/setup-libutfcpp.cmake +56 -0
- data/tools/cmake-scripts/version.cmake +162 -0
- data/tools/docker/alpine-3.17-dev.Dockerfile +49 -0
- data/tools/docker/tools/tools.sh +66 -0
- data/tools/docker/ubuntu-20.04-dev.Dockerfile +51 -0
- data/tools/dwarfs-test-helper/CMakeLists.txt +34 -0
- data/tools/include/pro-statvfs.h +57 -0
- data/tools/tests/cmake/CMakeLists.txt +81 -0
- data/tools/tests/setup-libfmt/CMakeLists.txt +35 -0
- data/tools/tests/setup-libhowardhinnerdate/CMakeLists.txt +35 -0
- data/tools/tests/setup-librachive/CMakeLists.txt +35 -0
- data/tools/tests/setup-libutfcpp/CMakeLists.txt +36 -0
- data/tools/tests/setup-openssl/CMakeLists.txt +36 -0
- metadata +312 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require "stringio"
|
|
29
|
+
|
|
30
|
+
module Tebako
|
|
31
|
+
# Tebako application package descriptor
|
|
32
|
+
class PackageDescriptor
|
|
33
|
+
SIGNATURE = "TAMATEBAKO"
|
|
34
|
+
|
|
35
|
+
attr_reader :ruby_version_major, :ruby_version_minor, :ruby_version_patch, :tebako_version_major,
|
|
36
|
+
:tebako_version_minor, :tebako_version_patch, :mount_point, :entry_point, :cwd
|
|
37
|
+
|
|
38
|
+
def initialize(*args)
|
|
39
|
+
if args.size == 1 && args[0].is_a?(Array)
|
|
40
|
+
deserialize(args[0])
|
|
41
|
+
elsif args.size == 5
|
|
42
|
+
construct_from_params(*args)
|
|
43
|
+
else
|
|
44
|
+
raise ArgumentError, "Invalid arguments"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def serialize
|
|
49
|
+
buffer = StringIO.new
|
|
50
|
+
|
|
51
|
+
buffer.write(SIGNATURE)
|
|
52
|
+
serialize_versions(buffer)
|
|
53
|
+
|
|
54
|
+
write_string(buffer, @mount_point)
|
|
55
|
+
write_string(buffer, @entry_point)
|
|
56
|
+
|
|
57
|
+
serialize_cwd(buffer)
|
|
58
|
+
buffer.string
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
def deserialize(buffer)
|
|
64
|
+
stream = StringIO.new(buffer.pack("C*"))
|
|
65
|
+
|
|
66
|
+
signature = stream.read(SIGNATURE.size)
|
|
67
|
+
raise ArgumentError, "Invalid or missing signature" if signature != SIGNATURE
|
|
68
|
+
|
|
69
|
+
deserialize_versions(stream)
|
|
70
|
+
@mount_point = read_string(stream)
|
|
71
|
+
@entry_point = read_string(stream)
|
|
72
|
+
|
|
73
|
+
cwd_present = stream.read(1).unpack1("C")
|
|
74
|
+
@cwd = cwd_present == 1 ? read_string(stream) : nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def construct_from_params(ruby_version, tebako_version, mount_point, entry_point, cwd)
|
|
78
|
+
parse_version(ruby_version, :@ruby_version_major, :@ruby_version_minor, :@ruby_version_patch)
|
|
79
|
+
parse_version(tebako_version, :@tebako_version_major, :@tebako_version_minor, :@tebako_version_patch)
|
|
80
|
+
|
|
81
|
+
@mount_point = mount_point
|
|
82
|
+
@entry_point = entry_point
|
|
83
|
+
@cwd = cwd
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def deserialize_versions(stream)
|
|
87
|
+
@ruby_version_major = read_uint16(stream)
|
|
88
|
+
@ruby_version_minor = read_uint16(stream)
|
|
89
|
+
@ruby_version_patch = read_uint16(stream)
|
|
90
|
+
@tebako_version_major = read_uint16(stream)
|
|
91
|
+
@tebako_version_minor = read_uint16(stream)
|
|
92
|
+
@tebako_version_patch = read_uint16(stream)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def parse_version(version, major_sym, minor_sym, patch_sym)
|
|
96
|
+
major, minor, patch = version.split(".").map(&:to_i)
|
|
97
|
+
raise ArgumentError, "Invalid version format" unless major && minor && patch
|
|
98
|
+
|
|
99
|
+
instance_variable_set(major_sym, major)
|
|
100
|
+
instance_variable_set(minor_sym, minor)
|
|
101
|
+
instance_variable_set(patch_sym, patch)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def write_uint16(buffer, value)
|
|
105
|
+
buffer.write([value].pack("v"))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def read_uint16(stream)
|
|
109
|
+
data = stream.read(2)
|
|
110
|
+
raise ArgumentError, "Unexpected end of stream" if data.nil?
|
|
111
|
+
|
|
112
|
+
data.unpack1("v")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def serialize_cwd(buffer)
|
|
116
|
+
if @cwd
|
|
117
|
+
buffer.write([1].pack("C"))
|
|
118
|
+
write_string(buffer, @cwd)
|
|
119
|
+
else
|
|
120
|
+
buffer.write([0].pack("C"))
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def serialize_versions(buffer)
|
|
125
|
+
write_uint16(buffer, @ruby_version_major)
|
|
126
|
+
write_uint16(buffer, @ruby_version_minor)
|
|
127
|
+
write_uint16(buffer, @ruby_version_patch)
|
|
128
|
+
write_uint16(buffer, @tebako_version_major)
|
|
129
|
+
write_uint16(buffer, @tebako_version_minor)
|
|
130
|
+
write_uint16(buffer, @tebako_version_patch)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def write_string(buffer, str)
|
|
134
|
+
write_uint16(buffer, str.size)
|
|
135
|
+
buffer.write(str)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def read_string(stream)
|
|
139
|
+
size = read_uint16(stream)
|
|
140
|
+
stream.read(size)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2021-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require_relative "patch_helpers"
|
|
29
|
+
require_relative "patch_buildsystem"
|
|
30
|
+
|
|
31
|
+
require_relative "patch"
|
|
32
|
+
require_relative "rubygems_patch"
|
|
33
|
+
# Tebako - an executable packager
|
|
34
|
+
module Tebako
|
|
35
|
+
# Packager module
|
|
36
|
+
module Packager
|
|
37
|
+
class << self
|
|
38
|
+
def crt_pass1_patch(ostype, mount_point, ruby_ver)
|
|
39
|
+
scmb = ScenarioManagerBase.new(ostype)
|
|
40
|
+
if scmb.macos?
|
|
41
|
+
Pass1DarwinPatch.new(mount_point, ruby_ver)
|
|
42
|
+
elsif scmb.msys?
|
|
43
|
+
Pass1MSysPatch.new(mount_point, ruby_ver)
|
|
44
|
+
else
|
|
45
|
+
Pass1Patch.new(mount_point, ruby_ver)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
# Ruby patching definitions (pass1 - common)
|
|
50
|
+
class Pass1Patch < RubygemsPatch
|
|
51
|
+
# [TODO] looks like it does not exist in 3.1.4
|
|
52
|
+
# May be obsolete
|
|
53
|
+
TOOL_RBINSTALL_RB_PATCH = {
|
|
54
|
+
" next if files.empty?" => "# tebako patched next if files.empty?"
|
|
55
|
+
}.freeze
|
|
56
|
+
|
|
57
|
+
EXT_SETUP_PATCH = {
|
|
58
|
+
"#option nodynamic" => "option nodynamic"
|
|
59
|
+
}.freeze
|
|
60
|
+
|
|
61
|
+
# ....................................................
|
|
62
|
+
# This is something that I cannnot explain
|
|
63
|
+
# (this patch does not seem related to static compilation)
|
|
64
|
+
|
|
65
|
+
EXT_BIGDECIMAL_BIGDECIMAL_H_PATCH = {
|
|
66
|
+
"#include \"ruby/ruby.h\"" => <<~SUBST
|
|
67
|
+
#include "ruby/ruby.h"
|
|
68
|
+
|
|
69
|
+
/* -- Start of tebako patch -- */
|
|
70
|
+
#ifndef HAVE_RB_SYM2STR
|
|
71
|
+
#define HAVE_RB_SYM2STR 1
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
#ifndef HAVE_RB_ARRAY_CONST_PTR
|
|
75
|
+
#define HAVE_RB_ARRAY_CONST_PTR 1
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
#ifndef HAVE_RB_RATIONAL_NUM
|
|
79
|
+
#define HAVE_RB_RATIONAL_NUM 1
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
#ifndef HAVE_RB_RATIONAL_DEN
|
|
83
|
+
#define HAVE_RB_RATIONAL_DEN 1
|
|
84
|
+
#endif
|
|
85
|
+
|
|
86
|
+
#ifndef HAVE_RB_COMPLEX_REAL
|
|
87
|
+
#define HAVE_RB_COMPLEX_REAL
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
#ifndef HAVE_RB_COMPLEX_IMAG
|
|
91
|
+
#define HAVE_RB_COMPLEX_IMAG
|
|
92
|
+
#endif
|
|
93
|
+
/* -- End of tebako patch -- */
|
|
94
|
+
|
|
95
|
+
SUBST
|
|
96
|
+
}.freeze
|
|
97
|
+
|
|
98
|
+
# The logic for statically linked extensions is broken entirely in the latest Ruby versions.
|
|
99
|
+
# The code below looks reasonble - we do not set -bundle_loader when building with -with-static-ext option
|
|
100
|
+
# However Gems bundled with Ruby just ignore with-static-ext option and build extensions as shared libraries
|
|
101
|
+
# So the -bundler_loader option is required for them to link.
|
|
102
|
+
# It is strange that it is disabled in any case because this option does not create any issues for static
|
|
103
|
+
# libraries.
|
|
104
|
+
# ---------------------------------------------------
|
|
105
|
+
# elif test "x$EXTSTATIC" = x
|
|
106
|
+
# then :
|
|
107
|
+
#
|
|
108
|
+
# # When building exts as bundles, a mach-o bundle needs to know its loader
|
|
109
|
+
# # program to bind symbols from the ruby executable
|
|
110
|
+
# EXTDLDFLAGS="-bundle_loader '\$(BUILTRUBY)'"
|
|
111
|
+
|
|
112
|
+
OPENSSL_EXTCONF_RB_SUBST = <<~SUBST
|
|
113
|
+
# Start of tebako patch
|
|
114
|
+
$defs.push("-DRUBY_EXPORT=1")
|
|
115
|
+
# End of tebako patch
|
|
116
|
+
|
|
117
|
+
Logging::message "=== Checking done. ===\\n"
|
|
118
|
+
SUBST
|
|
119
|
+
|
|
120
|
+
OPENSSL_EXTCONF_RB_PATCH = {
|
|
121
|
+
"Logging::message \"=== Checking done. ===\\n\"" => OPENSSL_EXTCONF_RB_SUBST
|
|
122
|
+
}.freeze
|
|
123
|
+
|
|
124
|
+
ENC_JIS_PROPS_H_PATCH = {
|
|
125
|
+
"static const struct enc_property *onig_jis_property(/*const char *str, unsigned int len*/);" =>
|
|
126
|
+
"/* tebako patched */ static const struct enc_property *onig_jis_property(const char *str, size_t len);"
|
|
127
|
+
}.freeze
|
|
128
|
+
|
|
129
|
+
def initialize(mount_point, ruby_ver)
|
|
130
|
+
super(mount_point)
|
|
131
|
+
@ruby_ver = ruby_ver
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def base_patch_map
|
|
135
|
+
{
|
|
136
|
+
# ....................................................
|
|
137
|
+
# It won't install gems with no files defined in spec
|
|
138
|
+
# However if
|
|
139
|
+
# -- we are installing a default gem from extension
|
|
140
|
+
# -- extension is build statically
|
|
141
|
+
# there may be no files install in addition to spec
|
|
142
|
+
# Example: io/wait extension (and others)
|
|
143
|
+
# [TODO] Check if it is still required
|
|
144
|
+
# No match and patching on Ruby 3.1.4 but works wo issues
|
|
145
|
+
"tool/rbinstall.rb" => TOOL_RBINSTALL_RB_PATCH,
|
|
146
|
+
|
|
147
|
+
# ....................................................
|
|
148
|
+
# Allow only packaged gems (from within memfs)
|
|
149
|
+
"lib/rubygems/path_support.rb" => rubygems_path_support_patch(@mount_point),
|
|
150
|
+
|
|
151
|
+
# ....................................................
|
|
152
|
+
# Disable dynamic extensions
|
|
153
|
+
"ext/Setup" => EXT_SETUP_PATCH
|
|
154
|
+
}
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def patch_map
|
|
158
|
+
pm = base_patch_map
|
|
159
|
+
pm.merge!(super)
|
|
160
|
+
|
|
161
|
+
# ....................................................
|
|
162
|
+
pm.store("ext/bigdecimal/bigdecimal.h", EXT_BIGDECIMAL_BIGDECIMAL_H_PATCH) unless @ruby_ver.ruby34?
|
|
163
|
+
|
|
164
|
+
# ....................................................
|
|
165
|
+
# autoload :OpenSSL, "openssl"
|
|
166
|
+
# fails to deal with a default gem from statically linked extension
|
|
167
|
+
pm.store("lib/rubygems/openssl.rb", RUBYGEMS_OPENSSL_RB_PATCH) if @ruby_ver.ruby3x?
|
|
168
|
+
|
|
169
|
+
# ....................................................
|
|
170
|
+
# fix onig_jis_property signature (gcc 15 compatibility issue)
|
|
171
|
+
pm.store("enc/jis/props.h", ENC_JIS_PROPS_H_PATCH) unless @ruby_ver.ruby32?
|
|
172
|
+
|
|
173
|
+
pm.freeze
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Ruby patching definitions (pass1 - darwin)
|
|
178
|
+
class Pass1DarwinPatch < Pass1Patch
|
|
179
|
+
DARWIN_CONFIGURE_PATCH = {
|
|
180
|
+
"elif test \"x$EXTSTATIC\" = x" => "elif true"
|
|
181
|
+
}.freeze
|
|
182
|
+
|
|
183
|
+
def patch_map
|
|
184
|
+
pm = { "configure" => DARWIN_CONFIGURE_PATCH }
|
|
185
|
+
pm.merge!(super)
|
|
186
|
+
pm.freeze
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Ruby patching definitions (pass1 - Windows)
|
|
191
|
+
class Pass1MSysPatch < Pass1Patch
|
|
192
|
+
INCLUDE_RUBY_ONIGMO_H_PATCH = {
|
|
193
|
+
"# define ONIG_EXTERN RUBY_EXTERN" => "# define ONIG_EXTERN extern"
|
|
194
|
+
}.freeze
|
|
195
|
+
|
|
196
|
+
WIN32_WINMAIN_C_PATCH = {
|
|
197
|
+
"WinMain(HINSTANCE current, HINSTANCE prev, LPSTR cmdline, int showcmd)" =>
|
|
198
|
+
"wWinMain(HINSTANCE current, HINSTANCE prev, LPWSTR cmdline, int showcmd) /* tebako patched */"
|
|
199
|
+
}.freeze
|
|
200
|
+
|
|
201
|
+
EXT_IO_CONSOLE_WIN32_VK_INC_PATCH = {
|
|
202
|
+
"static const struct vktable *console_win32_vk(/*const char *, unsigned int*/);" =>
|
|
203
|
+
"/* tebako patched */ static const struct vktable *console_win32_vk(const char *, size_t);"
|
|
204
|
+
}.freeze
|
|
205
|
+
|
|
206
|
+
def patch_map
|
|
207
|
+
pm = msys_patches
|
|
208
|
+
pm.merge!(super)
|
|
209
|
+
pm.freeze
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
private
|
|
213
|
+
|
|
214
|
+
def gnumakefile_in_patch_p1 # rubocop:disable Metrics/MethodLength
|
|
215
|
+
objext = @ruby_ver.ruby32? ? "$(OBJEXT)" : "@OBJEXT@"
|
|
216
|
+
{
|
|
217
|
+
"$(Q) $(DLLWRAP) \\" => GNUMAKEFILE_IN_DLLTOOL_SUBST,
|
|
218
|
+
|
|
219
|
+
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext}" =>
|
|
220
|
+
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext} $(WINMAINOBJ) # tebako patched",
|
|
221
|
+
|
|
222
|
+
"$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@" =>
|
|
223
|
+
"$(WINMAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@ # tebako patched",
|
|
224
|
+
|
|
225
|
+
"--output-exp=$(RUBY_EXP) \\" => "# tebako patched --output-exp=$(RUBY_EXP) \\",
|
|
226
|
+
|
|
227
|
+
"--export-all $(LIBRUBY_A) $(LIBS) -o $(PROGRAM)" =>
|
|
228
|
+
"# tebako patched --export-all $(LIBRUBY_A) $(LIBS) -o $(PROGRAM)",
|
|
229
|
+
|
|
230
|
+
"@rm -f $(PROGRAM)" => "# tebako patched @rm -f $(PROGRAM)",
|
|
231
|
+
|
|
232
|
+
" $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)" =>
|
|
233
|
+
"# tebako patched $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)",
|
|
234
|
+
|
|
235
|
+
"RUBYDEF = $(DLL_BASE_NAME).def" => GNUMAKEFILE_IN_WINMAIN_SUBST
|
|
236
|
+
}
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def msys_base_patches
|
|
240
|
+
{
|
|
241
|
+
# ....................................................
|
|
242
|
+
# Generate export definitions; use WinMain to build rubyw.exe
|
|
243
|
+
"cygwin/GNUmakefile.in" => gnumakefile_in_patch_p1,
|
|
244
|
+
# ....................................................
|
|
245
|
+
# RUBY_EXPORT=1 (shall be set for static builds but is missing in openssl extension)
|
|
246
|
+
"ext/openssl/extconf.rb" => OPENSSL_EXTCONF_RB_PATCH,
|
|
247
|
+
# ....................................................
|
|
248
|
+
# Fix the signature of console_win32_vk
|
|
249
|
+
"ext/io/console/win32_vk.inc" => EXT_IO_CONSOLE_WIN32_VK_INC_PATCH
|
|
250
|
+
}
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def msys_patches
|
|
254
|
+
pm = msys_base_patches
|
|
255
|
+
|
|
256
|
+
if @ruby_ver.ruby3x7?
|
|
257
|
+
# ....................................................
|
|
258
|
+
# RUBY_EXTERN shall be extern for static build but is set to __declspec(dllimport) for encodin libarary
|
|
259
|
+
pm.store("include/ruby/onigmo.h", INCLUDE_RUBY_ONIGMO_H_PATCH)
|
|
260
|
+
pm.store("win32/winmain.c", WIN32_WINMAIN_C_PATCH)
|
|
261
|
+
end
|
|
262
|
+
pm
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2024-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require_relative "patch"
|
|
29
|
+
# Tebako - an executable packager
|
|
30
|
+
module Tebako
|
|
31
|
+
module Packager
|
|
32
|
+
# Ruby patching definitions (pass1a)
|
|
33
|
+
class Pass1APatch < Patch
|
|
34
|
+
GEM_PRELUDE_RB_PATCH = {
|
|
35
|
+
"if defined?(DidYouMean)" => <<~SUBST
|
|
36
|
+
if defined?(DidYouMean)
|
|
37
|
+
|
|
38
|
+
# -- Start of tebako patch --
|
|
39
|
+
begin
|
|
40
|
+
require 'tebako-runtime'
|
|
41
|
+
rescue LoadError
|
|
42
|
+
warn "'tebako-runtime' was not loaded."
|
|
43
|
+
end
|
|
44
|
+
# -- End of tebako patch --
|
|
45
|
+
SUBST
|
|
46
|
+
}.freeze
|
|
47
|
+
|
|
48
|
+
def patch_map
|
|
49
|
+
{
|
|
50
|
+
"gem_prelude.rb" => GEM_PRELUDE_RB_PATCH
|
|
51
|
+
}.freeze
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2021-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require_relative "patch_literals"
|
|
29
|
+
require_relative "patch_main"
|
|
30
|
+
require_relative "patch_libraries"
|
|
31
|
+
require_relative "patch_helpers"
|
|
32
|
+
require_relative "patch_buildsystem"
|
|
33
|
+
|
|
34
|
+
# Tebako - an executable packager
|
|
35
|
+
module Tebako
|
|
36
|
+
# Packager module
|
|
37
|
+
module Packager
|
|
38
|
+
# Ruby patching definitions (pass2)
|
|
39
|
+
class Pass2Patch < Patch
|
|
40
|
+
def initialize(ostype, deps_lib_dir, ruby_ver)
|
|
41
|
+
super()
|
|
42
|
+
@ostype = ostype
|
|
43
|
+
@scmb = ScenarioManagerBase.new(@ostype)
|
|
44
|
+
@deps_lib_dir = deps_lib_dir
|
|
45
|
+
@ruby_ver = ruby_ver
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def patch_map
|
|
49
|
+
pm = patch_map_base
|
|
50
|
+
pm.store("thread_pthread.c", LINUX_MUSL_THREAD_PTHREAD_PATCH) if @scmb.musl?
|
|
51
|
+
pm.store("prism_compile.c", PRISM_PATCHES) if @ruby_ver.ruby34?
|
|
52
|
+
pm
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
protected
|
|
56
|
+
|
|
57
|
+
def io_c_patch
|
|
58
|
+
PatchHelpers.patch_c_file_pre("/* define system APIs */")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
include Tebako::Packager::PatchBuildsystem
|
|
64
|
+
include Tebako::Packager::PatchLiterals
|
|
65
|
+
|
|
66
|
+
def dir_c_patch
|
|
67
|
+
pattern = @scmb.msys? ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST"
|
|
68
|
+
patch = PatchHelpers.patch_c_file_pre(pattern)
|
|
69
|
+
patch.merge!(DIR_C_BASE_PATCH)
|
|
70
|
+
patch
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def dln_c_patch
|
|
74
|
+
pattern = "#ifndef dln_loaderror"
|
|
75
|
+
# Not using substitutions of dlxxx functions on Windows
|
|
76
|
+
patch = {
|
|
77
|
+
pattern => "#{@scmb.msys? ? C_FILE_SUBST_LESS : C_FILE_SUBST}\n#{pattern}\n"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if @scmb.msys?
|
|
81
|
+
patch.merge!(@ruby_ver.ruby32? ? DLN_C_MSYS_PATCH : DLN_C_MSYS_PATCH_PRE32)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
patch
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def util_c_patch
|
|
88
|
+
if @ruby_ver.ruby31?
|
|
89
|
+
PatchHelpers.patch_c_file_post("#endif /* !HAVE_GNU_QSORT_R */")
|
|
90
|
+
else
|
|
91
|
+
PatchHelpers.patch_c_file_pre("#ifndef S_ISDIR")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def tool_mkconfig_rb_patch
|
|
96
|
+
subst = @scmb.msys? ? TOOL_MKCONFIG_RB_SUBST_MSYS : TOOL_MKCONFIG_RB_SUBST
|
|
97
|
+
{
|
|
98
|
+
" if fast[name]" => subst
|
|
99
|
+
}
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def patch_map_base
|
|
103
|
+
{
|
|
104
|
+
"template/Makefile.in" => template_makefile_in_patch,
|
|
105
|
+
"tool/mkconfig.rb" => tool_mkconfig_rb_patch,
|
|
106
|
+
"dir.c" => dir_c_patch, "dln.c" => dln_c_patch,
|
|
107
|
+
"io.c" => io_c_patch, "main.c" => PatchMain.get_main_c_patch(@ruby_ver),
|
|
108
|
+
"file.c" => PatchHelpers.patch_c_file_pre("/* define system APIs */"),
|
|
109
|
+
"util.c" => util_c_patch
|
|
110
|
+
}
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def mlibs_subst
|
|
114
|
+
yjit_libs = @ruby_ver.ruby32only? ? "$(YJIT_LIBS) " : ""
|
|
115
|
+
{
|
|
116
|
+
"MAINLIBS = #{yjit_libs}@MAINLIBS@" =>
|
|
117
|
+
"# -- Start of tebako patch -- \n" \
|
|
118
|
+
"MAINLIBS = #{yjit_libs}#{PatchLibraries.mlibs(@ostype, @deps_lib_dir, @ruby_ver, true)}\n" \
|
|
119
|
+
"# -- End of tebako patch -- \n"
|
|
120
|
+
}
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def template_makefile_in_patch
|
|
124
|
+
template_makefile_in_patch_two(@ruby_ver).merge(mlibs_subst)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Non-msys Pass2 patches
|
|
129
|
+
class Pass2NonMSysPatch < Pass2Patch
|
|
130
|
+
def patch_map
|
|
131
|
+
pm = super
|
|
132
|
+
pm.store("common.mk", COMMON_MK_PATCH) if @ruby_ver.ruby3x?
|
|
133
|
+
pm.store("config.status", get_config_status_patch(@ostype, @deps_lib_dir, @ruby_ver)) if @ruby_ver.ruby33?
|
|
134
|
+
pm
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
include Tebako::Packager::PatchLiterals
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2021-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require_relative "pass2_patch"
|
|
29
|
+
require_relative "pass2msys_patch"
|
|
30
|
+
|
|
31
|
+
# Tebako - an executable packager
|
|
32
|
+
module Tebako
|
|
33
|
+
# Packager module
|
|
34
|
+
module Packager
|
|
35
|
+
class << self
|
|
36
|
+
def crt_pass2_patch(ostype, deps_lib_dir, ruby_ver)
|
|
37
|
+
scmb = ScenarioManagerBase.new(ostype)
|
|
38
|
+
if scmb.msys?
|
|
39
|
+
Pass2MSysPatch.new(ostype, deps_lib_dir, ruby_ver)
|
|
40
|
+
else
|
|
41
|
+
Pass2NonMSysPatch.new(ostype, deps_lib_dir, ruby_ver)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|