tebako 0.14.0 → 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 +4 -4
- data/Brewfile +0 -5
- data/CMakeLists.txt +94 -46
- data/cmake/tebako-libtfs.cmake +456 -0
- data/common.env +1 -1
- data/include/tebako/tpkg.h +575 -0
- data/lib/tebako/cli.rb +91 -0
- data/lib/tebako/cli_helpers.rb +24 -0
- data/lib/tebako/error.rb +10 -0
- data/lib/tebako/launcher_abi.rb +99 -0
- data/lib/tebako/options_manager.rb +71 -0
- data/lib/tebako/packager/patch_libraries.rb +47 -27
- data/lib/tebako/packager.rb +40 -1
- data/lib/tebako/runtime_manager.rb +347 -0
- data/lib/tebako/stitcher.rb +255 -0
- data/lib/tebako/version.rb +1 -1
- data/src/tebako-main.cpp +577 -9
- data/tools/.github/workflows/test.yml +6 -6
- data/tools/cmake-scripts/macos-environment.cmake +11 -2
- metadata +7 -4
- data/tools/ci-scripts/patch-fbthrift.sh +0 -94
- data/tools/ci-scripts/patch-folly.sh +0 -551
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
# Copyright (c) 2021-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
|
+
# ...................................................................
|
|
27
|
+
# libtfs provisioning (included from the top-level CMakeLists.txt)
|
|
28
|
+
#
|
|
29
|
+
# Two consumption modes for the DwarFS-based tebako filesystem library:
|
|
30
|
+
# DWARFS_PRELOAD=ON (default) -- download the prebuilt libtfs package
|
|
31
|
+
# (libtfs-<ver>-<platform>.tar.gz) and the prebuilt mkdwarfs binary
|
|
32
|
+
# from the libtfs GitHub release, verify both against the release
|
|
33
|
+
# SHA256SUMS, and deploy them into ${DEPS}. The tarball is NOT
|
|
34
|
+
# self-contained (its libtfsConfig.cmake does find_dependency(dwarfs)
|
|
35
|
+
# and find_dependency(libzip), and no third-party static libs ship in
|
|
36
|
+
# it), so the transitive static dependencies are resolved by installing
|
|
37
|
+
# libtfs' own vcpkg manifest (pinned tag, overlay ports included) into
|
|
38
|
+
# ${DEPS}/vcpkg_installed. vcpkg's per-package archive cache makes
|
|
39
|
+
# repeated installs fast; set VCPKG_BINARY_SOURCES /
|
|
40
|
+
# VCPKG_DEFAULT_BINARY_CACHE to control the cache location (mirrors
|
|
41
|
+
# libtfs CI, which uses a files backend cache with readwrite access).
|
|
42
|
+
# DWARFS_PRELOAD=OFF -- build libtfs from source (ExternalProject,
|
|
43
|
+
# tamatebako/libtfs.git @ ${DWARFS_WR_TAG}) with the vcpkg toolchain.
|
|
44
|
+
# mkdwarfs still comes from the prebuilt release set (the press
|
|
45
|
+
# pipeline runs ${DEPS}/bin/mkdwarfs) and is passed to the libtfs
|
|
46
|
+
# build via -DMKDWARFS (which also selects TEBAKO_BUILD_SCOPE=LIB).
|
|
47
|
+
#
|
|
48
|
+
# Expected on entry (set by the top-level CMakeLists.txt):
|
|
49
|
+
# DEPS, DEPS_INCLUDE_DIR, DEPS_LIB_DIR, DEPS_BIN_DIR, DEPS_SRC_DIR
|
|
50
|
+
# IS_GNU, IS_MUSL, IS_MSYS, IS_DARWIN
|
|
51
|
+
# DWARFS_PRELOAD (option), DWARFS_WR_TAG (e.g. "v0.12.0")
|
|
52
|
+
# Sets for the rest of the build:
|
|
53
|
+
# LIBTFS_VERSION, LIBTFS_PLATFORM
|
|
54
|
+
# LIBTFS_INCLUDE_DIR -- libtfs headers (deps/include)
|
|
55
|
+
# LIBTFS_LIB_DIR -- libtfs.a + helper (deps/lib)
|
|
56
|
+
# LIBTFS_MKDWARFS -- mkdwarfs executable (deps/bin/mkdwarfs[.exe])
|
|
57
|
+
# LIBTFS_VCPKG_INSTALLED_DIR / LIBTFS_VCPKG_TRIPLET_DIR
|
|
58
|
+
# -- transitive static libs/headers (vcpkg)
|
|
59
|
+
# VCPKG_ROOT -- vcpkg checkout (env, cache, or bootstrapped)
|
|
60
|
+
|
|
61
|
+
# Pinned to the default-registry baseline of libtfs v0.12.0
|
|
62
|
+
# vcpkg-configuration.json. Only used when tebako bootstraps vcpkg itself
|
|
63
|
+
# (i.e. VCPKG_ROOT is not provided by the environment).
|
|
64
|
+
set(LIBTFS_VCPKG_BASELINE "11bbc873e00e9e58d4e9dffb30b7a5493a030e0b")
|
|
65
|
+
|
|
66
|
+
string(REGEX REPLACE "^v" "" LIBTFS_VERSION "${DWARFS_WR_TAG}")
|
|
67
|
+
set(LIBTFS_RELEASE_URL "https://github.com/tamatebako/libtfs/releases/download/v${LIBTFS_VERSION}")
|
|
68
|
+
set(LIBTFS_DOWNLOAD_DIR "${DEPS}/downloads/libtfs-${LIBTFS_VERSION}")
|
|
69
|
+
|
|
70
|
+
# ...................................................................
|
|
71
|
+
# Map (OSTYPE, host processor) to the libtfs release platform id
|
|
72
|
+
|
|
73
|
+
string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" __LIBTFS_ARCH)
|
|
74
|
+
if(__LIBTFS_ARCH MATCHES "^(x86_64|amd64)$")
|
|
75
|
+
set(__LIBTFS_ARCH "x86_64")
|
|
76
|
+
elseif(__LIBTFS_ARCH MATCHES "^(aarch64|arm64)$")
|
|
77
|
+
set(__LIBTFS_ARCH "arm64")
|
|
78
|
+
else()
|
|
79
|
+
message(FATAL_ERROR "Unsupported host processor '${CMAKE_HOST_SYSTEM_PROCESSOR}' for prebuilt libtfs")
|
|
80
|
+
endif()
|
|
81
|
+
|
|
82
|
+
if(IS_GNU)
|
|
83
|
+
set(LIBTFS_PLATFORM "linux-gnu-${__LIBTFS_ARCH}")
|
|
84
|
+
elseif(IS_MUSL)
|
|
85
|
+
if(NOT __LIBTFS_ARCH STREQUAL "x86_64")
|
|
86
|
+
message(FATAL_ERROR "No prebuilt libtfs package for linux-musl-${__LIBTFS_ARCH}; use -DDWARFS_PRELOAD=OFF (source build)")
|
|
87
|
+
endif()
|
|
88
|
+
set(LIBTFS_PLATFORM "linux-musl-${__LIBTFS_ARCH}")
|
|
89
|
+
elseif(IS_DARWIN)
|
|
90
|
+
set(LIBTFS_PLATFORM "macos-${__LIBTFS_ARCH}")
|
|
91
|
+
elseif(IS_MSYS)
|
|
92
|
+
set(LIBTFS_PLATFORM "windows-ucrt64")
|
|
93
|
+
else()
|
|
94
|
+
message(FATAL_ERROR "Unsupported platform for prebuilt libtfs (OSTYPE: '${OSTYPE_TXT}')")
|
|
95
|
+
endif()
|
|
96
|
+
|
|
97
|
+
if(IS_MSYS)
|
|
98
|
+
set(LIBTFS_PKG_NAME "libtfs-${LIBTFS_VERSION}-${LIBTFS_PLATFORM}.zip")
|
|
99
|
+
set(LIBTFS_MKDWARFS_NAME "mkdwarfs-${LIBTFS_PLATFORM}.exe")
|
|
100
|
+
set(LIBTFS_MKDWARFS "${DEPS_BIN_DIR}/mkdwarfs.exe")
|
|
101
|
+
else()
|
|
102
|
+
set(LIBTFS_PKG_NAME "libtfs-${LIBTFS_VERSION}-${LIBTFS_PLATFORM}.tar.gz")
|
|
103
|
+
set(LIBTFS_MKDWARFS_NAME "mkdwarfs-${LIBTFS_PLATFORM}")
|
|
104
|
+
set(LIBTFS_MKDWARFS "${DEPS_BIN_DIR}/mkdwarfs")
|
|
105
|
+
endif()
|
|
106
|
+
|
|
107
|
+
# Self-contained transitive static-lib package (libtfs releases >= v0.12.5).
|
|
108
|
+
# When present, consumers need no vcpkg at all on the prebuilt path.
|
|
109
|
+
# Releases built with the deps header contract also ship a curated include/
|
|
110
|
+
# tree (brotli, zstd, lz4, lzma, zlib, bzip2, libzip, xxhash, fmt,
|
|
111
|
+
# flatbuffers, boost filesystem+chrono subset) so consumers can compile
|
|
112
|
+
# against the shipped archives — gem native extensions need e.g.
|
|
113
|
+
# <brotli/encode.h>, which nothing else provides in the prebuilt world.
|
|
114
|
+
set(LIBTFS_DEPS_PKG_NAME "libtfs-deps-${LIBTFS_VERSION}-${LIBTFS_PLATFORM}.tar.gz")
|
|
115
|
+
|
|
116
|
+
set(LIBTFS_INCLUDE_DIR "${DEPS_INCLUDE_DIR}")
|
|
117
|
+
set(LIBTFS_LIB_DIR "${DEPS_LIB_DIR}")
|
|
118
|
+
set(LIBTFS_VCPKG_INSTALLED_DIR "${DEPS}/vcpkg_installed")
|
|
119
|
+
|
|
120
|
+
# ...................................................................
|
|
121
|
+
# Download helper: fetch url to dest, verify against the expected SHA256,
|
|
122
|
+
# fail the configure on any error. Skips the download when dest already
|
|
123
|
+
# matches the expected hash (file(DOWNLOAD EXPECTED_HASH) semantics).
|
|
124
|
+
|
|
125
|
+
function(libtfs_download URL DEST EXPECTED_SHA256 DESCRIPTION)
|
|
126
|
+
message(STATUS "libtfs: fetching ${DESCRIPTION}")
|
|
127
|
+
message(STATUS "libtfs: ${URL}")
|
|
128
|
+
file(DOWNLOAD "${URL}" "${DEST}"
|
|
129
|
+
EXPECTED_HASH "SHA256=${EXPECTED_SHA256}"
|
|
130
|
+
STATUS __DL_STATUS
|
|
131
|
+
SHOW_PROGRESS)
|
|
132
|
+
list(GET __DL_STATUS 0 __DL_CODE)
|
|
133
|
+
list(GET __DL_STATUS 1 __DL_MSG)
|
|
134
|
+
if(NOT __DL_CODE EQUAL 0)
|
|
135
|
+
file(REMOVE "${DEST}")
|
|
136
|
+
message(FATAL_ERROR "libtfs: failed to download ${DESCRIPTION}: ${__DL_MSG}")
|
|
137
|
+
endif()
|
|
138
|
+
message(STATUS "libtfs: SHA256 verified (${EXPECTED_SHA256})")
|
|
139
|
+
endfunction()
|
|
140
|
+
|
|
141
|
+
# ...................................................................
|
|
142
|
+
# Fetch the release SHA256SUMS manifest and pick out the hashes of the
|
|
143
|
+
# two assets this platform needs (libtfs package + mkdwarfs binary)
|
|
144
|
+
|
|
145
|
+
file(MAKE_DIRECTORY "${LIBTFS_DOWNLOAD_DIR}")
|
|
146
|
+
set(LIBTFS_SUMS_FILE "${LIBTFS_DOWNLOAD_DIR}/SHA256SUMS")
|
|
147
|
+
message(STATUS "libtfs: fetching SHA256SUMS for v${LIBTFS_VERSION}")
|
|
148
|
+
file(DOWNLOAD "${LIBTFS_RELEASE_URL}/SHA256SUMS" "${LIBTFS_SUMS_FILE}"
|
|
149
|
+
STATUS __SUMS_STATUS)
|
|
150
|
+
list(GET __SUMS_STATUS 0 __SUMS_CODE)
|
|
151
|
+
list(GET __SUMS_STATUS 1 __SUMS_MSG)
|
|
152
|
+
if(NOT __SUMS_CODE EQUAL 0)
|
|
153
|
+
message(FATAL_ERROR "libtfs: failed to download SHA256SUMS: ${__SUMS_MSG}")
|
|
154
|
+
endif()
|
|
155
|
+
|
|
156
|
+
set(LIBTFS_PKG_HASH "")
|
|
157
|
+
set(LIBTFS_MKDWARFS_HASH "")
|
|
158
|
+
set(LIBTFS_DEPS_HASH "")
|
|
159
|
+
file(STRINGS "${LIBTFS_SUMS_FILE}" __SUMS_LINES)
|
|
160
|
+
foreach(__LINE IN LISTS __SUMS_LINES)
|
|
161
|
+
# Note: CMake's regex engine mishandles {64} interval repetition, so the
|
|
162
|
+
# hash is matched with + and its length checked explicitly.
|
|
163
|
+
if(__LINE MATCHES "^([0-9a-f]+) (.+)$")
|
|
164
|
+
string(LENGTH "${CMAKE_MATCH_1}" __HASH_LEN)
|
|
165
|
+
if(__HASH_LEN EQUAL 64 AND CMAKE_MATCH_2 STREQUAL LIBTFS_PKG_NAME)
|
|
166
|
+
set(LIBTFS_PKG_HASH "${CMAKE_MATCH_1}")
|
|
167
|
+
elseif(__HASH_LEN EQUAL 64 AND CMAKE_MATCH_2 STREQUAL LIBTFS_MKDWARFS_NAME)
|
|
168
|
+
set(LIBTFS_MKDWARFS_HASH "${CMAKE_MATCH_1}")
|
|
169
|
+
elseif(__HASH_LEN EQUAL 64 AND CMAKE_MATCH_2 STREQUAL LIBTFS_DEPS_PKG_NAME)
|
|
170
|
+
set(LIBTFS_DEPS_HASH "${CMAKE_MATCH_1}")
|
|
171
|
+
endif()
|
|
172
|
+
endif()
|
|
173
|
+
endforeach()
|
|
174
|
+
|
|
175
|
+
if(NOT LIBTFS_PKG_HASH)
|
|
176
|
+
message(FATAL_ERROR "libtfs: ${LIBTFS_PKG_NAME} not found in the release SHA256SUMS")
|
|
177
|
+
endif()
|
|
178
|
+
if(NOT LIBTFS_MKDWARFS_HASH)
|
|
179
|
+
message(FATAL_ERROR "libtfs: ${LIBTFS_MKDWARFS_NAME} not found in the release SHA256SUMS")
|
|
180
|
+
endif()
|
|
181
|
+
|
|
182
|
+
# The self-contained deps package exists in releases >= v0.12.5; older tags
|
|
183
|
+
# fall back to the vcpkg manifest path for transitive deps.
|
|
184
|
+
if(LIBTFS_DEPS_HASH)
|
|
185
|
+
set(LIBTFS_DEPS_AVAILABLE ON)
|
|
186
|
+
message(STATUS "libtfs: self-contained deps package available (${LIBTFS_DEPS_PKG_NAME}) — no vcpkg needed")
|
|
187
|
+
else()
|
|
188
|
+
set(LIBTFS_DEPS_AVAILABLE OFF)
|
|
189
|
+
message(STATUS "libtfs: no self-contained deps package in this release — falling back to vcpkg for transitive deps")
|
|
190
|
+
endif()
|
|
191
|
+
|
|
192
|
+
# ...................................................................
|
|
193
|
+
# mkdwarfs comes from the prebuilt release set in BOTH modes
|
|
194
|
+
# (the press pipeline runs ${DEPS}/bin/mkdwarfs)
|
|
195
|
+
|
|
196
|
+
file(MAKE_DIRECTORY "${DEPS_BIN_DIR}")
|
|
197
|
+
libtfs_download("${LIBTFS_RELEASE_URL}/${LIBTFS_MKDWARFS_NAME}"
|
|
198
|
+
"${LIBTFS_MKDWARFS}" "${LIBTFS_MKDWARFS_HASH}"
|
|
199
|
+
"prebuilt mkdwarfs (${LIBTFS_MKDWARFS_NAME})")
|
|
200
|
+
if(NOT IS_MSYS)
|
|
201
|
+
file(CHMOD "${LIBTFS_MKDWARFS}"
|
|
202
|
+
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
203
|
+
GROUP_READ GROUP_EXECUTE
|
|
204
|
+
WORLD_READ WORLD_EXECUTE)
|
|
205
|
+
endif()
|
|
206
|
+
|
|
207
|
+
# ...................................................................
|
|
208
|
+
# vcpkg bootstrap — only when actually needed:
|
|
209
|
+
# - source fallback (DWARFS_PRELOAD=OFF): always
|
|
210
|
+
# - prebuilt mode: only when the self-contained deps package is absent
|
|
211
|
+
# (older tags); with libtfs-deps there is no vcpkg in the loop at all.
|
|
212
|
+
|
|
213
|
+
if(NOT DWARFS_PRELOAD OR NOT LIBTFS_DEPS_AVAILABLE)
|
|
214
|
+
|
|
215
|
+
if(DEFINED ENV{VCPKG_ROOT} AND EXISTS "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
|
|
216
|
+
set(VCPKG_ROOT "$ENV{VCPKG_ROOT}")
|
|
217
|
+
message(STATUS "libtfs: using VCPKG_ROOT from environment: ${VCPKG_ROOT}")
|
|
218
|
+
else()
|
|
219
|
+
set(VCPKG_ROOT "${DEPS}/vcpkg")
|
|
220
|
+
if(NOT EXISTS "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
|
|
221
|
+
message(STATUS "libtfs: bootstrapping vcpkg at ${VCPKG_ROOT} (baseline ${LIBTFS_VCPKG_BASELINE})")
|
|
222
|
+
find_package(Git REQUIRED)
|
|
223
|
+
file(MAKE_DIRECTORY "${VCPKG_ROOT}")
|
|
224
|
+
# NB: multiple COMMANDs in one execute_process run concurrently as a
|
|
225
|
+
# pipeline, so the git steps run as separate sequential calls.
|
|
226
|
+
execute_process(
|
|
227
|
+
COMMAND ${GIT_EXECUTABLE} init
|
|
228
|
+
WORKING_DIRECTORY "${VCPKG_ROOT}"
|
|
229
|
+
RESULT_VARIABLE __VCPKG_CLONE_RES
|
|
230
|
+
)
|
|
231
|
+
if(__VCPKG_CLONE_RES EQUAL 0)
|
|
232
|
+
execute_process(
|
|
233
|
+
COMMAND ${GIT_EXECUTABLE} remote add origin https://github.com/microsoft/vcpkg.git
|
|
234
|
+
WORKING_DIRECTORY "${VCPKG_ROOT}"
|
|
235
|
+
RESULT_VARIABLE __VCPKG_CLONE_RES
|
|
236
|
+
)
|
|
237
|
+
endif()
|
|
238
|
+
if(__VCPKG_CLONE_RES EQUAL 0)
|
|
239
|
+
execute_process(
|
|
240
|
+
COMMAND ${GIT_EXECUTABLE} fetch --depth 1 origin ${LIBTFS_VCPKG_BASELINE}
|
|
241
|
+
WORKING_DIRECTORY "${VCPKG_ROOT}"
|
|
242
|
+
RESULT_VARIABLE __VCPKG_CLONE_RES
|
|
243
|
+
)
|
|
244
|
+
endif()
|
|
245
|
+
if(__VCPKG_CLONE_RES EQUAL 0)
|
|
246
|
+
execute_process(
|
|
247
|
+
COMMAND ${GIT_EXECUTABLE} checkout -q FETCH_HEAD
|
|
248
|
+
WORKING_DIRECTORY "${VCPKG_ROOT}"
|
|
249
|
+
RESULT_VARIABLE __VCPKG_CLONE_RES
|
|
250
|
+
)
|
|
251
|
+
endif()
|
|
252
|
+
if(NOT __VCPKG_CLONE_RES EQUAL 0)
|
|
253
|
+
file(REMOVE_RECURSE "${VCPKG_ROOT}")
|
|
254
|
+
message(FATAL_ERROR "libtfs: failed to clone vcpkg at baseline ${LIBTFS_VCPKG_BASELINE}")
|
|
255
|
+
endif()
|
|
256
|
+
endif()
|
|
257
|
+
endif()
|
|
258
|
+
|
|
259
|
+
if(WIN32)
|
|
260
|
+
set(__VCPKG_EXE "${VCPKG_ROOT}/vcpkg.exe")
|
|
261
|
+
set(__VCPKG_BOOTSTRAP cmd /c "${VCPKG_ROOT}/bootstrap-vcpkg.bat" -disableMetrics)
|
|
262
|
+
else()
|
|
263
|
+
set(__VCPKG_EXE "${VCPKG_ROOT}/vcpkg")
|
|
264
|
+
set(__VCPKG_BOOTSTRAP "${VCPKG_ROOT}/bootstrap-vcpkg.sh" -disableMetrics)
|
|
265
|
+
endif()
|
|
266
|
+
|
|
267
|
+
if(NOT EXISTS "${__VCPKG_EXE}")
|
|
268
|
+
message(STATUS "libtfs: running vcpkg bootstrap")
|
|
269
|
+
execute_process(
|
|
270
|
+
COMMAND ${__VCPKG_BOOTSTRAP}
|
|
271
|
+
WORKING_DIRECTORY "${VCPKG_ROOT}"
|
|
272
|
+
RESULT_VARIABLE __VCPKG_BOOT_RES
|
|
273
|
+
)
|
|
274
|
+
if(NOT __VCPKG_BOOT_RES EQUAL 0 OR NOT EXISTS "${__VCPKG_EXE}")
|
|
275
|
+
message(FATAL_ERROR "libtfs: vcpkg bootstrap failed")
|
|
276
|
+
endif()
|
|
277
|
+
endif()
|
|
278
|
+
|
|
279
|
+
endif()
|
|
280
|
+
|
|
281
|
+
if(IS_MSYS)
|
|
282
|
+
set(LIBTFS_VCPKG_TRIPLET "x64-mingw-static")
|
|
283
|
+
set(__LIBTFS_VCPKG_TRIPLET_ARGS "--triplet" "x64-mingw-static")
|
|
284
|
+
set(LIBTFS_VCPKG_EP_TRIPLET_ARG "-DVCPKG_TARGET_TRIPLET=x64-mingw-static")
|
|
285
|
+
else()
|
|
286
|
+
# vcpkg default-host-triplet detection (matches the libtfs release builds)
|
|
287
|
+
set(LIBTFS_VCPKG_TRIPLET "")
|
|
288
|
+
set(__LIBTFS_VCPKG_TRIPLET_ARGS "")
|
|
289
|
+
set(LIBTFS_VCPKG_EP_TRIPLET_ARG "")
|
|
290
|
+
endif()
|
|
291
|
+
|
|
292
|
+
# ...................................................................
|
|
293
|
+
if(DWARFS_PRELOAD)
|
|
294
|
+
# ...................................................................
|
|
295
|
+
# Prebuilt mode: download, verify and deploy the libtfs package
|
|
296
|
+
|
|
297
|
+
if(IS_MSYS)
|
|
298
|
+
message(WARNING "libtfs: the prebuilt ${LIBTFS_PLATFORM} package is modern-API-only; "
|
|
299
|
+
"the legacy tebako API that tebako links requires -DDWARFS_PRELOAD=OFF (source build)")
|
|
300
|
+
endif()
|
|
301
|
+
|
|
302
|
+
libtfs_download("${LIBTFS_RELEASE_URL}/${LIBTFS_PKG_NAME}"
|
|
303
|
+
"${LIBTFS_DOWNLOAD_DIR}/${LIBTFS_PKG_NAME}" "${LIBTFS_PKG_HASH}"
|
|
304
|
+
"prebuilt libtfs package (${LIBTFS_PKG_NAME})")
|
|
305
|
+
|
|
306
|
+
set(__LIBTFS_EXTRACT_DIR "${LIBTFS_DOWNLOAD_DIR}/extract-${LIBTFS_PLATFORM}")
|
|
307
|
+
file(REMOVE_RECURSE "${__LIBTFS_EXTRACT_DIR}")
|
|
308
|
+
file(MAKE_DIRECTORY "${__LIBTFS_EXTRACT_DIR}")
|
|
309
|
+
file(ARCHIVE_EXTRACT INPUT "${LIBTFS_DOWNLOAD_DIR}/${LIBTFS_PKG_NAME}"
|
|
310
|
+
DESTINATION "${__LIBTFS_EXTRACT_DIR}")
|
|
311
|
+
|
|
312
|
+
# Deploy headers and static libraries into deps/. The bundled CMake package
|
|
313
|
+
# config (lib/cmake/libtfs) is intentionally NOT deployed: it does
|
|
314
|
+
# find_dependency(dwarfs) + find_dependency(libzip) and is only usable with
|
|
315
|
+
# a vcpkg prefix; tebako consumes the artifacts via DEPS_INCLUDE_DIR /
|
|
316
|
+
# DEPS_LIB_DIR and its own static link lists.
|
|
317
|
+
file(COPY "${__LIBTFS_EXTRACT_DIR}/include/" DESTINATION "${LIBTFS_INCLUDE_DIR}")
|
|
318
|
+
file(GLOB __LIBTFS_LIBS "${__LIBTFS_EXTRACT_DIR}/lib/*.a" "${__LIBTFS_EXTRACT_DIR}/lib/*.lib")
|
|
319
|
+
if(NOT __LIBTFS_LIBS)
|
|
320
|
+
message(FATAL_ERROR "libtfs: prebuilt package contains no static libraries")
|
|
321
|
+
endif()
|
|
322
|
+
file(COPY ${__LIBTFS_LIBS} DESTINATION "${LIBTFS_LIB_DIR}")
|
|
323
|
+
foreach(__LIB IN LISTS __LIBTFS_LIBS)
|
|
324
|
+
message(STATUS "libtfs: deployed ${__LIB}")
|
|
325
|
+
endforeach()
|
|
326
|
+
|
|
327
|
+
# ...................................................................
|
|
328
|
+
# Transitive dependencies (prebuilt mode)
|
|
329
|
+
# Preferred: the self-contained libtfs-deps package (libtfs releases >=
|
|
330
|
+
# v0.12.5) — download, verify, deploy; no vcpkg in the loop.
|
|
331
|
+
# Fallback (older tags): resolve with vcpkg using libtfs' own manifest at
|
|
332
|
+
# the pinned tag.
|
|
333
|
+
|
|
334
|
+
if(LIBTFS_DEPS_AVAILABLE)
|
|
335
|
+
|
|
336
|
+
libtfs_download("${LIBTFS_RELEASE_URL}/${LIBTFS_DEPS_PKG_NAME}"
|
|
337
|
+
"${LIBTFS_DOWNLOAD_DIR}/${LIBTFS_DEPS_PKG_NAME}" "${LIBTFS_DEPS_HASH}"
|
|
338
|
+
"libtfs transitive deps package (${LIBTFS_DEPS_PKG_NAME})")
|
|
339
|
+
|
|
340
|
+
if(NOT LIBTFS_VCPKG_TRIPLET)
|
|
341
|
+
if(IS_DARWIN)
|
|
342
|
+
set(LIBTFS_VCPKG_TRIPLET "${__LIBTFS_ARCH}-osx")
|
|
343
|
+
elseif(IS_GNU OR IS_MUSL)
|
|
344
|
+
set(LIBTFS_VCPKG_TRIPLET "${__LIBTFS_ARCH}-linux")
|
|
345
|
+
endif()
|
|
346
|
+
endif()
|
|
347
|
+
|
|
348
|
+
set(__LIBTFS_DEPS_EXTRACT_DIR "${LIBTFS_DOWNLOAD_DIR}/extract-deps-${LIBTFS_PLATFORM}")
|
|
349
|
+
file(REMOVE_RECURSE "${__LIBTFS_DEPS_EXTRACT_DIR}")
|
|
350
|
+
file(MAKE_DIRECTORY "${__LIBTFS_DEPS_EXTRACT_DIR}")
|
|
351
|
+
file(ARCHIVE_EXTRACT INPUT "${LIBTFS_DOWNLOAD_DIR}/${LIBTFS_DEPS_PKG_NAME}"
|
|
352
|
+
DESTINATION "${__LIBTFS_DEPS_EXTRACT_DIR}")
|
|
353
|
+
|
|
354
|
+
# Deploy into the triplet-shaped install dir the link lists consume.
|
|
355
|
+
# The whole-tree copy also restores the vcpkg layout — lib/, share/ and,
|
|
356
|
+
# for releases built with the deps header contract, include/ — so
|
|
357
|
+
# ${LIBTFS_VCPKG_TRIPLET_DIR}/include carries the curated dep headers.
|
|
358
|
+
file(MAKE_DIRECTORY "${LIBTFS_VCPKG_INSTALLED_DIR}/${LIBTFS_VCPKG_TRIPLET}")
|
|
359
|
+
file(COPY "${__LIBTFS_DEPS_EXTRACT_DIR}/"
|
|
360
|
+
DESTINATION "${LIBTFS_VCPKG_INSTALLED_DIR}/${LIBTFS_VCPKG_TRIPLET}")
|
|
361
|
+
file(GLOB __LIBTFS_DEPS_LIBS "${LIBTFS_VCPKG_INSTALLED_DIR}/${LIBTFS_VCPKG_TRIPLET}/lib/*.a")
|
|
362
|
+
if(NOT __LIBTFS_DEPS_LIBS)
|
|
363
|
+
message(FATAL_ERROR "libtfs: deps package contains no static libraries")
|
|
364
|
+
endif()
|
|
365
|
+
message(STATUS "libtfs: deployed ${LIBTFS_DEPS_PKG_NAME} to ${LIBTFS_VCPKG_INSTALLED_DIR}/${LIBTFS_VCPKG_TRIPLET}")
|
|
366
|
+
|
|
367
|
+
# Also deploy the curated dep headers into DEPS_INCLUDE_DIR, the include
|
|
368
|
+
# root the ruby build already carries as -I (RUBY_C_FLAGS) and that is
|
|
369
|
+
# baked into rbconfig — mkmf-driven gem native extensions (e.g. the
|
|
370
|
+
# brotli gem including <brotli/encode.h>) compile against these headers
|
|
371
|
+
# when the packaged build runs gem install. The check keys on the
|
|
372
|
+
# extracted package itself (not on possibly stale state in the triplet
|
|
373
|
+
# dir): older deps packages without an include/ tree keep the previous
|
|
374
|
+
# behavior (link-only self-contained).
|
|
375
|
+
if(EXISTS "${__LIBTFS_DEPS_EXTRACT_DIR}/include")
|
|
376
|
+
file(COPY "${__LIBTFS_DEPS_EXTRACT_DIR}/include/" DESTINATION "${LIBTFS_INCLUDE_DIR}")
|
|
377
|
+
message(STATUS "libtfs: deployed deps package headers to ${LIBTFS_INCLUDE_DIR}")
|
|
378
|
+
else()
|
|
379
|
+
message(WARNING "libtfs: deps package carries no include/ tree; "
|
|
380
|
+
"native gem extensions wrapping shipped codecs (brotli, zstd, ...) will not compile")
|
|
381
|
+
endif()
|
|
382
|
+
|
|
383
|
+
else()
|
|
384
|
+
|
|
385
|
+
set(LIBTFS_MANIFEST_DIR "${DEPS_SRC_DIR}/libtfs-manifest")
|
|
386
|
+
find_package(Git REQUIRED)
|
|
387
|
+
if(EXISTS "${LIBTFS_MANIFEST_DIR}/.git")
|
|
388
|
+
execute_process(
|
|
389
|
+
COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match HEAD
|
|
390
|
+
WORKING_DIRECTORY "${LIBTFS_MANIFEST_DIR}"
|
|
391
|
+
RESULT_VARIABLE __MANIFEST_TAG_RES
|
|
392
|
+
OUTPUT_VARIABLE __MANIFEST_TAG
|
|
393
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
394
|
+
ERROR_QUIET
|
|
395
|
+
)
|
|
396
|
+
if(NOT __MANIFEST_TAG_RES EQUAL 0 OR NOT "${__MANIFEST_TAG}" STREQUAL "${DWARFS_WR_TAG}")
|
|
397
|
+
message(STATUS "libtfs: manifest checkout is at '${__MANIFEST_TAG}', need '${DWARFS_WR_TAG}'; refreshing")
|
|
398
|
+
file(REMOVE_RECURSE "${LIBTFS_MANIFEST_DIR}")
|
|
399
|
+
endif()
|
|
400
|
+
endif()
|
|
401
|
+
if(NOT EXISTS "${LIBTFS_MANIFEST_DIR}/.git")
|
|
402
|
+
message(STATUS "libtfs: fetching vcpkg manifest from tamatebako/libtfs @ ${DWARFS_WR_TAG}")
|
|
403
|
+
execute_process(
|
|
404
|
+
COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch ${DWARFS_WR_TAG}
|
|
405
|
+
https://github.com/tamatebako/libtfs.git "${LIBTFS_MANIFEST_DIR}"
|
|
406
|
+
RESULT_VARIABLE __MANIFEST_CLONE_RES
|
|
407
|
+
)
|
|
408
|
+
if(NOT __MANIFEST_CLONE_RES EQUAL 0)
|
|
409
|
+
message(FATAL_ERROR "libtfs: failed to clone tamatebako/libtfs @ ${DWARFS_WR_TAG} (vcpkg manifest source)")
|
|
410
|
+
endif()
|
|
411
|
+
endif()
|
|
412
|
+
|
|
413
|
+
message(STATUS "libtfs: resolving transitive dependencies with vcpkg (this can take a while on a cold cache)")
|
|
414
|
+
execute_process(
|
|
415
|
+
COMMAND ${CMAKE_COMMAND} -E env VCPKG_DISABLE_METRICS=1
|
|
416
|
+
"${__VCPKG_EXE}" install
|
|
417
|
+
--x-manifest-root=${LIBTFS_MANIFEST_DIR}
|
|
418
|
+
--x-install-root=${LIBTFS_VCPKG_INSTALLED_DIR}
|
|
419
|
+
${__LIBTFS_VCPKG_TRIPLET_ARGS}
|
|
420
|
+
RESULT_VARIABLE __VCPKG_INSTALL_RES
|
|
421
|
+
)
|
|
422
|
+
if(NOT __VCPKG_INSTALL_RES EQUAL 0)
|
|
423
|
+
message(FATAL_ERROR "libtfs: vcpkg install of transitive dependencies failed")
|
|
424
|
+
endif()
|
|
425
|
+
|
|
426
|
+
endif()
|
|
427
|
+
|
|
428
|
+
endif(DWARFS_PRELOAD)
|
|
429
|
+
|
|
430
|
+
# ...................................................................
|
|
431
|
+
# Detect the vcpkg triplet directory (transitive static-lib location).
|
|
432
|
+
# There is exactly one triplet dir per tebako build; 'vcpkg' is vcpkg's
|
|
433
|
+
# own bookkeeping subdirectory of the install root.
|
|
434
|
+
|
|
435
|
+
if(NOT LIBTFS_VCPKG_TRIPLET)
|
|
436
|
+
file(GLOB __TRIPLET_DIRS LIST_DIRECTORIES true "${LIBTFS_VCPKG_INSTALLED_DIR}/*")
|
|
437
|
+
foreach(__DIR IN LISTS __TRIPLET_DIRS)
|
|
438
|
+
get_filename_component(__NAME "${__DIR}" NAME)
|
|
439
|
+
if(NOT __NAME STREQUAL "vcpkg")
|
|
440
|
+
set(LIBTFS_VCPKG_TRIPLET "${__NAME}")
|
|
441
|
+
endif()
|
|
442
|
+
endforeach()
|
|
443
|
+
endif()
|
|
444
|
+
if(NOT LIBTFS_VCPKG_TRIPLET)
|
|
445
|
+
# Source build on a cold tree: the triplet dir only appears when vcpkg
|
|
446
|
+
# installs during the libtfs build, so compute vcpkg's default host
|
|
447
|
+
# triplet the way the libtfs release builds do.
|
|
448
|
+
if(IS_DARWIN)
|
|
449
|
+
set(LIBTFS_VCPKG_TRIPLET "${__LIBTFS_ARCH}-osx")
|
|
450
|
+
elseif(IS_GNU OR IS_MUSL)
|
|
451
|
+
set(LIBTFS_VCPKG_TRIPLET "${__LIBTFS_ARCH}-linux")
|
|
452
|
+
endif()
|
|
453
|
+
endif()
|
|
454
|
+
if(LIBTFS_VCPKG_TRIPLET)
|
|
455
|
+
set(LIBTFS_VCPKG_TRIPLET_DIR "${LIBTFS_VCPKG_INSTALLED_DIR}/${LIBTFS_VCPKG_TRIPLET}")
|
|
456
|
+
endif()
|
data/common.env
CHANGED