tebako 0.6.5 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d02ef72aa920ed26d95b18dce3f2b0dc60aa66633d83876fd03e0da9161d5cf
4
- data.tar.gz: c1524406708fe09d25a800537af70f0df315ece0e41e9a6146739d201680fe2e
3
+ metadata.gz: a0c260fa919b77603c20cc5db12e51595c0a0fd0da649dd6f64d2022bebc50dc
4
+ data.tar.gz: 1bd24a7fa0d74fb44b95f0b5f41f736323553725741327b130cfadc36cb45cb6
5
5
  SHA512:
6
- metadata.gz: 751def113919ecca7b08900b246042b76942af841d40fb3db41da7bb7926ac30ce6c107b43864a3c2fca4ac1abdb0a700d99977e1562fa0405022cb6e6f09caf
7
- data.tar.gz: 9a3c9d1d09f4e7c7704e093926f63b629ad62bc34e9f5ed505af03dc6697072a4b26decb77bdc46c9f5723ec9fd831c73dadb1afcabd5449cae13cc37636e33e
6
+ metadata.gz: 145fe0a5fe1cb275c21db9e9d4b9092e7c7b342ee43e232d1a6e61a5bc606c62329c9a6a0082843a8b7c017667fda09317c1faa2f3371687e5e64c4a49a176b2
7
+ data.tar.gz: 4708ff850fc763b41d7e1d8e84bee81d4c6a17f1653ac6f697f39e7146fe8acb60ca7922ac1ff7693086fae3f5216d82d83bd1cb97b596c9607769ce022c00f0
data/CMakeLists.txt CHANGED
@@ -235,11 +235,11 @@ endif(DWARFS_PRELOAD)
235
235
  # Filesystem locations
236
236
 
237
237
  # DATA_SRC_DIR folder is used to collect all files that need to be packaged
238
- set(DATA_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/source_filesystem)
238
+ set(DATA_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/s)
239
239
  # DATA_PRE_DIR folder is used to build gems that need to be packaged
240
- set(DATA_PRE_DIR ${CMAKE_CURRENT_BINARY_DIR}/prepare_filesystem)
240
+ set(DATA_PRE_DIR ${CMAKE_CURRENT_BINARY_DIR}/r)
241
241
  # DATA_BIN_DIR folder is used to create packaged filesystem
242
- set(DATA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/packaged_filesystem)
242
+ set(DATA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/p)
243
243
  # DATA_BIN_FILE is packaged filesystem itself
244
244
  set(DATA_BIN_FILE ${DATA_BIN_DIR}/fs.bin)
245
245
  # Target binary directory
@@ -360,7 +360,7 @@ else(IS_DARWIN)
360
360
 
361
361
  if(RB_W32)
362
362
  string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DRB_W32=1")
363
- string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -L${TLIBD}")
363
+ string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -l:libstdc++.a -L${TLIBD}")
364
364
  endif(RB_W32)
365
365
  endif(IS_DARWIN)
366
366
 
@@ -388,6 +388,7 @@ ExternalProject_Add(${RUBY_PRJ}
388
388
  --prefix=${DATA_SRC_DIR} \
389
389
  ${C_FLAGS_DEST}=\"${RUBY_C_FLAGS}\" \
390
390
  LDFLAGS=\"${RUBY_L_FLAGS}\""
391
+ COMMAND ruby ${EXE}/tebako-packager pass1a ${RUBY_SOURCE_DIR}
391
392
  BUILD_COMMAND make ${RUBY_MAKEFILE} -j${NCORES}
392
393
  INSTALL_COMMAND make ${RUBY_MAKEFILE} install
393
394
  COMMAND ${GNU_BASH} -c "ruby ${EXE}/tebako-packager pass2 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${DEPS_LIB_DIR} ${DATA_SRC_DIR} ${RUBY_STASH_DIR} ${RUBY_VER}"
@@ -432,27 +433,31 @@ else (${SETUP_MODE})
432
433
  message("Collecting gem from gemspec ${GEMSPEC} and Gemfile")
433
434
  set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
434
435
  add_custom_target(source_filesystem
435
- COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
436
- COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
437
- COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
438
- ${TBD}/bundle${BAT_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
439
- COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
440
- ${TBD}/bundle${BAT_SUFFIX} install
441
- COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
442
- ${TBD}/bundle${BAT_SUFFIX} exec ${TBD}/gem${CMD_SUFFIX} build ${GEMSPEC}
443
- COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
444
- ${TBD}/gem${CMD_SUFFIX} install *.gem --verbose --no-document --install-dir ${TGD}
445
- COMMAND test -f ${DATA_SRC_DIR}${FS_ENTRY_POINT} ||
436
+ COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
437
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
438
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
439
+ ${TBD}/bundle${BAT_SUFFIX} config set --local build.ffi --disable-system-libffi
440
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
441
+ ${TBD}/bundle${BAT_SUFFIX} config set --local build.nokogiri --use-system-libraries
442
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
443
+ ${TBD}/bundle${BAT_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
444
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
445
+ ${TBD}/bundle${BAT_SUFFIX} install
446
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
447
+ ${TBD}/bundle${BAT_SUFFIX} exec ${TBD}/gem${CMD_SUFFIX} build ${GEMSPEC}
448
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
449
+ ${TBD}/gem${CMD_SUFFIX} install *.gem --verbose --no-document --install-dir ${TGD}
450
+ COMMAND test -f ${DATA_SRC_DIR}${FS_ENTRY_POINT} ||
446
451
  (${CMAKE_COMMAND} -E echo "Entry point ${DATA_SRC_DIR}${FS_ENTRY_POINT} does not exist" &&
447
452
  ${CMAKE_COMMAND} -E false )
448
- DEPENDS clean_filesystem
453
+ DEPENDS clean_filesystem
449
454
  )
450
455
  else(GFLENGTH GREATER 0)
451
456
  # Found xxx.gemspec but no Gemfile
452
- message("Collecting gem from gemspec ${GEMSPEC}")
453
- set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
454
- message("Target entry point will be at ${FS_MOUNT_POINT}${FS_ENTRY_POINT}")
455
- add_custom_target(source_filesystem
457
+ message("Collecting gem from gemspec ${GEMSPEC}")
458
+ set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
459
+ message("Target entry point will be at ${FS_MOUNT_POINT}${FS_ENTRY_POINT}")
460
+ add_custom_target(source_filesystem
456
461
  COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
457
462
  COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
458
463
  COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
@@ -478,7 +483,9 @@ else (${SETUP_MODE})
478
483
  COMMAND ${CMAKE_COMMAND} -E make_directory ${TLD}
479
484
  COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${TLD} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
480
485
  COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
481
- ${TBD}/bundle${BAT_SUFFIX} config build.ffi --disable-system-libffi
486
+ ${TBD}/bundle${BAT_SUFFIX} config set --local build.ffi --disable-system-libffi
487
+ COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
488
+ ${TBD}/bundle${BAT_SUFFIX} config set --local build.nokogiri --use-system-libraries
482
489
  COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
483
490
  ${TBD}/bundle${BAT_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
484
491
  COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
@@ -543,22 +550,7 @@ else (${SETUP_MODE})
543
550
  )
544
551
 
545
552
  add_custom_target(packaged_filesystem
546
- # [TODO] Open question - whether we shall delete ruby binaries from memfs or not
547
- # For debugging purposes it is very handy to have it here
548
- #
549
- COMMAND ${CMAKE_COMMAND} -E rm -rf ${DATA_SRC_DIR}/share ${DATA_SRC_DIR}/include ${DATA_SRC_DIR}/lib/pkgconfig
550
- ${DATA_SRC_DIR}/bin/bundle${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/bundle
551
- ${DATA_SRC_DIR}/bin/bundler${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/bundler
552
- ${DATA_SRC_DIR}/bin/bundle${BAT_SUFFIX} ${DATA_SRC_DIR}/bin/bundler${BAT_SUFFIX}
553
- ${DATA_SRC_DIR}/bin/erb${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/gem${CMD_SUFFIX}
554
- ${DATA_SRC_DIR}/bin/irb${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/racc${CMD_SUFFIX}
555
- ${DATA_SRC_DIR}/bin/racc2y${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/rake${BAT_SUFFIX}
556
- ${DATA_SRC_DIR}/bin/rake ${DATA_SRC_DIR}/bin/rdoc${CMD_SUFFIX}
557
- ${DATA_SRC_DIR}/bin/ri${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/y2racc${CMD_SUFFIX}
558
- ${DATA_SRC_DIR}/bin/ruby${EXE_SUFFIX} ${DATA_SRC_DIR}/bin/ruby${RUBY_SUFFIX}${EXE_SUFFIX}
559
-
560
- COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.a"
561
- COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.o"
553
+ COMMAND ruby ${EXE}/tebako-packager strip ${OSTYPE_TXT} ${DATA_SRC_DIR}
562
554
  COMMAND ${GNU_BASH} -c "chmod +x ${DEPS_BIN_DIR}/mkdwarfs${EXE_SUFFIX}"
563
555
  # No progress below is critical since in reporting mode mkdwarfs tries to work directly with terminal
564
556
  # and it creates issues for stderr redirects (&2 > 1) used by Ninja and our test srcipts
data/README.adoc CHANGED
@@ -46,7 +46,7 @@ The Tebako packager supports the following versions of Ruby for packaging:
46
46
 
47
47
  * 2.7.8 (Linux, MacOS)
48
48
  * 3.0.7 (Linux, MacOS)
49
- * 3.1.4, 3.1.5 (Linux, MacOS, Windows)
49
+ * 3.1.4, 3.1.5, 3.1.6 (Linux, MacOS, Windows)
50
50
  * 3.2.3, 3.2.4 (Linux, MacOS, Windows)
51
51
 
52
52
  Support of specific version including minor release requires some effort, sometimes extensive
@@ -128,10 +128,9 @@ brew install gnu-sed bash pkg-config bison flex binutils libffi gdbm zlib ncurse
128
128
  double-conversion boost jemalloc fmt glog libevent libsodium lz4 xz libyaml openssl@3
129
129
  ----
130
130
 
131
- === Windows (2019, 2022)
131
+ === Windows (workstation 10, 11; Server 2019, 2022)
132
132
 
133
133
  The simplest approach is to use Ruby development environment provided by RubyInstaller, for example Ruby+Devkit 3.1.4-1.
134
-
135
134
  Once it is installed use the following commands:
136
135
 
137
136
  [source,sh]
@@ -142,6 +141,11 @@ Once it is installed use the following commands:
142
141
  fmt glog dlfcn gtest autotools ncurses libyaml
143
142
  ----
144
143
 
144
+ Please note that on Windows tebako may face issues related by CMake path length limitations.
145
+ (https://gitlab.kitware.com/cmake/cmake/-/issues/25936)
146
+ This error may affect not tebako itself but the gems that need to be package and use CMake to build native extensions.
147
+ There is no workaround for this issue as it lloks like is a limitation of the manifest used to build CMake executable.
148
+
145
149
  == Installation
146
150
 
147
151
  === General
@@ -275,7 +279,7 @@ based on ```tebako setup``` output. Building cache based on ```tebako press``` m
275
279
  ----
276
280
  tebako setup \
277
281
  [-p |--prefix=<tebako-root-folder>] \
278
- [-R |--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.2.3|3.2.4>]
282
+ [-R |--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.1.6|3.2.3|3.2.4>]
279
283
  ----
280
284
 
281
285
  Where:
@@ -283,7 +287,7 @@ Where:
283
287
  * `<tebako-root-folder>`, the Tebako setup folder (optional, defaults to current
284
288
  folder)
285
289
 
286
- * `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.5)
290
+ * `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
287
291
 
288
292
  ==== Clean
289
293
 
data/common.env CHANGED
@@ -2,4 +2,4 @@ BUILD_TYPE=Release
2
2
  DEPS=deps
3
3
  INCBIN_TAG=348e36b
4
4
  DWARFS_WR_TAG=v0.5.2
5
- RUBY_VER=3.1.5
5
+ RUBY_VER=3.1.6
data/exe/tebako-packager CHANGED
@@ -27,6 +27,7 @@
27
27
  # POSSIBILITY OF SUCH DAMAGE.
28
28
 
29
29
  require_relative "../lib/tebako/packager"
30
+ require_relative "../lib/tebako/stripper"
30
31
 
31
32
  begin
32
33
  unless ARGV.length.positive?
@@ -57,6 +58,24 @@ begin
57
58
  end
58
59
 
59
60
  Tebako::Packager.stash(ARGV[1], ARGV[2])
61
+ when "strip"
62
+ # ARGV[0] -- command
63
+ # ARGV[1] -- OSTYPE
64
+ # ARGV[2] -- DATA_SRC_DIR
65
+ unless ARGV.length == 3
66
+ raise Tebako::Error,
67
+ "tebako-packager strip command expects 3 arguments, #{ARGV.length} has been provided."
68
+ end
69
+
70
+ Tebako::Stripper.strip(ARGV[1], ARGV[2])
71
+ when "pass1a"
72
+ # ARGV[0] -- command
73
+ # ARGV[1] -- RUBY_SOURCE_DIR
74
+ unless ARGV.length == 2
75
+ raise Tebako::Error,
76
+ "tebako-packager pass1a command expects 2 arguments, #{ARGV.length} has been provided."
77
+ end
78
+ Tebako::Packager.pass1a(ARGV[1])
60
79
  when "pass2"
61
80
  # ARGV[0] -- command
62
81
  # ARGV[1] -- OSTYPE
@@ -99,7 +99,7 @@ module Tebako
99
99
  # rubocop:enable Metrics/MethodLength
100
100
 
101
101
  def output
102
- @output ||= File.join(prefix, "output")
102
+ @output ||= File.join(prefix, "o")
103
103
  end
104
104
 
105
105
  def package
@@ -42,11 +42,13 @@ module Tebako
42
42
  "3.0.7" => "2a3411977f2850431136b0fab8ad53af09fb74df2ee2f4fb7f11b378fe034388",
43
43
  "3.1.4" => "a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6",
44
44
  "3.1.5" => "3685c51eeee1352c31ea039706d71976f53d00ab6d77312de6aa1abaf5cda2c5",
45
+ "3.1.6" => "0d0dafb859e76763432571a3109d1537d976266be3083445651dc68deed25c22",
45
46
  "3.2.3" => "af7f1757d9ddb630345988139211f1fd570ff5ba830def1cc7c468ae9b65c9ba",
46
47
  "3.2.4" => "c72b3c5c30482dca18b0f868c9075f3f47d8168eaf626d4e682ce5b59c858692"
48
+ # "3.3.3" => "83c05b2177ee9c335b631b29b8c077b4770166d02fa527f3a9f6a40d13f3cce2"
47
49
  }.freeze
48
50
 
49
- DEFAULT_RUBY_VERSION = "3.1.5"
51
+ DEFAULT_RUBY_VERSION = "3.1.6"
50
52
 
51
53
  def version_check(version)
52
54
  return if RUBY_VERSIONS.key?(version)
@@ -150,7 +150,7 @@ module Tebako
150
150
  # Generate export definitions; use WinMain to build rubyw.exe
151
151
  patch_map.store("cygwin/GNUmakefile.in", get_gnumakefile_in_patch_p1(ruby_ver))
152
152
  # ....................................................
153
- # RUBY_EXPORT=1 (shall ve set for static builds but is missing in openssl extension)
153
+ # RUBY_EXPORT=1 (shall be set for static builds but is missing in openssl extension)
154
154
  patch_map.store("ext/openssl/extconf.rb", OPENSSL_EXTCONF_RB_PATCH)
155
155
  end
156
156
 
@@ -0,0 +1,46 @@
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_relative "patch_literals"
29
+
30
+ # Tebako - an executable packager
31
+ module Tebako
32
+ module Packager
33
+ # Ruby patching definitions (pass1a)
34
+ module Pass1A
35
+ class << self
36
+ def get_patch_map # rubocop:disable Naming/AccessorMethodName
37
+ {
38
+ "gem_prelude.rb" => GEM_PRELUDE_RB_PATCH
39
+ }
40
+ end
41
+
42
+ include Tebako::Packager::PatchLiterals
43
+ end
44
+ end
45
+ end
46
+ end
@@ -58,7 +58,7 @@ module Tebako
58
58
 
59
59
  def get_dir_c_patch(ostype)
60
60
  pattern = PatchHelpers.msys?(ostype) ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST"
61
- dir_c_patch = PatchHelpers.patch_c_file(pattern)
61
+ dir_c_patch = PatchHelpers.patch_c_file_pre(pattern)
62
62
  dir_c_patch.merge!(DIR_C_BASE_PATCH)
63
63
  dir_c_patch
64
64
  end
@@ -85,11 +85,19 @@ module Tebako
85
85
  end
86
86
 
87
87
  def get_io_c_patch(ostype, ruby_ver)
88
- io_c_patch = PatchHelpers.patch_c_file("/* define system APIs */")
88
+ io_c_patch = PatchHelpers.patch_c_file_pre("/* define system APIs */")
89
89
  io_c_patch.merge!(get_io_c_msys_patch(ruby_ver)) if PatchHelpers.msys?(ostype)
90
90
  io_c_patch
91
91
  end
92
92
 
93
+ def get_util_c_patch(ruby_ver)
94
+ if PatchHelpers.ruby316?(ruby_ver)
95
+ PatchHelpers.patch_c_file_post("#endif /* !HAVE_GNU_QSORT_R */")
96
+ else
97
+ PatchHelpers.patch_c_file_pre("#ifndef S_ISDIR")
98
+ end
99
+ end
100
+
93
101
  def get_msys_mkconfig_rb_patches(ruby_ver)
94
102
  {
95
103
  " if fast[name]" => TOOLS_MKCONFIG_RB_SUBST,
@@ -115,11 +123,10 @@ module Tebako
115
123
  {
116
124
  "template/Makefile.in" => template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver),
117
125
  "tool/mkconfig.rb" => mcrb_subst,
118
- "gem_prelude.rb" => GEM_PRELUDE_RB_PATCH,
119
126
  "dir.c" => get_dir_c_patch(ostype), "dln.c" => get_dln_c_patch(ostype, ruby_ver),
120
127
  "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")
128
+ "file.c" => PatchHelpers.patch_c_file_pre("/* define system APIs */"),
129
+ "util.c" => get_util_c_patch(ruby_ver)
123
130
  }
124
131
  end
125
132
 
@@ -40,6 +40,7 @@ module Tebako
40
40
  puts " ... patching #{fname}"
41
41
  restore_and_save(fname)
42
42
  contents = File.read(fname)
43
+
43
44
  mapping.each { |pattern, subst| contents.sub!(pattern, subst) }
44
45
  File.open(fname, "w") { |file| file << contents }
45
46
  end
@@ -65,12 +66,18 @@ module Tebako
65
66
  ostype =~ /msys|cygwin|mingw/
66
67
  end
67
68
 
68
- def patch_c_file(pattern)
69
+ def patch_c_file_pre(pattern)
69
70
  {
70
71
  pattern => "#{PatchLiterals::C_FILE_SUBST}\n#{pattern}"
71
72
  }
72
73
  end
73
74
 
75
+ def patch_c_file_post(pattern)
76
+ {
77
+ pattern => "#{pattern}\n\n#{PatchLiterals::C_FILE_SUBST}"
78
+ }
79
+ end
80
+
74
81
  def recreate(dirname)
75
82
  FileUtils.rm_rf(dirname, noop: nil, verbose: nil, secure: true)
76
83
  FileUtils.mkdir(dirname)
@@ -101,12 +108,16 @@ module Tebako
101
108
  ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 1
102
109
  end
103
110
 
111
+ def ruby316?(ruby_ver)
112
+ ruby3x?(ruby_ver) && ruby_ver[2] == "1" && ruby_ver[4].to_i >= 6
113
+ end
114
+
104
115
  def ruby32?(ruby_ver)
105
116
  ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 2
106
117
  end
107
118
 
108
119
  def ruby32only?(ruby_ver)
109
- ruby3x?(ruby_ver) && ruby_ver[2].to_i == 2
120
+ ruby3x?(ruby_ver) && ruby_ver[2] == "2"
110
121
  end
111
122
 
112
123
  def ruby33?(ruby_ver)
@@ -29,6 +29,7 @@ require "fileutils"
29
29
 
30
30
  require_relative "error"
31
31
  require_relative "packager/pass1"
32
+ require_relative "packager/pass1a"
32
33
  require_relative "packager/pass2"
33
34
  require_relative "packager/patch_helpers"
34
35
 
@@ -73,11 +74,8 @@ module Tebako
73
74
  class << self
74
75
  # Create implib
75
76
  def create_implib(src_dir, package_src_dir, app_name, ruby_ver)
77
+ create_def(src_dir, app_name)
76
78
  puts " ... creating Windows import library"
77
- File.open(def_fname(src_dir, app_name), "w") do |file|
78
- file.puts "LIBRARY #{out_fname(app_name)}"
79
- file.puts File.read(File.join(src_dir, "tebako.def"))
80
- end
81
79
  params = ["dlltool", "-d", def_fname(src_dir, app_name), "-D", out_fname(app_name),
82
80
  "--output-lib", lib_fname(package_src_dir, ruby_ver)]
83
81
  out, st = Open3.capture2e(*params)
@@ -111,13 +109,21 @@ module Tebako
111
109
  PatchHelpers.recreate(src_dir)
112
110
  do_patch(Pass1.get_patch_map(ostype, mount_point, ruby_ver), ruby_source_dir)
113
111
 
114
- # Roll back pass2 patches
112
+ # Roll back pass1a, pass2 patches
115
113
  # Just in case we are recovering after some error
116
114
  PatchHelpers.restore_and_save_files(FILES_TO_RESTORE, ruby_source_dir)
117
115
  PatchHelpers.restore_and_save_files(FILES_TO_RESTORE_MUSL, ruby_source_dir) if ostype =~ /linux-musl/
118
116
  PatchHelpers.restore_and_save_files(FILES_TO_RESTORE_MSYS, ruby_source_dir) if ostype =~ /msys/
119
117
  end
120
118
 
119
+ # Pass1A
120
+ # Patch gem_prelude.rb
121
+ def pass1a(ruby_source_dir)
122
+ puts "-- Running pass1a script"
123
+
124
+ do_patch(Pass1A.get_patch_map, ruby_source_dir)
125
+ end
126
+
121
127
  # Pass2
122
128
  # Creates packaging environment, patching ensures that tebako package is linked statically
123
129
  def pass2(ostype, ruby_source_dir, deps_lib_dir, ruby_ver)
@@ -146,6 +152,16 @@ module Tebako
146
152
 
147
153
  private
148
154
 
155
+ def create_def(src_dir, app_name)
156
+ puts " ... creating Windows def file"
157
+ File.open(def_fname(src_dir, app_name), "w") do |file|
158
+ file.puts "LIBRARY #{out_fname(app_name)}"
159
+ File.readlines(File.join(src_dir, "tebako.def")).each do |line|
160
+ file.puts line unless line.include?("DllMain")
161
+ end
162
+ end
163
+ end
164
+
149
165
  def def_fname(src_dir, app_name)
150
166
  File.join(src_dir, "#{app_name}.def")
151
167
  end
@@ -0,0 +1,94 @@
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 "find"
30
+
31
+ # Tebako - an executable packager
32
+ module Tebako
33
+ # Tebako packaging support (stripper)
34
+ module Stripper
35
+ DELETE_EXTENSIONS = %w[o lo obj a lib].freeze
36
+ STRIP_EXTENSIONS = %w[dll so].freeze
37
+ BIN_FILES = %w[
38
+ bundle bundler rbs erb gem irb racc racc2y rake rdoc ri y2racc rdbg typeprof
39
+ ].freeze
40
+ CMD_SUFFIX = ".cmd"
41
+ BAT_SUFFIX = ".bat"
42
+
43
+ class << self
44
+ # Strip
45
+ # Removes build artefacts, strip shared objects
46
+ # [TODO] We probably need debug option/flag to say whether we shall delete ruby binaries
47
+ # from memfs or not. For debugging purposes it is very handy to have it here
48
+ def strip(ostype, src_dir)
49
+ puts " ... stripping the output"
50
+ strip_bs(ostype, src_dir)
51
+ strip_fi(ostype, src_dir)
52
+ strip_li(ostype, src_dir)
53
+ end
54
+
55
+ private
56
+
57
+ def get_files(ostype)
58
+ exe_suffix = ostype =~ /msys/ ? ".exe" : ""
59
+ files = BIN_FILES.flat_map do |f|
60
+ [f, "#{f}#{CMD_SUFFIX}", "#{f}#{BAT_SUFFIX}"]
61
+ end
62
+
63
+ files += ["ruby#{exe_suffix}", "rubyw#{exe_suffix}"]
64
+ files
65
+ end
66
+
67
+ def strip_bs(_ostype, src_dir)
68
+ FileUtils.rm_rf([
69
+ File.join(src_dir, "share"),
70
+ File.join(src_dir, "include"),
71
+ File.join(src_dir, "lib", "pkgconfig")
72
+ ])
73
+ end
74
+
75
+ def strip_fi(ostype, src_dir)
76
+ files = get_files(ostype).map { |f| "#{src_dir}/bin/#{f}" }
77
+ FileUtils.rm(files, force: true)
78
+ end
79
+
80
+ def strip_li(ostype, src_dir)
81
+ Find.find(src_dir) do |file|
82
+ next if File.directory?(file)
83
+
84
+ extension = File.extname(file).delete_prefix(".").downcase
85
+ if DELETE_EXTENSIONS.include?(extension)
86
+ FileUtils.rm(file)
87
+ elsif STRIP_EXTENSIONS.include?(extension)
88
+ system("strip \"#{file}\"") unless ostype =~ /darwin/
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.6.5"
29
+ VERSION = "0.7.0"
30
30
  end
@@ -1,5 +1,5 @@
1
1
  #! /bin/bash
2
- # Copyright (c) 2022, [Ribose Inc](https://www.ribose.com).
2
+ # Copyright (c) 2022,2024 [Ribose Inc](https://www.ribose.com).
3
3
  # All rights reserved.
4
4
  # This file is a part of tebako
5
5
  #
@@ -43,70 +43,17 @@ do_patch_multiline() {
43
43
  "$gSed" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1"
44
44
  }
45
45
 
46
- # ....................................................
47
- # Surprise, surprise ... Upstream project shall found boost libraries for fbthrift
48
- # https://github.com/facebook/fbthrift/commit/c23af9dee42374d43d2f10e0e07edf1c1c97c328
49
-
50
-
51
46
  if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "linux-musl"* || "$OSTYPE" == "msys" ]]; then
52
47
  gSed="sed"
53
- # shellcheck disable=SC2251
54
- ! IFS= read -r -d '' sbst << EOM
55
- find_package(OpenSSL REQUIRED)
56
- # -- Start of tebako patch --
57
- find_package(Boost 1.65 REQUIRED COMPONENTS filesystem)
58
- include_directories(\${Boost_INCLUDE_DIRS})
59
- # -- End of tebako patch --
60
- EOM
61
-
62
48
  elif [[ "$OSTYPE" == "darwin"* ]]; then
63
49
  gSed="gsed"
64
-
65
- # shellcheck disable=SC2251
66
- ! IFS= read -r -d '' sbst << EOM
67
- find_package(OpenSSL REQUIRED)
68
- # -- Start of tebako patch --
69
- find_package(Boost 1.65 REQUIRED COMPONENTS filesystem)
70
- include_directories(\${Boost_INCLUDE_DIRS})
71
- # Suppress superfluous randlib warnings about \"*.a\" having no symbols on MacOSX.
72
- set(CMAKE_C_ARCHIVE_CREATE \"<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>\")
73
- set(CMAKE_CXX_ARCHIVE_CREATE \"<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>\")
74
- set(CMAKE_C_ARCHIVE_FINISH \"<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>\")
75
- set(CMAKE_CXX_ARCHIVE_FINISH \"<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>\")
76
- # -- End of tebako patch --
77
- EOM
78
-
79
50
  else
80
51
  echo "Unknown OSTYPE=$OSTYPE"
81
52
  exit 1
82
53
  fi
83
54
 
84
- restore_and_save "$1/CMakeLists.txt"
85
- re="find_package(OpenSSL REQUIRED)"
86
- "$gSed" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMakeLists.txt"
87
-
88
- # GCC 13 compatibility
89
- # --- thrift/compiler/lib/cpp2/util.cc ---
90
- re="#include <stdexcept>"
91
- # shellcheck disable=SC2251
92
- ! IFS= read -r -d '' sbst << EOM
93
- #include <stdexcept>
94
-
95
- \/* -- Start of tebako patch -- *\/
96
- #include <cstdint>
97
- \/* -- End of tebako patch -- *\/
98
- EOM
99
-
100
- do_patch_multiline "$1/thrift/compiler/lib/cpp2/util.cc"
101
-
102
-
103
55
  if [[ "$OSTYPE" == "msys" ]]; then
104
- re="if(WIN32)"
105
- sbst="if(MSVC) # tebako patched"
106
- do_patch "$1/thrift/compiler/CMakeLists.txt" "$re" "$sbst"
107
-
108
- re="ftruncate(file\.fd(), finalBufferSize);"
109
- sbst="folly::portability::unistd::ftruncate(file.fd(), finalBufferSize); \/* tebako patched *\/"
56
+ re="ftruncate(file\.fd(), finalBufferSize),"
57
+ sbst="folly::portability::unistd::ftruncate(file.fd(), finalBufferSize), \/* tebako patched *\/"
110
58
  do_patch "$1/thrift/lib/cpp2/frozen/FrozenUtil.h" "$re" "$sbst"
111
-
112
59
  fi
@@ -1,5 +1,5 @@
1
1
  #! /bin/bash
2
- # Copyright (c) 2022-2023, [Ribose Inc](https://www.ribose.com).
2
+ # Copyright (c) 2022-2024, [Ribose Inc](https://www.ribose.com).
3
3
  # All rights reserved.
4
4
  # This file is a part of tebako
5
5
  #
@@ -41,6 +41,7 @@ restore_and_save() {
41
41
 
42
42
  do_patch() {
43
43
  restore_and_save "$1"
44
+ # echo "$GNU_SED" -i "s/$2/$3/g" "$1"
44
45
  "$GNU_SED" -i "s/$2/$3/g" "$1"
45
46
  }
46
47
 
@@ -316,15 +317,6 @@ EOM
316
317
  sbst=" \/* tebako patched *\/ folly::portability::unistd::lseek(fd,"
317
318
  do_patch "$1/folly/portability/SysUio.cpp" "$re" "$sbst"
318
319
 
319
- # --- folly/portability/Unistd.cpp ---
320
- re="(lseek(fd,"
321
- sbst="( \/* tebako patched *\/ folly::portability::unistd::lseek(fd,"
322
- do_patch "$1/folly/portability/Unistd.cpp" "$re" "$sbst"
323
-
324
- re="lseek(fd, 0,"
325
- sbst=" \/* tebako patched *\/ folly::portability::unistd::lseek(fd, 0,"
326
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.cpp"
327
-
328
320
  # --- folly/logging/ImmediateFileWriter.h ---
329
321
  re="isatty(file"
330
322
  sbst=" \/* tebako patched *\/ folly::portability::unistd::isatty(file"
@@ -402,6 +394,7 @@ EOM
402
394
  #ifdef __MINGW32__
403
395
  #include <mswsock.h>
404
396
  using cmsghdr = WSACMSGHDR;
397
+ #define CMSG_SPACE WSA_CMSG_SPACE
405
398
  #endif
406
399
  \/* -- End of tebako patch -- *\/
407
400
 
@@ -448,7 +441,55 @@ EOM
448
441
  sbst="#if defined(__XROS__) || defined(__MINGW32__) \/* tebako patched *\/"
449
442
  "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/system/ThreadName.cpp"
450
443
 
444
+ # --- folly/net/NetOps.h ---
445
+
446
+ re="#include <WS2tcpip\.h> \/\/ @manual"
447
+ # shellcheck disable=SC2251
448
+ ! IFS= read -r -d '' sbst << EOM
449
+ #include <WS2tcpip.h> \/\/ @manual
450
+
451
+ \/* -- Start of tebako patch -- *\/
452
+ #ifdef __MINGW32__
453
+ #include <memory>
454
+ #include <mswsock.h>
455
+ #endif
456
+ \/* -- End of tebako patch -- *\/
457
+ EOM
458
+ do_patch_multiline "$1/folly/net/NetOps.h" "$re" "$sbst"
459
+
460
+ # --- folly/Random.cpp ---
461
+
462
+ re="#include <folly\/synchronization\/RelaxedAtomic\.h>"
463
+ # shellcheck disable=SC2251
464
+ ! IFS= read -r -d '' sbst << EOM
465
+ #include <folly\/synchronization\/RelaxedAtomic.h>
466
+
467
+ \/* -- Start of tebako patch -- *\/
468
+ #include <folly\/portability\/Fcntl.h>
469
+ \/* -- End of tebako patch -- *\/
470
+ EOM
471
+ do_patch_multiline "$1/folly/Random.cpp" "$re" "$sbst"
472
+
473
+ # --- folly/Utility.h ---
474
+ re="T uninit;"
475
+ sbst="T uninit = 0; \/* tebako patched *\/"
476
+ do_patch "$1/folly/Utility.h" "$re" "$sbst"
477
+
478
+ # --- folly/experimental/io/AsyncBase.cpp ---
479
+ re="CHECK_ERR(close(pollFd_));"
480
+ sbst="CHECK_ERR(folly::portability::unistd::close(pollFd_)); \/* tebako patched *\/"
481
+ do_patch "$1/folly/experimental/io/AsyncBase.cpp" "$re" "$sbst"
482
+
483
+ # --- folly/portability/Unistd.cpp ---
484
+ re="res = lseek64(fd, offset, whence);"
485
+ sbst="res = folly::portability::unistd::lseek64(fd, offset, whence); \/* tebako patched *\/ "
486
+ do_patch "$1/folly/portability/Unistd.cpp" "$re" "$sbst"
487
+
488
+ re="res = lseek(fd, offset, whence);"
489
+ sbst="res = folly::portability::unistd::lseek(fd, offset, whence); \/* tebako patched *\/ "
490
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.cpp"
451
491
  # ---
492
+
452
493
  defined_msc_ver_to_win32 "$1/folly/external/farmhash/farmhash.cpp"
453
494
  defined_msc_ver_to_win32 "$1/folly/detail/IPAddressSource.h"
454
495
  defined_msc_ver_to_win32 "$1/folly/portability/Sockets.cpp"
@@ -471,5 +512,6 @@ EOM
471
512
  # while gettimeofday is provided by MSys, the other two functions are lost
472
513
  defined_n_win32_to_msc_ver "$1/folly/portability/SysTime.h"
473
514
  defined_win32_to_msc_ver "$1/folly/portability/SysTime.cpp"
515
+ defined_win32_to_msc_ver "$1/folly/lang/Exception.cpp"
474
516
 
475
517
  fi
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.6.5
1
+ 0.7.0
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.5
4
+ version: 0.7.0
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-05-15 00:00:00.000000000 Z
11
+ date: 2024-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -69,11 +69,13 @@ files:
69
69
  - lib/tebako/error.rb
70
70
  - lib/tebako/packager.rb
71
71
  - lib/tebako/packager/pass1.rb
72
+ - lib/tebako/packager/pass1a.rb
72
73
  - lib/tebako/packager/pass2.rb
73
74
  - lib/tebako/packager/patch_buildsystem.rb
74
75
  - lib/tebako/packager/patch_helpers.rb
75
76
  - lib/tebako/packager/patch_libraries.rb
76
77
  - lib/tebako/packager/patch_literals.rb
78
+ - lib/tebako/stripper.rb
77
79
  - lib/tebako/version.rb
78
80
  - resources/tebako-fs.cpp.in
79
81
  - resources/tebako-version.h.in
@@ -135,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
137
  - !ruby/object:Gem::Version
136
138
  version: '0'
137
139
  requirements: []
138
- rubygems_version: 3.5.9
140
+ rubygems_version: 3.5.11
139
141
  signing_key:
140
142
  specification_version: 4
141
143
  summary: Packager for Ruby executables