rbe-tebako 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.
- checksums.yaml +7 -0
- data/.clang-format +4 -0
- data/Brewfile +23 -0
- data/CMakeLists.txt +464 -0
- data/CODE_OF_CONDUCT.adoc +128 -0
- data/CONTRIBUTING.adoc +294 -0
- data/Gemfile +31 -0
- data/INSTALLATION.adoc +233 -0
- data/LICENSE.md +33 -0
- data/README.adoc +1363 -0
- data/Rakefile +35 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/cmake/copy_dir.cmake +29 -0
- data/common.env +5 -0
- data/exe/rbe-tebako +32 -0
- data/exe/rbe-tebako-packager +77 -0
- data/include/tebako/tebako-fs.h +43 -0
- data/include/tebako/tebako-main.h +42 -0
- data/include/tebako/tebako-prism.h +51 -0
- data/lib/rbe-tebako.rb +6 -0
- data/lib/tebako/build_helpers.rb +77 -0
- data/lib/tebako/cache_manager.rb +112 -0
- data/lib/tebako/cli.rb +220 -0
- data/lib/tebako/cli_helpers.rb +165 -0
- data/lib/tebako/codegen.rb +252 -0
- data/lib/tebako/deploy_helper.rb +258 -0
- data/lib/tebako/error.rb +70 -0
- data/lib/tebako/options_manager.rb +338 -0
- data/lib/tebako/package_descriptor.rb +143 -0
- data/lib/tebako/packager/pass1_patch.rb +266 -0
- data/lib/tebako/packager/pass1a_patch.rb +55 -0
- data/lib/tebako/packager/pass2_patch.rb +140 -0
- data/lib/tebako/packager/pass2_patch_crt.rb +46 -0
- data/lib/tebako/packager/pass2msys_patch.rb +190 -0
- data/lib/tebako/packager/patch.rb +54 -0
- data/lib/tebako/packager/patch_buildsystem.rb +124 -0
- data/lib/tebako/packager/patch_helpers.rb +109 -0
- data/lib/tebako/packager/patch_libraries.rb +188 -0
- data/lib/tebako/packager/patch_literals.rb +275 -0
- data/lib/tebako/packager/patch_main.rb +93 -0
- data/lib/tebako/packager/rubygems_patch.rb +83 -0
- data/lib/tebako/packager.rb +210 -0
- data/lib/tebako/packager_lite.rb +78 -0
- data/lib/tebako/ruby_builder.rb +71 -0
- data/lib/tebako/ruby_version.rb +206 -0
- data/lib/tebako/scenario_manager.rb +251 -0
- data/lib/tebako/stripper.rb +135 -0
- data/lib/tebako/version.rb +30 -0
- data/lib/tebako.rb +34 -0
- data/src/tebako-main.cpp +168 -0
- data/tools/.gitattributes +4 -0
- data/tools/.github/workflows/build-containers.yml +190 -0
- data/tools/.github/workflows/lint.yml +41 -0
- data/tools/.github/workflows/test.yml +331 -0
- data/tools/.gitignore +1 -0
- data/tools/README.md +49 -0
- data/tools/ci-scripts/arm-brew-install.sh +43 -0
- data/tools/ci-scripts/arm-brew-setup.sh +33 -0
- data/tools/ci-scripts/level-up.sh +35 -0
- data/tools/ci-scripts/patch-fbthrift.sh +94 -0
- data/tools/ci-scripts/patch-folly.sh +551 -0
- data/tools/ci-scripts/patch-glog.sh +57 -0
- data/tools/ci-scripts/patch-zstd.sh +57 -0
- data/tools/ci-scripts/tools.sh +63 -0
- data/tools/ci-scripts/x86-brew-install.sh +43 -0
- data/tools/ci-scripts/x86-brew-setup.sh +33 -0
- data/tools/cmake-scripts/def-external-project.cmake +96 -0
- data/tools/cmake-scripts/macos-environment.cmake +91 -0
- data/tools/cmake-scripts/msys-environment.cmake +78 -0
- data/tools/cmake-scripts/setup-libarchive.cmake +93 -0
- data/tools/cmake-scripts/setup-libfmt.cmake +61 -0
- data/tools/cmake-scripts/setup-libhowardhinnerdate.cmake +55 -0
- data/tools/cmake-scripts/setup-libutfcpp.cmake +56 -0
- data/tools/cmake-scripts/version.cmake +162 -0
- data/tools/docker/alpine-3.17-dev.Dockerfile +49 -0
- data/tools/docker/tools/tools.sh +66 -0
- data/tools/docker/ubuntu-20.04-dev.Dockerfile +51 -0
- data/tools/dwarfs-test-helper/CMakeLists.txt +34 -0
- data/tools/include/pro-statvfs.h +57 -0
- data/tools/tests/cmake/CMakeLists.txt +81 -0
- data/tools/tests/setup-libfmt/CMakeLists.txt +35 -0
- data/tools/tests/setup-libhowardhinnerdate/CMakeLists.txt +35 -0
- data/tools/tests/setup-librachive/CMakeLists.txt +35 -0
- data/tools/tests/setup-libutfcpp/CMakeLists.txt +36 -0
- data/tools/tests/setup-openssl/CMakeLists.txt +36 -0
- metadata +312 -0
|
@@ -0,0 +1,551 @@
|
|
|
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
|
+
re="int nanosleep(const struct timespec\* request, struct timespec\* remain) {"
|
|
145
|
+
sbst="int _folly_nanosleep(const struct timespec* request, struct timespec* remain) { \/* tebako patched *\/"
|
|
146
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1"
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
funky_formatter_patch() {
|
|
150
|
+
re="if (!localtime_r(&unixTimestamp, <ime)) {"
|
|
151
|
+
sbst="if (!_folly_localtime_r(\&unixTimestamp, \<ime)) { \/* tebako patched *\/"
|
|
152
|
+
do_patch "$1" "$re" "$sbst"
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
re="cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)"
|
|
157
|
+
sbst="cmake_minimum_required(VERSION 3.24.0)"
|
|
158
|
+
do_patch "$1/CMakeLists.txt" "$re" "$sbst"
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
re="find_package(Boost 1.51.0 MODULE"
|
|
162
|
+
# shellcheck disable=SC2251
|
|
163
|
+
! IFS= read -r -d '' sbst << EOM
|
|
164
|
+
if (POLICY CMP0167)
|
|
165
|
+
cmake_policy(SET CMP0167 NEW)
|
|
166
|
+
endif()
|
|
167
|
+
|
|
168
|
+
find_package(Boost 1.67.0 COMPONENTS
|
|
169
|
+
EOM
|
|
170
|
+
do_patch_multiline "$1/CMake/folly-deps.cmake" "$re" "$sbst"
|
|
171
|
+
|
|
172
|
+
re=" system"
|
|
173
|
+
sbst="# system tebako patched"
|
|
174
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/CMake/folly-deps.cmake"
|
|
175
|
+
|
|
176
|
+
if [[ "$OSTYPE" == "linux-musl"* ]]; then
|
|
177
|
+
# https://github.com/facebook/folly/issues/1478
|
|
178
|
+
re="#elif defined(__FreeBSD__)"
|
|
179
|
+
sbst="#elif defined(__FreeBSD__) || defined(__musl__) \/* Tebako patched *\/"
|
|
180
|
+
do_patch "$1/folly/debugging/symbolizer/Elf.cpp" "$re" "$sbst"
|
|
181
|
+
|
|
182
|
+
restore_and_save "$1/CMake/FollyConfigChecks.cmake"
|
|
183
|
+
re="FOLLY_HAVE_IFUNC"
|
|
184
|
+
sbst="FOLLY_HAVE_IFUNC_NOT_PATCHED"
|
|
185
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/CMake/FollyConfigChecks.cmake"
|
|
186
|
+
|
|
187
|
+
re="set(CMAKE_REQUIRED_FLAGS \"\${FOLLY_ORIGINAL_CMAKE_REQUIRED_FLAGS}\")"
|
|
188
|
+
|
|
189
|
+
# shellcheck disable=SC2251
|
|
190
|
+
! IFS= read -r -d '' sbst << EOM
|
|
191
|
+
set(CMAKE_REQUIRED_FLAGS \"\${FOLLY_ORIGINAL_CMAKE_REQUIRED_FLAGS}\")
|
|
192
|
+
|
|
193
|
+
# -- Start of tebako patch --
|
|
194
|
+
check_cxx_source_runs(\"
|
|
195
|
+
#pragma GCC diagnostic error \\\"-Wattributes\\\"
|
|
196
|
+
extern \\\"C\\\" int resolved_ifunc(void) { return 0; }
|
|
197
|
+
extern \\\"C\\\" int (*test_ifunc(void))() { return resolved_ifunc; }
|
|
198
|
+
int func() __attribute__((ifunc(\\\"test_ifunc\\\")));
|
|
199
|
+
int main() { return func(); }\"
|
|
200
|
+
FOLLY_HAVE_IFUNC
|
|
201
|
+
)
|
|
202
|
+
# -- End of tebako patch --
|
|
203
|
+
EOM
|
|
204
|
+
|
|
205
|
+
"$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMake/FollyConfigChecks.cmake"
|
|
206
|
+
|
|
207
|
+
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
208
|
+
re=" set(OPENSSL_ROOT_DIR \"\/usr\/local\/opt\/openssl\" )"
|
|
209
|
+
|
|
210
|
+
# shellcheck disable=SC2251
|
|
211
|
+
! IFS= read -r -d '' sbst << EOM
|
|
212
|
+
# -- Start of tebako patch --
|
|
213
|
+
if (NOT OPENSSL_ROOT_DIR)
|
|
214
|
+
set(OPENSSL_ROOT_DIR \"\/usr\/local\/opt\/openssl\")
|
|
215
|
+
endif(NOT OPENSSL_ROOT_DIR)
|
|
216
|
+
# -- End of tebako patch --
|
|
217
|
+
EOM
|
|
218
|
+
|
|
219
|
+
"$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMakeLists.txt"
|
|
220
|
+
|
|
221
|
+
re="set(OPENSSL_LIBRARIES \"\/usr\/local\/opt\/openssl\/lib\" )"
|
|
222
|
+
sbst="set(OPENSSL_LIBRARIES \"\${OPENSSL_ROOT_DIR}\/lib\") # tebako patched"
|
|
223
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/CMakeLists.txt"
|
|
224
|
+
|
|
225
|
+
re="set(OPENSSL_INCLUDE_DIR \"\/usr\/local\/opt\/openssl\/include\" )"
|
|
226
|
+
sbst="set(OPENSSL_INCLUDE_DIR \"\${OPENSSL_ROOT_DIR}\/include\") # tebako patched"
|
|
227
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/CMakeLists.txt"
|
|
228
|
+
|
|
229
|
+
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
|
|
230
|
+
# --- folly/portability/Stdlib.h ---
|
|
231
|
+
re="#define PATH_MAX _MAX_PATH"
|
|
232
|
+
sbst="\/* #define PATH_MAX _MAX_PATH --- tebako patched *\/"
|
|
233
|
+
do_patch "$1/folly/portability/Stdlib.h" "$re" "$sbst"
|
|
234
|
+
|
|
235
|
+
# --- folly/portability/Stdlib.cpp ---
|
|
236
|
+
re="ret = mkdir(ptr, 0700);"
|
|
237
|
+
sbst="ret = _folly_mkdir(ptr, 0700); \/* tebako patched *\/"
|
|
238
|
+
do_patch "$1/folly/portability/Stdlib.cpp" "$re" "$sbst"
|
|
239
|
+
|
|
240
|
+
# --- folly/portability/SysTypes.h ---
|
|
241
|
+
re="using pid_t = int;"
|
|
242
|
+
sbst="\/* using pid_t = int; --- tebako patched *\/"
|
|
243
|
+
do_patch "$1/folly/portability/SysTypes.h" "$re" "$sbst"
|
|
244
|
+
|
|
245
|
+
re="using mode_t = unsigned int;"
|
|
246
|
+
sbst="\/* using mode_t = unsigned int; --- tebako patched *\/"
|
|
247
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
|
|
248
|
+
|
|
249
|
+
re="using uid_t = int;"
|
|
250
|
+
sbst="using uid_t = short; \/* --- tebako patched *\/"
|
|
251
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
|
|
252
|
+
|
|
253
|
+
re="using gid_t = int;"
|
|
254
|
+
# shellcheck disable=SC2251
|
|
255
|
+
! IFS= read -r -d '' sbst << EOM
|
|
256
|
+
using gid_t = short; \/* --- tebako patched *\/
|
|
257
|
+
using nlink_t = short; \/* --- tebako patched *\/
|
|
258
|
+
EOM
|
|
259
|
+
"$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysTypes.h"
|
|
260
|
+
|
|
261
|
+
# --- folly/portability/SysStat.cpp ---
|
|
262
|
+
funky_sysstat_patch "$1/folly/portability/SysStat.cpp"
|
|
263
|
+
|
|
264
|
+
# --- folly/portability/SysStat.h ---
|
|
265
|
+
funky_sysstat_patch "$1/folly/portability/SysStat.h"
|
|
266
|
+
|
|
267
|
+
re="#define S_IXUSR 0"
|
|
268
|
+
# shellcheck disable=SC2251
|
|
269
|
+
! IFS= read -r -d '' sbst << EOM
|
|
270
|
+
\/* -- Start of tebako patch --
|
|
271
|
+
#define S_IXUSR 0
|
|
272
|
+
EOM
|
|
273
|
+
"$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
|
|
274
|
+
|
|
275
|
+
re="#define S_ISREG(mode) (((mode) & (_S_IFREG)) == (_S_IFREG) ? 1 : 0)"
|
|
276
|
+
# shellcheck disable=SC2251
|
|
277
|
+
! IFS= read -r -d '' sbst << EOM
|
|
278
|
+
#define S_ISREG(mode) (((mode) \& (_S_IFREG)) == (_S_IFREG) ? 1 : 0)
|
|
279
|
+
*\/
|
|
280
|
+
#define _S_IFLNK 0xA000
|
|
281
|
+
#define S_IFLNK _S_IFLNK
|
|
282
|
+
#define S_ISLNK(mode) (((mode) \& (_S_IFLNK)) == (_S_IFLNK) ? 1 : 0)
|
|
283
|
+
|
|
284
|
+
\/* -- End of tebako patch -- *\/
|
|
285
|
+
EOM
|
|
286
|
+
"$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
|
|
287
|
+
|
|
288
|
+
# --- folly/portability/SysTime.h ---
|
|
289
|
+
re="int gettimeofday(timeval\* tv, folly_port_struct_timezone\*);"
|
|
290
|
+
sbst="\/* int gettimeofday(timeval* tv, folly_port_struct_timezone*); --- tebako patched *\/"
|
|
291
|
+
do_patch "$1/folly/portability/SysTime.h" "$re" "$sbst"
|
|
292
|
+
|
|
293
|
+
# --- folly/FileUtil.cpp ---
|
|
294
|
+
defined_msc_ver_to_win32 "$1/folly/FileUtil.cpp"
|
|
295
|
+
re="(open,"
|
|
296
|
+
sbst="(\/* tebako patched *\/ folly::portability::fcntl::open,"
|
|
297
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
|
|
298
|
+
|
|
299
|
+
re="close(tmpFD)"
|
|
300
|
+
sbst="\/* tebako patched *\/ folly::portability::unistd::close(tmpFD)"
|
|
301
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
|
|
302
|
+
|
|
303
|
+
re="(close(fd))"
|
|
304
|
+
sbst="(\/* tebako patched *\/ folly::portability::unistd::close(fd))"
|
|
305
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
|
|
306
|
+
|
|
307
|
+
re="(read,"
|
|
308
|
+
sbst="(\/* tebako patched *\/ folly::portability::unistd::read,"
|
|
309
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
|
|
310
|
+
|
|
311
|
+
re="(write,"
|
|
312
|
+
sbst="(\/* tebako patched *\/ folly::portability::unistd::write,"
|
|
313
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
|
|
314
|
+
|
|
315
|
+
re="(dup,"
|
|
316
|
+
sbst="(\/* tebako patched *\/ folly::portability::unistd::dup,"
|
|
317
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
|
|
318
|
+
|
|
319
|
+
re="(dup2,"
|
|
320
|
+
sbst="(\/* tebako patched *\/ folly::portability::unistd::dup2,"
|
|
321
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
|
|
322
|
+
|
|
323
|
+
# --- folly/testing/TestUtil.cpp ---
|
|
324
|
+
defined_win32_to_msc_ver "$1/folly/testing/TestUtil.cpp"
|
|
325
|
+
re="dup("
|
|
326
|
+
sbst="\/* tebako patched *\/ folly::portability::unistd::dup("
|
|
327
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
|
|
328
|
+
|
|
329
|
+
re="dup2("
|
|
330
|
+
sbst="\/* tebako patched *\/ folly::portability::unistd::dup2("
|
|
331
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
|
|
332
|
+
|
|
333
|
+
re="lseek("
|
|
334
|
+
sbst="\/* tebako patched *\/ folly::portability::unistd::lseek("
|
|
335
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
|
|
336
|
+
|
|
337
|
+
re="(close("
|
|
338
|
+
sbst="(\/* tebako patched *\/ folly::portability::unistd::close("
|
|
339
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/testing/TestUtil.cpp"
|
|
340
|
+
|
|
341
|
+
# --- folly/system/MemoryMapping.cpp ---
|
|
342
|
+
re="0 == ftruncate("
|
|
343
|
+
sbst="0 == \/* tebako patched *\/ folly::portability::unistd::ftruncate("
|
|
344
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/system/MemoryMapping.cpp"
|
|
345
|
+
|
|
346
|
+
# --- folly/portability/SysUio.cpp ---
|
|
347
|
+
re="lseek(fd,"
|
|
348
|
+
sbst=" \/* tebako patched *\/ folly::portability::unistd::lseek(fd,"
|
|
349
|
+
do_patch "$1/folly/portability/SysUio.cpp" "$re" "$sbst"
|
|
350
|
+
|
|
351
|
+
# --- folly/logging/ImmediateFileWriter.h ---
|
|
352
|
+
re="isatty(file"
|
|
353
|
+
sbst=" \/* tebako patched *\/ folly::portability::unistd::isatty(file"
|
|
354
|
+
do_patch "$1/folly/logging/ImmediateFileWriter.h" "$re" "$sbst"
|
|
355
|
+
|
|
356
|
+
# --- folly/logging/AsyncFileWriter.cpp ---
|
|
357
|
+
re="isatty(file"
|
|
358
|
+
sbst=" \/* tebako patched *\/ folly::portability::unistd::isatty(file"
|
|
359
|
+
do_patch "$1/folly/logging/AsyncFileWriter.cpp" "$re" "$sbst"
|
|
360
|
+
|
|
361
|
+
# --- folly/portability/Unistd.h ---
|
|
362
|
+
re="#define X_OK F_OK"
|
|
363
|
+
sbst="#define X_OK 1 \/* tebako patched *\/"
|
|
364
|
+
do_patch "$1/folly/portability/Unistd.h" "$re" "$sbst"
|
|
365
|
+
|
|
366
|
+
re="int getuid();"
|
|
367
|
+
sbst="uid_t getuid(); \/* tebako patched *\/"
|
|
368
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
|
|
369
|
+
|
|
370
|
+
re="int getgid();"
|
|
371
|
+
sbst="gid_t getgid(); \/* tebako patched *\/"
|
|
372
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
|
|
373
|
+
|
|
374
|
+
# --- folly/portability/Fcntl.cpp ---
|
|
375
|
+
re="#include <folly\/portability\/Windows\.h>"
|
|
376
|
+
|
|
377
|
+
# shellcheck disable=SC2251
|
|
378
|
+
! IFS= read -r -d '' sbst << EOM
|
|
379
|
+
#include <folly\/portability\/Windows.h>
|
|
380
|
+
\/* -- Start of tebako patch -- *\/
|
|
381
|
+
#include <share.h>
|
|
382
|
+
\/* -- End of tebako patch -- *\/
|
|
383
|
+
EOM
|
|
384
|
+
do_patch_multiline "$1/folly/portability/Fcntl.cpp" "$re" "$sbst"
|
|
385
|
+
|
|
386
|
+
# --- folly/net/detail/SocketFileDescriptorMap.cpp --
|
|
387
|
+
re="#include <fcntl\.h>"
|
|
388
|
+
|
|
389
|
+
# shellcheck disable=SC2251
|
|
390
|
+
! IFS= read -r -d '' sbst << EOM
|
|
391
|
+
#include <fcntl.h>
|
|
392
|
+
|
|
393
|
+
\/* -- Start of tebako patch -- *\/
|
|
394
|
+
#include <mutex>
|
|
395
|
+
\/* -- End of tebako patch -- *\/
|
|
396
|
+
|
|
397
|
+
EOM
|
|
398
|
+
do_patch_multiline "$1/folly/net/detail/SocketFileDescriptorMap.cpp" "$re" "$sbst"
|
|
399
|
+
|
|
400
|
+
re=" __try {"
|
|
401
|
+
# shellcheck disable=SC2251
|
|
402
|
+
! IFS= read -r -d '' sbst << EOM
|
|
403
|
+
#ifndef __MINGW32__ \/* -- Tebako patched -- *\/
|
|
404
|
+
__try {
|
|
405
|
+
EOM
|
|
406
|
+
"$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
|
|
407
|
+
|
|
408
|
+
re="\/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because"
|
|
409
|
+
# shellcheck disable=SC2251
|
|
410
|
+
! IFS= read -r -d '' sbst << EOM
|
|
411
|
+
#endif \/* -- Tebako patched -- *\/
|
|
412
|
+
\/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because
|
|
413
|
+
EOM
|
|
414
|
+
"$GNU_SED" -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
|
|
415
|
+
|
|
416
|
+
# --- folly/portability/Sockets.h ---
|
|
417
|
+
restore_and_save "$1/folly/portability/Sockets.h"
|
|
418
|
+
re="#ifdef _WIN32"
|
|
419
|
+
|
|
420
|
+
# shellcheck disable=SC2251
|
|
421
|
+
! IFS= read -r -d '' sbst << EOM
|
|
422
|
+
#ifdef _WIN32
|
|
423
|
+
|
|
424
|
+
\/* -- Start of tebako patch -- *\/
|
|
425
|
+
#ifdef __MINGW32__
|
|
426
|
+
#include <mswsock.h>
|
|
427
|
+
using cmsghdr = WSACMSGHDR;
|
|
428
|
+
#define CMSG_SPACE WSA_CMSG_SPACE
|
|
429
|
+
#endif
|
|
430
|
+
\/* -- End of tebako patch -- *\/
|
|
431
|
+
|
|
432
|
+
EOM
|
|
433
|
+
"$GNU_SED" -i -i "0,/$re/s||${sbst//$'\n'/"\\n"}|g" "$1/folly/portability/Sockets.h"
|
|
434
|
+
|
|
435
|
+
# --- folly/portability/Time.cpp ---
|
|
436
|
+
funky_time_patch "$1/folly/portability/Time.cpp"
|
|
437
|
+
|
|
438
|
+
re="(asctime_s(tmpBuf, tm))"
|
|
439
|
+
sbst="(asctime_s(tmpBuf, 64\/* tebako patched *\/, tm))"
|
|
440
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Time.cpp"
|
|
441
|
+
|
|
442
|
+
# ---
|
|
443
|
+
re="#if (defined(USE_JEMALLOC) || FOLLY_USE_JEMALLOC) && !FOLLY_SANITIZE"
|
|
444
|
+
# shellcheck disable=SC2251
|
|
445
|
+
! IFS= read -r -d '' sbst << EOM
|
|
446
|
+
\/* -- Start of tebako patch -- *\/
|
|
447
|
+
#if defined(FOLLY_ASSUME_NO_JEMALLOC)
|
|
448
|
+
#undef USE_JEMALLOC
|
|
449
|
+
#undef FOLLY_USE_JEMALLOC
|
|
450
|
+
#endif
|
|
451
|
+
\/* -- End of tebako patch -- *\/
|
|
452
|
+
#if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) \&\& !FOLLY_SANITIZE \/* tebako patched *\/
|
|
453
|
+
EOM
|
|
454
|
+
do_patch_multiline "$1/folly/portability/Malloc.h" "$re" "$sbst"
|
|
455
|
+
|
|
456
|
+
# ---
|
|
457
|
+
re="#include <folly\/Portability\.h>"
|
|
458
|
+
# shellcheck disable=SC2251
|
|
459
|
+
! IFS= read -r -d '' sbst << EOM
|
|
460
|
+
#include <folly\/Portability.h>
|
|
461
|
+
\/* -- Start of tebako patch -- *\/
|
|
462
|
+
#include <folly\/portability\/Malloc.h>
|
|
463
|
+
\/* -- End of tebako patch -- *\/
|
|
464
|
+
|
|
465
|
+
EOM
|
|
466
|
+
do_patch_multiline "$1/folly/memory/detail/MallocImpl.h" "$re" "$sbst"
|
|
467
|
+
|
|
468
|
+
# --- folly/system/ThreadName.cpp ---
|
|
469
|
+
defined_win32_to_msc_ver "$1/folly/system/ThreadName.cpp"
|
|
470
|
+
|
|
471
|
+
re="#if defined(__XROS__)"
|
|
472
|
+
sbst="#if defined(__XROS__) || defined(__MINGW32__) \/* tebako patched *\/"
|
|
473
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/system/ThreadName.cpp"
|
|
474
|
+
|
|
475
|
+
# --- folly/net/NetOps.h ---
|
|
476
|
+
|
|
477
|
+
re="#include <WS2tcpip\.h> \/\/ @manual"
|
|
478
|
+
# shellcheck disable=SC2251
|
|
479
|
+
! IFS= read -r -d '' sbst << EOM
|
|
480
|
+
#include <WS2tcpip.h> \/\/ @manual
|
|
481
|
+
|
|
482
|
+
\/* -- Start of tebako patch -- *\/
|
|
483
|
+
#ifdef __MINGW32__
|
|
484
|
+
#include <memory>
|
|
485
|
+
#include <mswsock.h>
|
|
486
|
+
#endif
|
|
487
|
+
\/* -- End of tebako patch -- *\/
|
|
488
|
+
EOM
|
|
489
|
+
do_patch_multiline "$1/folly/net/NetOps.h" "$re" "$sbst"
|
|
490
|
+
|
|
491
|
+
# --- folly/Random.cpp ---
|
|
492
|
+
|
|
493
|
+
re="#include <folly\/synchronization\/RelaxedAtomic\.h>"
|
|
494
|
+
# shellcheck disable=SC2251
|
|
495
|
+
! IFS= read -r -d '' sbst << EOM
|
|
496
|
+
#include <folly\/synchronization\/RelaxedAtomic.h>
|
|
497
|
+
|
|
498
|
+
\/* -- Start of tebako patch -- *\/
|
|
499
|
+
#include <folly\/portability\/Fcntl.h>
|
|
500
|
+
\/* -- End of tebako patch -- *\/
|
|
501
|
+
EOM
|
|
502
|
+
do_patch_multiline "$1/folly/Random.cpp" "$re" "$sbst"
|
|
503
|
+
|
|
504
|
+
# --- folly/Utility.h ---
|
|
505
|
+
re="T uninit;"
|
|
506
|
+
sbst="T uninit = 0; \/* tebako patched *\/"
|
|
507
|
+
do_patch "$1/folly/Utility.h" "$re" "$sbst"
|
|
508
|
+
|
|
509
|
+
# --- folly/portability/Unistd.cpp ---
|
|
510
|
+
re="res = lseek64(fd, offset, whence);"
|
|
511
|
+
sbst="res = folly::portability::unistd::lseek64(fd, offset, whence); \/* tebako patched *\/ "
|
|
512
|
+
do_patch "$1/folly/portability/Unistd.cpp" "$re" "$sbst"
|
|
513
|
+
|
|
514
|
+
re="res = lseek(fd, offset, whence);"
|
|
515
|
+
sbst="res = folly::portability::unistd::lseek(fd, offset, whence); \/* tebako patched *\/ "
|
|
516
|
+
"$GNU_SED" -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.cpp"
|
|
517
|
+
|
|
518
|
+
# --- folly/io/async/AsyncUDPSocket.cpp
|
|
519
|
+
re="#elif _WIN32"
|
|
520
|
+
sbst="#elif _MSC_VER \/* tebako patched *\/ "
|
|
521
|
+
do_patch "$1/folly/io/async/AsyncUDPSocket.cpp" "$re" "$sbst"
|
|
522
|
+
|
|
523
|
+
# ---
|
|
524
|
+
defined_msc_ver_to_win32 "$1/folly/external/farmhash/farmhash.cpp"
|
|
525
|
+
defined_msc_ver_to_win32 "$1/folly/detail/IPAddressSource.h"
|
|
526
|
+
defined_msc_ver_to_win32 "$1/folly/portability/Sockets.cpp"
|
|
527
|
+
defined_win32_to_msc_ver "$1/folly/portability/Sched.h"
|
|
528
|
+
defined_win32_to_msc_ver "$1/folly/portability/Sched.cpp"
|
|
529
|
+
|
|
530
|
+
defined_n_win32_to_msc_ver "$1/folly/portability/Dirent.h"
|
|
531
|
+
defined_win32_to_msc_ver "$1/folly/portability/Dirent.cpp"
|
|
532
|
+
|
|
533
|
+
funky_stdio_patch "$1/folly/portability/Stdio.h"
|
|
534
|
+
funky_stdio_patch "$1/folly/portability/Stdio.cpp"
|
|
535
|
+
funky_string_patch "$1/folly/portability/String.h"
|
|
536
|
+
funky_string_patch "$1/folly/portability/String.cpp"
|
|
537
|
+
funky_time_patch "$1/folly/portability/Time.h"
|
|
538
|
+
funky_formatter_patch "$1/folly/logging/CustomLogFormatter.cpp"
|
|
539
|
+
funky_formatter_patch "$1/folly/logging/GlogStyleFormatter.cpp"
|
|
540
|
+
|
|
541
|
+
# Note: the patch below comments out
|
|
542
|
+
# int gettimeofday(timeval* tv, folly_port_struct_timezone*);
|
|
543
|
+
# void timeradd(timeval* a, timeval* b, timeval* res);
|
|
544
|
+
# void timersub(timeval* a, timeval* b, timeval* res);
|
|
545
|
+
# while gettimeofday is provided by MSys, the other two functions are lost
|
|
546
|
+
defined_n_win32_to_msc_ver "$1/folly/portability/SysTime.h"
|
|
547
|
+
defined_win32_to_msc_ver "$1/folly/portability/SysTime.cpp"
|
|
548
|
+
defined_win32_to_msc_ver "$1/folly/lang/Exception.cpp"
|
|
549
|
+
|
|
550
|
+
defined_el_win32_to_msc_ver "$1/folly/io/async/AsyncUDPSocket.cpp"
|
|
551
|
+
fi
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#! /bin/bash
|
|
2
|
+
# Copyright (c) 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
|
+
# ....................................................
|
|
30
|
+
restore_and_save() {
|
|
31
|
+
echo "Patching $1"
|
|
32
|
+
test -e "$1.old" && cp -f "$1.old" "$1"
|
|
33
|
+
cp -f "$1" "$1.old"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
do_patch() {
|
|
37
|
+
restore_and_save "$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"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "linux-musl"* || "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
|
|
47
|
+
gSed="sed"
|
|
48
|
+
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
49
|
+
gSed="gsed"
|
|
50
|
+
else
|
|
51
|
+
echo "Unknown OSTYPE=$OSTYPE"
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
re="cmake_policy (VERSION 3.3)"
|
|
56
|
+
sbst="cmake_policy (VERSION 3.16...3.27)"
|
|
57
|
+
do_patch "$1/cmake/GetCacheVariables.cmake" "$re" "$sbst"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#! /bin/bash
|
|
2
|
+
# Copyright (c) 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
|
+
# ....................................................
|
|
30
|
+
restore_and_save() {
|
|
31
|
+
echo "Patching $1"
|
|
32
|
+
test -e "$1.old" && cp -f "$1.old" "$1"
|
|
33
|
+
cp -f "$1" "$1.old"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
do_patch() {
|
|
37
|
+
restore_and_save "$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"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "linux-musl"* || "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
|
|
47
|
+
gSed="sed"
|
|
48
|
+
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
49
|
+
gSed="gsed"
|
|
50
|
+
else
|
|
51
|
+
echo "Unknown OSTYPE=$OSTYPE"
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
re="cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)"
|
|
56
|
+
sbst="cmake_minimum_required(VERSION 3.24.0)"
|
|
57
|
+
do_patch "$1/build/cmake/CMakeLists.txt" "$re" "$sbst"
|