tebako 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/CMakeLists.txt +694 -0
  3. data/Gemfile +35 -0
  4. data/README.adoc +389 -0
  5. data/Rakefile +33 -0
  6. data/bin/console +15 -0
  7. data/bin/setup +8 -0
  8. data/cmake/copy_dir.cmake +29 -0
  9. data/cmake/def_tty_colours.cmake +19 -0
  10. data/common.env +6 -0
  11. data/exe/tebako +31 -0
  12. data/include/tebako/tebako-fs.h +40 -0
  13. data/include/tebako/tebako-main.h +40 -0
  14. data/lib/cli.rb +28 -0
  15. data/lib/tebako/cli.rb +137 -0
  16. data/lib/tebako/cli_helpers.rb +147 -0
  17. data/lib/tebako/error.rb +39 -0
  18. data/lib/tebako/packager/pass1.rb +155 -0
  19. data/lib/tebako/packager/pass2.rb +374 -0
  20. data/lib/tebako/packager.rb +210 -0
  21. data/lib/tebako/version.rb +30 -0
  22. data/resources/tebako-fs.cpp.in +37 -0
  23. data/resources/tebako-version.h.in +37 -0
  24. data/src/tebako-main.cpp +188 -0
  25. data/tebako.gemspec +63 -0
  26. data/tests/scripts/cross-tests.sh +34 -0
  27. data/tests/scripts/functional-tests.sh +335 -0
  28. data/tests/test-00/test.rb +4 -0
  29. data/tests/test-01/tebako-test-run.rb +5 -0
  30. data/tests/test-09/tebako-test-0.0.1.gem +0 -0
  31. data/tests/test-11/bin/tebako-test-run.rb +10 -0
  32. data/tests/test-11/lib/tebako-test.rb +20 -0
  33. data/tests/test-11/tebako-test.gemspec +15 -0
  34. data/tests/test-12/tebako-test-a.gemspec +15 -0
  35. data/tests/test-12/tebako-test-b.gemspec +15 -0
  36. data/tests/test-13/bin/tebako-test-run.rb +10 -0
  37. data/tests/test-13/lib/tebako-test.rb +20 -0
  38. data/tests/test-13/tebako-test.gemspec +15 -0
  39. data/tests/test-15/Gemfile +8 -0
  40. data/tests/test-15/Rakefile +4 -0
  41. data/tests/test-15/bin/tebako-test-run.rb +10 -0
  42. data/tests/test-15/lib/tebako/bundle/test/version.rb +9 -0
  43. data/tests/test-15/lib/tebako/bundle/test.rb +29 -0
  44. data/tests/test-15/tebako-bundle-test.gemspec +30 -0
  45. data/tests/test-16/Gemfile +8 -0
  46. data/tests/test-16/Rakefile +4 -0
  47. data/tests/test-16/bin/tebako-test-run.rb +10 -0
  48. data/tests/test-16/lib/tebako/bundle/test/version.rb +9 -0
  49. data/tests/test-16/lib/tebako/bundle/test.rb +29 -0
  50. data/tests/test-16/tebako-bundle-test.gemspec +24 -0
  51. data/tests/test-18/Gemfile +5 -0
  52. data/tests/test-18/tebako-test-run.rb +12 -0
  53. data/tests/test-19/Gemfile +6 -0
  54. data/tests/test-19/tebako-test-run.rb +11 -0
  55. data/tests-2/fixtures/gems-bundler/Gemfile +4 -0
  56. data/tests-2/fixtures/gems-bundler/gems-bundler.rb +34 -0
  57. data/tests-2/fixtures/gems-byebug/Gemfile +5 -0
  58. data/tests-2/fixtures/gems-byebug/gems-byebug.rb +31 -0
  59. data/tests-2/fixtures/gems-expressir/Gemfile +7 -0
  60. data/tests-2/fixtures/gems-expressir/gems-expressir.rb +33 -0
  61. data/tests-2/fixtures/gems-libmspack/Gemfile +5 -0
  62. data/tests-2/fixtures/gems-libmspack/gems-libmspack.rb +91 -0
  63. data/tests-2/fixtures/gems-sassc/Gemfile +6 -0
  64. data/tests-2/fixtures/gems-sassc/base_style/all.scss +1 -0
  65. data/tests-2/fixtures/gems-sassc/base_style/reset.scss +100 -0
  66. data/tests-2/fixtures/gems-sassc/gems-sassc.rb +129 -0
  67. data/tests-2/fixtures/gems-seven-zip/Gemfile +7 -0
  68. data/tests-2/fixtures/gems-seven-zip/gems-seven-zip.rb +53 -0
  69. data/tests-2/fixtures/launcher-coreincl/launcher-coreincl.rb +29 -0
  70. data/tests-2/fixtures/launcher-package/launcher-package.rb +29 -0
  71. data/tests-2/fixtures/launcher-pwd/launcher-pwd.rb +28 -0
  72. data/tests-2/fixtures/launcher-stdinredir/input.txt +1 -0
  73. data/tests-2/fixtures/launcher-stdinredir/launcher-stdinredir.rb +31 -0
  74. data/tests-2/fixtures/launcher-stdoutredir/launcher-stdoutredir.rb +28 -0
  75. data/tests-2/fixtures/patches-dir/level-1/level-2/file-1.txt +1 -0
  76. data/tests-2/fixtures/patches-dir/level-1/level-2/file-2.txt +1 -0
  77. data/tests-2/fixtures/patches-dir/level-1/level-2/file-3.txt +1 -0
  78. data/tests-2/fixtures/patches-dir/patches-dir.rb +154 -0
  79. data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-1.txt +1 -0
  80. data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-2.txt +2 -0
  81. data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-3.txt +1 -0
  82. data/tests-2/fixtures/patches-io-and-file/level-1/link-3 +1 -0
  83. data/tests-2/fixtures/patches-io-and-file/patches-io-and-file.rb +87 -0
  84. data/tests-2/fixtures/patches-main/patches-main.rb +6 -0
  85. data/tests-2/tebako-test.rb +312 -0
  86. metadata +170 -0
data/CMakeLists.txt ADDED
@@ -0,0 +1,694 @@
1
+ # Copyright (c) 2021-2023 [Ribose Inc](https://www.ribose.com).
2
+ # All rights reserved.
3
+ # This file is a part of tebako
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions
7
+ # are met:
8
+ # 1. Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
18
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ # POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ cmake_minimum_required (VERSION 3.20)
27
+ # Version 3.20 for cmake_path
28
+
29
+ # For project( ... VERSION ... )
30
+ cmake_policy(SET CMP0048 NEW)
31
+ # DOWNLOAD_EXTRACT_TIMESTAMP option default = true
32
+ if(${CMAKE_VERSION} VERSION_GREATER "3.23.10")
33
+ cmake_policy(SET CMP0135 NEW)
34
+ endif()
35
+
36
+ include(${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake-scripts/version.cmake)
37
+ determine_version("${CMAKE_CURRENT_SOURCE_DIR}" TEBAKO)
38
+
39
+ project(tebako_packager VERSION ${TEBAKO_VERSION})
40
+
41
+ execute_process(
42
+ COMMAND pwd
43
+ RESULT_VARIABLE PWD_RES
44
+ OUTPUT_VARIABLE FS_CURRENT_RAW
45
+ OUTPUT_STRIP_TRAILING_WHITESPACE
46
+ )
47
+
48
+ if(NOT (PWD_RES EQUAL 0))
49
+ message(FATAL_ERROR "Could not determine current folder")
50
+ endif()
51
+
52
+ if (MINGW)
53
+ execute_process(
54
+ COMMAND "cygpath" "-w" ${FS_CURRENT_RAW}
55
+ RESULT_VARIABLE CYGPATH_RES
56
+ OUTPUT_VARIABLE FS_CURRENT
57
+ OUTPUT_STRIP_TRAILING_WHITESPACE
58
+ )
59
+ if(NOT (CYGPATH_RES EQUAL 0))
60
+ message(FATAL_ERROR "Could not map MSys path to Windows")
61
+ endif()
62
+ else(MINGW)
63
+ set(FS_CURRENT ${FS_CURRENT_RAW})
64
+ endif(MINGW)
65
+
66
+ # External dependencies
67
+ # ---------------------------------------------------------------------------------------------------
68
+ # DwarFS dependencies:
69
+ # ronn binutils-dev libarchive-dev libevent-dev libjemalloc-dev acl-dev \
70
+ # libdouble-conversion-dev libiberty-dev liblz4-dev liblzma-dev libssl-dev \
71
+ # libboost-context-dev libboost-filesystem-dev libboost-program-options-dev \
72
+ # libboost-regex-dev libboost-system-dev libboost-thread-dev \
73
+ # libunwind-dev libdwarf-dev libelf-dev libfmt-dev libfuse3-dev libgoogle-glog-dev \
74
+ # bison flex fuse3 pkg-config libsodium-dev
75
+ # ---------------------------------------------------------------------------------------------------
76
+ # Ruby dependencies:
77
+ # libffi-dev libgdbm-dev libyaml-dev libncurses-dev libreadline-dev
78
+ # ---------------------------------------------------------------------------------------------------
79
+ # For Rails testing only:
80
+ # libsqlite3-dev
81
+ # ---------------------------------------------------------------------------------------------------
82
+
83
+ set(RUBY_DEBUG_BUILD OFF)
84
+
85
+ include(ExternalProject)
86
+ # This is the default that will be overwritten for MacOS and MSys
87
+ set(GNU_BASH "bash")
88
+
89
+ include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/macos-environment.cmake)
90
+ include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/msys-environment.cmake)
91
+ include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/def-external-project.cmake)
92
+
93
+ include(${CMAKE_SOURCE_DIR}/cmake/def_tty_colours.cmake)
94
+
95
+ option(SETUP_MODE "Tebako setup" OFF)
96
+ if(NOT LOG_LEVEL)
97
+ set(LOG_LEVEL "error")
98
+ endif()
99
+
100
+ set(START_WITH_PACKAGED_FILESYSTEM OFF CACHE BOOL "Start workflow from 'packaged filesystem' target!!!" FORCE)
101
+
102
+ if (NOT ${SETUP_MODE})
103
+ message("Running tebako press script")
104
+ if (${START_WITH_PACKAGED_FILESYSTEM})
105
+ message("${ColourBoldRed}*** Starting workflow from 'packaged filesystem' target ***${ColourReset}")
106
+ endif(${START_WITH_PACKAGED_FILESYSTEM})
107
+
108
+ if ("-${ROOT}" STREQUAL "-")
109
+ message(FATAL_ERROR "Project ROOT is not specified.")
110
+ endif()
111
+
112
+ if ("-${ENTRANCE}" STREQUAL "-")
113
+ message(FATAL_ERROR "Project ENTRANCE is not specified.")
114
+ endif()
115
+
116
+ cmake_path(SET FS_ENTRANCE NORMALIZE ${ENTRANCE})
117
+
118
+ cmake_path(IS_RELATIVE ROOT IS_RT_RELATIVE)
119
+ if(${IS_RT_RELATIVE})
120
+ cmake_path(SET FS_ROOT NORMALIZE ${FS_CURRENT}/${ROOT})
121
+ message("Relative path to root '${ROOT}' will be extended to '${FS_ROOT}'")
122
+ else()
123
+ cmake_path(SET FS_ROOT NORMALIZE ${ROOT})
124
+ endif()
125
+
126
+ cmake_path(IS_ABSOLUTE FS_ENTRANCE IS_EN_ABSOLUTE)
127
+ if(${IS_EN_ABSOLUTE})
128
+ cmake_path(IS_PREFIX FS_ROOT ${FS_ENTRANCE} IS_FS_EN_PREFIX)
129
+ if(NOT ${IS_FS_EN_PREFIX})
130
+ message(FATAL_ERROR "Entry point ${FS_ENTRANCE} is not in the project root ${FS_ROOT}")
131
+ endif(NOT ${IS_FS_EN_PREFIX})
132
+ set(FS_ENTR_TMP ${FS_ENTRANCE})
133
+ cmake_path(RELATIVE_PATH FS_ENTRANCE BASE_DIRECTORY ${FS_ROOT})
134
+ message("Absolute path to entry point '${FS_ENTR_TMP}' will be reduced '${FS_ENTRANCE}' relative to '${FS_ROOT}'")
135
+ endif(${IS_EN_ABSOLUTE})
136
+
137
+ if ("-${PCKG}" STREQUAL "-")
138
+ set(APP_NAME "${FS_CURRENT}/tebako")
139
+ else()
140
+ cmake_path(IS_RELATIVE PCKG IS_PK_RELATIVE)
141
+ if(${IS_PK_RELATIVE})
142
+ cmake_path(SET APP_NAME NORMALIZE ${FS_CURRENT}/${PCKG})
143
+ else()
144
+ cmake_path(SET APP_NAME NORMALIZE ${PCKG})
145
+ endif()
146
+ endif()
147
+
148
+ message("Packaging ${FS_ROOT} folder with ${FS_ENTRANCE} entry point to ${APP_NAME}")
149
+ else()
150
+ message("Running tebako setup script")
151
+ endif()
152
+
153
+ execute_process(
154
+ COMMAND "${GNU_BASH}"
155
+ "-c"
156
+ "echo \$OSTYPE"
157
+ RESULT_VARIABLE OSTYPE_RES
158
+ OUTPUT_VARIABLE OSTYPE_TXT
159
+ OUTPUT_STRIP_TRAILING_WHITESPACE
160
+ )
161
+ if(OSTYPE_RES EQUAL 0)
162
+ message(STATUS "OSTYPE: '${OSTYPE_TXT}'")
163
+ else(OSTYPE_RES EQUAL 0)
164
+ message(FATAL_ERROR "Failed to detect OSTYPE: ${OSTYPE_TXT}")
165
+ endif(OSTYPE_RES EQUAL 0)
166
+
167
+ set(IS_MUSL OFF)
168
+ set(IS_MSYS OFF)
169
+ set(IS_DARWIN OFF)
170
+ set(RB_W32 OFF)
171
+ set(FORCE_RUBY_PLATFORM "false")
172
+ set(RUBY_WITHOUT_EXT "dbm,win32,win32ole")
173
+ set(RUBY_NAME "ruby")
174
+ set(RUBY_SUFFIX "")
175
+ set(EXE_SUFFIX "")
176
+ set(CMD_SUFFIX "")
177
+ set(BAT_SUFFIX "")
178
+ set(RUBY_MAKEFILE "")
179
+
180
+ if("${OSTYPE_TXT}" MATCHES "^linux-musl.*")
181
+ set(IS_MUSL ON)
182
+ set(FORCE_RUBY_PLATFORM "true")
183
+ elseif("${OSTYPE_TXT}" MATCHES "^msys*")
184
+ set(IS_MSYS ON)
185
+ set(RB_W32 ON)
186
+ set(RUBY_WITHOUT_EXT "dbm,syslog,pty,gdbm,readline")
187
+ set(RUBY_SUFFIX "w")
188
+ set(EXE_SUFFIX ".exe")
189
+ set(CMD_SUFFIX ".cmd")
190
+ set(BAT_SUFFIX ".bat")
191
+ set(RUBY_MAKEFILE "--file=GNUmakefile")
192
+ elseif("${OSTYPE_TXT}" MATCHES "^darwin.*")
193
+ set(IS_DARWIN ON)
194
+ endif()
195
+
196
+ # Various locations for external projects
197
+ set(DEPS ${CMAKE_CURRENT_SOURCE_DIR}/deps CACHE STRING "Dependencies' folder'")
198
+ set(DEPS_INCLUDE_DIR ${DEPS}/include)
199
+ set(DEPS_SRC_DIR ${DEPS}/src)
200
+ set(DEPS_LIB_DIR ${DEPS}/lib)
201
+ set(DEPS_BIN_DIR ${DEPS}/bin)
202
+ set(DEPS_SBIN_DIR ${DEPS}/sbin)
203
+
204
+ set(PATCHES ${CMAKE_CURRENT_SOURCE_DIR}/patches)
205
+ set(LIB ${CMAKE_CURRENT_SOURCE_DIR}/lib/tebako)
206
+
207
+ # Project resources that are used during CMake configuration stage
208
+ set(DATA_RES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
209
+
210
+ # ...................................................................
211
+ # External projects
212
+
213
+ if ("-${RUBY_VER}" STREQUAL "-" OR "-${RUBY_HASH}" STREQUAL "-")
214
+ set(RUBY_VER "3.0.6")
215
+ set(RUBY_HASH "6e6cbd490030d7910c0ff20edefab4294dfcd1046f0f8f47f78b597987ac683e")
216
+ message(STATUS "Using default Ruby version ${RUBY_VER}")
217
+ endif()
218
+
219
+ set(RUBY_NAME ruby)
220
+ set(RUBY_PRJ _ruby_${RUBY_VER})
221
+ set(RUBY_SOURCE_DIR ${DEPS}/src/${RUBY_PRJ})
222
+ set(RUBY_BINARY_DIR ${DEPS}/src/${RUBY_PRJ})
223
+ set(RUBY_STASH_DIR ${DEPS}/stash_${RUBY_VER})
224
+
225
+ string(SUBSTRING ${RUBY_VER} 0 3 RUBY_VER_BASE)
226
+ string(CONCAT RUBY_API_VER ${RUBY_VER_BASE} ".0")
227
+
228
+ # May be overwritten on MSys platform by setup-openssl.cmake
229
+ set(WITH_OPENSSL_BUILD OFF)
230
+
231
+ if(IS_MSYS)
232
+ # ${RUBY_VER} VERSION_LESS "3.0.0"
233
+ include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/setup-openssl.cmake)
234
+ endif(IS_MSYS)
235
+
236
+ if(WITH_OPENSSL_BUILD)
237
+ def_ext_prj_g(OPENSSL "1.1.1s")
238
+ endif(WITH_OPENSSL_BUILD)
239
+
240
+ def_ext_prj_g(INCBIN "348e36b")
241
+ def_ext_prj_g(DWARFS_WR "v0.3.4")
242
+
243
+ if (DEFINED ENV{BUNDLER_VER})
244
+ set(BUNDLER_VER $ENV{BUNDLER_VER})
245
+ set(BUNDLER_ANNOTATION "environment")
246
+ else()
247
+ set(BUNDLER_VER "2.3.22")
248
+ set(BUNDLER_ANNOTATION "default")
249
+ endif()
250
+
251
+ find_library(_LIBNCURSES "libncurses.a")
252
+ if(${_LIBNCURSES} STREQUAL "_LIBNCURSES-NOTFOUND")
253
+ set(WITH_NCURSES_BUILD ON)
254
+ def_ext_prj_t(NCURSES "6.3" "97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059")
255
+ else()
256
+ set(WITH_NCURSES_BUILD OFF)
257
+ endif()
258
+
259
+ message("Configuration summary:")
260
+ message(STATUS "ruby: v${RUBY_VER} at ${RUBY_SOURCE_DIR}")
261
+ message(STATUS "bundler version: ${BUNDLER_VER} (${BUNDLER_ANNOTATION})")
262
+ if(WITH_OPENSSL_BUILD)
263
+ message(STATUS "openssl: building @${OPENSSL_TAG} at ${OPENSSL_SOURCE_DIR}")
264
+ endif(WITH_OPENSSL_BUILD)
265
+
266
+ if(WITH_NCURSES_BUILD)
267
+ message(STATUS "ncurses: building v${NCURSES_VER} at ${NCURSES_SOURCE_DIR}")
268
+ else()
269
+ message(STATUS "ncurses: ${_LIBNCURSES}")
270
+ endif(WITH_NCURSES_BUILD)
271
+ message(STATUS "incbin: @${INCBIN_TAG} at ${INCBIN_SOURCE_DIR}")
272
+ message(STATUS "dwarfs with tebako wrapper: @${DWARFS_WR_TAG} at ${DWARFS_WR_SOURCE_DIR}")
273
+
274
+ # ...................................................................
275
+ # Filesystem locations
276
+
277
+ # DATA_SRC_DIR folder is used to collect all files that need to be packaged
278
+ set(DATA_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/source_filesystem)
279
+ # DATA_PRE_DIR folder is used to build gems that need to be packaged
280
+ set(DATA_PRE_DIR ${CMAKE_CURRENT_BINARY_DIR}/prepare_filesystem)
281
+ # DATA_BIN_DIR folder is used to create packaged filesystem
282
+ set(DATA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/packaged_filesystem)
283
+ # DATA_BIN_FILE is packaged filesystem itself
284
+ set(DATA_BIN_FILE ${DATA_BIN_DIR}/fs.bin)
285
+ # Target binary directory
286
+ set (TBD ${DATA_SRC_DIR}/bin)
287
+ # Target 'local' directory
288
+ set (TLD ${DATA_SRC_DIR}/local)
289
+ # TGD folder is used to install gems
290
+ set (TGD ${DATA_SRC_DIR}/lib/ruby/gems/${RUBY_API_VER})
291
+ # This is actually a constant that shall match libdwarfs-wr TEBAKO_MOUNT_POINT at tebako-common.h
292
+ if(${IS_MSYS})
293
+ set(FS_MOUNT_POINT "A:/__tebako_memfs__")
294
+ else(${IS_MSYS})
295
+ set(FS_MOUNT_POINT "/__tebako_memfs__")
296
+ endif(${IS_MSYS})
297
+
298
+
299
+ message(STATUS "DATA_SRC_DIR: ${DATA_SRC_DIR}")
300
+ message(STATUS "DATA_PRE_DIR: ${DATA_PRE_DIR}")
301
+ message(STATUS "DATA_BIN_DIR: ${DATA_BIN_DIR}")
302
+ message(STATUS "DATA_BIN_FILE: ${DATA_BIN_FILE}")
303
+ message(STATUS "TBD: ${TBD}")
304
+ message(STATUS "TLD: ${TLD}")
305
+ message(STATUS "TGD: ${TGD}")
306
+ message(STATUS "FS_MOUNT_POINT: ${FS_MOUNT_POINT}")
307
+ message(STATUS "Building for Win32 Ruby (RB_W32): ${RB_W32}")
308
+
309
+ # ...................................................................
310
+ # Other options
311
+
312
+ message(STATUS "Force Ruby platform for Gems: ${FORCE_RUBY_PLATFORM}")
313
+ message(STATUS "Not building Ruby extensions: ${RUBY_WITHOUT_EXT}")
314
+
315
+ # ...................................................................
316
+ # incbin
317
+
318
+ ExternalProject_Add(${INCBIN_PRJ}
319
+ PREFIX ${DEPS}
320
+ GIT_REPOSITORY https://github.com/graphitemaster/incbin.git
321
+ GIT_TAG ${INCBIN_TAG}
322
+ CONFIGURE_COMMAND ""
323
+ BUILD_COMMAND ""
324
+ INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INCLUDE_DIR}/incbin
325
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INCBIN_SOURCE_DIR}/incbin.h ${DEPS_INCLUDE_DIR}/incbin
326
+ )
327
+
328
+ # ...................................................................
329
+ # OpenSSL
330
+ if(WITH_OPENSSL_BUILD)
331
+ message(STATUS "Building OpenSSL since Ruby 2.x requires 1.1.x")
332
+ def_ext_prj_g(OPENSSL "OpenSSL_1_1_1s")
333
+
334
+ set(__LIBSSL "${DEPS}/lib/libssl.a")
335
+ set(__LIBCRYPTO "${DEPS}/lib/libcrypto.a")
336
+
337
+ ExternalProject_Add(${OPENSSL_PRJ}
338
+ PREFIX ${DEPS}
339
+ GIT_REPOSITORY "https://github.com/openssl/openssl.git"
340
+ GIT_TAG ${OPENSSL_TAG}
341
+ UPDATE_COMMAND ""
342
+ SOURCE_DIR ${OPENSSL_SOURCE_DIR}
343
+ BINARY_DIR ${OPENSSL_BINARY_DIR}
344
+ CONFIGURE_COMMAND ${GNU_BASH} -c "${OPENSSL_SOURCE_DIR}/config \
345
+ --openssldir=${DEPS} \
346
+ --prefix=${DEPS}"
347
+ BUILD_BYPRODUCTS ${__LIBSSL} ${__LIBCRYPTO}
348
+ )
349
+ endif(WITH_OPENSSL_BUILD)
350
+
351
+ # ...................................................................
352
+ # DwarFS with tebako wrapper
353
+
354
+ # ...................................................................
355
+ # The libraries that are build by DwarFS project
356
+ # libdwarfs libfolly libfsst libxxhash libmetadata_thrift libthrift_light
357
+ # These forward-declarations and BUILD_BYPRODICTS are required to support 'Ninja'
358
+ # Otherwise add_dependencies would be enough for 'Unix makefiles' generator
359
+
360
+ set(__LIBDWARFS_WR "${DEPS_LIB_DIR}/libdwarfs-wr.a")
361
+ set(__LIBDWARFS "${DEPS_LIB_DIR}/libdwarfs.a")
362
+ set(__LIBFOLLY "${DEPS_LIB_DIR}/libfolly.a")
363
+ set(__LIBFSST "${DEPS_LIB_DIR}/libfsst.a")
364
+ set(__LIBT_METADATA "${DEPS_LIB_DIR}/libmetadata_thrift.a")
365
+ set(__LIBT_LIGHT "${DEPS_LIB_DIR}/libthrift_light.a")
366
+ set(__LIBXXHASH "${DEPS_LIB_DIR}/libxxhash.a")
367
+ set(__LIBZSTD "${DEPS_LIB_DIR}/libzstd.a")
368
+ set(__LIBARCHIVE "${DEPS_LIB_DIR}/libarchive.a")
369
+
370
+ ExternalProject_Add(${DWARFS_WR_PRJ}
371
+ PREFIX ${DEPS}
372
+ GIT_REPOSITORY https://github.com/tamatebako/libdwarfs.git
373
+ GIT_TAG ${DWARFS_WR_TAG}
374
+ SOURCE_DIR ${DWARFS_WR_SOURCE_DIR}
375
+ BINARY_DIR ${DWARFS_WR_BINARY_DIR}
376
+ UPDATE_COMMAND ""
377
+ BUILD_COMMAND ${CMAKE_COMMAND} --build ${DWARFS_WR_BINARY_DIR} --parallel 4
378
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DEPS}
379
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
380
+ -DWITH_TESTS:BOOL=OFF
381
+ -DWITH_ASAN:BOOL=OFF
382
+ -DWITH_COVERAGE:BOOL=OFF
383
+ -DTEBAKO_BUILD_SCOPE=MKD
384
+ -DRB_W32=${RB_W32}
385
+ BUILD_BYPRODUCTS ${__LIBDWARFS_WR}
386
+ ${__LIBDWARFS} ${__LIBFSST} ${__LIBFOLLY} ${__LIBT_METADATA}
387
+ ${__LIBT_LIGHT} ${__LIBXXHASH} ${__LIBZSTD} ${__LIBARCHIVE}
388
+ )
389
+ if(WITH_OPENSSL_BUILD)
390
+ add_dependencies(${DWARFS_WR_PRJ} ${OPENSSL_PRJ} )
391
+ endif(WITH_OPENSSL_BUILD)
392
+
393
+ if(WITH_NCURSES_BUILD)
394
+ ExternalProject_Add(${NCURSES_PRJ}
395
+ PREFIX ${DEPS}
396
+ URL https://ftp.gnu.org/pub/gnu/ncurses/ncurses-${NCURSES_VER}.tar.gz
397
+ URL_HASH SHA256=${NCURSES_HASH}
398
+ DOWNLOAD_NO_PROGRESS true
399
+ SOURCE_DIR ${NCURSES_SOURCE_DIR}
400
+ UPDATE_COMMAND ""
401
+ CONFIGURE_COMMAND ${NCURSES_SOURCE_DIR}/configure
402
+ --without-shared
403
+ --without-cxx-shared
404
+ --without-tests
405
+ --prefix=${DEPS}
406
+ --srcdir=${NCURSES_SOURCE_DIR}
407
+ BUILD_COMMAND make
408
+ INSTALL_COMMAND make install
409
+ )
410
+ endif(WITH_NCURSES_BUILD)
411
+
412
+ # ...................................................................
413
+ # Ruby
414
+
415
+ set(RUBY_L_FLAGS "-L${DEPS_LIB_DIR} -L${CMAKE_CURRENT_BINARY_DIR}")
416
+ set(RUBY_C_FLAGS "-pthread -I${DEPS_INCLUDE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}/include")
417
+
418
+ # Shadow
419
+ # https://github.com/deivid-rodriguez/byebug/issues/825
420
+ # (it happens under some conditions though it is hard to explain when)
421
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
422
+ string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -fdeclspec")
423
+ endif()
424
+
425
+ set(C_FLAGS_DEST cppflags)
426
+
427
+ if(IS_DARWIN)
428
+ string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -I${BUILD_BREW_PREFIX}/include -I/opt/openssl@1.1/include -I${BUILD_BREW_PREFIX}/opt/zlib/include")
429
+ string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -L${BUILD_BREW_PREFIX}/lib -L${BUILD_BREW_PREFIX}/opt/openssl@1.1/lib -L${BUILD_BREW_PREFIX}/opt/zlib/lib")
430
+ set(OPENSSL_RUBY_OPTION "--with-openssl-dir=${BUILD_BREW_PREFIX}/opt/openssl@1.1")
431
+ set(C_FLAGS_DEST cflags)
432
+ endif(IS_DARWIN)
433
+
434
+ if(IS_MUSL)
435
+ string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DENABLE_PATH_CHECK=0")
436
+ endif(IS_MUSL)
437
+
438
+ if(RB_W32)
439
+ string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DRB_W32=1")
440
+ endif(RB_W32)
441
+
442
+ message(STATUS "Ruby build ${C_FLAGS_DEST}='${RUBY_C_FLAGS}'")
443
+ message(STATUS "Ruby build LDFLAGS='${RUBY_L_FLAGS}'")
444
+ message(STATUS "Openssl Ruby option='${OPENSSL_RUBY_OPTION}'")
445
+
446
+ ExternalProject_Add(${RUBY_PRJ}
447
+ PREFIX ${DEPS}
448
+ URL https://cache.ruby-lang.org/pub/ruby/${RUBY_VER_BASE}/ruby-${RUBY_VER}.tar.gz
449
+ URL_HASH SHA256=${RUBY_HASH}
450
+ DOWNLOAD_NO_PROGRESS true
451
+ SOURCE_DIR ${RUBY_SOURCE_DIR}
452
+ BUILD_IN_SOURCE true
453
+ PATCH_COMMAND ruby ${LIB}/packager.rb pass1 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${FS_MOUNT_POINT} ${DATA_SRC_DIR} ${RUBY_VER}
454
+ CONFIGURE_COMMAND ${GNU_BASH} -c "${RUBY_SOURCE_DIR}/configure ${OPENSSL_RUBY_OPTION} \
455
+ --enable-bundled-libyaml \
456
+ --without-gmp \
457
+ --disable-dtrace \
458
+ --disable-debug-env \
459
+ --disable-shared \
460
+ --disable-install-doc \
461
+ --with-static-linked-ext \
462
+ --with-out-ext=${RUBY_WITHOUT_EXT} \
463
+ --prefix=${DATA_SRC_DIR} \
464
+ ${C_FLAGS_DEST}=\"${RUBY_C_FLAGS}\" \
465
+ LDFLAGS=\"${RUBY_L_FLAGS}\""
466
+ BUILD_COMMAND make ${RUBY_MAKEFILE}
467
+ INSTALL_COMMAND make ${RUBY_MAKEFILE} install
468
+ COMMAND ruby ${LIB}/packager.rb pass2 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${DEPS_LIB_DIR} ${DATA_SRC_DIR} ${RUBY_STASH_DIR} ${RUBY_VER}
469
+ )
470
+
471
+ add_dependencies(${RUBY_PRJ} ${DWARFS_WR_PRJ})
472
+ if(WITH_NCURSES_BUILD)
473
+ add_dependencies(${RUBY_PRJ} ${NCURSES_PRJ})
474
+ endif(WITH_NCURSES_BUILD)
475
+
476
+ if(WITH_OPENSSL_BUILD)
477
+ add_dependencies(${RUBY_PRJ} ${OPENSSL_PRJ} )
478
+ endif(WITH_OPENSSL_BUILD)
479
+
480
+ if (${SETUP_MODE})
481
+ add_custom_target(setup
482
+ ${CMAKE_COMMAND} -E echo "Tebako setup has completed"
483
+ DEPENDS ${DWARFS_WR_PRJ} ${INCBIN_PRJ} ${RUBY_PRJ}
484
+ )
485
+ else (${SETUP_MODE})
486
+ add_custom_target(setup
487
+ ${CMAKE_COMMAND} -E echo "Tebako setup has been verified"
488
+ DEPENDS ${DWARFS_WR_PRJ} ${INCBIN_PRJ} ${RUBY_PRJ}
489
+ )
490
+
491
+ file(GLOB GEMSPECS LIST_DIRECTORIES false ${FS_ROOT}/*.gemspec)
492
+ file(GLOB GEMFILES LIST_DIRECTORIES false ${FS_ROOT}/Gemfile)
493
+ file(GLOB GEMS LIST_DIRECTORIES false ${FS_ROOT}/*.gem)
494
+
495
+ list(LENGTH GEMSPECS GSLENGTH)
496
+ list(LENGTH GEMFILES GFLENGTH)
497
+ list(LENGTH GEMS GLENGTH)
498
+
499
+ add_custom_target(clean_filesystem
500
+ COMMAND ruby ${LIB}/packager.rb deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR}
501
+ DEPENDS ${RUBY_PRJ}
502
+ )
503
+ if(GSLENGTH GREATER 0)
504
+ if(GSLENGTH GREATER 1)
505
+ message(FATAL_ERROR "Multiple gemspecs detected in ${FS_ROOT}")
506
+ else(GSLENGTH GREATER 1)
507
+ list(GET GEMSPECS 0 GEMSPEC)
508
+ list(LENGTH GEMFILES GFLENGTH)
509
+ if(GFLENGTH GREATER 0)
510
+ # Found xxx.gemspec and Gemfile
511
+ message("Collecting gem from gemspec ${GEMSPEC} and Gemfile")
512
+ set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
513
+ add_custom_target(source_filesystem
514
+ COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
515
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
516
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
517
+ ${TBD}/gem${CMD_SUFFIX} install bundler -v '${BUNDLER_VER}' --source 'https://rubygems.org/' --no-document --install-dir ${TGD}
518
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
519
+ ${TBD}/bundle${CMD_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
520
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
521
+ ${TBD}/bundle${CMD_SUFFIX} install
522
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
523
+ ${TBD}/bundle${CMD_SUFFIX} exec ${TBD}/gem${CMD_SUFFIX} build ${GEMSPEC}
524
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
525
+ ${TBD}/gem${CMD_SUFFIX} install *.gem --verbose --no-document --install-dir ${TGD}
526
+ COMMAND test -f ${DATA_SRC_DIR}${FS_ENTRY_POINT} ||
527
+ (${CMAKE_COMMAND} -E echo "Entry point ${DATA_SRC_DIR}${FS_ENTRY_POINT} does not exist" &&
528
+ ${CMAKE_COMMAND} -E false )
529
+ DEPENDS clean_filesystem
530
+ )
531
+ else(GFLENGTH GREATER 0)
532
+ # Found xxx.gemspec but no Gemfile
533
+ message("Collecting gem from gemspec ${GEMSPEC}")
534
+ set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
535
+ message("Target entry point will be at ${FS_MOUNT_POINT}${FS_ENTRY_POINT}")
536
+ add_custom_target(source_filesystem
537
+ COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
538
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
539
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
540
+ ${TBD}/gem${CMD_SUFFIX} build ${GEMSPEC}
541
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
542
+ ${TBD}/gem${CMD_SUFFIX} install *.gem --verbose --no-document --install-dir ${TGD}
543
+ COMMAND test -f ${DATA_SRC_DIR}${FS_ENTRY_POINT} ||
544
+ (${CMAKE_COMMAND} -E echo "Entry point ${DATA_SRC_DIR}${FS_ENTRY_POINT} does not exist" &&
545
+ ${CMAKE_COMMAND} -E false )
546
+ DEPENDS clean_filesystem
547
+ )
548
+ endif(GFLENGTH GREATER 0)
549
+ endif(GSLENGTH GREATER 1)
550
+ elseif(GFLENGTH GREATER 0)
551
+ # Found Gemfile but no gemspec
552
+ message("Deploying Gemfile")
553
+ set(FS_ENTRY_POINT "/local/${FS_ENTRANCE}")
554
+ message("Target entry point will be at ${FS_MOUNT_POINT}${FS_ENTRY_POINT}")
555
+ add_custom_target(source_filesystem
556
+ COMMAND test -f ${FS_ROOT}/${FS_ENTRANCE} ||
557
+ (${CMAKE_COMMAND} -E echo "Entry point ${FS_ROOT}/${FS_ENTRANCE} does not exist or is not accessible" &&
558
+ ${CMAKE_COMMAND} -E false )
559
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TLD}
560
+ COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${TLD} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
561
+ COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
562
+ ${TBD}/gem${CMD_SUFFIX} install bundler -v '${BUNDLER_VER}'
563
+ --source 'https://rubygems.org/' --no-document --install-dir ${TGD}
564
+ COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
565
+ ${TBD}/bundle${CMD_SUFFIX} config build.ffi --disable-system-libffi
566
+ COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
567
+ ${TBD}/bundle${CMD_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
568
+ COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
569
+ ${TBD}/bundle${CMD_SUFFIX} install --jobs=4
570
+ # COMMAND_EXPAND_LISTS
571
+ # [TODO] Open question - how to deploy a project to source filesystem
572
+ # ruby packer does bundle install --deployment --binstubs
573
+ # [TODO] --jobs=4 probably can be more intellectual
574
+ # COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
575
+ # ${TBD}/bundle lock
576
+ # COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
577
+ # ${TBD}/bundle install --deployment --jobs=4
578
+ DEPENDS clean_filesystem
579
+ )
580
+ elseif(GLENGTH GREATER 0)
581
+ # xxx.gem, no gemspec, no gemfile
582
+ list(GET GEMS 0 GEM)
583
+ if(GLENGTH GREATER 1)
584
+ message(FATAL_ERROR "Multiple gems detected in ${FS_ROOT}")
585
+ else(GLENGTH GREATER 1)
586
+ message("Installing Ruby gem from ${GEM}")
587
+ set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
588
+ message("Target entry point will be at ${FS_MOUNT_POINT}${FS_ENTRY_POINT}")
589
+ add_custom_target(source_filesystem
590
+ COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
591
+ COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
592
+ ${TBD}/gem${CMD_SUFFIX} install ${GEM} --verbose --no-document --install-dir ${TGD}
593
+ COMMAND test -f ${DATA_SRC_DIR}${FS_ENTRY_POINT} ||
594
+ (${CMAKE_COMMAND} -E echo "Entry point ${DATA_SRC_DIR}${FS_ENTRY_POINT} does not exist or is not accessible" &&
595
+ ${CMAKE_COMMAND} -E false )
596
+ DEPENDS clean_filesystem
597
+ )
598
+ endif(GLENGTH GREATER 1)
599
+ else()
600
+ # No gem, no gemspec, no gemfile
601
+ # Simple ruby script
602
+ message("Collecting simple Ruby script from ${FS_ROOT}")
603
+ set(FS_ENTRY_POINT "/local/${FS_ENTRANCE}")
604
+ message("Target entry point will be at ${FS_MOUNT_POINT}${FS_ENTRY_POINT}")
605
+ add_custom_target(source_filesystem
606
+ COMMAND test -f ${FS_ROOT}/${FS_ENTRANCE} ||
607
+ (${CMAKE_COMMAND} -E echo "Entry point ${FS_ROOT}/${FS_ENTRANCE} does not exist or is not accessible" &&
608
+ ${CMAKE_COMMAND} -E false )
609
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TLD}
610
+ COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${TLD} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
611
+ DEPENDS clean_filesystem
612
+ )
613
+ endif()
614
+
615
+ # ...................................................................
616
+ # Packaged filesystem
617
+
618
+ configure_file(
619
+ ${DATA_RES_DIR}/tebako-version.h.in
620
+ ${DEPS_INCLUDE_DIR}/tebako/tebako-version.h
621
+ @ONLY
622
+ )
623
+
624
+ configure_file(
625
+ ${DATA_RES_DIR}/tebako-fs.cpp.in
626
+ ${DEPS_SRC_DIR}/tebako/tebako-fs.cpp
627
+ @ONLY
628
+ )
629
+
630
+ if (${START_WITH_PACKAGED_FILESYSTEM})
631
+ add_custom_target(packaged_filesystem
632
+ COMMAND chmod +x ${DEPS_BIN_DIR}/*
633
+ COMMAND ${DEPS_BIN_DIR}/mkdwarfs -o ${DATA_BIN_FILE} -i ${DATA_SRC_DIR}
634
+ COMMAND ${CMAKE_COMMAND} -E touch ${DEPS_SRC_DIR}/tebako-fs.cpp
635
+ BYPRODUCTS ${DATA_BIN_FILE}
636
+ )
637
+ else(${START_WITH_PACKAGED_FILESYSTEM})
638
+ add_custom_target(packaged_filesystem
639
+ # [TODO] Open question - whether we shall delete ruby binaries from memfs or not
640
+ # For debugging purposes it is very handy to have it here
641
+ #
642
+ COMMAND ${CMAKE_COMMAND} -E rm -rf ${DATA_SRC_DIR}/share ${DATA_SRC_DIR}/include ${DATA_SRC_DIR}/lib/pkgconfig
643
+ ${DATA_SRC_DIR}/bin/bundle${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/bundle
644
+ ${DATA_SRC_DIR}/bin/bundler${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/bundler
645
+ ${DATA_SRC_DIR}/bin/bundle${BAT_SUFFIX} ${DATA_SRC_DIR}/bin/bundler${BAT_SUFFIX}
646
+ ${DATA_SRC_DIR}/bin/erb${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/gem${CMD_SUFFIX}
647
+ ${DATA_SRC_DIR}/bin/irb${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/racc${CMD_SUFFIX}
648
+ ${DATA_SRC_DIR}/bin/racc2y${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/rake${BAT_SUFFIX}
649
+ ${DATA_SRC_DIR}/bin/rake ${DATA_SRC_DIR}/bin/rdoc${CMD_SUFFIX}
650
+ ${DATA_SRC_DIR}/bin/ri${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/y2racc${CMD_SUFFIX}
651
+ ${DATA_SRC_DIR}/bin/ruby${EXE_SUFFIX} ${DATA_SRC_DIR}/bin/ruby${RUBY_SUFFIX}${EXE_SUFFIX}
652
+
653
+ COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.a"
654
+ COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.o"
655
+ COMMAND chmod +x ${DEPS_BIN_DIR}/*
656
+ COMMAND ${DEPS_BIN_DIR}/mkdwarfs -o ${DATA_BIN_FILE} -i ${DATA_SRC_DIR}
657
+ COMMAND ${CMAKE_COMMAND} -E touch ${DEPS_SRC_DIR}/tebako/tebako-fs.cpp
658
+ DEPENDS setup source_filesystem
659
+ BYPRODUCTS ${DATA_BIN_FILE}
660
+ )
661
+ endif (${START_WITH_PACKAGED_FILESYSTEM})
662
+
663
+ set(CMAKE_CXX_FLAGS "${RUBY_C_FLAGS}")
664
+
665
+ add_library(tebako-fs STATIC
666
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/tebako-main.cpp
667
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/tebako/tebako-main.h
668
+ ${DEPS_SRC_DIR}/tebako/tebako-fs.cpp
669
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/tebako/tebako-fs.h
670
+ ${DEPS_INCLUDE_DIR}/tebako/tebako-version.h
671
+ )
672
+
673
+ add_dependencies(tebako-fs ${INCBIN_PRJ} packaged_filesystem)
674
+
675
+ if (${RUBY_VER} VERSION_LESS "3.0.0")
676
+ add_custom_target(patched_ruby
677
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE}
678
+ )
679
+ else()
680
+ add_custom_target(patched_ruby
681
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ruby ${RUBY_MAKEFILE}
682
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE}
683
+ )
684
+ endif()
685
+
686
+ add_dependencies(patched_ruby setup tebako-fs)
687
+
688
+ add_custom_target(tebako ALL
689
+ COMMAND ${CMAKE_COMMAND} -E copy ${RUBY_SOURCE_DIR}/ruby${RUBY_SUFFIX}${EXE_SUFFIX} ${APP_NAME}${EXE_SUFFIX}
690
+ COMMAND ${CMAKE_COMMAND} -E echo "Tebako packaging has completed"
691
+ DEPENDS patched_ruby
692
+ )
693
+
694
+ endif(${SETUP_MODE})