tebako 0.12.9 → 0.12.11

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.
@@ -35,7 +35,7 @@ require_relative "ruby_builder"
35
35
  require_relative "stripper"
36
36
  require_relative "packager/pass1_patch"
37
37
  require_relative "packager/pass1a_patch"
38
- require_relative "packager/pass2"
38
+ require_relative "packager/pass2_patch"
39
39
  require_relative "packager/patch_helpers"
40
40
 
41
41
  # Tebako - an executable packager
@@ -89,15 +89,20 @@ module Tebako
89
89
  Tebako::Stripper.strip(deploy_helper, target_dir)
90
90
  end
91
91
 
92
- def finalize(os_type, src_dir, app_name, ruby_ver, patchelf)
92
+ def do_patch(patch_map, root)
93
+ patch_map.each { |fname, mapping| PatchHelpers.patch_file("#{root}/#{fname}", mapping) }
94
+ end
95
+
96
+ def finalize(src_dir, app_name, ruby_ver, patchelf)
93
97
  puts "-- Running finalize script"
94
98
 
95
99
  RubyBuilder.new(ruby_ver, src_dir).target_build
96
- exe_suffix = Packager::PatchHelpers.exe_suffix(os_type)
100
+ exe_suffix = ScenarioManagerBase.new.exe_suffix
97
101
  src_name = File.join(src_dir, "ruby#{exe_suffix}")
98
102
  patchelf(src_name, patchelf)
99
103
  package_name = "#{app_name}#{exe_suffix}"
100
- strip_or_copy(os_type, src_name, package_name)
104
+ # strip_or_copy(os_type, src_name, package_name)
105
+ Tebako::Stripper.strip_file(src_name, package_name)
101
106
  puts "Created tebako package at \"#{package_name}\""
102
107
  end
103
108
 
@@ -136,8 +141,8 @@ module Tebako
136
141
  # Patch gem_prelude.rb
137
142
  def pass1a(ruby_source_dir)
138
143
  puts "-- Running pass1a script"
139
- patch = Pass1APatch.new.patch_map
140
- do_patch(patch, ruby_source_dir)
144
+ patch = Pass1APatch.new
145
+ do_patch(patch.patch_map, ruby_source_dir)
141
146
  end
142
147
 
143
148
  # Pass2
@@ -145,7 +150,8 @@ module Tebako
145
150
  def pass2(ostype, ruby_source_dir, deps_lib_dir, ruby_ver)
146
151
  puts "-- Running pass2 script"
147
152
 
148
- do_patch(Pass2.get_patch_map(ostype, deps_lib_dir, ruby_ver), ruby_source_dir)
153
+ patch = crt_pass2_patch(ostype, deps_lib_dir, ruby_ver)
154
+ do_patch(patch.patch_map, ruby_source_dir)
149
155
  end
150
156
 
151
157
  # Stash
@@ -183,10 +189,6 @@ module Tebako
183
189
  File.join(src_dir, "lib", "libx64-ucrt-ruby#{ruby_ver.lib_version}.a")
184
190
  end
185
191
 
186
- def do_patch(patch_map, root)
187
- patch_map.each { |fname, mapping| PatchHelpers.patch_file("#{root}/#{fname}", mapping) }
188
- end
189
-
190
192
  def patchelf(src_name, patchelf)
191
193
  return if patchelf.nil?
192
194
 
@@ -194,15 +196,15 @@ module Tebako
194
196
  BuildHelpers.run_with_capture(params)
195
197
  end
196
198
 
197
- def strip_or_copy(os_type, src_name, package_name)
198
- # [TODO] On MSys strip sometimes creates a broken executable
199
- # https://github.com/tamatebako/tebako/issues/172
200
- if Packager::PatchHelpers.msys?(os_type)
201
- FileUtils.cp(src_name, package_name)
202
- else
203
- Tebako::Stripper.strip_file(src_name, package_name)
204
- end
205
- end
199
+ # def strip_or_copy(_os_type, src_name, package_name)
200
+ # [TODO] On MSys strip sometimes creates a broken executable
201
+ # https://github.com/tamatebako/tebako/issues/172
202
+ # if Packager::PatchHelpers.msys?(os_type)
203
+ # FileUtils.cp(src_name, package_name)
204
+ # else
205
+ # Tebako::Stripper.strip_file(src_name, package_name)
206
+ # end
207
+ # end
206
208
  end
207
209
  end
208
210
  end
@@ -37,7 +37,7 @@ module Tebako
37
37
  def initialize(ruby_ver, src_dir)
38
38
  @ruby_ver = ruby_ver
39
39
  @src_dir = src_dir
40
- @ncores = BuildHelpers.ncores
40
+ @ncores = ScenarioManagerBase.new.ncores
41
41
  end
42
42
 
43
43
  # Final build of tebako package
@@ -120,8 +120,7 @@ module Tebako
120
120
  end
121
121
 
122
122
  def version_check_msys
123
- if Gem::Version.new(@ruby_version) < Gem::Version.new(MIN_RUBY_VERSION_WINDOWS) &&
124
- RUBY_PLATFORM =~ /msys|mingw|cygwin/
123
+ if Gem::Version.new(@ruby_version) < Gem::Version.new(MIN_RUBY_VERSION_WINDOWS) && ScenarioManagerBase.new.msys?
125
124
  raise Tebako::Error.new("Ruby version #{@ruby_version} is not supported on Windows", 111)
126
125
  end
127
126
  end
@@ -132,14 +131,14 @@ module Tebako
132
131
  def initialize(ruby_version, gemfile_path)
133
132
  # Assuming that it does not attempt to load any gems or resolve dependencies
134
133
  # this can be done with any bundler version
135
- gemfile = Bundler::Definition.build(gemfile_path, nil, nil)
136
- ruby_v = gemfile.ruby_version&.versions
134
+ ruby_v = Bundler::Definition.build(gemfile_path, nil, nil).ruby_version&.versions
137
135
  if ruby_v.nil?
138
136
  super(ruby_version)
139
137
  else
140
138
  process_gemfile_ruby_version(ruby_version, ruby_v)
141
- run_checks
142
139
  end
140
+ rescue Tebako::Error
141
+ raise
143
142
  rescue StandardError => e
144
143
  Tebako.packaging_error(115, e.message)
145
144
  end
@@ -153,12 +152,13 @@ module Tebako
153
152
  else
154
153
  process_gemfile_ruby_version_d(ruby_version, requirement)
155
154
  end
155
+ run_checks
156
156
  end
157
157
 
158
158
  def process_gemfile_ruby_version_d(ruby_version, requirement)
159
159
  current_version = Gem::Version.new(ruby_version)
160
160
  unless requirement.satisfied_by?(current_version)
161
- raise Tebako::Error.new("Ruby version #{ruby_version} does not satisfy requirement #{ruby_v}", 116)
161
+ raise Tebako::Error.new("Ruby version #{ruby_version} does not satisfy requirement '#{requirement}'", 116)
162
162
  end
163
163
 
164
164
  @ruby_version = ruby_version
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
3
+ # Copyright (c) 2024-2025 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
5
  # This file is a part of tebako
6
6
  #
@@ -32,64 +32,99 @@ require_relative "error"
32
32
 
33
33
  # Tebako - an executable packager
34
34
  module Tebako
35
- # Manages packaging scenario based on input files (gemfile, gemspec, etc)
36
- class ScenarioManager
37
- def initialize(fs_root, fs_entrance)
38
- @with_gemfile = false
39
- initialize_root(fs_root)
40
- initialize_entry_point(fs_entrance || "stub.rb")
35
+ # Magic version numbers used to ensure compatibility for Ruby 2.7.x, 3.0.x
36
+ # These are the minimal versions required to provide linux-gnu / linux-musl differentiation by bundler
37
+ # Ruby 3.1+ default rubygems versions work correctly out of the box
38
+ BUNDLER_VERSION = "2.4.22"
39
+ RUBYGEMS_VERSION = "3.4.22"
40
+
41
+ # A couple of static Scenario definitions
42
+ class ScenarioManagerBase
43
+ def initialize(ostype = RUBY_PLATFORM)
44
+ @ostype = ostype
45
+ @linux = @ostype =~ /linux/ ? true : false
46
+ @musl = @ostype =~ /linux-musl/ ? true : false
47
+ @macos = @ostype =~ /darwin/ ? true : false
48
+ @msys = @ostype =~ /msys|mingw|cygwin/ ? true : false
49
+
50
+ @fs_mount_point = @msys ? "A:/__tebako_memfs__" : "/__tebako_memfs__"
51
+ @exe_suffix = @msys ? ".exe" : ""
41
52
  end
42
53
 
43
- attr_reader :fs_entry_point, :fs_mount_point, :fs_entrance, :gemfile_path, :with_gemfile
54
+ attr_reader :fs_mount_point, :exe_suffix
44
55
 
45
- def configure_scenario
46
- @fs_mount_point = if msys?
47
- "A:/__tebako_memfs__"
48
- else
49
- "/__tebako_memfs__"
50
- end
56
+ def b_env
57
+ u_flags = if @macos
58
+ "-DTARGET_OS_SIMULATOR=0 -DTARGET_OS_IPHONE=0 #{ENV.fetch("CXXFLAGS", nil)}"
59
+ else
60
+ ENV.fetch("CXXFLAGS", nil)
61
+ end
62
+ @b_env ||= { "CXXFLAGS" => u_flags }
63
+ end
51
64
 
52
- lookup_files
53
- configure_scenario_inner
65
+ def linux?
66
+ @linux
54
67
  end
55
68
 
56
- def exe_suffix
57
- @exe_suffix ||= msys? ? ".exe" : ""
69
+ def m_files
70
+ # [TODO]
71
+ # Ninja generates incorrect script for tebako press target -- gets lost in a chain custom targets
72
+ # Using makefiles has negative performance impact so it needs to be fixed
73
+
74
+ @m_files ||= if @linux || @macos
75
+ "Unix Makefiles"
76
+ elsif @msys
77
+ "MinGW Makefiles"
78
+ else
79
+ raise Tebako::Error.new("#{RUBY_PLATFORM} is not supported.", 112)
80
+ end
58
81
  end
59
82
 
60
83
  def macos?
61
- @macos ||= RUBY_PLATFORM =~ /darwin/ ? true : false
84
+ @macos
62
85
  end
63
86
 
64
87
  def msys?
65
- @msys ||= RUBY_PLATFORM =~ /msys|mingw|cygwin/ ? true : false
88
+ @msys
66
89
  end
67
90
 
68
- private
69
-
70
- def initialize_entry_point(fs_entrance)
71
- @fs_entrance = Pathname.new(fs_entrance).cleanpath.to_s
91
+ def musl?
92
+ @musl
93
+ end
72
94
 
73
- if Pathname.new(@fs_entrance).absolute?
74
- Tebako.packaging_error 114 unless @fs_entrance.start_with?(@fs_root)
95
+ def ncores
96
+ if @ncores.nil?
97
+ if @macos
98
+ out, st = Open3.capture2e("sysctl", "-n", "hw.ncpu")
99
+ else
100
+ out, st = Open3.capture2e("nproc", "--all")
101
+ end
75
102
 
76
- fetmp = @fs_entrance
77
- @fs_entrance = Pathname.new(@fs_entrance).relative_path_from(Pathname.new(@fs_root)).to_s
78
- puts "-- Absolute path to entry point '#{fetmp}' will be reduced to '#{@fs_entrance}' relative to '#{@fs_root}'"
103
+ @ncores = !st.signaled? && st.exitstatus.zero? ? out.strip.to_i : 4
79
104
  end
80
- # Can check after deploy, because entry point can be generated during bundle install or gem install
81
- # Tebako.packaging_error 106 unless File.file?(File.join(@fs_root, @fs_entrance))
82
- @fs_entry_point = "/bin/#{@fs_entrance}"
105
+ @ncores
83
106
  end
107
+ end
84
108
 
85
- def initialize_root(fs_root)
86
- Tebako.packaging_error 107 unless Dir.exist?(fs_root)
87
- p_root = Pathname.new(fs_root).cleanpath
88
- Tebako.packaging_error 113 unless p_root.absolute?
89
- @fs_root = p_root.realpath.to_s
109
+ # Manages packaging scenario based on input files (gemfile, gemspec, etc)
110
+ class ScenarioManager < ScenarioManagerBase
111
+ def initialize(fs_root, fs_entrance)
112
+ super()
113
+ @with_gemfile = @with_lockfile = @needs_bundler = false
114
+ @bundler_version = BUNDLER_VERSION
115
+ initialize_root(fs_root)
116
+ initialize_entry_point(fs_entrance || "stub.rb")
117
+ end
118
+
119
+ attr_reader :fs_entry_point, :fs_entrance, :gemfile_path, :needs_bundler, :with_gemfile
120
+
121
+ def bundler_reference
122
+ @needs_bundler ? "_#{@bundler_version}_" : nil
90
123
  end
91
124
 
92
- def configure_scenario_inner
125
+ def configure_scenario
126
+ lookup_files
127
+
93
128
  case @gs_length
94
129
  when 0
95
130
  configure_scenario_no_gemspec
@@ -100,6 +135,8 @@ module Tebako
100
135
  end
101
136
  end
102
137
 
138
+ private
139
+
103
140
  def configure_scenario_no_gemspec
104
141
  @fs_entry_point = "/local/#{@fs_entrance}" if @with_gemfile || @g_length.zero?
105
142
 
@@ -112,11 +149,93 @@ module Tebako
112
149
  end
113
150
  end
114
151
 
152
+ def initialize_entry_point(fs_entrance)
153
+ @fs_entrance = Pathname.new(fs_entrance).cleanpath.to_s
154
+
155
+ if Pathname.new(@fs_entrance).absolute?
156
+ Tebako.packaging_error 114 unless @fs_entrance.start_with?(@fs_root)
157
+
158
+ fetmp = @fs_entrance
159
+ @fs_entrance = Pathname.new(@fs_entrance).relative_path_from(Pathname.new(@fs_root)).to_s
160
+ puts "-- Absolute path to entry point '#{fetmp}' will be reduced to '#{@fs_entrance}' relative to '#{@fs_root}'"
161
+ end
162
+ # Can check after deploy, because entry point can be generated during bundle install or gem install
163
+ # Tebako.packaging_error 106 unless File.file?(File.join(@fs_root, @fs_entrance))
164
+ @fs_entry_point = "/bin/#{@fs_entrance}"
165
+ end
166
+
167
+ def initialize_root(fs_root)
168
+ Tebako.packaging_error 107 unless Dir.exist?(fs_root)
169
+ p_root = Pathname.new(fs_root).cleanpath
170
+ Tebako.packaging_error 113 unless p_root.absolute?
171
+ @fs_root = p_root.realpath.to_s
172
+ end
173
+
115
174
  def lookup_files
116
- @gemfile_path = File.join(@fs_root, "Gemfile")
117
175
  @gs_length = Dir.glob(File.join(@fs_root, "*.gemspec")).length
118
- @with_gemfile = File.exist?(@gemfile_path)
119
176
  @g_length = Dir.glob(File.join(@fs_root, "*.gem")).length
177
+ @with_gemfile = File.exist?(@gemfile_path = File.join(@fs_root, "Gemfile"))
178
+ @with_lockfile = File.exist?(@lockfile_path = File.join(@fs_root, "Gemfile.lock"))
179
+ end
180
+ end
181
+
182
+ # Configure scenraio and do bundler resolution
183
+ class ScenarioManagerWithBundler < ScenarioManager
184
+ protected
185
+
186
+ def lookup_files
187
+ super
188
+ if @with_lockfile
189
+ update_bundler_version_from_lockfile(@lockfile_path)
190
+ elsif @with_gemfile
191
+ update_bundler_version_from_gemfile(@gemfile_path)
192
+ end
193
+ end
194
+
195
+ private
196
+
197
+ def store_compatible_bundler_version(requirement)
198
+ fetcher = Gem::SpecFetcher.fetcher
199
+ tuples = fetcher.detect(:released) do |name_tuple|
200
+ name_tuple.name == "bundler" && requirement.satisfied_by?(name_tuple.version)
201
+ end
202
+
203
+ Tebako.packaging_error 119 if tuples.empty?
204
+
205
+ # Get latest compatible version
206
+ @bundler_version = tuples.map { |tuple, _| tuple.version }.max.to_s
207
+ end
208
+
209
+ def update_bundler_version_from_gemfile(gemfile_path)
210
+ # Build definition without lockfile
211
+ definition = Bundler::Definition.build(gemfile_path, nil, nil)
212
+
213
+ # Get bundler dependency from Gemfile
214
+ bundler_dep = definition.dependencies.find { |d| d.name == "bundler" }
215
+
216
+ return unless bundler_dep
217
+
218
+ @needs_bundler = true
219
+ min_requirement = Gem::Requirement.create(">= #{Tebako::BUNDLER_VERSION}")
220
+ requirement = Gem::Requirement.create(bundler_dep.requirement, min_requirement)
221
+
222
+ store_compatible_bundler_version(requirement)
223
+ end
224
+
225
+ def update_bundler_version_from_lockfile(lockfile_path)
226
+ puts " ... using lockfile at #{@lockfile_path}"
227
+ Tebako.packaging_error 117 unless File.exist?(lockfile_path)
228
+
229
+ lockfile_content = File.read(lockfile_path)
230
+ Tebako.packaging_error 117 unless lockfile_content =~ /BUNDLED WITH\n\s+(#{Gem::Version::VERSION_PATTERN})\n/
231
+
232
+ @bundler_version = ::Regexp.last_match(1)
233
+ @needs_bundler = true
234
+
235
+ bundler_requirement = Gem::Requirement.new(">= #{BUNDLER_VERSION}")
236
+ return if bundler_requirement.satisfied_by?(Gem::Version.new(@bundler_version))
237
+
238
+ Tebako.packaging_error 118, " : #{@bundler_version} requested, #{BUNDLER_VERSION} minimum required"
120
239
  end
121
240
  end
122
241
  end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.12.9"
29
+ VERSION = "0.12.11"
30
30
  end
data/tebako.gemspec CHANGED
@@ -63,8 +63,10 @@ Gem::Specification.new do |spec|
63
63
  spec.add_dependency "thor", "~> 1.2"
64
64
  spec.add_dependency "yaml", "~> 0.2.1"
65
65
 
66
+ spec.add_development_dependency "debug"
66
67
  spec.add_development_dependency "hoe"
67
68
  spec.add_development_dependency "minitest"
69
+ spec.add_development_dependency "rdbg"
68
70
  spec.add_development_dependency "rspec", "~> 3.2"
69
71
  spec.add_development_dependency "rubocop", "~> 1.52"
70
72
  spec.add_development_dependency "rubocop-rubycw"
@@ -36,13 +36,52 @@ concurrency:
36
36
  cancel-in-progress: true
37
37
 
38
38
  jobs:
39
+ test-setup-libfmt:
40
+ name: test setup-libfmt on ${{ matrix.os }}
41
+ runs-on: ${{ matrix.os }}
42
+ strategy:
43
+ fail-fast: false
44
+ matrix:
45
+ os: [ ubuntu-20.04, macos-13, macos-14 ]
46
+ steps:
47
+ - name: Checkout
48
+ uses: actions/checkout@v4
49
+
50
+ - name: Run cmake script
51
+ run: |
52
+ cmake -B build/setup-libfmt -DROOT=$PWD tests/setup-libfmt
53
+ cmake --build build/setup-libfmt
54
+
55
+ - name: Test setup-libfmt
56
+ run: |
57
+ set -o errexit -o pipefail -o noclobber -o nounset
58
+ test -f build/setup-libfmt/deps/lib/libfmt.a
59
+ test -f build/setup-libfmt/deps/include/fmt/args.h
60
+ test -f build/setup-libfmt/deps/include/fmt/chrono.h
61
+ test -f build/setup-libfmt/deps/include/fmt/color.h
62
+ test -f build/setup-libfmt/deps/include/fmt/compile.h
63
+ test -f build/setup-libfmt/deps/include/fmt/core.h
64
+ test -f build/setup-libfmt/deps/include/fmt/format.h
65
+ test -f build/setup-libfmt/deps/include/fmt/format-inl.h
66
+ test -f build/setup-libfmt/deps/include/fmt/os.h
67
+ test -f build/setup-libfmt/deps/include/fmt/ostream.h
68
+ test -f build/setup-libfmt/deps/include/fmt/printf.h
69
+ test -f build/setup-libfmt/deps/include/fmt/ranges.h
70
+ test -f build/setup-libfmt/deps/include/fmt/std.h
71
+ test -f build/setup-libfmt/deps/include/fmt/xchar.h
72
+ test -f build/setup-libfmt/deps/lib/cmake/fmt/fmt-config.cmake
73
+ test -f build/setup-libfmt/deps/lib/cmake/fmt/fmt-config-version.cmake
74
+ test -f build/setup-libfmt/deps/lib/cmake/fmt/fmt-targets.cmake
75
+ test -f build/setup-libfmt/deps/lib/cmake/fmt/fmt-targets-release.cmake
76
+ test -f build/setup-libfmt/deps/lib/pkgconfig/fmt.pc
77
+
39
78
  test-setup-librachive:
40
79
  name: test setup-librachive on ${{ matrix.os }}
41
80
  runs-on: ${{ matrix.os }}
42
81
  strategy:
43
82
  fail-fast: false
44
83
  matrix:
45
- os: [ ubuntu-20.04, macos-12 ]
84
+ os: [ ubuntu-20.04, macos-13, macos-14 ]
46
85
  steps:
47
86
  - name: Checkout
48
87
  uses: actions/checkout@v4
@@ -67,7 +106,7 @@ jobs:
67
106
  strategy:
68
107
  fail-fast: false
69
108
  matrix:
70
- os: [ ubuntu-20.04, macos-12 ]
109
+ os: [ ubuntu-20.04, macos-13, macos-14 ]
71
110
  steps:
72
111
  - name: Checkout
73
112
  uses: actions/checkout@v4
@@ -89,7 +128,7 @@ jobs:
89
128
  strategy:
90
129
  fail-fast: false
91
130
  matrix:
92
- os: [ ubuntu-20.04, macos-12 ]
131
+ os: [ ubuntu-20.04, macos-13 ]
93
132
  steps:
94
133
  - name: Checkout
95
134
  uses: actions/checkout@v4
@@ -106,7 +145,7 @@ jobs:
106
145
 
107
146
  test-cross-brew-install:
108
147
  name: test arm-brew-setup/install
109
- runs-on: macos-12
148
+ runs-on: macos-13
110
149
  steps:
111
150
  - name: Checkout
112
151
  uses: actions/checkout@v4
@@ -129,7 +168,7 @@ jobs:
129
168
  strategy:
130
169
  fail-fast: false
131
170
  matrix:
132
- os: [ macos-12, macos-13, macos-14 ]
171
+ os: [ macos-13, macos-14 ]
133
172
 
134
173
  steps:
135
174
  - name: Checkout
@@ -37,7 +37,7 @@ DIR1="$DIR0/arm-homebrew"
37
37
  for bottle in "${@:2}"
38
38
  do
39
39
  echo "Installing $bottle"
40
- response=$("$DIR1/bin/brew" fetch --force --bottle-tag=arm64_big_sur "$bottle" | grep "Downloaded to")
40
+ response=$("$DIR1/bin/brew" fetch --force --bottle-tag=arm64_ventura "$bottle" | grep "bottle.tar.gz")
41
41
  IFS=" " read -r -a parsed <<< "$response"
42
42
  "$DIR1/bin/brew" install "${parsed[2]}"
43
43
  done
@@ -43,7 +43,7 @@ do_patch_multiline() {
43
43
  "$gSed" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1"
44
44
  }
45
45
 
46
- if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "linux-musl"* || "$OSTYPE" == "msys" ]]; then
46
+ if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "linux-musl"* || "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
47
47
  gSed="sed"
48
48
  elif [[ "$OSTYPE" == "darwin"* ]]; then
49
49
  gSed="gsed"
@@ -52,7 +52,7 @@ else
52
52
  exit 1
53
53
  fi
54
54
 
55
- if [[ "$OSTYPE" == "msys" ]]; then
55
+ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
56
56
  re="ftruncate(file\.fd(), finalBufferSize),"
57
57
  sbst="folly::portability::unistd::ftruncate(file.fd(), finalBufferSize), \/* tebako patched *\/"
58
58
  do_patch "$1/thrift/lib/cpp2/frozen/FrozenUtil.h" "$re" "$sbst"
@@ -60,4 +60,19 @@ if [[ "$OSTYPE" == "msys" ]]; then
60
60
  re="if (detail::platform_is_windows()) {"
61
61
  sbst="if (false) { \/* tebako patched *\/"
62
62
  do_patch "$1/thrift/compiler/source_location.cc" "$re" "$sbst"
63
+
64
+ re="#include <fmt\/fmt-format\.h>"
65
+ # shellcheck disable=SC2251
66
+ ! IFS= read -r -d '' sbst << EOM
67
+ #include <fmt\/format.h>
68
+
69
+ \/* -- Start of tebako patch -- *\/
70
+ #include <fmt\/fmt-ranges.h>
71
+ \/* -- End of tebako patch -- *\/
72
+ EOM
73
+
74
+ do_patch_multiline "$1/thrift/compiler/lib/cpp2/util.h" "$re" "$sbst"
75
+ do_patch_multiline "$1/thrift/compiler/gen/cpp/namespace_resolver.cc" "$re" "$sbst"
76
+ do_patch_multiline "$1/thrift/compiler/ast/t_const_value.h" "$re" "$sbst"
77
+
63
78
  fi
@@ -70,6 +70,12 @@ defined_n_win32_to_msc_ver() {
70
70
  "$GNU_SED" -i "s/$re/$sbst/g" "$1"
71
71
  }
72
72
 
73
+ defined_el_win32_to_msc_ver() {
74
+ re="#elif _WIN32"
75
+ sbst="#elif _MSC_VER \/* tebako patched *\/ "
76
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
77
+ }
78
+
73
79
  defined_msc_ver_to_win32() {
74
80
  re="defined(_MSC_VER)"
75
81
  sbst="defined(_WIN32) \/* tebako patched *\/ "
@@ -195,7 +201,7 @@ EOM
195
201
  sbst="set(OPENSSL_INCLUDE_DIR \"\${OPENSSL_ROOT_DIR}\/include\") # tebako patched"
196
202
  "$GNU_SED" -i "s/$re/$sbst/g" "$1/CMakeLists.txt"
197
203
 
198
- elif [[ "$OSTYPE" == "msys"* ]]; then
204
+ elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
199
205
  # --- folly/portability/Stdlib.h ---
200
206
  re="#define PATH_MAX _MAX_PATH"
201
207
  sbst="\/* #define PATH_MAX _MAX_PATH --- tebako patched *\/"
@@ -514,4 +520,5 @@ EOM
514
520
  defined_win32_to_msc_ver "$1/folly/portability/SysTime.cpp"
515
521
  defined_win32_to_msc_ver "$1/folly/lang/Exception.cpp"
516
522
 
523
+ defined_el_win32_to_msc_ver "$1/folly/io/async/AsyncUDPSocket.cpp"
517
524
  fi
@@ -0,0 +1,61 @@
1
+ # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
2
+ # All rights reserved.
3
+ # This file is a part of tebako
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions
7
+ # are met:
8
+ # 1. Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
18
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ # POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ def_ext_prj_t(LIBFMT "10.2.1" "312151a2d13c8327f5c9c586ac6cf7cddc1658e8f53edae0ec56509c8fa516c9")
27
+
28
+ message(STATUS "Collecting libfmt - " v${LIBFMT_VER} " at " ${LIBFMT_SOURCE_DIR})
29
+
30
+ set(__LIBFMT "${DEPS}/lib/libfmt.a")
31
+
32
+ set(CMAKE_ARGUMENTS -DCMAKE_INSTALL_PREFIX=${DEPS}
33
+ -DFMT_DOC=OFF
34
+ -DFMT_TEST=OFF
35
+ -DFMT_FUZZ=OFF
36
+ -DFMT_CUDA_TEST=OFF
37
+ -DCMAKE_BUILD_TYPE=Release
38
+ -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
39
+ -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
40
+ )
41
+
42
+ if(TEBAKO_BUILD_TARGET)
43
+ list(APPEND CMAKE_ARGUMENTS -DCMAKE_C_FLAGS=--target=${TEBAKO_BUILD_TARGET})
44
+ list(APPEND CMAKE_ARGUMENTS -DCMAKE_EXE_LINKER_FLAGS=--target=${TEBAKO_BUILD_TARGET})
45
+ list(APPEND CMAKE_ARGUMENTS -DCMAKE_SHARED_LINKER_FLAGS=--target=${TEBAKO_BUILD_TARGET})
46
+ endif(TEBAKO_BUILD_TARGET)
47
+
48
+ ExternalProject_Add(${LIBFMT_PRJ}
49
+ PREFIX "${DEPS}"
50
+ URL https://github.com/fmtlib/fmt/releases/download/${LIBFMT_VER}/fmt-${LIBFMT_VER}.zip
51
+ URL_HASH SHA256=${LIBFMT_HASH}
52
+ DOWNLOAD_NO_PROGRESS true
53
+ CMAKE_ARGS ${CMAKE_ARGUMENTS}
54
+ SOURCE_DIR ${LIBFMT_SOURCE_DIR}
55
+ BINARY_DIR ${LIBFMT_BINARY_DIR}
56
+ BUILD_BYPRODUCTS ${__LIBFMT}
57
+ )
58
+
59
+ add_library(_LIBFMT STATIC IMPORTED)
60
+ set_target_properties(_LIBFMT PROPERTIES IMPORTED_LOCATION ${__LIBFMT})
61
+ add_dependencies(_LIBFMT ${LIBFMT_PRJ})
@@ -0,0 +1,35 @@
1
+ # Copyright (c) 2024, [Ribose Inc](https://www.ribose.com).
2
+ # All rights reserved.
3
+ # This file is a part of tebako
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions
7
+ # are met:
8
+ # 1. Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
18
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ # POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ cmake_minimum_required(VERSION 3.24.0)
27
+ project(setup-libfmt-test)
28
+
29
+ include(ExternalProject)
30
+
31
+ set(ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
32
+ set(DEPS ${CMAKE_CURRENT_BINARY_DIR}/deps)
33
+
34
+ include(${ROOT}/cmake-scripts/def-external-project.cmake)
35
+ include(${ROOT}/cmake-scripts/setup-libfmt.cmake)