tebako 0.13.4 → 0.15.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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Brewfile +0 -5
  3. data/CMakeLists.txt +94 -46
  4. data/README.adoc +0 -1
  5. data/cmake/tebako-libtfs.cmake +456 -0
  6. data/common.env +2 -2
  7. data/include/tebako/tpkg.h +575 -0
  8. data/lib/tebako/cli.rb +91 -0
  9. data/lib/tebako/cli_helpers.rb +24 -0
  10. data/lib/tebako/error.rb +10 -0
  11. data/lib/tebako/launcher_abi.rb +99 -0
  12. data/lib/tebako/options_manager.rb +71 -0
  13. data/lib/tebako/packager/pass2msys_patch.rb +5 -1
  14. data/lib/tebako/packager/patch_libraries.rb +47 -27
  15. data/lib/tebako/packager.rb +40 -1
  16. data/lib/tebako/runtime_manager.rb +347 -0
  17. data/lib/tebako/scenario_manager.rb +2 -0
  18. data/lib/tebako/stitcher.rb +255 -0
  19. data/lib/tebako/version.rb +1 -1
  20. data/src/tebako-main.cpp +577 -9
  21. data/tools/.github/workflows/build-containers.yml +1 -1
  22. data/tools/.github/workflows/lint.yml +1 -1
  23. data/tools/.github/workflows/test.yml +17 -35
  24. data/tools/ci-scripts/arm-brew-install.sh +1 -1
  25. data/tools/ci-scripts/arm-brew-setup.sh +1 -1
  26. data/tools/ci-scripts/level-up.sh +1 -1
  27. data/tools/ci-scripts/{patch-fbthrift.sh → patch-glog.sh} +4 -25
  28. data/tools/ci-scripts/patch-zstd.sh +57 -0
  29. data/tools/ci-scripts/tools.sh +1 -1
  30. data/tools/ci-scripts/x86-brew-install.sh +1 -1
  31. data/tools/ci-scripts/x86-brew-setup.sh +1 -1
  32. data/tools/cmake-scripts/def-external-project.cmake +1 -1
  33. data/tools/cmake-scripts/macos-environment.cmake +12 -3
  34. data/tools/cmake-scripts/msys-environment.cmake +1 -1
  35. data/tools/cmake-scripts/setup-libarchive.cmake +3 -7
  36. data/tools/cmake-scripts/setup-libfmt.cmake +1 -1
  37. data/tools/cmake-scripts/setup-libhowardhinnerdate.cmake +1 -1
  38. data/tools/cmake-scripts/version.cmake +1 -1
  39. data/tools/dwarfs-test-helper/CMakeLists.txt +1 -1
  40. data/tools/include/pro-statvfs.h +1 -1
  41. data/tools/tests/cmake/CMakeLists.txt +1 -1
  42. data/tools/tests/setup-libfmt/CMakeLists.txt +1 -1
  43. data/tools/tests/setup-libhowardhinnerdate/CMakeLists.txt +1 -1
  44. data/tools/tests/setup-librachive/CMakeLists.txt +1 -1
  45. data/tools/tests/setup-libutfcpp/CMakeLists.txt +1 -1
  46. data/tools/tests/setup-openssl/CMakeLists.txt +1 -1
  47. metadata +9 -5
  48. data/tools/ci-scripts/patch-folly.sh +0 -526
  49. data/tools/cmake-scripts/setup-openssl-1.1.1.cmake +0 -95
@@ -1,526 +0,0 @@
1
- #! /bin/bash
2
- # Copyright (c) 2022-2025, [Ribose Inc](https://www.ribose.com).
3
- # All rights reserved.
4
- # This file is a part of the Tebako project.
5
- #
6
- # Redistribution and use in source and binary forms, with or without
7
- # modification, are permitted provided that the following conditions
8
- # are met:
9
- # 1. Redistributions of source code must retain the above copyright
10
- # notice, this list of conditions and the following disclaimer.
11
- # 2. Redistributions in binary form must reproduce the above copyright
12
- # notice, this list of conditions and the following disclaimer in the
13
- # documentation and/or other materials provided with the distribution.
14
- #
15
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
- # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
- # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
- # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
19
- # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
- # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
- # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
- # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
- # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
- # POSSIBILITY OF SUCH DAMAGE.
26
-
27
- set -o errexit -o pipefail -o noclobber -o nounset
28
-
29
- if [[ "$OSTYPE" == "darwin"* ]]; then
30
- GNU_SED="gsed"
31
- else
32
- GNU_SED="sed"
33
- fi
34
-
35
- # ....................................................
36
- restore_and_save() {
37
- echo "Patching $1"
38
- test -e "$1.old" && cp -f "$1.old" "$1"
39
- cp -f "$1" "$1.old"
40
- }
41
-
42
- do_patch() {
43
- restore_and_save "$1"
44
- # echo "$GNU_SED" -i "s/$2/$3/g" "$1"
45
- "$GNU_SED" -i "s/$2/$3/g" "$1"
46
- }
47
-
48
- do_patch_multiline() {
49
- restore_and_save "$1"
50
- "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1"
51
- }
52
-
53
- defined_win32_to_msc_ver() {
54
- re="defined(_WIN32)"
55
- sbst="defined(_MSC_VER) \/* tebako patched *\/ "
56
- do_patch "$1" "$re" "$sbst"
57
-
58
- re="#ifdef _WIN32"
59
- sbst="#ifdef _MSC_VER \/* tebako patched *\/ "
60
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
61
- }
62
-
63
- defined_n_win32_to_msc_ver() {
64
- re="!defined(_WIN32)"
65
- sbst="!defined(_MSC_VER) \/* tebako patched *\/ "
66
- do_patch "$1" "$re" "$sbst"
67
-
68
- re="#ifndef _WIN32"
69
- sbst="#ifndef _MSC_VER \/* tebako patched *\/ "
70
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
71
- }
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
-
79
- defined_msc_ver_to_win32() {
80
- re="defined(_MSC_VER)"
81
- sbst="defined(_WIN32) \/* tebako patched *\/ "
82
- do_patch "$1" "$re" "$sbst"
83
-
84
- re="#ifdef _MSC_VER"
85
- sbst="#ifdef _WIN32 \/* tebako patched *\/ "
86
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
87
- }
88
-
89
- funky_stdio_patch() {
90
- re="int pclose(FILE\* f)"
91
- sbst="int _folly_pclose(FILE* f) \/* tebako patched *\/"
92
- do_patch "$1" "$re" "$sbst"
93
-
94
- re="FILE\* popen(const char\* name, const char\* mode)"
95
- sbst="FILE* _folly_popen(const char* name, const char* mode) \/* tebako patched *\/"
96
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
97
-
98
- re="int vasprintf(char\*\* dest, const char\* format, va_list ap)"
99
- sbst="int _folly_vasprintf(char** dest, const char* format, va_list ap) \/* tebako patched *\/"
100
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
101
- }
102
-
103
- funky_sysstat_patch() {
104
- re="int chmod(char const\* fn, int am)"
105
- sbst="int _folly_chmod(char const* fn, int am) \/* tebako patched *\/"
106
- do_patch "$1" "$re" "$sbst"
107
-
108
- re="int mkdir(const char\* fn, int mode)"
109
- sbst="int _folly_mkdir(const char* fn, int mode) \/* tebako patched *\/"
110
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
111
-
112
- re="int mkdir(const char\* fn, int \/\* mode \*\/)"
113
- sbst="int _folly_mkdir(const char* fn, int \/* mode *\/) \/* tebako patched *\/"
114
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
115
-
116
- re="int umask(int md)"
117
- sbst="int _folly_umask(int md) \/* tebako patched *\/"
118
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
119
- }
120
-
121
- funky_string_patch() {
122
- re="int strcasecmp(const char\* a, const char\* b)"
123
- sbst="int _folly_strcasecmp(const char* a, const char* b) \/* tebako patched *\/"
124
- do_patch "$1" "$re" "$sbst"
125
-
126
- re="int strncasecmp(const char\* a, const char\* b, size_t c)"
127
- sbst="int _folly_strncasecmp(const char* a, const char* b, size_t c) \/* tebako patched *\/"
128
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
129
- }
130
-
131
- funky_time_patch() {
132
- re="char\* asctime_r(const tm\* tm, char\* buf)"
133
- sbst="char* _folly_asctime_r(const tm* tm, char* buf) \/* tebako patched *\/"
134
- do_patch "$1" "$re" "$sbst"
135
-
136
- re="tm\* gmtime_r(const time_t\* t, tm\* res)"
137
- sbst="tm* _folly_gmtime_r(const time_t* t, tm* res) \/* tebako patched *\/"
138
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
139
-
140
- re="tm\* localtime_r(const time_t\* t, tm\* o)"
141
- sbst="tm* _folly_localtime_r(const time_t* t, tm* o) \/* tebako patched *\/"
142
- "$GNU_SED" -i "s/$re/$sbst/g" "$1"
143
- }
144
-
145
- funky_formatter_patch() {
146
- re="if (!localtime_r(&unixTimestamp, &ltime)) {"
147
- sbst="if (!_folly_localtime_r(\&unixTimestamp, \&ltime)) { \/* tebako patched *\/"
148
- do_patch "$1" "$re" "$sbst"
149
- }
150
-
151
- if [[ "$OSTYPE" == "linux-musl"* ]]; then
152
- # https://github.com/facebook/folly/issues/1478
153
- re="#elif defined(__FreeBSD__)"
154
- sbst="#elif defined(__FreeBSD__) || defined(__musl__) \/* Tebako patched *\/"
155
- do_patch "$1/folly/debugging/symbolizer/Elf.cpp" "$re" "$sbst"
156
-
157
- restore_and_save "$1/CMake/FollyConfigChecks.cmake"
158
- re="FOLLY_HAVE_IFUNC"
159
- sbst="FOLLY_HAVE_IFUNC_NOT_PATCHED"
160
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/CMake/FollyConfigChecks.cmake"
161
-
162
- re="set(CMAKE_REQUIRED_FLAGS \"\${FOLLY_ORIGINAL_CMAKE_REQUIRED_FLAGS}\")"
163
-
164
- # shellcheck disable=SC2251
165
- ! IFS= read -r -d '' sbst << EOM
166
- set(CMAKE_REQUIRED_FLAGS \"\${FOLLY_ORIGINAL_CMAKE_REQUIRED_FLAGS}\")
167
-
168
- # -- Start of tebako patch --
169
- check_cxx_source_runs(\"
170
- #pragma GCC diagnostic error \\\"-Wattributes\\\"
171
- extern \\\"C\\\" int resolved_ifunc(void) { return 0; }
172
- extern \\\"C\\\" int (*test_ifunc(void))() { return resolved_ifunc; }
173
- int func() __attribute__((ifunc(\\\"test_ifunc\\\")));
174
- int main() { return func(); }\"
175
- FOLLY_HAVE_IFUNC
176
- )
177
- # -- End of tebako patch --
178
- EOM
179
-
180
- "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMake/FollyConfigChecks.cmake"
181
-
182
- elif [[ "$OSTYPE" == "darwin"* ]]; then
183
- re=" set(OPENSSL_ROOT_DIR \"\/usr\/local\/opt\/openssl\" )"
184
-
185
- # shellcheck disable=SC2251
186
- ! IFS= read -r -d '' sbst << EOM
187
- # -- Start of tebako patch --
188
- if (NOT OPENSSL_ROOT_DIR)
189
- set(OPENSSL_ROOT_DIR \"\/usr\/local\/opt\/openssl\")
190
- endif(NOT OPENSSL_ROOT_DIR)
191
- # -- End of tebako patch --
192
- EOM
193
-
194
- do_patch_multiline "$1/CMakeLists.txt" "$re" "$sbst"
195
-
196
- re="set(OPENSSL_LIBRARIES \"\/usr\/local\/opt\/openssl\/lib\" )"
197
- sbst="set(OPENSSL_LIBRARIES \"\${OPENSSL_ROOT_DIR}\/lib\") # tebako patched"
198
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/CMakeLists.txt"
199
-
200
- re="set(OPENSSL_INCLUDE_DIR \"\/usr\/local\/opt\/openssl\/include\" )"
201
- sbst="set(OPENSSL_INCLUDE_DIR \"\${OPENSSL_ROOT_DIR}\/include\") # tebako patched"
202
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/CMakeLists.txt"
203
-
204
- elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
205
- # --- folly/portability/Stdlib.h ---
206
- re="#define PATH_MAX _MAX_PATH"
207
- sbst="\/* #define PATH_MAX _MAX_PATH --- tebako patched *\/"
208
- do_patch "$1/folly/portability/Stdlib.h" "$re" "$sbst"
209
-
210
- # --- folly/portability/Stdlib.cpp ---
211
- re="ret = mkdir(ptr, 0700);"
212
- sbst="ret = _folly_mkdir(ptr, 0700); \/* tebako patched *\/"
213
- do_patch "$1/folly/portability/Stdlib.cpp" "$re" "$sbst"
214
-
215
- # --- folly/portability/SysTypes.h ---
216
- re="using pid_t = int;"
217
- sbst="\/* using pid_t = int; --- tebako patched *\/"
218
- do_patch "$1/folly/portability/SysTypes.h" "$re" "$sbst"
219
-
220
- re="using mode_t = unsigned int;"
221
- sbst="\/* using mode_t = unsigned int; --- tebako patched *\/"
222
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
223
-
224
- re="using uid_t = int;"
225
- sbst="using uid_t = short; \/* --- tebako patched *\/"
226
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
227
-
228
- re="using gid_t = int;"
229
- # shellcheck disable=SC2251
230
- ! IFS= read -r -d '' sbst << EOM
231
- using gid_t = short; \/* --- tebako patched *\/
232
- using nlink_t = short; \/* --- tebako patched *\/
233
- EOM
234
- "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysTypes.h"
235
-
236
- # --- folly/portability/SysStat.cpp ---
237
- funky_sysstat_patch "$1/folly/portability/SysStat.cpp"
238
-
239
- # --- folly/portability/SysStat.h ---
240
- funky_sysstat_patch "$1/folly/portability/SysStat.h"
241
-
242
- re="#define S_IXUSR 0"
243
- # shellcheck disable=SC2251
244
- ! IFS= read -r -d '' sbst << EOM
245
- \/* -- Start of tebako patch --
246
- #define S_IXUSR 0
247
- EOM
248
- "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
249
-
250
- re="#define S_ISREG(mode) (((mode) & (_S_IFREG)) == (_S_IFREG) ? 1 : 0)"
251
- # shellcheck disable=SC2251
252
- ! IFS= read -r -d '' sbst << EOM
253
- #define S_ISREG(mode) (((mode) \& (_S_IFREG)) == (_S_IFREG) ? 1 : 0)
254
- *\/
255
- #define _S_IFLNK 0xA000
256
- #define S_IFLNK _S_IFLNK
257
- #define S_ISLNK(mode) (((mode) \& (_S_IFLNK)) == (_S_IFLNK) ? 1 : 0)
258
-
259
- \/* -- End of tebako patch -- *\/
260
- EOM
261
- "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
262
-
263
- # --- folly/portability/SysTime.h ---
264
- re="int gettimeofday(timeval\* tv, folly_port_struct_timezone\*);"
265
- sbst="\/* int gettimeofday(timeval* tv, folly_port_struct_timezone*); --- tebako patched *\/"
266
- do_patch "$1/folly/portability/SysTime.h" "$re" "$sbst"
267
-
268
- # --- folly/FileUtil.cpp ---
269
- defined_msc_ver_to_win32 "$1/folly/FileUtil.cpp"
270
- re="(open,"
271
- sbst="(\/* tebako patched *\/ folly::portability::fcntl::open,"
272
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
273
-
274
- re="close(tmpFD)"
275
- sbst="\/* tebako patched *\/ folly::portability::unistd::close(tmpFD)"
276
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
277
-
278
- re="(close(fd))"
279
- sbst="(\/* tebako patched *\/ folly::portability::unistd::close(fd))"
280
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
281
-
282
- re="(read,"
283
- sbst="(\/* tebako patched *\/ folly::portability::unistd::read,"
284
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
285
-
286
- re="(write,"
287
- sbst="(\/* tebako patched *\/ folly::portability::unistd::write,"
288
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
289
-
290
- re="(dup,"
291
- sbst="(\/* tebako patched *\/ folly::portability::unistd::dup,"
292
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
293
-
294
- re="(dup2,"
295
- sbst="(\/* tebako patched *\/ folly::portability::unistd::dup2,"
296
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
297
-
298
- # --- folly/testing/TestUtil.cpp ---
299
- defined_win32_to_msc_ver "$1/folly/testing/TestUtil.cpp"
300
- re="dup("
301
- sbst="\/* tebako patched *\/ folly::portability::unistd::dup("
302
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
303
-
304
- re="dup2("
305
- sbst="\/* tebako patched *\/ folly::portability::unistd::dup2("
306
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
307
-
308
- re="lseek("
309
- sbst="\/* tebako patched *\/ folly::portability::unistd::lseek("
310
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
311
-
312
- re="(close("
313
- sbst="(\/* tebako patched *\/ folly::portability::unistd::close("
314
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
315
-
316
- # --- folly/system/MemoryMapping.cpp ---
317
- re="0 == ftruncate("
318
- sbst="0 == \/* tebako patched *\/ folly::portability::unistd::ftruncate("
319
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/system/MemoryMapping.cpp"
320
-
321
- # --- folly/portability/SysUio.cpp ---
322
- re="lseek(fd,"
323
- sbst=" \/* tebako patched *\/ folly::portability::unistd::lseek(fd,"
324
- do_patch "$1/folly/portability/SysUio.cpp" "$re" "$sbst"
325
-
326
- # --- folly/logging/ImmediateFileWriter.h ---
327
- re="isatty(file"
328
- sbst=" \/* tebako patched *\/ folly::portability::unistd::isatty(file"
329
- do_patch "$1/folly/logging/ImmediateFileWriter.h" "$re" "$sbst"
330
-
331
- # --- folly/logging/AsyncFileWriter.cpp ---
332
- re="isatty(file"
333
- sbst=" \/* tebako patched *\/ folly::portability::unistd::isatty(file"
334
- do_patch "$1/folly/logging/AsyncFileWriter.cpp" "$re" "$sbst"
335
-
336
- # --- folly/portability/Unistd.h ---
337
- re="#define X_OK F_OK"
338
- sbst="#define X_OK 1 \/* tebako patched *\/"
339
- do_patch "$1/folly/portability/Unistd.h" "$re" "$sbst"
340
-
341
- re="int getuid();"
342
- sbst="uid_t getuid(); \/* tebako patched *\/"
343
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
344
-
345
- re="int getgid();"
346
- sbst="gid_t getgid(); \/* tebako patched *\/"
347
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
348
-
349
- # --- folly/portability/Fcntl.cpp ---
350
- re="#include <folly\/portability\/Windows\.h>"
351
-
352
- # shellcheck disable=SC2251
353
- ! IFS= read -r -d '' sbst << EOM
354
- #include <folly\/portability\/Windows.h>
355
- \/* -- Start of tebako patch -- *\/
356
- #include <share.h>
357
- \/* -- End of tebako patch -- *\/
358
- EOM
359
- do_patch_multiline "$1/folly/portability/Fcntl.cpp" "$re" "$sbst"
360
-
361
- # --- folly/net/detail/SocketFileDescriptorMap.cpp --
362
- re="#include <fcntl\.h>"
363
-
364
- # shellcheck disable=SC2251
365
- ! IFS= read -r -d '' sbst << EOM
366
- #include <fcntl.h>
367
-
368
- \/* -- Start of tebako patch -- *\/
369
- #include <mutex>
370
- \/* -- End of tebako patch -- *\/
371
-
372
- EOM
373
- do_patch_multiline "$1/folly/net/detail/SocketFileDescriptorMap.cpp" "$re" "$sbst"
374
-
375
- re=" __try {"
376
- # shellcheck disable=SC2251
377
- ! IFS= read -r -d '' sbst << EOM
378
- #ifndef __MINGW32__ \/* -- Tebako patched -- *\/
379
- __try {
380
- EOM
381
- "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
382
-
383
- re="\/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because"
384
- # shellcheck disable=SC2251
385
- ! IFS= read -r -d '' sbst << EOM
386
- #endif \/* -- Tebako patched -- *\/
387
- \/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because
388
- EOM
389
- "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
390
-
391
- # --- folly/portability/Sockets.h ---
392
- restore_and_save "$1/folly/portability/Sockets.h"
393
- re="#ifdef _WIN32"
394
-
395
- # shellcheck disable=SC2251
396
- ! IFS= read -r -d '' sbst << EOM
397
- #ifdef _WIN32
398
-
399
- \/* -- Start of tebako patch -- *\/
400
- #ifdef __MINGW32__
401
- #include <mswsock.h>
402
- using cmsghdr = WSACMSGHDR;
403
- #define CMSG_SPACE WSA_CMSG_SPACE
404
- #endif
405
- \/* -- End of tebako patch -- *\/
406
-
407
- EOM
408
- "$GNU_SED" -i -i "0,/$re/s||${sbst//$'\n'/"\\n"}|g" "$1/folly/portability/Sockets.h"
409
-
410
- # --- folly/portability/Time.cpp ---
411
- funky_time_patch "$1/folly/portability/Time.cpp"
412
-
413
- re="(asctime_s(tmpBuf, tm))"
414
- sbst="(asctime_s(tmpBuf, 64\/* tebako patched *\/, tm))"
415
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Time.cpp"
416
-
417
- # ---
418
- re="#if (defined(USE_JEMALLOC) || FOLLY_USE_JEMALLOC) && !FOLLY_SANITIZE"
419
- # shellcheck disable=SC2251
420
- ! IFS= read -r -d '' sbst << EOM
421
- \/* -- Start of tebako patch -- *\/
422
- #if defined(FOLLY_ASSUME_NO_JEMALLOC)
423
- #undef USE_JEMALLOC
424
- #undef FOLLY_USE_JEMALLOC
425
- #endif
426
- \/* -- End of tebako patch -- *\/
427
- #if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) \&\& !FOLLY_SANITIZE \/* tebako patched *\/
428
- EOM
429
- do_patch_multiline "$1/folly/portability/Malloc.h" "$re" "$sbst"
430
-
431
- # ---
432
- re="#include <folly\/Portability\.h>"
433
- # shellcheck disable=SC2251
434
- ! IFS= read -r -d '' sbst << EOM
435
- #include <folly\/Portability.h>
436
- \/* -- Start of tebako patch -- *\/
437
- #include <folly\/portability\/Malloc.h>
438
- \/* -- End of tebako patch -- *\/
439
-
440
- EOM
441
- do_patch_multiline "$1/folly/memory/detail/MallocImpl.h" "$re" "$sbst"
442
-
443
- # --- folly/system/ThreadName.cpp ---
444
- defined_win32_to_msc_ver "$1/folly/system/ThreadName.cpp"
445
-
446
- re="#if defined(__XROS__)"
447
- sbst="#if defined(__XROS__) || defined(__MINGW32__) \/* tebako patched *\/"
448
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/system/ThreadName.cpp"
449
-
450
- # --- folly/net/NetOps.h ---
451
-
452
- re="#include <WS2tcpip\.h> \/\/ @manual"
453
- # shellcheck disable=SC2251
454
- ! IFS= read -r -d '' sbst << EOM
455
- #include <WS2tcpip.h> \/\/ @manual
456
-
457
- \/* -- Start of tebako patch -- *\/
458
- #ifdef __MINGW32__
459
- #include <memory>
460
- #include <mswsock.h>
461
- #endif
462
- \/* -- End of tebako patch -- *\/
463
- EOM
464
- do_patch_multiline "$1/folly/net/NetOps.h" "$re" "$sbst"
465
-
466
- # --- folly/Random.cpp ---
467
-
468
- re="#include <folly\/synchronization\/RelaxedAtomic\.h>"
469
- # shellcheck disable=SC2251
470
- ! IFS= read -r -d '' sbst << EOM
471
- #include <folly\/synchronization\/RelaxedAtomic.h>
472
-
473
- \/* -- Start of tebako patch -- *\/
474
- #include <folly\/portability\/Fcntl.h>
475
- \/* -- End of tebako patch -- *\/
476
- EOM
477
- do_patch_multiline "$1/folly/Random.cpp" "$re" "$sbst"
478
-
479
- # --- folly/Utility.h ---
480
- re="T uninit;"
481
- sbst="T uninit = 0; \/* tebako patched *\/"
482
- do_patch "$1/folly/Utility.h" "$re" "$sbst"
483
-
484
- # --- folly/portability/Unistd.cpp ---
485
- re="res = lseek64(fd, offset, whence);"
486
- sbst="res = folly::portability::unistd::lseek64(fd, offset, whence); \/* tebako patched *\/ "
487
- do_patch "$1/folly/portability/Unistd.cpp" "$re" "$sbst"
488
-
489
- re="res = lseek(fd, offset, whence);"
490
- sbst="res = folly::portability::unistd::lseek(fd, offset, whence); \/* tebako patched *\/ "
491
- "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.cpp"
492
-
493
- # --- folly/io/async/AsyncUDPSocket.cpp
494
- re="#elif _WIN32"
495
- sbst="#elif _MSC_VER \/* tebako patched *\/ "
496
- do_patch "$1/folly/io/async/AsyncUDPSocket.cpp" "$re" "$sbst"
497
-
498
- # ---
499
- defined_msc_ver_to_win32 "$1/folly/external/farmhash/farmhash.cpp"
500
- defined_msc_ver_to_win32 "$1/folly/detail/IPAddressSource.h"
501
- defined_msc_ver_to_win32 "$1/folly/portability/Sockets.cpp"
502
- defined_win32_to_msc_ver "$1/folly/portability/Sched.h"
503
- defined_win32_to_msc_ver "$1/folly/portability/Sched.cpp"
504
-
505
- defined_n_win32_to_msc_ver "$1/folly/portability/Dirent.h"
506
- defined_win32_to_msc_ver "$1/folly/portability/Dirent.cpp"
507
-
508
- funky_stdio_patch "$1/folly/portability/Stdio.h"
509
- funky_stdio_patch "$1/folly/portability/Stdio.cpp"
510
- funky_string_patch "$1/folly/portability/String.h"
511
- funky_string_patch "$1/folly/portability/String.cpp"
512
- funky_time_patch "$1/folly/portability/Time.h"
513
- funky_formatter_patch "$1/folly/logging/CustomLogFormatter.cpp"
514
- funky_formatter_patch "$1/folly/logging/GlogStyleFormatter.cpp"
515
-
516
- # Note: the patch below comments out
517
- # int gettimeofday(timeval* tv, folly_port_struct_timezone*);
518
- # void timeradd(timeval* a, timeval* b, timeval* res);
519
- # void timersub(timeval* a, timeval* b, timeval* res);
520
- # while gettimeofday is provided by MSys, the other two functions are lost
521
- defined_n_win32_to_msc_ver "$1/folly/portability/SysTime.h"
522
- defined_win32_to_msc_ver "$1/folly/portability/SysTime.cpp"
523
- defined_win32_to_msc_ver "$1/folly/lang/Exception.cpp"
524
-
525
- defined_el_win32_to_msc_ver "$1/folly/io/async/AsyncUDPSocket.cpp"
526
- fi
@@ -1,95 +0,0 @@
1
- # Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
2
- # All rights reserved.
3
- # This file is a part of the Tebako project.
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
- set(WITH_OPENSSL_BUILD ON)
27
-
28
- execute_process(
29
- COMMAND "${DEPS}/bin/openssl" "version"
30
- RESULT_VARIABLE OPENSSL_RES
31
- OUTPUT_VARIABLE OPENSSL_VER_STR
32
- OUTPUT_STRIP_TRAILING_WHITESPACE
33
- )
34
-
35
- if(OPENSSL_RES EQUAL 0)
36
- string(REGEX MATCH "^OpenSSL ([1-9][.][0-9][.][0-9])" OPENSSL_VER_TMP ${OPENSSL_VER_STR})
37
- set(OPENSSL_VER ${CMAKE_MATCH_1})
38
- message(STATUS "Found OpenSSL version ${OPENSSL_VER} at ${DEPS}/bin/openssl")
39
- if((${OPENSSL_VER} VERSION_GREATER_EQUAL "1.1.0") AND (${OPENSSL_VER} VERSION_LESS "3.0.0"))
40
- set(WITH_OPENSSL_BUILD OFF)
41
- set(OPENSSL_ROOT_DIR "${DEPS}")
42
- endif((${OPENSSL_VER} VERSION_GREATER_EQUAL "1.1.0") AND (${OPENSSL_VER} VERSION_LESS "3.0.0"))
43
- endif(OPENSSL_RES EQUAL 0)
44
-
45
- if(WITH_OPENSSL_BUILD)
46
- execute_process(
47
- COMMAND "openssl" "version"
48
- RESULT_VARIABLE OPENSSL_RES
49
- OUTPUT_VARIABLE OPENSSL_VER_STR
50
- OUTPUT_STRIP_TRAILING_WHITESPACE
51
- )
52
- if(OPENSSL_RES EQUAL 0)
53
- execute_process(
54
- COMMAND "which" "openssl"
55
- RESULT_VARIABLE OPENSSL_RES
56
- OUTPUT_VARIABLE OPENSSL_LOC
57
- OUTPUT_STRIP_TRAILING_WHITESPACE
58
- )
59
- if(NOT OPENSSL_RES EQUAL 0)
60
- set(OPENSSL_LOC "<unknown>")
61
- endif(NOT OPENSSL_RES EQUAL 0)
62
-
63
- string(REGEX MATCH "^OpenSSL ([1-9][.][0-9][.][0-9])" OPENSSL_VER_TMP ${OPENSSL_VER_STR})
64
- set(OPENSSL_VER ${CMAKE_MATCH_1})
65
- message(STATUS "Found OpenSSL version ${OPENSSL_VER} at ${OPENSSL_LOC}")
66
- if((${OPENSSL_VER} VERSION_GREATER_EQUAL "1.1.0") AND (${OPENSSL_VER} VERSION_LESS "3.0.0"))
67
- set(WITH_OPENSSL_BUILD OFF)
68
- endif((${OPENSSL_VER} VERSION_GREATER_EQUAL "1.1.0") AND (${OPENSSL_VER} VERSION_LESS "3.0.0"))
69
- endif(OPENSSL_RES EQUAL 0)
70
- endif(WITH_OPENSSL_BUILD)
71
-
72
- if(WITH_OPENSSL_BUILD)
73
- message(STATUS "Building OpenSSL 1.1.1w")
74
- def_ext_prj_g(OPENSSL "OpenSSL_1_1_1w")
75
-
76
- set(__LIBSSL "${DEPS}/lib/libssl.a")
77
- set(__LIBCRYPTO "${DEPS}/lib/libcrypto.a")
78
-
79
- ExternalProject_Add(${OPENSSL_PRJ}
80
- PREFIX ${DEPS}
81
- GIT_REPOSITORY "https://github.com/openssl/openssl.git"
82
- GIT_TAG ${OPENSSL_TAG}
83
- UPDATE_COMMAND ""
84
- SOURCE_DIR ${OPENSSL_SOURCE_DIR}
85
- BINARY_DIR ${OPENSSL_BINARY_DIR}
86
- CONFIGURE_COMMAND ${GNU_BASH} -c "${OPENSSL_SOURCE_DIR}/config \
87
- --openssldir=${DEPS} \
88
- --prefix=${DEPS} \
89
- no-shared"
90
- BUILD_BYPRODUCTS ${__LIBSSL} ${__LIBCRYPTO}
91
- )
92
-
93
- set(OPENSSL_ROOT_DIR "${DEPS}")
94
-
95
- endif(WITH_OPENSSL_BUILD)