tebako 0.5.5 → 0.5.7

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.
data/tools/README.md CHANGED
@@ -1,5 +1,49 @@
1
1
  [![lint](https://github.com/tamatebako/macos-cross-compile/actions/workflows/lint.yml/badge.svg)](https://github.com/tamatebako/macos-cross-compile/actions/workflows/lint.yml)
2
+ [![test](https://github.com/tamatebako/tebako-tools/actions/workflows/test.yml/badge.svg)](https://github.com/tamatebako/tebako-tools/actions/workflows/test.yml)
2
3
 
3
4
  ## Tebako portability tools ##
4
5
 
5
6
  This repository contains cmake, shell scripts and include files aimed to support tebako builds on different platforms.
7
+
8
+ ## Homebrew cross-installation scripts ##
9
+
10
+ Sometimes you need to build MacOS application in a foreign environment. For example, GitHub Actions provides x86 runners only, but you may need to build and package arm64 binary.
11
+ Most of the applications rely on external dependencies, so on MacOS you will require a method to use another instance of homebrew to support the target environment.
12
+
13
+ Among other tools this repository provides a set of simple scripts to cross install homebrew dependencies
14
+
15
+ ### arm64 packages on x86_64 system
16
+
17
+ ```
18
+ arm-brew-install <arm brew parent folder>
19
+ arm-brew-setup <arm brew folder> <formula to install 1> ... <formula to install 1>
20
+ ```
21
+
22
+ For example
23
+
24
+ ```
25
+ arm-brew-install ~/test
26
+ arm-brew-setup ~/test glog gflags
27
+ ```
28
+
29
+ Will create arm brew environment in ~/test/arm-homebrew and install glog and gflags formulae there
30
+
31
+
32
+ ### x86_64 packages on arm system
33
+
34
+ ```
35
+ x86_64-brew-install <x86_64 brew parent folder>
36
+ x86_64-brew-setup <x86_64 brew folder> <formula to install 1> ... <formula to install 1>
37
+ ```
38
+
39
+ For example
40
+
41
+ ```
42
+ x86_64-brew-install ~/test
43
+ x86_64-brew-setup ~/test glog gflags
44
+ ```
45
+
46
+ Will create x86_64 brew environment in ~/test/x86_64-homebrew and install glog and gflags formulae there
47
+
48
+ There are related discussions at https://github.com/orgs/Homebrew/discussions/2843
49
+ and https://stackoverflow.com/questions/70821136/can-i-install-arm64-libraries-on-x86-64-with-homebrew/70822921#70822921
@@ -35,7 +35,12 @@ restore_and_save() {
35
35
 
36
36
  do_patch() {
37
37
  restore_and_save "$1"
38
- sed -i "s/$2/$3/g" "$1"
38
+ "$gSed" -i "s/$2/$3/g" "$1"
39
+ }
40
+
41
+ do_patch_multiline() {
42
+ restore_and_save "$1"
43
+ "$gSed" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1"
39
44
  }
40
45
 
41
46
  # ....................................................
@@ -80,6 +85,21 @@ restore_and_save "$1/CMakeLists.txt"
80
85
  re="find_package(OpenSSL REQUIRED)"
81
86
  "$gSed" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMakeLists.txt"
82
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
+
83
103
  if [[ "$OSTYPE" == "msys" ]]; then
84
104
  re="if(WIN32)"
85
105
  sbst="if(MSVC) # tebako patched"
@@ -1,5 +1,5 @@
1
1
  #! /bin/bash
2
- # Copyright (c) 2022, [Ribose Inc](https://www.ribose.com).
2
+ # Copyright (c) 2022-2023, [Ribose Inc](https://www.ribose.com).
3
3
  # All rights reserved.
4
4
  # This file is a part of tebako
5
5
  #
@@ -26,6 +26,12 @@
26
26
 
27
27
  set -o errexit -o pipefail -o noclobber -o nounset
28
28
 
29
+ if [[ "$OSTYPE" == "darwin"* ]]; then
30
+ GNU_SED="gsed"
31
+ else
32
+ GNU_SED="sed"
33
+ fi
34
+
29
35
  # ....................................................
30
36
  restore_and_save() {
31
37
  echo "Patching $1"
@@ -35,12 +41,12 @@ restore_and_save() {
35
41
 
36
42
  do_patch() {
37
43
  restore_and_save "$1"
38
- sed -i "s/$2/$3/g" "$1"
44
+ "$GNU_SED" -i "s/$2/$3/g" "$1"
39
45
  }
40
46
 
41
47
  do_patch_multiline() {
42
48
  restore_and_save "$1"
43
- sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1"
49
+ "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1"
44
50
  }
45
51
 
46
52
  defined_win32_to_msc_ver() {
@@ -50,7 +56,7 @@ defined_win32_to_msc_ver() {
50
56
 
51
57
  re="#ifdef _WIN32"
52
58
  sbst="#ifdef _MSC_VER \/* tebako patched *\/ "
53
- sed -i "s/$re/$sbst/g" "$1"
59
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
54
60
  }
55
61
 
56
62
  defined_n_win32_to_msc_ver() {
@@ -60,7 +66,7 @@ defined_n_win32_to_msc_ver() {
60
66
 
61
67
  re="#ifndef _WIN32"
62
68
  sbst="#ifndef _MSC_VER \/* tebako patched *\/ "
63
- sed -i "s/$re/$sbst/g" "$1"
69
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
64
70
  }
65
71
 
66
72
  defined_msc_ver_to_win32() {
@@ -70,7 +76,7 @@ defined_msc_ver_to_win32() {
70
76
 
71
77
  re="#ifdef _MSC_VER"
72
78
  sbst="#ifdef _WIN32 \/* tebako patched *\/ "
73
- sed -i "s/$re/$sbst/g" "$1"
79
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
74
80
  }
75
81
 
76
82
  funky_stdio_patch() {
@@ -80,11 +86,11 @@ funky_stdio_patch() {
80
86
 
81
87
  re="FILE\* popen(const char\* name, const char\* mode)"
82
88
  sbst="FILE* _folly_popen(const char* name, const char* mode) \/* tebako patched *\/"
83
- sed -i "s/$re/$sbst/g" "$1"
89
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
84
90
 
85
91
  re="int vasprintf(char\*\* dest, const char\* format, va_list ap)"
86
92
  sbst="int _folly_vasprintf(char** dest, const char* format, va_list ap) \/* tebako patched *\/"
87
- sed -i "s/$re/$sbst/g" "$1"
93
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
88
94
  }
89
95
 
90
96
  funky_sysstat_patch() {
@@ -94,15 +100,15 @@ funky_sysstat_patch() {
94
100
 
95
101
  re="int mkdir(const char\* fn, int mode)"
96
102
  sbst="int _folly_mkdir(const char* fn, int mode) \/* tebako patched *\/"
97
- sed -i "s/$re/$sbst/g" "$1"
103
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
98
104
 
99
105
  re="int mkdir(const char\* fn, int \/\* mode \*\/)"
100
106
  sbst="int _folly_mkdir(const char* fn, int \/* mode *\/) \/* tebako patched *\/"
101
- sed -i "s/$re/$sbst/g" "$1"
107
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
102
108
 
103
109
  re="int umask(int md)"
104
110
  sbst="int _folly_umask(int md) \/* tebako patched *\/"
105
- sed -i "s/$re/$sbst/g" "$1"
111
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
106
112
  }
107
113
 
108
114
  funky_string_patch() {
@@ -112,7 +118,7 @@ funky_string_patch() {
112
118
 
113
119
  re="int strncasecmp(const char\* a, const char\* b, size_t c)"
114
120
  sbst="int _folly_strncasecmp(const char* a, const char* b, size_t c) \/* tebako patched *\/"
115
- sed -i "s/$re/$sbst/g" "$1"
121
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
116
122
  }
117
123
 
118
124
  funky_time_patch() {
@@ -122,11 +128,11 @@ funky_time_patch() {
122
128
 
123
129
  re="tm\* gmtime_r(const time_t\* t, tm\* res)"
124
130
  sbst="tm* _folly_gmtime_r(const time_t* t, tm* res) \/* tebako patched *\/"
125
- sed -i "s/$re/$sbst/g" "$1"
131
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
126
132
 
127
133
  re="tm\* localtime_r(const time_t\* t, tm\* o)"
128
134
  sbst="tm* _folly_localtime_r(const time_t* t, tm* o) \/* tebako patched *\/"
129
- sed -i "s/$re/$sbst/g" "$1"
135
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1"
130
136
  }
131
137
 
132
138
  funky_formatter_patch() {
@@ -138,13 +144,13 @@ funky_formatter_patch() {
138
144
  if [[ "$OSTYPE" == "linux-musl"* ]]; then
139
145
  # https://github.com/facebook/folly/issues/1478
140
146
  re="#elif defined(__FreeBSD__)"
141
- sbst="#else \/* Tebako patched *\/"
147
+ sbst="#elif defined(__FreeBSD__) || defined(__musl__) \/* Tebako patched *\/"
142
148
  do_patch "$1/folly/experimental/symbolizer/Elf.cpp" "$re" "$sbst"
143
149
 
144
150
  restore_and_save "$1/CMake/FollyConfigChecks.cmake"
145
151
  re="FOLLY_HAVE_IFUNC"
146
152
  sbst="FOLLY_HAVE_IFUNC_NOT_PATCHED"
147
- sed -i "s/$re/$sbst/g" "$1/CMake/FollyConfigChecks.cmake"
153
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/CMake/FollyConfigChecks.cmake"
148
154
 
149
155
  re="set(CMAKE_REQUIRED_FLAGS \"\${FOLLY_ORIGINAL_CMAKE_REQUIRED_FLAGS}\")"
150
156
 
@@ -164,7 +170,29 @@ check_cxx_source_runs(\"
164
170
  # -- End of tebako patch --
165
171
  EOM
166
172
 
167
- sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMake/FollyConfigChecks.cmake"
173
+ "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMake/FollyConfigChecks.cmake"
174
+
175
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
176
+ re=" set(OPENSSL_ROOT_DIR \"\/usr\/local\/opt\/openssl\" )"
177
+
178
+ # shellcheck disable=SC2251
179
+ ! IFS= read -r -d '' sbst << EOM
180
+ # -- Start of tebako patch --
181
+ if (NOT OPENSSL_ROOT_DIR)
182
+ set(OPENSSL_ROOT_DIR \"\/usr\/local\/opt\/openssl\")
183
+ endif(NOT OPENSSL_ROOT_DIR)
184
+ # -- End of tebako patch --
185
+ EOM
186
+
187
+ do_patch_multiline "$1/CMakeLists.txt" "$re" "$sbst"
188
+
189
+ re="set(OPENSSL_LIBRARIES \"\/usr\/local\/opt\/openssl\/lib\" )"
190
+ sbst="set(OPENSSL_LIBRARIES \"\${OPENSSL_ROOT_DIR}\/lib\") # tebako patched"
191
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/CMakeLists.txt"
192
+
193
+ re="set(OPENSSL_INCLUDE_DIR \"\/usr\/local\/opt\/openssl\/include\" )"
194
+ sbst="set(OPENSSL_INCLUDE_DIR \"\${OPENSSL_ROOT_DIR}\/include\") # tebako patched"
195
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/CMakeLists.txt"
168
196
 
169
197
  elif [[ "$OSTYPE" == "msys"* ]]; then
170
198
  # --- folly/portability/Stdlib.h ---
@@ -184,11 +212,11 @@ elif [[ "$OSTYPE" == "msys"* ]]; then
184
212
 
185
213
  re="using mode_t = unsigned int;"
186
214
  sbst="\/* using mode_t = unsigned int; --- tebako patched *\/"
187
- sed -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
215
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
188
216
 
189
217
  re="using uid_t = int;"
190
218
  sbst="using uid_t = short; \/* --- tebako patched *\/"
191
- sed -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
219
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
192
220
 
193
221
  re="using gid_t = int;"
194
222
  # shellcheck disable=SC2251
@@ -196,7 +224,7 @@ elif [[ "$OSTYPE" == "msys"* ]]; then
196
224
  using gid_t = short; \/* --- tebako patched *\/
197
225
  using nlink_t = short; \/* --- tebako patched *\/
198
226
  EOM
199
- sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysTypes.h"
227
+ "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysTypes.h"
200
228
 
201
229
  # --- folly/portability/SysStat.cpp ---
202
230
  funky_sysstat_patch "$1/folly/portability/SysStat.cpp"
@@ -210,7 +238,7 @@ EOM
210
238
  \/* -- Start of tebako patch --
211
239
  #define S_IXUSR 0
212
240
  EOM
213
- sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
241
+ "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
214
242
 
215
243
  re="#define S_ISREG(mode) (((mode) & (_S_IFREG)) == (_S_IFREG) ? 1 : 0)"
216
244
  # shellcheck disable=SC2251
@@ -223,7 +251,7 @@ EOM
223
251
 
224
252
  \/* -- End of tebako patch -- *\/
225
253
  EOM
226
- sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
254
+ "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
227
255
 
228
256
  # --- folly/portability/SysTime.h ---
229
257
  re="int gettimeofday(timeval\* tv, folly_port_struct_timezone\*);"
@@ -234,54 +262,54 @@ EOM
234
262
  defined_msc_ver_to_win32 "$1/folly/FileUtil.cpp"
235
263
  re="(open,"
236
264
  sbst="(\/* tebako patched *\/ folly::portability::fcntl::open,"
237
- sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
265
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
238
266
 
239
267
  re="close(tmpFD)"
240
268
  sbst="\/* tebako patched *\/ folly::portability::unistd::close(tmpFD)"
241
- sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
269
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
242
270
 
243
271
  re="(close(fd))"
244
272
  sbst="(\/* tebako patched *\/ folly::portability::unistd::close(fd))"
245
- sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
273
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
246
274
 
247
275
  re="(read,"
248
276
  sbst="(\/* tebako patched *\/ folly::portability::unistd::read,"
249
- sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
277
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
250
278
 
251
279
  re="(write,"
252
280
  sbst="(\/* tebako patched *\/ folly::portability::unistd::write,"
253
- sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
281
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
254
282
 
255
283
  re="(dup,"
256
284
  sbst="(\/* tebako patched *\/ folly::portability::unistd::dup,"
257
- sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
285
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
258
286
 
259
287
  re="(dup2,"
260
288
  sbst="(\/* tebako patched *\/ folly::portability::unistd::dup2,"
261
- sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
289
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
262
290
 
263
291
  # --- folly/experimental/TestUtil.cpp ---
264
292
  defined_win32_to_msc_ver "$1/folly/experimental/TestUtil.cpp"
265
293
  re="dup("
266
294
  sbst="\/* tebako patched *\/ folly::portability::unistd::dup("
267
- sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
295
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
268
296
 
269
297
  re="dup2("
270
298
  sbst="\/* tebako patched *\/ folly::portability::unistd::dup2("
271
- sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
299
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
272
300
 
273
301
  re="lseek("
274
302
  sbst="\/* tebako patched *\/ folly::portability::unistd::lseek("
275
- sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
303
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
276
304
 
277
305
  re="(close("
278
306
  sbst="(\/* tebako patched *\/ folly::portability::unistd::close("
279
- sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
307
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
280
308
 
281
309
  # --- folly/system/MemoryMapping.cpp ---
282
310
  re="0 == ftruncate("
283
311
  sbst="0 == \/* tebako patched *\/ folly::portability::unistd::ftruncate("
284
- sed -i "s/$re/$sbst/g" "$1/folly/system/MemoryMapping.cpp"
312
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/system/MemoryMapping.cpp"
285
313
 
286
314
  # --- folly/portability/SysUio.cpp ---
287
315
  re="lseek(fd,"
@@ -295,7 +323,7 @@ EOM
295
323
 
296
324
  re="lseek(fd, 0,"
297
325
  sbst=" \/* tebako patched *\/ folly::portability::unistd::lseek(fd, 0,"
298
- sed -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.cpp"
326
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.cpp"
299
327
 
300
328
  # --- folly/logging/ImmediateFileWriter.h ---
301
329
  re="isatty(file"
@@ -314,11 +342,11 @@ EOM
314
342
 
315
343
  re="int getuid();"
316
344
  sbst="uid_t getuid(); \/* tebako patched *\/"
317
- sed -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
345
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
318
346
 
319
347
  re="int getgid();"
320
348
  sbst="gid_t getgid(); \/* tebako patched *\/"
321
- sed -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
349
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
322
350
 
323
351
  # --- folly/portability/Fcntl.cpp ---
324
352
  re="#include <folly\/portability\/Windows\.h>"
@@ -352,7 +380,7 @@ EOM
352
380
  #ifndef __MINGW32__ \/* -- Tebako patched -- *\/
353
381
  __try {
354
382
  EOM
355
- sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
383
+ "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
356
384
 
357
385
  re="\/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because"
358
386
  # shellcheck disable=SC2251
@@ -360,7 +388,7 @@ EOM
360
388
  #endif \/* -- Tebako patched -- *\/
361
389
  \/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because
362
390
  EOM
363
- sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
391
+ "$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
364
392
 
365
393
  # --- folly/portability/Sockets.h ---
366
394
  restore_and_save "$1/folly/portability/Sockets.h"
@@ -378,14 +406,14 @@ EOM
378
406
  \/* -- End of tebako patch -- *\/
379
407
 
380
408
  EOM
381
- sed -i -i "0,/$re/s||${sbst//$'\n'/"\\n"}|g" "$1/folly/portability/Sockets.h"
409
+ "$GNU_SED" -i -i "0,/$re/s||${sbst//$'\n'/"\\n"}|g" "$1/folly/portability/Sockets.h"
382
410
 
383
411
  # --- folly/portability/Time.cpp ---
384
412
  funky_time_patch "$1/folly/portability/Time.cpp"
385
413
 
386
414
  re="(asctime_s(tmpBuf, tm))"
387
415
  sbst="(asctime_s(tmpBuf, 64\/* tebako patched *\/, tm))"
388
- sed -i "s/$re/$sbst/g" "$1/folly/portability/Time.cpp"
416
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Time.cpp"
389
417
 
390
418
  # ---
391
419
  re="#if (defined(USE_JEMALLOC) || FOLLY_USE_JEMALLOC) && !FOLLY_SANITIZE"
@@ -418,7 +446,7 @@ EOM
418
446
 
419
447
  re="#if defined(__XROS__)"
420
448
  sbst="#if defined(__XROS__) || defined(__MINGW32__) \/* tebako patched *\/"
421
- sed -i "s/$re/$sbst/g" "$1/folly/system/ThreadName.cpp"
449
+ "$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/system/ThreadName.cpp"
422
450
 
423
451
  # ---
424
452
  defined_msc_ver_to_win32 "$1/folly/external/farmhash/farmhash.cpp"
@@ -0,0 +1,63 @@
1
+ #!/bin/bash
2
+ # Copyright (c) 2023, [Ribose Inc](https://www.ribose.com).
3
+ # All rights reserved.
4
+ # This file is a part of tebako
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
+ : "${LOCAL_BUILDS:=/tmp/local_builds}"
30
+ : "${LOCAL_INSTALLS:=/opt}"
31
+ : "${CMAKE_VERSION:=3.26.5}"
32
+ : "${LIBARCHIVE_VERSION:=3.6.2}"
33
+ : "${ARCH:=linux-x86_64}"
34
+
35
+ install_cmake() {
36
+ echo "Running install_cmake version ${CMAKE_VERSION} for ${ARCH}"
37
+ local cmake_install="${LOCAL_BUILDS}/cmake"
38
+ mkdir -p "${cmake_install}"
39
+ pushd "${cmake_install}"
40
+ wget "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-${ARCH}.sh"
41
+ chmod +x "cmake-${CMAKE_VERSION}-${ARCH}.sh"
42
+ "./cmake-${CMAKE_VERSION}-${ARCH}.sh" --skip-license --prefix=/usr
43
+ popd
44
+ rm -rf "${cmake_install}"
45
+ }
46
+
47
+ build_and_install_libarchive() {
48
+ echo "Running build_and_install_libarchive version $LIBARCHIVE_VERSION"
49
+ local libarchive_build="$LOCAL_BUILDS/libarchive"
50
+ mkdir -p "$libarchive_build"
51
+ pushd "$libarchive_build"
52
+ wget "https://github.com/libarchive/libarchive/releases/download/v$LIBARCHIVE_VERSION/libarchive-$LIBARCHIVE_VERSION.tar.xz"
53
+ tar xf "libarchive-$LIBARCHIVE_VERSION.tar.xz"
54
+ cd "libarchive-$LIBARCHIVE_VERSION"
55
+ ./configure --prefix="$LOCAL_INSTALLS" --without-iconv --without-xml2 --without-expat
56
+ make -j8
57
+ make install
58
+ popd
59
+ rm -rf "$libarchive_build"
60
+ }
61
+
62
+ # shellcheck disable=SC2068
63
+ $@
@@ -24,27 +24,23 @@
24
24
  # POSSIBILITY OF SUCH DAMAGE.
25
25
  #
26
26
 
27
- set(GNU_BASH "bash")
28
-
29
27
  if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
30
- # If we are cross compiling TARGET_HOMEBREW will point to homebrew environment for target
31
- # If we are not cross-compiling it will be empty
32
- # Note that below for Bison, Flex and bash we are using host homebrew environment (just 'brew')
33
- # while other packages refer target environment potentially specified by BREW_BIN
34
28
  execute_process(
35
29
  COMMAND brew --prefix
36
30
  RESULT_VARIABLE BREW_PREFIX_RES
37
- OUTPUT_VARIABLE BUILD_BREW_PREFIX
31
+ OUTPUT_VARIABLE BREW_PREFIX
38
32
  OUTPUT_STRIP_TRAILING_WHITESPACE
39
33
  )
40
- if(NOT (BREW_PREFIX_RES EQUAL 0 AND EXISTS ${BUILD_BREW_PREFIX}))
34
+ if(NOT (BREW_PREFIX_RES EQUAL 0 AND EXISTS ${BREW_PREFIX}))
41
35
  message(FATAL "Could not find build brew setup")
42
36
  endif()
43
37
 
44
- message("Using build brew environment at ${BUILD_BREW_PREFIX}")
45
- # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.me
46
- set(BUILD_OPENSSL_ROOT_DIR "${BUILD_BREW_PREFIX}/opt/openssl@1.1")
47
- set(BUILD_CMAKE_PREFIX_PATH "${BUILD_BREW_PREFIX}")
38
+ message(STATUS "Using brew environment at ${BREW_PREFIX}")
39
+ # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.me
40
+ set(OPENSSL_ROOT_DIR "${BREW_PREFIX}/opt/openssl@3")
41
+ set(CMAKE_PREFIX_PATH "${BREW_PREFIX}")
42
+ include_directories("${OPENSSL_ROOT_DIR}/include")
43
+ include_directories("${TARGET_BREW_PREFIX}/include")
48
44
 
49
45
  # https://stackoverflow.com/questions/53877344/cannot-configure-cmake-to-look-for-homebrew-installed-version-of-bison
50
46
  execute_process(
@@ -80,25 +76,6 @@ if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
80
76
  set(GNU_BASH "${BREW_BASH_PREFIX}/bin/bash")
81
77
  endif()
82
78
 
83
- if(NOT TARGET_HOMEBREW)
84
- set(TARGET_BREW_PREFIX ${BUILD_BREW_PREFIX} )
85
- else()
86
- execute_process(
87
- COMMAND "${TARGET_HOMEBREW}/bin/brew" --prefix
88
- RESULT_VARIABLE BREW_PREFIX_RES
89
- OUTPUT_VARIABLE TARGET_BREW_PREFIX
90
- OUTPUT_STRIP_TRAILING_WHITESPACE
91
- )
92
- if(NOT (BREW_PREFIX_RES EQUAL 0 AND EXISTS ${TARGET_BREW_PREFIX}))
93
- message(FATAL "Could not find target brew setup")
94
- endif()
95
- endif()
96
-
97
- message("Using target brew environment at ${TARGET_BREW_PREFIX}")
98
- set(OPENSSL_ROOT_DIR "${TARGET_BREW_PREFIX}/opt/openssl@1.1")
99
- set(CMAKE_PREFIX_PATH "${TARGET_BREW_PREFIX}")
100
- include_directories("${TARGET_BREW_PREFIX}/include")
101
-
102
79
  # Suppress superfluous randlib warnings about "*.a" having no symbols on MacOSX.
103
80
  set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
104
81
  set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
@@ -0,0 +1,92 @@
1
+ # Copyright (c) 2022-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(LIBARCHIVE "3.6.2" "9e2c1b80d5fbe59b61308fdfab6c79b5021d7ff4ff2489fb12daf0a96a83551d")
27
+
28
+ message(STATUS "Collecting libarchive - " v${LIBARCHIVE_VER} " at " ${LIBARCHIVE_SOURCE_DIR})
29
+
30
+ set(CMAKE_ARGUMENTS -DCMAKE_INSTALL_PREFIX=${DEPS}
31
+ -DCMAKE_BUILD_TYPE=Release
32
+ -DBUILD_SHARED_LIBS:BOOL=OFF
33
+ -DENABLE_ACL:BOOL=OFF
34
+ -DENABLE_CNG:BOOL=OFF
35
+ -DENABLE_ICONV:BOOL=OFF
36
+ -DENABLE_LIBXML2:BOOL=OFF
37
+ -DENABLE_BZip2:BOOL=OFF
38
+ -DENABLE_CPIO:BOOL=OFF
39
+ -DENABLE_CAT:BOOL=OFF
40
+ -DENABLE_TAR:BOOL=OFF
41
+ -DENABLE_TEST:BOOL=OFF
42
+ -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
43
+ -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
44
+ )
45
+
46
+ if(TEBAKO_BUILD_TARGET)
47
+ list(APPEND CMAKE_ARGUMENTS -DCMAKE_C_FLAGS=--target=${TEBAKO_BUILD_TARGET})
48
+ list(APPEND CMAKE_ARGUMENTS -DCMAKE_EXE_LINKER_FLAGS=--target=${TEBAKO_BUILD_TARGET})
49
+ list(APPEND CMAKE_ARGUMENTS -DCMAKE_SHARED_LINKER_FLAGS=--target=${TEBAKO_BUILD_TARGET})
50
+ endif(TEBAKO_BUILD_TARGET)
51
+
52
+ # ...................................................................
53
+ # libarchive is the module that creates the real pain here
54
+ # Its shared version looks around to find other shared libraries which
55
+ # can do the real work. For example, if liblzma.so is found then libarchive
56
+ # supports lzma encoding.
57
+ # Static libary is compiled against predefined set of static archive libraries
58
+ # at the time when binary distribution created. This is not necessarily the
59
+ # set of libraries which is present at the system where this script is
60
+ # executed.
61
+ #
62
+ # There are two options to fix it:
63
+ #
64
+ # 1) Build local version of libarchive.a
65
+ #
66
+ # 2) Use LIBARCHIVE_STATIC_LIBRARIES and LIBARCHIVE_STATIC_LDFLAGS that are
67
+ # set by pkg_check_modules(LIBARCHIVE IMPORTED_TARGET libarchive>=3.1.2)
68
+ #
69
+ # Method #1 is implemented here.
70
+ # ...................................................................
71
+
72
+ if(${IS_MSYS})
73
+ set(__LIBARCHIVE "${DEPS}/lib/libarchive_static.a")
74
+ else(${IS_MSYS})
75
+ set(__LIBARCHIVE "${DEPS}/lib/libarchive.a")
76
+ endif(${IS_MSYS})
77
+
78
+ ExternalProject_Add(${LIBARCHIVE_PRJ}
79
+ PREFIX "${DEPS}"
80
+ URL http://www.libarchive.org/downloads/libarchive-${LIBARCHIVE_VER}.tar.xz
81
+ URL_HASH SHA256=${LIBARCHIVE_HASH}
82
+ DOWNLOAD_NO_PROGRESS true
83
+ UPDATE_COMMAND ""
84
+ CMAKE_ARGS ${CMAKE_ARGUMENTS}
85
+ SOURCE_DIR ${LIBARCHIVE_SOURCE_DIR}
86
+ BINARY_DIR ${LIBARCHIVE_BINARY_DIR}
87
+ BUILD_BYPRODUCTS ${__LIBARCHIVE}
88
+ )
89
+
90
+ add_library(_LIBARCHIVE STATIC IMPORTED)
91
+ set_target_properties(_LIBARCHIVE PROPERTIES IMPORTED_LOCATION ${__LIBARCHIVE})
92
+ add_dependencies(_LIBARCHIVE ${LIBARCHIVE_PRJ})