tebako 0.5.3 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 573cd1ec24b37fafbebc82a0a8a11a4a1c05e22b6feeba1af89dc8670923c5e2
4
- data.tar.gz: 03d3c8f200d209a6b419960f76f499c4ccad0a0b726cf8ba85a780fb6c6d3aa4
3
+ metadata.gz: 22aea474f49445f022530cf4cc3c16c2bce29da88bb1c3bc0c4d0a64838676a8
4
+ data.tar.gz: 3f3efc915bcde108bdd14b6f21946cf6c2e20edc7d48e2703db54f9ea9ed5dfb
5
5
  SHA512:
6
- metadata.gz: 5a362b80444f6288964158034d58fd4e86749127f173d0f4d30445790d4a86481467b3b82e75a4d7398729633bdb537f0f146ff168d5893db57f155d0d16776c
7
- data.tar.gz: 3da8e9e840d4bbf72f28c6b4e3b4c75bcdc076da51c000ef2e9a2d63121b8a694154be279d787694ee9728961e045a98e4f919740112c36579104b7d3565291e
6
+ metadata.gz: 78be29f984b8505a537327970820f91151411dde2fd0bbb6d760741cd373e61324d1b225ca2e1792f22f53b32a52ad0b3bcfa8c23ec7ede3df221c6435d8cb45
7
+ data.tar.gz: 13f0505477b14079016a48c83f44da433dcabf1858ea99ae2e8ab3892d7231493d5d46f02defdf57908ad5b652c6b8713d5ef0129b25ae979798bc549e3442f7
data/CMakeLists.txt CHANGED
@@ -73,8 +73,6 @@ include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/macos-environment.cmake)
73
73
  include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/msys-environment.cmake)
74
74
  include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/def-external-project.cmake)
75
75
 
76
- include(${CMAKE_SOURCE_DIR}/cmake/def_tty_colours.cmake)
77
-
78
76
  option(SETUP_MODE "Tebako setup" OFF)
79
77
  if(NOT LOG_LEVEL)
80
78
  set(LOG_LEVEL "error")
@@ -85,7 +83,7 @@ set(START_WITH_PACKAGED_FILESYSTEM OFF CACHE BOOL "Start workflow from 'packaged
85
83
  if (NOT ${SETUP_MODE})
86
84
  message("Running tebako press script")
87
85
  if (${START_WITH_PACKAGED_FILESYSTEM})
88
- message("${ColourBoldRed}*** Starting workflow from 'packaged filesystem' target ***${ColourReset}")
86
+ message("*** Starting workflow from 'packaged filesystem' target ***")
89
87
  endif(${START_WITH_PACKAGED_FILESYSTEM})
90
88
 
91
89
  if ("-${ROOT}" STREQUAL "-")
@@ -174,9 +172,37 @@ elseif("${OSTYPE_TXT}" MATCHES "^msys*")
174
172
  set(RUBY_MAKEFILE "--file=GNUmakefile")
175
173
  elseif("${OSTYPE_TXT}" MATCHES "^darwin.*")
176
174
  set(IS_DARWIN ON)
177
- set(BUILD_OPENSSL_ROOT_DIR "${BUILD_BREW_PREFIX}/opt/openssl@1.1")
175
+ if(${RUBY_VER} VERSION_LESS "3.1.0")
176
+ set(OPENSSL_VER "1.1")
177
+ else(${RUBY_VER} VERSION_LESS "3.1.0")
178
+ set(OPENSSL_VER "3")
179
+ endif(${RUBY_VER} VERSION_LESS "3.1.0")
180
+ set(BUILD_OPENSSL_ROOT_DIR "${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}")
178
181
  endif()
179
182
 
183
+ if(IS_DARWIN)
184
+ execute_process(
185
+ COMMAND "sysctl" "-n" "hw.ncpu"
186
+ RESULT_VARIABLE NCORES_RES
187
+ OUTPUT_VARIABLE NCORES
188
+ OUTPUT_STRIP_TRAILING_WHITESPACE
189
+ )
190
+ else(IS_DARWIN)
191
+ execute_process(
192
+ COMMAND "nproc" "--all"
193
+ RESULT_VARIABLE NCORES_RES
194
+ OUTPUT_VARIABLE NCORES
195
+ OUTPUT_STRIP_TRAILING_WHITESPACE
196
+ )
197
+ endif(IS_DARWIN)
198
+
199
+ if(NCORES_RES EQUAL 0)
200
+ message(STATUS "NCORES: ${NCORES}")
201
+ else(NCORES_RES EQUAL 0)
202
+ set(NCORES 4)
203
+ message(WARNING "Failed to detect NCORES, resetting to ${NCORES} (default)")
204
+ endif(NCORES_RES EQUAL 0)
205
+
180
206
  # Various locations for external projects
181
207
  set(DEPS ${CMAKE_CURRENT_SOURCE_DIR}/deps CACHE STRING "Dependencies' folder'")
182
208
  set(DEPS_INCLUDE_DIR ${DEPS}/include)
@@ -217,7 +243,7 @@ if(IS_MSYS)
217
243
  endif(IS_MSYS)
218
244
 
219
245
  def_ext_prj_g(INCBIN "348e36b")
220
- def_ext_prj_g(DWARFS_WR "v0.3.4")
246
+ def_ext_prj_g(DWARFS_WR "v0.4.0")
221
247
 
222
248
  if (DEFINED ENV{BUNDLER_VER})
223
249
  set(BUNDLER_VER $ENV{BUNDLER_VER})
@@ -360,7 +386,7 @@ ExternalProject_Add(${DWARFS_WR_PRJ}
360
386
  SOURCE_DIR ${DWARFS_WR_SOURCE_DIR}
361
387
  BINARY_DIR ${DWARFS_WR_BINARY_DIR}
362
388
  UPDATE_COMMAND ""
363
- BUILD_COMMAND ${CMAKE_COMMAND} --build ${DWARFS_WR_BINARY_DIR} --parallel 4
389
+ BUILD_COMMAND ${CMAKE_COMMAND} --build ${DWARFS_WR_BINARY_DIR} --parallel ${NCORES}
364
390
  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DEPS}
365
391
  -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
366
392
  -DWITH_TESTS:BOOL=OFF
@@ -411,24 +437,21 @@ endif()
411
437
  set(C_FLAGS_DEST cppflags)
412
438
 
413
439
  if(IS_DARWIN)
414
- if(${RUBY_VER} VERSION_LESS "3.2.2")
415
- set(OPENSSL_VER "1.1")
416
- else(${RUBY_VER} VERSION_LESS "3.2.2")
417
- set(OPENSSL_VER "3")
418
- endif(${RUBY_VER} VERSION_LESS "3.2.2")
419
440
  string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -I${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}/include -I${BUILD_BREW_PREFIX}/opt/zlib/include -I${BUILD_BREW_PREFIX}/include")
420
441
  string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -L${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}/lib -L${BUILD_BREW_PREFIX}/opt/zlib/lib -L${BUILD_BREW_PREFIX}/lib")
421
442
  set(OPENSSL_RUBY_OPTION "--with-openssl-dir=${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}")
422
443
  set(C_FLAGS_DEST cflags)
423
- endif(IS_DARWIN)
444
+ else(IS_DARWIN)
445
+ string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -static-libgcc")
424
446
 
425
- if(IS_MUSL)
426
- string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DENABLE_PATH_CHECK=0")
427
- endif(IS_MUSL)
447
+ if(IS_MUSL)
448
+ string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DENABLE_PATH_CHECK=0")
449
+ endif(IS_MUSL)
428
450
 
429
- if(RB_W32)
430
- string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DRB_W32=1")
431
- endif(RB_W32)
451
+ if(RB_W32)
452
+ string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DRB_W32=1")
453
+ endif(RB_W32)
454
+ endif(IS_DARWIN)
432
455
 
433
456
  message(STATUS "Ruby build ${C_FLAGS_DEST}='${RUBY_C_FLAGS}'")
434
457
  message(STATUS "Ruby build LDFLAGS='${RUBY_L_FLAGS}'")
@@ -454,7 +477,7 @@ ExternalProject_Add(${RUBY_PRJ}
454
477
  --prefix=${DATA_SRC_DIR} \
455
478
  ${C_FLAGS_DEST}=\"${RUBY_C_FLAGS}\" \
456
479
  LDFLAGS=\"${RUBY_L_FLAGS}\""
457
- BUILD_COMMAND make ${RUBY_MAKEFILE}
480
+ BUILD_COMMAND make ${RUBY_MAKEFILE} -j${NCORES}
458
481
  INSTALL_COMMAND make ${RUBY_MAKEFILE} install
459
482
  COMMAND ruby ${EXE}/tebako-packager pass2 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${DEPS_LIB_DIR} ${DATA_SRC_DIR} ${RUBY_STASH_DIR} ${RUBY_VER}
460
483
  )
@@ -488,7 +511,7 @@ else (${SETUP_MODE})
488
511
  list(LENGTH GEMS GLENGTH)
489
512
 
490
513
  add_custom_target(clean_filesystem
491
- COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR}
514
+ COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR} ${TBD} ${TGD}
492
515
  DEPENDS ${RUBY_PRJ}
493
516
  )
494
517
  if(GSLENGTH GREATER 0)
@@ -557,15 +580,14 @@ else (${SETUP_MODE})
557
580
  COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
558
581
  ${TBD}/bundle${CMD_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
559
582
  COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
560
- ${TBD}/bundle${CMD_SUFFIX} install --jobs=4
583
+ ${TBD}/bundle${CMD_SUFFIX} install --jobs=${NCORES}
561
584
  # COMMAND_EXPAND_LISTS
562
585
  # [TODO] Open question - how to deploy a project to source filesystem
563
586
  # ruby packer does bundle install --deployment --binstubs
564
- # [TODO] --jobs=4 probably can be more intellectual
565
587
  # COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
566
588
  # ${TBD}/bundle lock
567
589
  # COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
568
- # ${TBD}/bundle install --deployment --jobs=4
590
+ # ${TBD}/bundle install --deployment --jobs=${NCORES}
569
591
  DEPENDS clean_filesystem
570
592
  )
571
593
  elseif(GLENGTH GREATER 0)
@@ -665,12 +687,12 @@ else (${SETUP_MODE})
665
687
 
666
688
  if (${RUBY_VER} VERSION_LESS "3.0.0")
667
689
  add_custom_target(patched_ruby
668
- COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE}
690
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE} -j${NCORES}
669
691
  )
670
692
  else()
671
693
  add_custom_target(patched_ruby
672
- COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ruby ${RUBY_MAKEFILE}
673
- COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE}
694
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ruby ${RUBY_MAKEFILE} -j${NCORES}
695
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE} -j${NCORES}
674
696
  )
675
697
  endif()
676
698
 
data/Rakefile CHANGED
@@ -36,7 +36,7 @@ desc "Generate version.txt"
36
36
  task "generate_version_txt" do
37
37
  require_relative "lib/tebako/version"
38
38
  File.write(File.join(__dir__, "version.txt"), "#{Tebako::VERSION}\n")
39
- puts "Generating version.txt #{Tebako::VERSION} --> #{File.join(__dir__, "version.txt")}"
39
+ puts "Generating #{File.join(__dir__, "version.txt")}; version = #{Tebako::VERSION}"
40
40
  end
41
41
 
42
42
  task build: :generate_version_txt
data/common.env CHANGED
@@ -1,6 +1,6 @@
1
1
  BUILD_TYPE=Release
2
2
  DEPS=deps
3
3
  INCBIN_TAG=348e36b
4
- DWARFS_WR_TAG=v0.3.4
4
+ DWARFS_WR_TAG=v0.4.0
5
5
  BUNDLER_VER=2.3.22
6
6
  RUBY_VER=3.1.4
data/exe/tebako-packager CHANGED
@@ -78,11 +78,13 @@ begin
78
78
  # ARGV[2] -- DATA_SRC_DIR
79
79
  # ARGV[3] -- DATA_PRE_DIR
80
80
  # ARGV[4] -- DATA_BIN_DIR
81
- unless ARGV.length == 5
81
+ # ARGV[5] -- TARGET_BIN_DIR (TBD)
82
+ # ARGV[6] -- TARGET_GEM_DIR (TGD)
83
+ unless ARGV.length == 7
82
84
  raise Tebako::Error,
83
- "tebako-packager deploy command expects 5 arguments, #{ARGV.length} has been provided."
85
+ "tebako-packager deploy command expects 7 arguments, #{ARGV.length} has been provided."
84
86
  end
85
- Tebako::Packager.deploy(ARGV[1], ARGV[2], ARGV[3], ARGV[4])
87
+ Tebako::Packager.deploy(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5])
86
88
  else
87
89
  raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
88
90
  end
@@ -44,8 +44,6 @@ module Tebako
44
44
  else
45
45
  ENV.fetch("CXXFLAGS", nil)
46
46
  end
47
- # cc = ENV.fetch("CC", "gcc")
48
- # cxx = ENV.fetch("CXX", "g++")
49
47
  @b_env ||= { "CXXFLAGS" => u_flags }
50
48
  end
51
49
 
@@ -34,64 +34,82 @@ module Tebako
34
34
  # Ruby patching definitions (pass2)
35
35
  module Pass2
36
36
  class << self
37
- def get_dir_c_patch(ostype)
38
- dir_c_patch = patch_c_file(ostype =~ /msys/ ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST")
39
- dir_c_patch.merge!(DIR_C_BASE_PATCH)
40
- end
41
-
42
37
  def get_patch_map(ostype, deps_lib_dir, ruby_ver)
43
- patch_map = {
44
- "template/Makefile.in" => template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver),
45
- "main.c" => MAIN_C_PATCH,
46
- "tool/mkconfig.rb" => TOOL_MKCONFIG_RB_PATCH,
47
- "dir.c" => get_dir_c_patch(ostype)
48
- }
38
+ patch_map = get_patch_map_base(ostype, deps_lib_dir, ruby_ver)
49
39
 
50
40
  C_FILES_TO_PATCH.each { |patch| patch_map.store(patch[0], patch_c_file(patch[1])) }
51
41
  patch_map.store("thread_pthread.c", LINUX_MUSL_THREAD_PTHREAD_PATCH) if ostype =~ /linux-musl/
52
42
  patch_map.store("common.mk", COMMON_MK_PATCH) if PatchHelpers.ruby3x?(ruby_ver)
53
43
 
54
44
  ostype =~ /msys/ ? patch_map.merge!(MSYS_PATCHES) : patch_map
45
+ # patch_map.merge!(LINUX_PATCHES)
55
46
  end
56
47
 
57
48
  private
58
49
 
59
50
  include Tebako::Packager::PatchLiterals
60
51
 
52
+ def get_dir_c_patch(ostype)
53
+ dir_c_patch = patch_c_file(ostype =~ /msys/ ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST")
54
+ dir_c_patch.merge!(DIR_C_BASE_PATCH)
55
+ end
56
+
57
+ def get_patch_map_base(ostype, deps_lib_dir, ruby_ver)
58
+ {
59
+ "template/Makefile.in" => template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver),
60
+ "main.c" => MAIN_C_PATCH,
61
+ "tool/mkconfig.rb" => TOOL_MKCONFIG_RB_PATCH,
62
+ "gem_prelude.rb" => GEM_PRELUDE_RB_PATCH,
63
+ "dir.c" => get_dir_c_patch(ostype)
64
+ }
65
+ end
66
+
61
67
  def process_brew_libs!(libs, brew_libs)
62
- brew_libs.each { |lib| libs << "#{PatchHelpers.get_prefix(lib[0]).chop}/lib/lib#{lib[1]}.a " }
68
+ brew_libs.each { |lib| libs << "#{PatchHelpers.get_prefix_macos(lib[0]).chop}/lib/lib#{lib[1]}.a " }
63
69
  end
64
70
 
65
71
  def darwin_libs(deps_lib_dir, ruby_ver)
66
72
  libs = String.new
73
+
74
+ process_brew_libs!(libs, PatchHelpers.ruby31?(ruby_ver) ? DARWIN_BREW_LIBS_31 : DARWIN_BREW_LIBS_PRE_31)
67
75
  process_brew_libs!(libs, DARWIN_BREW_LIBS)
68
- process_brew_libs!(libs, DARWIN_BREW_LIBS_32) if PatchHelpers.ruby32?(ruby_ver)
76
+
69
77
  DARWIN_DEP_LIBS.each { |lib| libs << "#{deps_lib_dir}/lib#{lib}.a " }
70
78
  <<~SUBST
71
- -ltebako-fs -ldwarfs-wr -ldwarfs -lfolly -lfsst -lmetadata_thrift -lthrift_light -lxxhash \
72
- -lzstd #{libs} -ljemalloc -lc++
79
+ -ltebako-fs -ldwarfs-wr -ldwarfs -force_load #{deps_lib_dir}/libdwarfs_compression.a -lfolly -lfsst -lmetadata_thrift -lthrift_light -lxxhash \
80
+ -lzstd #{libs} -ljemalloc -lc++ -lc++abi
73
81
  SUBST
74
82
  end
75
83
 
76
- def yaml_reference(ruby_ver)
77
- PatchHelpers.ruby32?(ruby_ver) ? "-l:libyaml.a" : ""
78
- end
84
+ # .....................................................
85
+ # Notes re linux libraries
86
+ # 1) This order is important: -lgcc_eh -l:libunwind.a -l:liblzma.a lzma is used to process debug sections.
87
+ # gcc_eh shall be linked before unwind to avoid duplicate symbols.
88
+ # 2) -lgcc_eh assumes -static-libgcc (applied in CMakeLists.ext, RUBY_C_FLAGS)
89
+ # 3) -static-libstdc++ did not work, not sure why [TODO ?]
90
+ # 4) When clang is used linker links libraries specified in exensions in such way that they are linked shared
91
+ # (libz, libffi, libreadline, libncurses, libtinfo, ... )
92
+ # Using stuff like -l:libz.a does not help; there is a reference to libz.so anyway.
93
+ # This is fixed by ext/extmk.rb patch [TODO ?]
94
+ # .....................................................
79
95
 
80
96
  def linux_gnu_libs(ruby_ver)
81
97
  <<~SUBST
82
- -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -l:libfolly.a -l:libfsst.a -l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a \
83
- -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a -l:libiberty.a -l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a \
84
- -l:libzstd.a -l:libgdbm.a -l:libreadline.a -l:libtinfo.a -l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libunwind.a -l:libcrypt.a -l:libanl.a -l:liblzma.a \
85
- #{yaml_reference(ruby_ver)} -l:libboost_system.a -l:libstdc++.a -l:librt.a -ldl -lpthread
98
+ -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -Wl,--push-state,--whole-archive -l:libdwarfs_compression.a -Wl,--pop-state -l:libfolly.a -l:libfsst.a \
99
+ -l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a -l:libarchive.a -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a \
100
+ -l:libiberty.a -l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a -l:libzstd.a -l:libbrotlienc.a -l:libbrotlidec.a -l:libbrotlicommon.a -l:libgdbm.a \
101
+ -l:libreadline.a -l:libtinfo.a -l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libcrypt.a -l:libanl.a #{PatchHelpers.yaml_reference(ruby_ver)} \
102
+ -l:libboost_system.a -l:libboost_chrono.a -l:libutil.a -l:libstdc++.a -lgcc_eh -l:libunwind.a -l:liblzma.a -l:librt.a -ldl -lpthread -lm
86
103
  SUBST
87
104
  end
88
105
 
89
106
  def linux_musl_libs(ruby_ver)
90
107
  <<~SUBST
91
- -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -l:libfolly.a -l:libfsst.a -l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a \
92
- -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a -l:libiberty.a -l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a \
93
- -l:libzstd.a -l:libgdbm.a -l:libreadline.a -l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libunwind.a -l:libcrypt.a -l:liblzma.a \
94
- #{yaml_reference(ruby_ver)} -l:libboost_system.a -l:libstdc++.a -l:librt.a -ldl -lpthread
108
+ -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -Wl,--push-state,--whole-archive -l:libdwarfs_compression.a -Wl,--pop-state -l:libfolly.a -l:libfsst.a \
109
+ -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 -l:libiberty.a \
110
+ -l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a -l:libzstd.a -l:libbrotlienc.a -l:libbrotlidec.a -l:libbrotlicommon.a -l:libgdbm.a -l:libreadline.a \
111
+ -l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libcrypt.a #{PatchHelpers.yaml_reference(ruby_ver)} -l:libboost_system.a -l:libboost_chrono.a -l:librt.a \
112
+ -l:libstdc++.a -lgcc_eh -l:libunwind.a -l:liblzma.a -ldl -lpthread
95
113
  SUBST
96
114
  end
97
115
 
@@ -100,7 +118,7 @@ module Tebako
100
118
  -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -l:libfolly.a -l:libfsst.a -l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a \
101
119
  -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a \
102
120
  -l:libzstd.a -l:libffi.a -l:libgdbm.a -l:libncurses.a -l:libjemalloc.a -l:libunwind.a -l:liblzma.a -l:libiberty.a \
103
- #{yaml_reference(ruby_ver)} -l:libstdc++.a -l:libdl.a -lole32 -loleaut32 -luuid
121
+ #{PatchHelpers.yaml_reference(ruby_ver)} -l:libstdc++.a -l:libdl.a -lole32 -loleaut32 -luuid
104
122
  SUBST
105
123
  end
106
124
 
@@ -138,22 +156,14 @@ module Tebako
138
156
  end
139
157
 
140
158
  def template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver)
141
- base_patch = {
142
- "LIBS = @LIBS@ $(EXTLIBS)" => <<~SUBST
143
- # -- Start of tebako patch --
144
- LIBS = $(MAINLIBS) @LIBS@
145
- # -- End of tebako patch --
146
- SUBST
147
- }
148
- base_patch.merge!(mlibs_subst(ostype, deps_lib_dir, ruby_ver))
149
- base_patch.merge!(template_makefile_in_patch_two(ruby_ver))
159
+ template_makefile_in_patch_two(ruby_ver).merge(mlibs_subst(ostype, deps_lib_dir, ruby_ver))
150
160
  end
151
161
 
152
162
  def template_makefile_in_patch_two(ruby_ver)
153
163
  if PatchHelpers.ruby31?(ruby_ver)
154
- { TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO => TEMPLATE_MAKEFILE_IN_BASE_PATCH_TWO }
164
+ { TEMPLATE_MAKEFILE_IN_BASE_PATTERN => TEMPLATE_MAKEFILE_IN_BASE_PATCH }
155
165
  else
156
- { TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO_PRE_3_1 => TEMPLATE_MAKEFILE_IN_BASE_PATCH_TWO_PRE_3_1 }
166
+ { TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 => TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 }
157
167
  end
158
168
  end
159
169
  end
@@ -34,13 +34,23 @@ module Tebako
34
34
  # Ruby patching helpers (pass2)
35
35
  module PatchHelpers
36
36
  class << self
37
- def get_prefix(package)
37
+ def get_prefix_macos(package)
38
38
  out, st = Open3.capture2("brew --prefix #{package}")
39
39
  raise Tebako::Error, "brew --prefix #{package} failed with code #{st.exitstatus}" unless st.exitstatus.zero?
40
40
 
41
41
  out
42
42
  end
43
43
 
44
+ def get_prefix_linux(package)
45
+ out, st = Open3.capture2("pkg-config --variable=libdir #{package}")
46
+ unless st.exitstatus.zero?
47
+ raise Tebako::Error,
48
+ "pkg-config --variable=libdir #{package} failed with code #{st.exitstatus}"
49
+ end
50
+
51
+ out
52
+ end
53
+
44
54
  def ruby3x?(ruby_ver)
45
55
  ruby_ver[0] == "3"
46
56
  end
@@ -52,6 +62,10 @@ module Tebako
52
62
  def ruby32?(ruby_ver)
53
63
  ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 2
54
64
  end
65
+
66
+ def yaml_reference(ruby_ver)
67
+ ruby32?(ruby_ver) ? "-l:libyaml.a" : ""
68
+ end
55
69
  end
56
70
  end
57
71
  end
@@ -168,24 +168,24 @@ module Tebako
168
168
  ["dln.c", "static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;"]
169
169
  ].freeze
170
170
 
171
- TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO_PRE_3_1 =
171
+ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 =
172
172
  "\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
173
173
  "$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
174
174
 
175
- TEMPLATE_MAKEFILE_IN_BASE_PATCH_TWO_PRE_3_1 =
175
+ TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 =
176
176
  "# -- Start of tebako patch --\n" \
177
177
  "\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
178
- "$(EXTOBJS) $(LIBRUBYARG_STATIC) $(LIBS) $(OUTFLAG)$@\n" \
178
+ "$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
179
179
  "# -- End of tebako patch --"
180
180
 
181
- TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO =
182
- "\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
183
- "$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
181
+ TEMPLATE_MAKEFILE_IN_BASE_PATTERN =
182
+ "\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) " \
183
+ "$(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
184
184
 
185
- TEMPLATE_MAKEFILE_IN_BASE_PATCH_TWO =
185
+ TEMPLATE_MAKEFILE_IN_BASE_PATCH =
186
186
  "# -- Start of tebako patch --\n" \
187
187
  "\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
188
- "$(EXTOBJS) $(LIBRUBYARG_STATIC) $(LIBS) $(OUTFLAG)$@\n" \
188
+ "$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
189
189
  "# -- End of tebako patch --"
190
190
 
191
191
  C_FILE_SUBST = <<~SUBST
@@ -199,6 +199,20 @@ module Tebako
199
199
  /* -- End of tebako patch -- */
200
200
  SUBST
201
201
 
202
+ GEM_PRELUDE_RB_PATCH = {
203
+ "if defined?(DidYouMean)" => <<~SUBST
204
+ if defined?(DidYouMean)
205
+
206
+ # -- Start of tebako patch --
207
+ begin
208
+ require 'tebako-runtime'
209
+ rescue LoadError
210
+ warn "'tebako-runtime' was not loaded."
211
+ end
212
+ # -- End of tebako patch --
213
+ SUBST
214
+ }.freeze
215
+
202
216
  MSYS_PATCHES = {
203
217
  "ruby.c" => {
204
218
  "#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))" =>
@@ -237,17 +251,28 @@ module Tebako
237
251
 
238
252
  }.freeze
239
253
 
254
+ LINUX_PATCHES = {
255
+ "ext/extmk.rb" => {
256
+ "mf.macro \"EXTLIBS\", $extlibs" => "# mf.macro \"EXTLIBS\", $extlibs tebako patched"
257
+ }
258
+ }.freeze
259
+
240
260
  # rubocop:disable Style/WordArray
261
+
262
+ # NOTE: folly provides build-in implementation of jemalloc
263
+
241
264
  DARWIN_BREW_LIBS = [
242
- ["openssl@1.1", "ssl"], ["openssl@1.1", "crypto"], ["zlib", "z"], ["gdbm", "gdbm"],
243
- ["readline", "readline"], ["libffi", "ffi"], ["ncurses", "ncurses"], ["fmt", "fmt"],
244
- ["lz4", "lz4"], ["xz", "lzma"], ["libyaml", "yaml"],
265
+ ["zlib", "z"], ["gdbm", "gdbm"], ["readline", "readline"], ["libffi", "ffi"],
266
+ ["ncurses", "ncurses"], ["fmt", "fmt"], ["lz4", "lz4"], ["xz", "lzma"],
267
+ ["libyaml", "yaml"], ["boost", "boost_chrono"],
245
268
  ["double-conversion", "double-conversion"]
246
269
  ].freeze
247
270
 
248
- DARWIN_BREW_LIBS_32 = [["libyaml", "yaml"]].freeze
271
+ DARWIN_BREW_LIBS_PRE_31 = [["openssl@1.1", "ssl"], ["openssl@1.1", "crypto"]].freeze
272
+
273
+ DARWIN_BREW_LIBS_31 = [["libyaml", "yaml"], ["openssl@3", "ssl"], ["openssl@3", "crypto"]].freeze
249
274
 
250
- DARWIN_DEP_LIBS = ["glog", "gflags"].freeze
275
+ DARWIN_DEP_LIBS = ["glog", "gflags", "brotlienc", "brotlidec", "brotlicommon"].freeze
251
276
  # rubocop:enable Style/WordArray
252
277
  end
253
278
  # rubocop:enable Metrics/ModuleLength
@@ -42,6 +42,7 @@ module Tebako
42
42
  file.c
43
43
  io.c
44
44
  tool/mkconfig.rb
45
+ gem_prelude.rb
45
46
  ].freeze
46
47
 
47
48
  FILES_TO_RESTORE_MSYS = %w[
@@ -55,6 +56,12 @@ module Tebako
55
56
  thread_pthread.c
56
57
  ].freeze
57
58
 
59
+ DEPLOY_ENV = {
60
+ "GEM_HOME" => nil,
61
+ "GEM_PATH" => nil,
62
+ "TEBAKO_PASS_THROUGH" => "1"
63
+ }.freeze
64
+
58
65
  class << self
59
66
  # Pass1
60
67
  # Executed before Ruby build, patching ensures that Ruby itself is linked statically
@@ -83,7 +90,7 @@ module Tebako
83
90
  # Saves pristine Ruby environment that is used to deploy applications for packaging
84
91
  def stash(src_dir, stash_dir)
85
92
  puts "-- Running stash script"
86
- # .... this code snippet is executed 'outdside' of Ruby scripts
93
+ # .... this code snippet is executed 'outside' of Ruby scripts
87
94
  # shall be reconsidered
88
95
  # FileUtils.cd ruby_source_dir do
89
96
  # puts " ... creating pristine ruby environment at #{src_dir} [patience, it will take some time]"
@@ -98,18 +105,40 @@ module Tebako
98
105
  end
99
106
 
100
107
  # Deploy
101
- # To be extended
102
- # Now it just recreates Ruby prostine environment from stash
103
- def deploy(stash_dir, src_dir, pre_dir, bin_dir)
108
+ def deploy(stash_dir, src_dir, pre_dir, bin_dir, tbd)
104
109
  puts "-- Running deploy script"
105
110
 
106
111
  puts " ... creating packaging environment at #{src_dir}"
107
112
  recreate([src_dir, pre_dir, bin_dir])
108
113
  FileUtils.cp_r "#{stash_dir}/.", src_dir
114
+
115
+ install_gem tbd, "tebako-runtime"
109
116
  end
110
117
 
111
118
  private
112
119
 
120
+ def install_gem(tbd, name)
121
+ puts " ... installing #{name} gem"
122
+ with_env(DEPLOY_ENV) do
123
+ out, st = Open3.capture2e("#{tbd}/gem", "install", name.to_s, "--no-doc")
124
+ raise Tebako::Error, "Failed to install #{name} (#{st}):\n #{out}" unless st.exitstatus.zero?
125
+ end
126
+ end
127
+
128
+ def do_patch(patch_map, root)
129
+ patch_map.each { |fname, mapping| patch_file("#{root}/#{fname}", mapping) }
130
+ end
131
+
132
+ def patch_file(fname, mapping)
133
+ raise Tebako::Error, "Could not patch #{fname} because it does not exist." unless File.exist?(fname)
134
+
135
+ puts " ... patching #{fname}"
136
+ restore_and_save(fname)
137
+ contents = File.read(fname)
138
+ mapping.each { |pattern, subst| contents.sub!(pattern, subst) }
139
+ File.open(fname, "w") { |file| file << contents }
140
+ end
141
+
113
142
  def recreate(dirname)
114
143
  FileUtils.rm_rf(dirname, noop: nil, verbose: nil, secure: true)
115
144
  FileUtils.mkdir(dirname)
@@ -132,18 +161,20 @@ module Tebako
132
161
  end
133
162
  end
134
163
 
135
- def patch_file(fname, mapping)
136
- raise Tebako::Error, "Could not patch #{fname} because it does not exist." unless File.exist?(fname)
137
-
138
- puts " ... patching #{fname}"
139
- restore_and_save(fname)
140
- contents = File.read(fname)
141
- mapping.each { |pattern, subst| contents.sub!(pattern, subst) }
142
- File.open(fname, "w") { |file| file << contents }
143
- end
144
-
145
- def do_patch(patch_map, root)
146
- patch_map.each { |fname, mapping| patch_file("#{root}/#{fname}", mapping) }
164
+ # Sets up temporary environment variables and yields to the
165
+ # block. When the block exits, the environment variables are set
166
+ # back to their original values.
167
+ def with_env(hash)
168
+ old = {}
169
+ hash.each do |k, v|
170
+ old[k] = ENV.fetch(k, nil)
171
+ ENV[k] = v
172
+ end
173
+ begin
174
+ yield
175
+ ensure
176
+ hash.each { |k, _v| ENV[k] = old[k] }
177
+ end
147
178
  end
148
179
  end
149
180
  end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.5.3"
29
+ VERSION = "0.5.5"
30
30
  end
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  *
3
- * Copyright (c) 2021-2022 [Ribose Inc](https://www.ribose.com).
3
+ * Copyright (c) 2021-2023 [Ribose Inc](https://www.ribose.com).
4
4
  * All rights reserved.
5
5
  * This file is a part of tebako
6
6
  *
@@ -34,4 +34,4 @@ namespace tebako {
34
34
  const char * fs_mount_point = "@FS_MOUNT_POINT@";
35
35
  const char * fs_entry_point = "@FS_ENTRY_POINT@";
36
36
  INCBIN(fs, "@DATA_BIN_FILE@");
37
- }
37
+ }
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.5
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.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-18 00:00:00.000000000 Z
11
+ date: 2023-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -57,7 +57,6 @@ files:
57
57
  - bin/console
58
58
  - bin/setup
59
59
  - cmake/copy_dir.cmake
60
- - cmake/def_tty_colours.cmake
61
60
  - common.env
62
61
  - exe/tebako
63
62
  - exe/tebako-packager
@@ -1,19 +0,0 @@
1
- if(NOT WIN32)
2
- string(ASCII 27 Escape)
3
- set(ColourReset "${Escape}[m")
4
- set(ColourBold "${Escape}[1m")
5
- set(ColourRed "${Escape}[31m")
6
- set(ColourGreen "${Escape}[32m")
7
- set(ColourYellow "${Escape}[33m")
8
- set(ColourBlue "${Escape}[34m")
9
- set(ColourMagenta "${Escape}[35m")
10
- set(ColourCyan "${Escape}[36m")
11
- set(ColourWhite "${Escape}[37m")
12
- set(ColourBoldRed "${Escape}[1;31m")
13
- set(ColourBoldGreen "${Escape}[1;32m")
14
- set(ColourBoldYellow "${Escape}[1;33m")
15
- set(ColourBoldBlue "${Escape}[1;34m")
16
- set(ColourBoldMagenta "${Escape}[1;35m")
17
- set(ColourBoldCyan "${Escape}[1;36m")
18
- set(ColourBoldWhite "${Escape}[1;37m")
19
- endif()