tebako 0.6.0 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +4 -4
- data/README.adoc +14 -15
- data/common.env +1 -1
- data/include/tebako/tebako-main.h +2 -1
- data/lib/tebako/cli_rubies.rb +6 -6
- data/lib/tebako/packager/pass1.rb +2 -0
- data/lib/tebako/packager/pass2.rb +35 -44
- data/lib/tebako/packager/patch_buildsystem.rb +125 -0
- data/lib/tebako/packager/patch_helpers.rb +10 -0
- data/lib/tebako/packager/patch_libraries.rb +12 -0
- data/lib/tebako/packager/patch_literals.rb +49 -59
- data/lib/tebako/version.rb +1 -1
- data/src/tebako-main.cpp +8 -1
- data/version.txt +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34a8463d460a7d42e197e9237b49175944f3119aed26735246c65cd915be82cf
|
4
|
+
data.tar.gz: f699b42afc5529fb1d3a0651d4e2462eed3630d3e12369ef7feea09cb7296f6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0282fce5e343e77c355e86528ddc5f640e6331f354d834f166175351c13e13476d888f78a0c6a221f857be7f071b9240f730095edd876d2674c47515fcb62581'
|
7
|
+
data.tar.gz: e0c9755655e63b19248a9d61ee7933bf8c6891bb1aeb23597e9a65d6015d26f7e6c807006ea3729dbaa0ef41c1a2a12116ddddcc123f8d76cf4d412a25726df1
|
data/CMakeLists.txt
CHANGED
@@ -214,7 +214,7 @@ if(DWARFS_PRELOAD)
|
|
214
214
|
list(GET LIBDWARFS_WR_VER_COMPONENTS 2 LIBDWARFS_WR_VER_PATCH)
|
215
215
|
set (LIBDWARFS_WR_VER_M ${LIBDWARFS_WR_VER_MAJOR}.${LIBDWARFS_WR_VER_MINOR}.${LIBDWARFS_WR_VER_PATCH})
|
216
216
|
else(DWARFS_PRELOAD)
|
217
|
-
def_ext_prj_g(DWARFS_WR "v0.5.
|
217
|
+
def_ext_prj_g(DWARFS_WR "v0.5.2")
|
218
218
|
endif(DWARFS_PRELOAD)
|
219
219
|
|
220
220
|
set(LIBYAML_RUBY_OPTION "")
|
@@ -560,9 +560,9 @@ else (${SETUP_MODE})
|
|
560
560
|
COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.a"
|
561
561
|
COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.o"
|
562
562
|
COMMAND ${GNU_BASH} -c "chmod +x ${DEPS_BIN_DIR}/mkdwarfs${EXE_SUFFIX}"
|
563
|
-
# No progress below is
|
564
|
-
# and it creates
|
565
|
-
# It may be fixable bit is very difficult to reproduce in
|
563
|
+
# No progress below is critical since in reporting mode mkdwarfs tries to work directly with terminal
|
564
|
+
# and it creates issues for stderr redirects (&2 > 1) used by Ninja and our test srcipts
|
565
|
+
# It may be fixable bit is very difficult to reproduce in test environment
|
566
566
|
COMMAND ${DEPS_BIN_DIR}/mkdwarfs -o ${DATA_BIN_FILE} -i ${DATA_SRC_DIR} --no-progress
|
567
567
|
COMMAND ${CMAKE_COMMAND} -E touch ${DEPS_SRC_DIR}/tebako/tebako-fs.cpp
|
568
568
|
DEPENDS setup source_filesystem
|
data/README.adoc
CHANGED
@@ -5,7 +5,6 @@ image:https://github.com/tamatebako/tebako/actions/workflows/alpine.yml/badge.sv
|
|
5
5
|
image:https://github.com/tamatebako/tebako/actions/workflows/macos.yml/badge.svg["MacOS amd64", link="https://github.com/tamatebako/tebako/actions/workflows/macos.yml"]
|
6
6
|
image:https://github.com/tamatebako/tebako/actions/workflows/windows-msys.yml/badge.svg["Windows msys", link="https://github.com/tamatebako/tebako/actions/workflows/windows-msys.yml"]
|
7
7
|
|
8
|
-
image:https://api.cirrus-ci.com/github/tamatebako/tebako.svg?branch=main&task=macos-arm64["MacOS arm64", link="https://cirrus-ci.com/github/tamatebako/tebako"]
|
9
8
|
image:https://api.cirrus-ci.com/github/tamatebako/tebako.svg?branch=main&task=ubuntu-aarch64["Ubuntu aarch64", link="https://cirrus-ci.com/github/tamatebako/tebako"]
|
10
9
|
|
11
10
|
image:https://github.com/tamatebako/tebako/actions/workflows/lint.yml/badge.svg["lint", link="https://github.com/tamatebako/tebako/actions/workflows/lint.yml"]
|
@@ -36,7 +35,7 @@ In the future:
|
|
36
35
|
The Tebako packager is tested on the following platforms:
|
37
36
|
|
38
37
|
* Linux: Ubuntu 20.04; Alpine 3.17
|
39
|
-
* MacOS: macOS 12 (Monterey), 13 (Ventura)
|
38
|
+
* MacOS: macOS 12 (Monterey), 13 (Ventura), 14 (Sonoma)
|
40
39
|
* Windows: 2019, 2022 (using MinGW ucrt64 toolchain)
|
41
40
|
|
42
41
|
Please note that Windows support is in pre-release and is a subject of further testing and optimization
|
@@ -48,7 +47,7 @@ The Tebako packager supports the following versions of Ruby for packaging:
|
|
48
47
|
* 2.7.8 (Linux, MacOS)
|
49
48
|
* 3.0.6 (Linux, MacOS)
|
50
49
|
* 3.1.4 (Linux, MacOS, Windows)
|
51
|
-
* 3.2.3 (Linux, MacOS)
|
50
|
+
* 3.2.3 (Linux, MacOS, Windows)
|
52
51
|
|
53
52
|
Support of specific version including minor release requires some effort, sometimes extensive
|
54
53
|
but our goal is to be able to package all maintained Ruby releases.
|
@@ -129,31 +128,31 @@ brew install gnu-sed bash pkg-config bison flex binutils libffi gdbm zlib ncurse
|
|
129
128
|
double-conversion boost jemalloc fmt glog libevent libsodium lz4 xz libyaml openssl@3
|
130
129
|
----
|
131
130
|
|
132
|
-
|
131
|
+
=== Windows (2019, 2022)
|
133
132
|
|
134
|
-
|
133
|
+
The simplest approach is to use Ruby development environment provided by RubyInstaller, for example Ruby+Devkit 3.1.4-1.
|
135
134
|
|
136
|
-
|
135
|
+
Once it is installed use the following commands:
|
137
136
|
|
138
137
|
[source,sh]
|
139
138
|
----
|
140
|
-
|
139
|
+
ridk enable ucrt64
|
140
|
+
pacman -S git tar bison flex toolchain make cmake
|
141
|
+
boost diffutils libevent double-conversion
|
142
|
+
fmt glog dlfcn gtest autotools ncurses libyaml
|
141
143
|
----
|
142
144
|
|
143
|
-
|
145
|
+
== Installation
|
144
146
|
|
145
|
-
|
146
|
-
|
147
|
+
=== General
|
148
|
+
|
149
|
+
Tebako is distributed as a Ruby gem
|
147
150
|
|
148
151
|
[source,sh]
|
149
152
|
----
|
150
|
-
|
151
|
-
pacman -S git tar bison flex toolchain make cmake
|
152
|
-
boost diffutils libevent double-conversion
|
153
|
-
fmt glog dlfcn gtest autotools ncurses libyaml
|
153
|
+
gem install tebako
|
154
154
|
----
|
155
155
|
|
156
|
-
|
157
156
|
=== Quick setup on Ubuntu 20.04 on Docker
|
158
157
|
|
159
158
|
Launch a container on the target platform:
|
data/common.env
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
*
|
3
|
-
* Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
|
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
|
*
|
@@ -32,6 +32,7 @@ extern "C" {
|
|
32
32
|
#endif
|
33
33
|
int tebako_main(int* argc, char*** argv);
|
34
34
|
const char* tebako_mount_point(void);
|
35
|
+
int tebako_is_running_miniruby(void);
|
35
36
|
#ifdef RB_W32
|
36
37
|
int tebako_file_load_ok(const char *path);
|
37
38
|
#endif
|
data/lib/tebako/cli_rubies.rb
CHANGED
@@ -57,12 +57,12 @@ module Tebako
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def version_check_msys(version)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
if Gem::Version.new(version) < Gem::Version.new(DEFAULT_RUBY_VERSION) && RUBY_PLATFORM =~ /msys|mingw|cygwin/
|
61
|
+
raise Tebako::Error.new(
|
62
|
+
"Windows packaging works for Ruby #{DEFAULT_RUBY_VERSION} or above, version #{version} is not supported",
|
63
|
+
252
|
64
|
+
)
|
65
|
+
end
|
66
66
|
end
|
67
67
|
|
68
68
|
def extend_ruby_version
|
@@ -27,6 +27,7 @@
|
|
27
27
|
|
28
28
|
require_relative "patch_literals"
|
29
29
|
require_relative "patch_helpers"
|
30
|
+
require_relative "patch_buildsystem"
|
30
31
|
|
31
32
|
# Tebako - an executable packager
|
32
33
|
module Tebako
|
@@ -159,6 +160,7 @@ module Tebako
|
|
159
160
|
private
|
160
161
|
|
161
162
|
include Tebako::Packager::PatchLiterals
|
163
|
+
include Tebako::Packager::PatchBuildsystem
|
162
164
|
|
163
165
|
def get_gnumakefile_in_patch_p1(ruby_ver) # rubocop:disable Metrics/MethodLength
|
164
166
|
objext = PatchHelpers.ruby32?(ruby_ver) ? "$(OBJEXT)" : "@OBJEXT@"
|
@@ -28,6 +28,7 @@
|
|
28
28
|
require_relative "patch_literals"
|
29
29
|
require_relative "patch_libraries"
|
30
30
|
require_relative "patch_helpers"
|
31
|
+
require_relative "patch_buildsystem"
|
31
32
|
|
32
33
|
# Tebako - an executable packager
|
33
34
|
module Tebako
|
@@ -40,7 +41,7 @@ module Tebako
|
|
40
41
|
|
41
42
|
patch_map.store("thread_pthread.c", LINUX_MUSL_THREAD_PTHREAD_PATCH) if ostype =~ /linux-musl/
|
42
43
|
|
43
|
-
if ostype
|
44
|
+
if PatchHelpers.msys?(ostype)
|
44
45
|
patch_map.merge!(get_msys_patches(ruby_ver))
|
45
46
|
elsif PatchHelpers.ruby3x?(ruby_ver)
|
46
47
|
# [TODO] Do we really need it for platforms other then Windows ??
|
@@ -52,47 +53,51 @@ module Tebako
|
|
52
53
|
|
53
54
|
private
|
54
55
|
|
56
|
+
include Tebako::Packager::PatchBuildsystem
|
55
57
|
include Tebako::Packager::PatchLiterals
|
56
58
|
|
57
59
|
def get_dir_c_patch(ostype)
|
58
|
-
|
60
|
+
pattern = PatchHelpers.msys?(ostype) ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST"
|
61
|
+
dir_c_patch = PatchHelpers.patch_c_file(pattern)
|
59
62
|
dir_c_patch.merge!(DIR_C_BASE_PATCH)
|
63
|
+
dir_c_patch
|
60
64
|
end
|
61
65
|
|
62
|
-
def get_dln_c_patch(ostype)
|
66
|
+
def get_dln_c_patch(ostype, ruby_ver)
|
63
67
|
# Not using substitutions of dlxxx functions on Windows
|
64
68
|
dln_c_patch = {
|
65
69
|
"static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;" =>
|
66
|
-
"#{ostype
|
70
|
+
"#{PatchHelpers.msys?(ostype) ? C_FILE_SUBST_LESS : C_FILE_SUBST}\n" \
|
67
71
|
"static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;\n"
|
68
72
|
}
|
69
|
-
|
73
|
+
|
74
|
+
if PatchHelpers.msys?(ostype)
|
75
|
+
patch = PatchHelpers.ruby32?(ruby_ver) ? DLN_C_MSYS_PATCH : DLN_C_MSYS_PATCH_PRE32
|
76
|
+
dln_c_patch.merge!(patch)
|
77
|
+
end
|
78
|
+
|
70
79
|
dln_c_patch
|
71
80
|
end
|
72
81
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
82
|
+
def get_io_c_msys_patch(ruby_ver)
|
83
|
+
io_c_msys_patch = PatchHelpers.ruby32?(ruby_ver) ? IO_C_MSYS_PATCH : IO_C_MSYS_PATCH_PRE_32
|
84
|
+
io_c_msys_patch.merge(IO_C_MSYS_BASE_PATCH)
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_io_c_patch(ostype, ruby_ver)
|
88
|
+
io_c_patch = PatchHelpers.patch_c_file("/* define system APIs */")
|
89
|
+
io_c_patch.merge!(get_io_c_msys_patch(ruby_ver)) if PatchHelpers.msys?(ostype)
|
76
90
|
io_c_patch
|
77
91
|
end
|
78
92
|
|
79
|
-
def
|
80
|
-
# For pass 2 we 'kill ruby.exp' regeneration
|
81
|
-
objext = PatchHelpers.ruby32?(ruby_ver) ? "$(OBJEXT)" : "@OBJEXT@"
|
93
|
+
def get_msys_mkconfig_rb_patches(ruby_ver)
|
82
94
|
{
|
83
|
-
"
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
"
|
88
|
-
|
89
|
-
"RUBYDEF = $(DLL_BASE_NAME).def" => GNUMAKEFILE_IN_WINMAIN_SUBST,
|
90
|
-
|
91
|
-
"$(RUBY_EXP): $(LIBRUBY_A)" => "dummy.exp: $(LIBRUBY_A) # tebako patched",
|
92
|
-
|
93
|
-
"$(PROGRAM): $(RUBY_INSTALL_NAME).res.#{objext}" =>
|
94
|
-
"$(PROGRAM): $(RUBY_INSTALL_NAME).res.#{objext} $(LIBRUBY_A) # tebako patched\n" \
|
95
|
-
"$(LIBRUBY_A): $(LIBRUBY_A_OBJS) $(INITOBJS) # tebako patched\n"
|
95
|
+
" if fast[name]" => TOOLS_MKCONFIG_RB_SUBST,
|
96
|
+
"when /RUBYGEMS/; next" =>
|
97
|
+
"when /RUBYGEMS/; next\n\n" \
|
98
|
+
"# Start of tebako patch\n" \
|
99
|
+
"when /MAINLIBS/; val = #{PatchLibraries.msys_base_libs(ruby_ver)}\n" \
|
100
|
+
"# End of tebako patch"
|
96
101
|
}
|
97
102
|
end
|
98
103
|
|
@@ -106,13 +111,15 @@ module Tebako
|
|
106
111
|
end
|
107
112
|
|
108
113
|
def get_patch_map_base(ostype, deps_lib_dir, ruby_ver)
|
114
|
+
mcrb_subst = PatchHelpers.msys?(ostype) ? get_msys_mkconfig_rb_patches(ruby_ver) : TOOL_MKCONFIG_RB_PATCH
|
109
115
|
{
|
110
116
|
"template/Makefile.in" => template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver),
|
111
|
-
"tool/mkconfig.rb" =>
|
117
|
+
"tool/mkconfig.rb" => mcrb_subst,
|
112
118
|
"gem_prelude.rb" => GEM_PRELUDE_RB_PATCH,
|
113
|
-
"dir.c" => get_dir_c_patch(ostype), "dln.c" => get_dln_c_patch(ostype),
|
114
|
-
"io.c" => get_io_c_patch(ostype),
|
115
|
-
"
|
119
|
+
"dir.c" => get_dir_c_patch(ostype), "dln.c" => get_dln_c_patch(ostype, ruby_ver),
|
120
|
+
"io.c" => get_io_c_patch(ostype, ruby_ver), "main.c" => MAIN_C_PATCH,
|
121
|
+
"file.c" => PatchHelpers.patch_c_file("/* define system APIs */"),
|
122
|
+
"util.c" => PatchHelpers.patch_c_file("#ifndef S_ISDIR")
|
116
123
|
}
|
117
124
|
end
|
118
125
|
|
@@ -126,25 +133,9 @@ module Tebako
|
|
126
133
|
}
|
127
134
|
end
|
128
135
|
|
129
|
-
def patch_c_file(pattern)
|
130
|
-
{
|
131
|
-
pattern => "#{C_FILE_SUBST}\n#{pattern}"
|
132
|
-
}
|
133
|
-
end
|
134
|
-
|
135
136
|
def template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver)
|
136
137
|
template_makefile_in_patch_two(ostype, ruby_ver).merge(mlibs_subst(ostype, deps_lib_dir, ruby_ver))
|
137
138
|
end
|
138
|
-
|
139
|
-
def template_makefile_in_patch_two(ostype, ruby_ver)
|
140
|
-
if ostype =~ /msys/
|
141
|
-
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN => TEMPLATE_MAKEFILE_IN_BASE_PATCH_MSYS }
|
142
|
-
elsif PatchHelpers.ruby31?(ruby_ver)
|
143
|
-
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN => TEMPLATE_MAKEFILE_IN_BASE_PATCH }
|
144
|
-
else
|
145
|
-
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 => TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 }
|
146
|
-
end
|
147
|
-
end
|
148
139
|
end
|
149
140
|
end
|
150
141
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2023-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_relative "patch_helpers"
|
29
|
+
|
30
|
+
# Tebako - an executable packager
|
31
|
+
module Tebako
|
32
|
+
module Packager
|
33
|
+
# Ruby buildsystem patches (pass2)
|
34
|
+
module PatchBuildsystem
|
35
|
+
# This patch forces rebuild of extinit.c when exts.mk changes
|
36
|
+
# exts.mk changes when we rebuild extensions to make them statically linked
|
37
|
+
# [TODO] it is possible that we can build extensions statically on pass1 and it will
|
38
|
+
# eliminate the need for this patch
|
39
|
+
COMMON_MK_PATCH = {
|
40
|
+
"ext/extinit.c: $(srcdir)/template/extinit.c.tmpl $(PREP)" =>
|
41
|
+
"ext/extinit.c: $(srcdir)/template/extinit.c.tmpl $(PREP) $(EXTS_MK)"
|
42
|
+
}.freeze
|
43
|
+
|
44
|
+
# This patch changes libraries that are used for Ruby linking
|
45
|
+
# MAINLIBS is patched elsewhere (not with literal but dynamically)
|
46
|
+
# to haold the list of sattic libraries and related options
|
47
|
+
# Also we have to put LIBRUBYARG_STATIC instead of LIBRUBYARG to link with static libruby,
|
48
|
+
# configure's --disable-shared option does not do it
|
49
|
+
# Several variants depending on os and version
|
50
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 =
|
51
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
52
|
+
"$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
53
|
+
|
54
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 =
|
55
|
+
"# -- Start of tebako patch --\n" \
|
56
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
57
|
+
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
58
|
+
"# -- End of tebako patch --"
|
59
|
+
|
60
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATTERN =
|
61
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) " \
|
62
|
+
"$(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
63
|
+
|
64
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATCH =
|
65
|
+
"# -- Start of tebako patch --\n" \
|
66
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
67
|
+
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
68
|
+
"# -- End of tebako patch --"
|
69
|
+
|
70
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATCH_MSYS =
|
71
|
+
"# -- Start of tebako patch --\n" \
|
72
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(RUBY_EXP) $(MAINOBJ) " \
|
73
|
+
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
74
|
+
"# -- End of tebako patch --"
|
75
|
+
|
76
|
+
def template_makefile_in_patch_two(ostype, ruby_ver)
|
77
|
+
if PatchHelpers.msys?(ostype)
|
78
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN => TEMPLATE_MAKEFILE_IN_BASE_PATCH_MSYS }
|
79
|
+
elsif PatchHelpers.ruby31?(ruby_ver)
|
80
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN => TEMPLATE_MAKEFILE_IN_BASE_PATCH }
|
81
|
+
else
|
82
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 => TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# This MSYS specific thing ensure compilation of winmain.c
|
87
|
+
# Did try to understand why it did not work out of the box
|
88
|
+
GNUMAKEFILE_IN_WINMAIN_SUBST = <<~SUBST
|
89
|
+
RUBYDEF = $(DLL_BASE_NAME).def
|
90
|
+
|
91
|
+
# Start of tebako patch
|
92
|
+
WINMAINOBJ = win32/winmain.$(OBJEXT)
|
93
|
+
$(WINMAINOBJ): win32/winmain.c
|
94
|
+
# End of tebako patch
|
95
|
+
SUBST
|
96
|
+
|
97
|
+
# Other MSYS (GNUMakefile) specific patches
|
98
|
+
# - The same issue with libraries as for Makefile above
|
99
|
+
# - 'Kill' ruby.exp regeneration on pass2
|
100
|
+
# since we want to use outpu from pass1 for implib generation
|
101
|
+
# [VERY UGLY HACK]
|
102
|
+
# - Introduce LIBRUBY dependency on static extensions
|
103
|
+
# This is an addition to COMMON_MK_PATCH specified above
|
104
|
+
def get_gnumakefile_in_patch_p2(ruby_ver) # rubocop:disable Metrics/MethodLength
|
105
|
+
objext = PatchHelpers.ruby32?(ruby_ver) ? "$(OBJEXT)" : "@OBJEXT@"
|
106
|
+
|
107
|
+
{
|
108
|
+
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext}" =>
|
109
|
+
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext} $(WINMAINOBJ) # tebako patched",
|
110
|
+
|
111
|
+
"RUBYDEF = $(DLL_BASE_NAME).def" => GNUMAKEFILE_IN_WINMAIN_SUBST,
|
112
|
+
|
113
|
+
"$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@" =>
|
114
|
+
"$(WINMAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) -o $@ # tebako patched",
|
115
|
+
|
116
|
+
"$(RUBY_EXP): $(LIBRUBY_A)" => "dummy.exp: $(LIBRUBY_A) # tebako patched",
|
117
|
+
|
118
|
+
"$(PROGRAM): $(RUBY_INSTALL_NAME).res.#{objext}" =>
|
119
|
+
"$(PROGRAM): $(RUBY_INSTALL_NAME).res.#{objext} $(LIBRUBY_A) # tebako patched\n" \
|
120
|
+
"$(LIBRUBY_A): $(LIBRUBY_A_OBJS) $(INITOBJS) # tebako patched\n"
|
121
|
+
}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -61,6 +61,16 @@ module Tebako
|
|
61
61
|
out
|
62
62
|
end
|
63
63
|
|
64
|
+
def msys?(ostype)
|
65
|
+
ostype =~ /msys|cygwin|mingw/
|
66
|
+
end
|
67
|
+
|
68
|
+
def patch_c_file(pattern)
|
69
|
+
{
|
70
|
+
pattern => "#{PatchLiterals::C_FILE_SUBST}\n#{pattern}"
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
64
74
|
def recreate(dirname)
|
65
75
|
FileUtils.rm_rf(dirname, noop: nil, verbose: nil, secure: true)
|
66
76
|
FileUtils.mkdir(dirname)
|
@@ -109,6 +109,18 @@ module Tebako
|
|
109
109
|
SUBST
|
110
110
|
end
|
111
111
|
|
112
|
+
# Used for mkconfig.rb
|
113
|
+
def msys_base_libs(ruby_ver)
|
114
|
+
<<~SUBST
|
115
|
+
"-l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -l:libdwarfs_compression.a -l:libfolly.a -l:libfsst.a " \\
|
116
|
+
"-l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a " \\
|
117
|
+
"-l:liblz4.a -l:libz.a -l:libzstd.a -l:liblzma.a -l:libncurses.a -l:libunwind.a -l:liblzma.a -l:libiberty.a #{PatchHelpers.yaml_reference(ruby_ver)} " \\
|
118
|
+
"-l:libffi.a -l:libboost_system-mt.a -l:libboost_chrono-mt.a -l:libstdc++.a -l:libdl.a -static-libgcc -static-libstdc++ -l:libssl.a -l:libcrypto.a " \\
|
119
|
+
"-l:libz.a -l:libwinpthread.a -lcrypt32 -lshlwapi -lwsock32 -liphlpapi -limagehlp -lbcrypt -lole32 -loleaut32 -luuid"
|
120
|
+
SUBST
|
121
|
+
end
|
122
|
+
|
123
|
+
# Used in Makefile
|
112
124
|
def msys_libs(ruby_ver)
|
113
125
|
<<~SUBST
|
114
126
|
-Wl,-Bstatic #{linux_common_libs} \
|
@@ -29,7 +29,7 @@
|
|
29
29
|
module Tebako
|
30
30
|
module Packager
|
31
31
|
# Ruby patching literals (pass2)
|
32
|
-
module PatchLiterals
|
32
|
+
module PatchLiterals
|
33
33
|
TOOL_MKCONFIG_RB_PATCH = {
|
34
34
|
" if fast[name]" => <<~SUBST
|
35
35
|
# -- Start of tebako patch --
|
@@ -48,23 +48,21 @@ module Tebako
|
|
48
48
|
SUBST
|
49
49
|
}.freeze
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
SUBST
|
67
|
-
}.freeze
|
51
|
+
TOOLS_MKCONFIG_RB_SUBST = <<~SUBST
|
52
|
+
# -- Start of tebako patch --
|
53
|
+
v_head_comp = " CONFIG[\\"prefix\\"] \#{eq} "
|
54
|
+
if v_head_comp == v[0...(v_head_comp.length)]
|
55
|
+
v = "\#{v[0...(v_head_comp.length)]}CONFIG[\\"RUBY_EXEC_PREFIX\\"] = 'A:/__tebako_memfs__'
|
56
|
+
"
|
57
|
+
end
|
58
|
+
v_head_comp = " CONFIG[\\"RUBY_EXEC_PREFIX\\"] \#{eq} "
|
59
|
+
if v_head_comp == v[0...(v_head_comp.length)]
|
60
|
+
v = "\#{v[0...(v_head_comp.length)]}'A:/__tebako_memfs__'
|
61
|
+
"
|
62
|
+
end
|
63
|
+
# -- End of tebako patch --
|
64
|
+
if fast[name]
|
65
|
+
SUBST
|
68
66
|
|
69
67
|
# Alpine-specific patches https://github.com/docker-library/ruby/blob/master/3.1/alpine3.15/Dockerfile
|
70
68
|
# -- Patch no. 1 --
|
@@ -169,7 +167,7 @@ module Tebako
|
|
169
167
|
"else if (e == EIO /* tebako patch */ && !within_tebako_memfs(path)) {"
|
170
168
|
}.freeze
|
171
169
|
|
172
|
-
|
170
|
+
DLN_C_MSYS_PATCH_PRE32 = {
|
173
171
|
" winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);" => <<~SUBST
|
174
172
|
/* -- Start of tebako patch -- */
|
175
173
|
char *f = NULL;
|
@@ -191,37 +189,28 @@ module Tebako
|
|
191
189
|
SUBST
|
192
190
|
}.freeze
|
193
191
|
|
194
|
-
|
195
|
-
"
|
196
|
-
|
192
|
+
DLN_C_MSYS_PATCH = {
|
193
|
+
" WCHAR *winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);" => <<~SUBST
|
194
|
+
/* -- Start of tebako patch -- */
|
195
|
+
char *f = NULL;
|
196
|
+
WCHAR *winfile = NULL;
|
197
|
+
if (file && within_tebako_memfs(file)) {
|
198
|
+
f = tebako_dlmap2file(file);
|
199
|
+
if (f) {
|
200
|
+
winfile = rb_w32_mbstr_to_wstr(CP_UTF8, f, -1, NULL);
|
201
|
+
free(f);
|
202
|
+
}
|
203
|
+
else {
|
204
|
+
goto failed;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
else {
|
208
|
+
winfile = rb_w32_mbstr_to_wstr(CP_UTF8, file, -1, NULL);
|
209
|
+
}
|
210
|
+
/* -- End of tebako patch -- */
|
211
|
+
SUBST
|
197
212
|
}.freeze
|
198
213
|
|
199
|
-
TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 =
|
200
|
-
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
201
|
-
"$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
202
|
-
|
203
|
-
TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 =
|
204
|
-
"# -- Start of tebako patch --\n" \
|
205
|
-
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
206
|
-
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
207
|
-
"# -- End of tebako patch --"
|
208
|
-
|
209
|
-
TEMPLATE_MAKEFILE_IN_BASE_PATTERN =
|
210
|
-
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) " \
|
211
|
-
"$(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
212
|
-
|
213
|
-
TEMPLATE_MAKEFILE_IN_BASE_PATCH =
|
214
|
-
"# -- Start of tebako patch --\n" \
|
215
|
-
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
216
|
-
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
217
|
-
"# -- End of tebako patch --"
|
218
|
-
|
219
|
-
TEMPLATE_MAKEFILE_IN_BASE_PATCH_MSYS =
|
220
|
-
"# -- Start of tebako patch --\n" \
|
221
|
-
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(RUBY_EXP) $(MAINOBJ) " \
|
222
|
-
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
223
|
-
"# -- End of tebako patch --"
|
224
|
-
|
225
214
|
C_FILE_SUBST = <<~SUBST
|
226
215
|
/* -- Start of tebako patch -- */
|
227
216
|
#include <tebako/tebako-config.h>
|
@@ -251,15 +240,6 @@ module Tebako
|
|
251
240
|
SUBST
|
252
241
|
}.freeze
|
253
242
|
|
254
|
-
GNUMAKEFILE_IN_WINMAIN_SUBST = <<~SUBST
|
255
|
-
RUBYDEF = $(DLL_BASE_NAME).def
|
256
|
-
|
257
|
-
# Start of tebako patch
|
258
|
-
WINMAINOBJ = win32/winmain.$(OBJEXT)
|
259
|
-
$(WINMAINOBJ): win32/winmain.c
|
260
|
-
# End of tebako patch
|
261
|
-
SUBST
|
262
|
-
|
263
243
|
IO_C_SUBST = <<~SUBST
|
264
244
|
/* -- Start of tebako patch -- */
|
265
245
|
if (is_tebako_file_descriptor(fd)) return;
|
@@ -267,13 +247,23 @@ module Tebako
|
|
267
247
|
flags = fcntl(fd, F_GETFD); /* should not fail except EBADF. */
|
268
248
|
SUBST
|
269
249
|
|
270
|
-
|
271
|
-
"#define open rb_w32_uopen" => "#define open(p, f, m) tebako_open(3, (p), (f), (m))"
|
250
|
+
IO_C_MSYS_BASE_PATCH = {
|
251
|
+
"#define open rb_w32_uopen" => "#define open(p, f, m) tebako_open(3, (p), (f), (m))"
|
252
|
+
}.freeze
|
253
|
+
|
254
|
+
IO_C_MSYS_PATCH_PRE_32 = {
|
272
255
|
"(rb_w32_io_cancelable_p((fptr)->fd) ? Qnil : rb_io_wait(fptr->self, RB_INT2NUM(RUBY_IO_READABLE), Qnil))" =>
|
273
256
|
"((is_tebako_file_descriptor((fptr)->fd) || rb_w32_io_cancelable_p((fptr)->fd)) ? \\\n" \
|
274
257
|
"Qnil : rb_io_wait(fptr->self, RB_INT2NUM(RUBY_IO_READABLE), Qnil))"
|
275
258
|
}.freeze
|
276
259
|
|
260
|
+
IO_C_MSYS_PATCH = {
|
261
|
+
"(rb_w32_io_cancelable_p((fptr)->fd) ? Qnil : rb_io_wait(fptr->self, " \
|
262
|
+
"RB_INT2NUM(RUBY_IO_READABLE), RUBY_IO_TIMEOUT_DEFAULT))" =>
|
263
|
+
"((is_tebako_file_descriptor((fptr)->fd) || rb_w32_io_cancelable_p((fptr)->fd)) ? \\\n" \
|
264
|
+
"Qnil : rb_io_wait(fptr->self, RB_INT2NUM(RUBY_IO_READABLE), RUBY_IO_TIMEOUT_DEFAULT))"
|
265
|
+
}.freeze
|
266
|
+
|
277
267
|
FILE_C_MSYS_SUBST = <<~SUBST
|
278
268
|
/* -- Start of tebako patch -- */
|
279
269
|
if (is_tebako_file_descriptor((fptr)->fd)) return ENOTSUP;
|
data/lib/tebako/version.rb
CHANGED
data/src/tebako-main.cpp
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
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
|
*
|
@@ -50,6 +50,8 @@
|
|
50
50
|
#include <tebako/tebako-main.h>
|
51
51
|
#include <tebako/tebako-fs.h>
|
52
52
|
|
53
|
+
static int running_miniruby = 0;
|
54
|
+
|
53
55
|
extern "C" int tebako_main(int* argc, char*** argv) {
|
54
56
|
int ret = -1, fsret = -1;
|
55
57
|
char** new_argv = NULL;
|
@@ -59,6 +61,7 @@ extern "C" int tebako_main(int* argc, char*** argv) {
|
|
59
61
|
// Ruby build script is designed in such a way that this patch is also applied towards miniruby
|
60
62
|
// Just pass through in such case
|
61
63
|
ret = 0;
|
64
|
+
running_miniruby = -1;
|
62
65
|
}
|
63
66
|
else {
|
64
67
|
try {
|
@@ -149,3 +152,7 @@ extern "C" int tebako_main(int* argc, char*** argv) {
|
|
149
152
|
extern "C" const char* tebako_mount_point(void) {
|
150
153
|
return tebako::fs_mount_point;
|
151
154
|
}
|
155
|
+
|
156
|
+
extern "C" int tebako_is_running_miniruby(void) {
|
157
|
+
return running_miniruby;
|
158
|
+
}
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tebako
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/tebako/packager.rb
|
71
71
|
- lib/tebako/packager/pass1.rb
|
72
72
|
- lib/tebako/packager/pass2.rb
|
73
|
+
- lib/tebako/packager/patch_buildsystem.rb
|
73
74
|
- lib/tebako/packager/patch_helpers.rb
|
74
75
|
- lib/tebako/packager/patch_libraries.rb
|
75
76
|
- lib/tebako/packager/patch_literals.rb
|
@@ -134,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
- !ruby/object:Gem::Version
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
|
-
rubygems_version: 3.5.
|
138
|
+
rubygems_version: 3.5.9
|
138
139
|
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: Packager for Ruby executables
|