tebako 0.5.12 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +107 -196
- data/README.adoc +82 -22
- data/common.env +1 -1
- data/exe/tebako-packager +15 -9
- data/lib/tebako/cli.rb +25 -32
- data/lib/tebako/cli_helpers.rb +53 -44
- data/lib/tebako/cli_rubies.rb +75 -0
- data/lib/tebako/error.rb +17 -2
- data/lib/tebako/packager/pass1.rb +71 -6
- data/lib/tebako/packager/pass2.rb +58 -79
- data/lib/tebako/packager/patch_libraries.rb +138 -0
- data/lib/tebako/packager/patch_literals.rb +150 -70
- data/lib/tebako/packager.rb +28 -2
- data/lib/tebako/version.rb +1 -1
- data/src/tebako-main.cpp +1 -38
- data/version.txt +1 -1
- metadata +4 -2
data/exe/tebako-packager
CHANGED
@@ -74,19 +74,25 @@ begin
|
|
74
74
|
Tebako::Packager.pass2(ARGV[1], ARGV[2], ARGV[3], ARGV[6])
|
75
75
|
when "deploy"
|
76
76
|
# ARGV[0] -- command
|
77
|
-
# ARGV[1] --
|
78
|
-
# ARGV[2] --
|
79
|
-
# ARGV[3] --
|
80
|
-
# ARGV[4] --
|
81
|
-
# ARGV[5] --
|
82
|
-
|
77
|
+
# ARGV[1] -- OSTYPE
|
78
|
+
# ARGV[2] -- RUBY_SOURCE_DIR
|
79
|
+
# ARGV[3] -- FS_STASH_DIR
|
80
|
+
# ARGV[4] -- DATA_SRC_DIR
|
81
|
+
# ARGV[5] -- DATA_PRE_DIR
|
82
|
+
# ARGV[6] -- DATA_BIN_DIR
|
83
|
+
# ARGV[7] -- GFLENGTH
|
84
|
+
# ARGV[8] -- APP_NAME
|
85
|
+
# ARGV[9] -- RUBY_VER
|
86
|
+
unless ARGV.length == 10
|
83
87
|
raise Tebako::Error,
|
84
|
-
"tebako-packager deploy command expects
|
88
|
+
"tebako-packager deploy command expects 10 arguments, #{ARGV.length} has been provided."
|
85
89
|
end
|
86
|
-
Tebako::Packager.init(ARGV[
|
90
|
+
Tebako::Packager.init(ARGV[3], ARGV[4], ARGV[5], ARGV[6])
|
91
|
+
Tebako::Packager.create_implib(ARGV[2], ARGV[4], File.basename(ARGV[8]), ARGV[9]) if ARGV[1] =~ /msys/
|
87
92
|
# Assume that "<TARGET_BIN_DIR (TBD)>" is <DATA_SRC_DIR>/bin"
|
88
93
|
# That shall match CMakeLists.txt settings
|
89
|
-
Tebako::Packager.deploy(ARGV[
|
94
|
+
Tebako::Packager.deploy(ARGV[4], "#{ARGV[4]}/bin", ARGV[7])
|
95
|
+
|
90
96
|
else
|
91
97
|
raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
|
92
98
|
end
|
data/lib/tebako/cli.rb
CHANGED
@@ -28,10 +28,12 @@
|
|
28
28
|
|
29
29
|
require "digest"
|
30
30
|
require "fileutils"
|
31
|
+
require "open3"
|
31
32
|
require "thor"
|
32
33
|
require "yaml"
|
33
34
|
|
34
35
|
require_relative "cli_helpers"
|
36
|
+
require_relative "cli_rubies"
|
35
37
|
require_relative "error"
|
36
38
|
|
37
39
|
# Tebako - an executable packager
|
@@ -47,24 +49,21 @@ module Tebako
|
|
47
49
|
desc "clean", "Clean tebako packaging environment"
|
48
50
|
def clean
|
49
51
|
puts "Cleaning tebako packaging environment"
|
50
|
-
|
52
|
+
# Using File.join(deps, "") to ensure that the slashes are appropriate
|
53
|
+
FileUtils.rm_rf([File.join(deps, ""), File.join(output, "")], secure: true)
|
51
54
|
end
|
52
55
|
|
53
56
|
desc "clean_ruby", "Clean Ruby source from tebako packaging environment"
|
54
57
|
method_option :Ruby, type: :string, aliases: "-R", required: false,
|
55
|
-
enum: Tebako::
|
58
|
+
enum: Tebako::CliRubies::RUBY_VERSIONS.keys,
|
56
59
|
desc: "Ruby version to clean, all available versions by default"
|
57
60
|
def clean_ruby
|
58
61
|
puts "Cleaning Ruby sources from tebako packaging environment"
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
nms = "#{deps}/stash_#{options["Ruby"]}"
|
65
|
-
end
|
66
|
-
FileUtils.rm_rf(Dir.glob(nmr), secure: true)
|
67
|
-
FileUtils.rm_rf(Dir.glob(nms), secure: true)
|
62
|
+
suffix = options["Ruby"].nil? ? "" : "_#{options["Ruby"]}"
|
63
|
+
nmr = "src/_ruby_#{suffix}*"
|
64
|
+
nms = "stash_#{suffix}"
|
65
|
+
FileUtils.rm_rf(Dir.glob(File.join(deps, nmr)), secure: true)
|
66
|
+
FileUtils.rm_rf(Dir.glob(File.join(deps, nms)), secure: true)
|
68
67
|
end
|
69
68
|
|
70
69
|
desc "hash", "Print build script hash (ci cache key)"
|
@@ -81,8 +80,8 @@ module Tebako
|
|
81
80
|
desc: "Tebako package file name, entry point base file name in the current folder by default"
|
82
81
|
method_option :root, type: :string, aliases: "-r", required: true, desc: "Root folder of the Ruby application"
|
83
82
|
method_option :Ruby, type: :string, aliases: "-R", required: false,
|
84
|
-
enum: Tebako::
|
85
|
-
desc: "Tebako package Ruby version, #{Tebako::
|
83
|
+
enum: Tebako::CliRubies::RUBY_VERSIONS.keys,
|
84
|
+
desc: "Tebako package Ruby version, #{Tebako::CliRubies::DEFAULT_RUBY_VERSION} by default"
|
86
85
|
def press
|
87
86
|
puts press_announce
|
88
87
|
do_press
|
@@ -93,8 +92,8 @@ module Tebako
|
|
93
92
|
|
94
93
|
desc "setup", "Set up tebako packaging environment"
|
95
94
|
method_option :Ruby, type: :string, aliases: "-R", required: false,
|
96
|
-
enum: Tebako::
|
97
|
-
desc: "Tebako package Ruby version, #{Tebako::
|
95
|
+
enum: Tebako::CliRubies::RUBY_VERSIONS.keys,
|
96
|
+
desc: "Tebako package Ruby version, #{Tebako::CliRubies::DEFAULT_RUBY_VERSION} by default."
|
98
97
|
def setup
|
99
98
|
puts "Setting up tebako packaging environment"
|
100
99
|
do_setup
|
@@ -122,29 +121,23 @@ module Tebako
|
|
122
121
|
|
123
122
|
no_commands do
|
124
123
|
def do_press
|
125
|
-
|
126
|
-
|
127
|
-
|
124
|
+
cfg_cmd = "cmake -DSETUP_MODE:BOOLEAN=OFF #{cfg_options} #{press_options}"
|
125
|
+
build_cmd = "cmake --build #{output} --target tebako --parallel #{Etc.nprocessors}"
|
126
|
+
merged_env = ENV.to_h.merge(b_env)
|
127
|
+
Tebako.packaging_error(103) unless system(merged_env, cfg_cmd)
|
128
|
+
Tebako.packaging_error(104) unless system(merged_env, build_cmd)
|
128
129
|
end
|
129
130
|
|
130
131
|
def do_setup
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
def press_announce
|
137
|
-
@press_announce ||= <<~ANN
|
138
|
-
Running tebako press at #{prefix}
|
139
|
-
Ruby version: '#{extend_ruby_version[0]}'
|
140
|
-
Project root: '#{options["root"]}'
|
141
|
-
Application entry point: '#{options["entry-point"]}'
|
142
|
-
Package file name: '#{package}'
|
143
|
-
Loging level: '#{l_level}'
|
144
|
-
ANN
|
132
|
+
cfg_cmd = "cmake -DSETUP_MODE:BOOLEAN=ON #{cfg_options}"
|
133
|
+
build_cmd = "cmake --build \"#{output}\" --target setup --parallel #{Etc.nprocessors}"
|
134
|
+
merged_env = ENV.to_h.merge(b_env)
|
135
|
+
Tebako.packaging_error(101) unless system(merged_env, cfg_cmd)
|
136
|
+
Tebako.packaging_error(102) unless system(merged_env, build_cmd)
|
145
137
|
end
|
146
138
|
end
|
147
139
|
|
148
140
|
include Tebako::CliHelpers
|
141
|
+
include Tebako::CliRubies
|
149
142
|
end
|
150
143
|
end
|
data/lib/tebako/cli_helpers.rb
CHANGED
@@ -30,13 +30,14 @@ require "fileutils"
|
|
30
30
|
require "pathname"
|
31
31
|
require "rbconfig"
|
32
32
|
|
33
|
+
require_relative "cli_rubies"
|
33
34
|
require_relative "error"
|
34
35
|
require_relative "version"
|
35
36
|
|
36
37
|
# Tebako - an executable packager
|
37
38
|
# Command-line interface methods
|
38
39
|
module Tebako
|
39
|
-
# Cli
|
40
|
+
# Cli helpers
|
40
41
|
module CliHelpers
|
41
42
|
def b_env
|
42
43
|
u_flags = if RbConfig::CONFIG["host_os"] =~ /darwin/
|
@@ -49,35 +50,25 @@ module Tebako
|
|
49
50
|
|
50
51
|
def cfg_options
|
51
52
|
ruby_ver, ruby_hash = extend_ruby_version
|
53
|
+
# Cannot use 'xxx' as parameters because it does not work in Windows shells
|
54
|
+
# So we have to use \"xxx\"
|
52
55
|
@cfg_options ||=
|
53
|
-
"-DCMAKE_BUILD_TYPE=Release -DRUBY_VER:STRING
|
54
|
-
"-DDEPS:STRING
|
56
|
+
"-DCMAKE_BUILD_TYPE=Release -DRUBY_VER:STRING=\"#{ruby_ver}\" -DRUBY_HASH:STRING=\"#{ruby_hash}\" " \
|
57
|
+
"-DDEPS:STRING=\"#{deps}\" -G \"#{m_files}\" -B \"#{output}\" -S \"#{source}\""
|
55
58
|
end
|
56
59
|
|
57
60
|
def deps
|
58
61
|
@deps ||= File.join(prefix, "deps")
|
59
62
|
end
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}.freeze
|
68
|
-
|
69
|
-
DEFAULT_RUBY_VERSION = "3.1.4"
|
70
|
-
|
71
|
-
def extend_ruby_version
|
72
|
-
version = options["Ruby"].nil? ? DEFAULT_RUBY_VERSION : options["Ruby"]
|
73
|
-
unless RUBY_VERSIONS.key?(version)
|
74
|
-
raise Tebako::Error.new(
|
75
|
-
"Ruby version #{version} is not supported yet, exiting",
|
76
|
-
253
|
77
|
-
)
|
64
|
+
def fs_current
|
65
|
+
fs_current = Dir.pwd
|
66
|
+
if RUBY_PLATFORM =~ /msys|mingw|cygwin/
|
67
|
+
fs_current, cygpath_res = Open3.capture2e("cygpath", "-w", fs_current)
|
68
|
+
Tebako.packaging_error(101) unless cygpath_res.success?
|
69
|
+
fs_current.strip!
|
78
70
|
end
|
79
|
-
|
80
|
-
@extend_ruby_version ||= [version, RUBY_VERSIONS[version]]
|
71
|
+
@fs_current ||= fs_current
|
81
72
|
end
|
82
73
|
|
83
74
|
def l_level
|
@@ -90,14 +81,17 @@ module Tebako
|
|
90
81
|
|
91
82
|
# rubocop:disable Metrics/MethodLength
|
92
83
|
def m_files
|
93
|
-
|
84
|
+
# [TODO]
|
85
|
+
# Ninja generates incorrect script fot tebako press target -- gets lost in a chain custom targets
|
86
|
+
# Using makefiles has negative performance impact so it needs to be fixed
|
87
|
+
@m_files ||= case RUBY_PLATFORM
|
94
88
|
when /linux/, /darwin/
|
95
89
|
"Unix Makefiles"
|
96
|
-
when /msys/
|
97
|
-
"
|
90
|
+
when /msys|mingw|cygwin/
|
91
|
+
"MinGW Makefiles"
|
98
92
|
else
|
99
93
|
raise Tebako::Error.new(
|
100
|
-
"#{
|
94
|
+
"#{RUBY_PLATFORM} is not supported yet, exiting",
|
101
95
|
254
|
102
96
|
)
|
103
97
|
end
|
@@ -109,26 +103,18 @@ module Tebako
|
|
109
103
|
end
|
110
104
|
|
111
105
|
def package
|
112
|
-
|
113
|
-
|
106
|
+
package = if options["output"].nil?
|
107
|
+
File.join(Dir.pwd, File.basename(options["entry-point"], ".*"))
|
108
|
+
else
|
109
|
+
options["output"]
|
110
|
+
end
|
111
|
+
@package ||= if relative?(package)
|
112
|
+
File.join(fs_current, package)
|
114
113
|
else
|
115
|
-
|
114
|
+
package
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
119
|
-
PACKAGING_ERRORS = {
|
120
|
-
101 => "'tebako setup' configure step failed",
|
121
|
-
102 => "'tebako setup' build step failed",
|
122
|
-
103 => "'tebako press' configure step failed",
|
123
|
-
104 => "'tebako press' build step failed"
|
124
|
-
}.freeze
|
125
|
-
|
126
|
-
def packaging_error(code)
|
127
|
-
msg = PACKAGING_ERRORS[code]
|
128
|
-
msg = "Unknown packaging error" if msg.nil?
|
129
|
-
raise Tebako::Error.new msg, code
|
130
|
-
end
|
131
|
-
|
132
118
|
def prefix
|
133
119
|
@prefix ||= if options["prefix"].nil?
|
134
120
|
puts "No prefix specified, using ~/.tebako"
|
@@ -140,10 +126,33 @@ module Tebako
|
|
140
126
|
end
|
141
127
|
end
|
142
128
|
|
129
|
+
def press_announce
|
130
|
+
@press_announce ||= <<~ANN
|
131
|
+
Running tebako press at #{prefix}
|
132
|
+
Ruby version: '#{extend_ruby_version[0]}'
|
133
|
+
Project root: '#{root}'
|
134
|
+
Application entry point: '#{options["entry-point"]}'
|
135
|
+
Package file name: '#{package}'
|
136
|
+
Loging level: '#{l_level}'
|
137
|
+
ANN
|
138
|
+
end
|
139
|
+
|
143
140
|
def press_options
|
144
141
|
@press_options ||=
|
145
|
-
"-DROOT:STRING='#{
|
146
|
-
"-DPCKG:STRING='#{package}' -DLOG_LEVEL:STRING='#{options["log-level"]}'"
|
142
|
+
"-DROOT:STRING='#{root}' -DENTRANCE:STRING='#{options["entry-point"]}' " \
|
143
|
+
"-DPCKG:STRING='#{package}' -DLOG_LEVEL:STRING='#{options["log-level"]}' "
|
144
|
+
end
|
145
|
+
|
146
|
+
def relative?(path)
|
147
|
+
Pathname.new(path).relative?
|
148
|
+
end
|
149
|
+
|
150
|
+
def root
|
151
|
+
@root ||= if relative?(options["root"])
|
152
|
+
File.join(fs_current, options["root"])
|
153
|
+
else
|
154
|
+
File.join(options["root"], "")
|
155
|
+
end
|
147
156
|
end
|
148
157
|
|
149
158
|
def source
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
|
4
|
+
# All rights reserved.
|
5
|
+
# This file is a part of tebako
|
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 "fileutils"
|
29
|
+
require "pathname"
|
30
|
+
require "rbconfig"
|
31
|
+
|
32
|
+
require_relative "error"
|
33
|
+
require_relative "version"
|
34
|
+
|
35
|
+
# Tebako - an executable packager
|
36
|
+
# Command-line interface methods
|
37
|
+
module Tebako
|
38
|
+
# Ruby version helpers
|
39
|
+
module CliRubies
|
40
|
+
RUBY_VERSIONS = {
|
41
|
+
"2.7.8" => "c2dab63cbc8f2a05526108ad419efa63a67ed4074dbbcf9fc2b1ca664cb45ba0",
|
42
|
+
"3.0.6" => "6e6cbd490030d7910c0ff20edefab4294dfcd1046f0f8f47f78b597987ac683e",
|
43
|
+
"3.1.4" => "a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6",
|
44
|
+
"3.2.3" => "af7f1757d9ddb630345988139211f1fd570ff5ba830def1cc7c468ae9b65c9ba",
|
45
|
+
"3.3.0" => "96518814d9832bece92a85415a819d4893b307db5921ae1f0f751a9a89a56b7d"
|
46
|
+
}.freeze
|
47
|
+
|
48
|
+
DEFAULT_RUBY_VERSION = "3.1.4"
|
49
|
+
|
50
|
+
def version_check(version)
|
51
|
+
return if RUBY_VERSIONS.key?(version)
|
52
|
+
|
53
|
+
raise Tebako::Error.new(
|
54
|
+
"Ruby version #{version} is not supported yet, exiting",
|
55
|
+
253
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
def version_check_msys(version)
|
60
|
+
return unless version != DEFAULT_RUBY_VERSION && RbConfig::CONFIG["host_os"] =~ /msys|mingw|cygwin/
|
61
|
+
|
62
|
+
raise Tebako::Error.new(
|
63
|
+
"Windows packaging is compatible with Ruby #{DEFAULT_RUBY_VERSION} only, version #{version} is not supported",
|
64
|
+
252
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
def extend_ruby_version
|
69
|
+
version = options["Ruby"].nil? ? DEFAULT_RUBY_VERSION : options["Ruby"]
|
70
|
+
version_check(version)
|
71
|
+
version_check_msys(version)
|
72
|
+
@extend_ruby_version ||= [version, RUBY_VERSIONS[version]]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/tebako/error.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
|
3
|
+
# Copyright (c) 2023-204 [Ribose Inc](https://www.ribose.com).
|
4
4
|
# All rights reserved.
|
5
5
|
# This file is a part of tebako
|
6
6
|
#
|
@@ -26,8 +26,23 @@
|
|
26
26
|
# POSSIBILITY OF SUCH DAMAGE.
|
27
27
|
|
28
28
|
# Tebako - an executable packager
|
29
|
-
# Tebako error class
|
30
29
|
module Tebako
|
30
|
+
PACKAGING_ERRORS = {
|
31
|
+
101 => "'tebako setup' configure step failed",
|
32
|
+
102 => "'tebako setup' build step failed",
|
33
|
+
103 => "'tebako press' configure step failed",
|
34
|
+
104 => "'tebako press' build step failed",
|
35
|
+
105 => "Failed to map MSys path to Windows"
|
36
|
+
}.freeze
|
37
|
+
|
38
|
+
class << self
|
39
|
+
def packaging_error(code)
|
40
|
+
msg = PACKAGING_ERRORS[code]
|
41
|
+
msg = "Unknown packaging error" if msg.nil?
|
42
|
+
raise Tebako::Error.new msg, code
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
31
46
|
# Tebako error class
|
32
47
|
class Error < StandardError
|
33
48
|
def initialize(msg = "Unspecified error", code = 255)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2021-
|
3
|
+
# Copyright (c) 2021-2024 [Ribose Inc](https://www.ribose.com).
|
4
4
|
# All rights reserved.
|
5
5
|
# This file is a part of tebako
|
6
6
|
#
|
@@ -25,6 +25,7 @@
|
|
25
25
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
26
|
# POSSIBILITY OF SUCH DAMAGE.
|
27
27
|
|
28
|
+
require_relative "patch_literals"
|
28
29
|
require_relative "patch_helpers"
|
29
30
|
|
30
31
|
# Tebako - an executable packager
|
@@ -32,12 +33,21 @@ module Tebako
|
|
32
33
|
module Packager
|
33
34
|
# Ruby patching definitions (pass1)
|
34
35
|
module Pass1
|
36
|
+
# [TODO] looks like it does not exist in 3.1.4
|
37
|
+
# May be obsolete
|
35
38
|
TOOL_RBINSTALL_RB_PATCH = {
|
36
39
|
" next if files.empty?" => "# tebako patched next if files.empty?"
|
37
40
|
}.freeze
|
38
41
|
|
42
|
+
RUBYGEM_OPENSSL_RB_SUBST = <<~SUBST
|
43
|
+
# Start of tebako patch
|
44
|
+
require "openssl"
|
45
|
+
# End of tebako patch
|
46
|
+
autoload :OpenSSL, "openssl"
|
47
|
+
SUBST
|
48
|
+
|
39
49
|
RUBYGEM_OPENSSL_RB_PATCH = {
|
40
|
-
'autoload :OpenSSL, "openssl"' =>
|
50
|
+
'autoload :OpenSSL, "openssl"' => RUBYGEM_OPENSSL_RB_SUBST
|
41
51
|
}.freeze
|
42
52
|
|
43
53
|
EXT_SETUP_PATCH = {
|
@@ -77,13 +87,25 @@ module Tebako
|
|
77
87
|
SUBST
|
78
88
|
}.freeze
|
79
89
|
|
80
|
-
|
90
|
+
DARWIN_CONFIGURE_PATCH = {
|
81
91
|
"EXTDLDFLAGS=\"-bundle_loader '\\$(BUILTRUBY)'\"" => ""
|
82
92
|
}.freeze
|
83
93
|
|
94
|
+
OPENSSL_EXTCONF_RB_SUBST = <<~SUBST
|
95
|
+
# Start of tebako patch
|
96
|
+
$defs.push("-DRUBY_EXPORT=1")
|
97
|
+
# End of tebako patch
|
98
|
+
|
99
|
+
Logging::message "=== Checking done. ===\\n"
|
100
|
+
SUBST
|
101
|
+
|
102
|
+
OPENSSL_EXTCONF_RB_PATCH = {
|
103
|
+
"Logging::message \"=== Checking done. ===\\n\"" => OPENSSL_EXTCONF_RB_SUBST
|
104
|
+
}.freeze
|
105
|
+
|
84
106
|
class << self
|
85
|
-
def
|
86
|
-
|
107
|
+
def get_base_patch_map(mount_point)
|
108
|
+
{
|
87
109
|
# ....................................................
|
88
110
|
# It won't install gems with no files defined in spec
|
89
111
|
# However if
|
@@ -91,6 +113,8 @@ module Tebako
|
|
91
113
|
# -- extension is build statically
|
92
114
|
# there may be no files install in addition to spec
|
93
115
|
# Example: io/wait extension (and others)
|
116
|
+
# [TODO] Check if it is still required
|
117
|
+
# No match and patching on Ruby 3.1.4 but works wo issues
|
94
118
|
"tool/rbinstall.rb" => TOOL_RBINSTALL_RB_PATCH,
|
95
119
|
|
96
120
|
# ....................................................
|
@@ -106,20 +130,61 @@ module Tebako
|
|
106
130
|
# Disable dynamic extensions
|
107
131
|
"ext/Setup" => EXT_SETUP_PATCH
|
108
132
|
}
|
133
|
+
end
|
134
|
+
|
135
|
+
def get_patch_map(ostype, mount_point, ruby_ver)
|
136
|
+
patch_map = get_base_patch_map(mount_point)
|
137
|
+
|
109
138
|
# ....................................................
|
110
139
|
# Fixing (bypassing) configure script bug where a variable is used before initialization
|
111
|
-
patch_map.store("configure",
|
140
|
+
patch_map.store("configure", DARWIN_CONFIGURE_PATCH) if ostype =~ /darwin/
|
112
141
|
|
113
142
|
# ....................................................
|
114
143
|
# autoload :OpenSSL, "openssl"
|
115
144
|
# fails to deal with a default gem from statically linked extension
|
116
145
|
patch_map.store("lib/rubygems/openssl.rb", RUBYGEM_OPENSSL_RB_PATCH) if PatchHelpers.ruby3x?(ruby_ver)
|
117
146
|
|
147
|
+
if ostype =~ /msys/
|
148
|
+
# ....................................................
|
149
|
+
# Generate export definitions; use WinMain to build rubyw.exe
|
150
|
+
patch_map.store("cygwin/GNUmakefile.in", get_gnumakefile_in_patch_p1(ruby_ver))
|
151
|
+
# ....................................................
|
152
|
+
# RUBY_EXPORT=1 (shall ve set for static builds but is missing in openssl extension)
|
153
|
+
patch_map.store("ext/openssl/extconf.rb", OPENSSL_EXTCONF_RB_PATCH)
|
154
|
+
end
|
155
|
+
|
118
156
|
patch_map
|
119
157
|
end
|
120
158
|
|
121
159
|
private
|
122
160
|
|
161
|
+
include Tebako::Packager::PatchLiterals
|
162
|
+
|
163
|
+
def get_gnumakefile_in_patch_p1(ruby_ver) # rubocop:disable Metrics/MethodLength
|
164
|
+
objext = PatchHelpers.ruby32?(ruby_ver) ? "$(OBJEXT)" : "@OBJEXT@"
|
165
|
+
{
|
166
|
+
" DLLWRAP += -mno-cygwin" =>
|
167
|
+
"# tebako patched DLLWRAP += -mno-cygwin",
|
168
|
+
|
169
|
+
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext}" =>
|
170
|
+
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext} $(WINMAINOBJ) # tebako patched",
|
171
|
+
|
172
|
+
"$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@" =>
|
173
|
+
"$(WINMAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@ # tebako patched",
|
174
|
+
|
175
|
+
"--output-exp=$(RUBY_EXP) \\" =>
|
176
|
+
"--output-exp=$(RUBY_EXP) --output-lib=$(LIBRUBY) --output-def=tebako.def \\",
|
177
|
+
|
178
|
+
" @rm -f $(PROGRAM)" =>
|
179
|
+
"# tebako patched @rm -f $(PROGRAM)",
|
180
|
+
|
181
|
+
" $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)" =>
|
182
|
+
"# tebako patched $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)",
|
183
|
+
|
184
|
+
"RUBYDEF = $(DLL_BASE_NAME).def" => GNUMAKEFILE_IN_WINMAIN_SUBST
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
123
188
|
def rubygems_path_support_patch_one(mount_point)
|
124
189
|
<<~SUBST
|
125
190
|
@home = env["GEM_HOME"] || Gem.default_dir
|