fstd 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. fstd-0.1.0/CMakeLists.txt +392 -0
  2. fstd-0.1.0/LICENSE +21 -0
  3. fstd-0.1.0/MANIFEST.in +25 -0
  4. fstd-0.1.0/PKG-INFO +276 -0
  5. fstd-0.1.0/README.md +260 -0
  6. fstd-0.1.0/cmake_uninstall.cmake.in +26 -0
  7. fstd-0.1.0/fstd/__init__.py +4 -0
  8. fstd-0.1.0/fstd.egg-info/PKG-INFO +276 -0
  9. fstd-0.1.0/fstd.egg-info/SOURCES.txt +80 -0
  10. fstd-0.1.0/fstd.egg-info/dependency_links.txt +1 -0
  11. fstd-0.1.0/fstd.egg-info/not-zip-safe +1 -0
  12. fstd-0.1.0/fstd.egg-info/top_level.txt +1 -0
  13. fstd-0.1.0/lib/include/fstd/common.h +282 -0
  14. fstd-0.1.0/lib/include/fstd/fstdd_compressor.h +90 -0
  15. fstd-0.1.0/lib/include/fstd/fstdd_reader.h +57 -0
  16. fstd-0.1.0/lib/include/fstd/fstdd_writer.h +36 -0
  17. fstd-0.1.0/lib/include/fstd/fstdx_compressor.h +68 -0
  18. fstd-0.1.0/lib/include/fstd/fstdx_reader.h +132 -0
  19. fstd-0.1.0/lib/include/fstd/fstdx_searcher.h +112 -0
  20. fstd-0.1.0/lib/include/fstd/fstdx_writer.h +80 -0
  21. fstd-0.1.0/lib/include/fstd/fstlib_wrapper.h +172 -0
  22. fstd-0.1.0/lib/include/fstd/hash_index.h +262 -0
  23. fstd-0.1.0/lib/include/fstd/logger.h +98 -0
  24. fstd-0.1.0/lib/include/fstd/thread_pool.h +130 -0
  25. fstd-0.1.0/lib/include/fstlib/automaton.h +317 -0
  26. fstd-0.1.0/lib/include/fstlib/build_fst.h +267 -0
  27. fstd-0.1.0/lib/include/fstlib/byte_code.h +245 -0
  28. fstd-0.1.0/lib/include/fstlib/compile.h +85 -0
  29. fstd-0.1.0/lib/include/fstlib/decompile.h +72 -0
  30. fstd-0.1.0/lib/include/fstlib/map.h +189 -0
  31. fstd-0.1.0/lib/include/fstlib/matcher.h +638 -0
  32. fstd-0.1.0/lib/include/fstlib/matcher_utility.h +261 -0
  33. fstd-0.1.0/lib/include/fstlib/minimize.h +162 -0
  34. fstd-0.1.0/lib/include/fstlib/output_traits.h +322 -0
  35. fstd-0.1.0/lib/include/fstlib/set.h +113 -0
  36. fstd-0.1.0/lib/include/fstlib/state_transition.h +204 -0
  37. fstd-0.1.0/lib/include/fstlib/utility.h +225 -0
  38. fstd-0.1.0/lib/include/fstlib/writer.h +491 -0
  39. fstd-0.1.0/lib/src/common.cpp +187 -0
  40. fstd-0.1.0/lib/src/fstdd_compressor.cpp +367 -0
  41. fstd-0.1.0/lib/src/fstdd_reader.cpp +204 -0
  42. fstd-0.1.0/lib/src/fstdd_writer.cpp +97 -0
  43. fstd-0.1.0/lib/src/fstdx_compressor.cpp +324 -0
  44. fstd-0.1.0/lib/src/fstdx_reader.cpp +371 -0
  45. fstd-0.1.0/lib/src/fstdx_searcher.cpp +502 -0
  46. fstd-0.1.0/lib/src/fstdx_writer.cpp +414 -0
  47. fstd-0.1.0/lib/src/fstlib_wrapper.cpp +21 -0
  48. fstd-0.1.0/lib/src/logger.cpp +39 -0
  49. fstd-0.1.0/prior_suffix.json +19 -0
  50. fstd-0.1.0/pyproject.toml +32 -0
  51. fstd-0.1.0/python/CMakeLists.txt +16 -0
  52. fstd-0.1.0/python/fstd_pybind.cpp +247 -0
  53. fstd-0.1.0/setup.cfg +4 -0
  54. fstd-0.1.0/setup.py +67 -0
  55. fstd-0.1.0/src/fstd_cli.h +656 -0
  56. fstd-0.1.0/src/main.cpp +8 -0
  57. fstd-0.1.0/tests/CMakeLists.txt +50 -0
  58. fstd-0.1.0/tests/cache/extract/dict.txt +70809 -0
  59. fstd-0.1.0/tests/cache/extract/src/common.cpp +187 -0
  60. fstd-0.1.0/tests/cache/extract/src/fstdd_compressor.cpp +367 -0
  61. fstd-0.1.0/tests/cache/extract/src/fstdd_reader.cpp +204 -0
  62. fstd-0.1.0/tests/cache/extract/src/fstdd_writer.cpp +97 -0
  63. fstd-0.1.0/tests/cache/extract/src/fstdx_compressor.cpp +324 -0
  64. fstd-0.1.0/tests/cache/extract/src/fstdx_reader.cpp +371 -0
  65. fstd-0.1.0/tests/cache/extract/src/fstdx_searcher.cpp +502 -0
  66. fstd-0.1.0/tests/cache/extract/src/fstdx_writer.cpp +414 -0
  67. fstd-0.1.0/tests/cache/extract/src/fstlib_wrapper.cpp +21 -0
  68. fstd-0.1.0/tests/cache/extract/src/logger.cpp +39 -0
  69. fstd-0.1.0/tests/cache/extract_all/dict.txt +70809 -0
  70. fstd-0.1.0/tests/cache/extract_all/src/common.cpp +187 -0
  71. fstd-0.1.0/tests/cache/extract_all/src/fstdd_compressor.cpp +367 -0
  72. fstd-0.1.0/tests/cache/extract_all/src/fstdd_reader.cpp +204 -0
  73. fstd-0.1.0/tests/cache/extract_all/src/fstdd_writer.cpp +97 -0
  74. fstd-0.1.0/tests/cache/extract_all/src/fstdx_compressor.cpp +324 -0
  75. fstd-0.1.0/tests/cache/extract_all/src/fstdx_reader.cpp +371 -0
  76. fstd-0.1.0/tests/cache/extract_all/src/fstdx_searcher.cpp +502 -0
  77. fstd-0.1.0/tests/cache/extract_all/src/fstdx_writer.cpp +414 -0
  78. fstd-0.1.0/tests/cache/extract_all/src/fstlib_wrapper.cpp +21 -0
  79. fstd-0.1.0/tests/cache/extract_all/src/logger.cpp +39 -0
  80. fstd-0.1.0/tests/cache/extract_dict.txt +70809 -0
  81. fstd-0.1.0/tests/dict/dict.txt +70809 -0
  82. fstd-0.1.0/tests/test_fstd.cpp +194 -0
@@ -0,0 +1,392 @@
1
+ cmake_minimum_required (VERSION 3.24) # Upgraded from 3.10 to unlock safe system fallback features
2
+
3
+ # Build type postfix configuration
4
+ set(RELEASE_POSTFIX "" CACHE STRING "Postfix for release build binaries")
5
+ set(DEBUG_POSTFIX "d" CACHE STRING "Postfix for debug build binaries")
6
+ set(COVERAGE_POSTFIX "" CACHE STRING "Postfix for coverage build binaries")
7
+ set(GPERF_POSTFIX "" CACHE STRING "Postfix for gperf build binaries")
8
+
9
+ if(NOT CMAKE_BUILD_TYPE)
10
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
11
+ endif()
12
+
13
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
14
+
15
+ if (CMAKE_BUILD_TYPE_LOWER STREQUAL "release")
16
+ set(BUILD_TYPE ${RELEASE_POSTFIX})
17
+ elseif (CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
18
+ set(BUILD_TYPE ${DEBUG_POSTFIX})
19
+ elseif(CMAKE_BUILD_TYPE_LOWER STREQUAL "coverage")
20
+ set(BUILD_TYPE ${COVERAGE_POSTFIX})
21
+ elseif(CMAKE_BUILD_TYPE_LOWER STREQUAL "gperf")
22
+ set(BUILD_TYPE ${GPERF_POSTFIX})
23
+ else()
24
+ message(WARNING "Unknown build type '${CMAKE_BUILD_TYPE}', defaulting to release")
25
+ set(BUILD_TYPE ${RELEASE_POSTFIX})
26
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
27
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
28
+ endif()
29
+
30
+ set(PYBIND11_FINDPYTHON ON CACHE BOOL "Use FindPython instead of deprecated modules")
31
+ cmake_policy(SET CMP0148 NEW)
32
+
33
+ # Project configuration
34
+ project (fstd LANGUAGES CXX)
35
+ set(fstd_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
36
+
37
+ # ================= Python Binding Switch =================
38
+ option(BUILD_PYTHON_BINDING "Build pybind11 python extension module" OFF)
39
+ # =========================================================
40
+
41
+ # CRITICAL FOR LINUX DYNAMIC LIBRARIES:
42
+ # Forces compiled modules from FetchContent (spdlog, fmt, zstd, pcre2) to use -fPIC
43
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
44
+
45
+ # Require C++20 standard
46
+ set(CMAKE_CXX_STANDARD 20)
47
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
48
+ set(CMAKE_CXX_EXTENSIONS OFF)
49
+
50
+ include(GNUInstallDirs)
51
+ enable_testing()
52
+
53
+ # ===================== Library Configuration =====================
54
+ aux_source_directory(${fstd_ROOT_DIR}/lib/src DIR_LIB_SRCS)
55
+ set(FSTD_INCLUDE_DIR ${fstd_ROOT_DIR}/lib/include)
56
+
57
+ # 1. Build shared library
58
+ add_library(fstd_shared SHARED ${DIR_LIB_SRCS})
59
+ set_target_properties(fstd_shared PROPERTIES
60
+ OUTPUT_NAME fstd${BUILD_TYPE}
61
+ VERSION 0.1.0
62
+ SOVERSION 1
63
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
64
+ )
65
+
66
+ # 2. Build static library
67
+ add_library(fstd_static STATIC ${DIR_LIB_SRCS})
68
+ set_target_properties(fstd_static PROPERTIES
69
+ OUTPUT_NAME fstd${BUILD_TYPE}
70
+ ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
71
+ )
72
+
73
+ target_include_directories(fstd_shared PUBLIC
74
+ $<BUILD_INTERFACE:${FSTD_INCLUDE_DIR}>
75
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
76
+ )
77
+ target_include_directories(fstd_static PUBLIC
78
+ $<BUILD_INTERFACE:${FSTD_INCLUDE_DIR}>
79
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
80
+ )
81
+ # ============================================================================
82
+
83
+ # ===================== Executable Configuration =====================
84
+ add_executable(fstd ${fstd_ROOT_DIR}/src/main.cpp)
85
+ target_link_libraries(fstd PRIVATE fstd_static)
86
+ # ============================================================================
87
+
88
+ target_compile_definitions(fstd PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
89
+
90
+ if(WIN32)
91
+ add_compile_definitions(NOMINMAX)
92
+ endif()
93
+
94
+ if(MSVC)
95
+ set(COMMON_COMPILE_OPTIONS /W4)
96
+ else()
97
+ set(COMMON_COMPILE_OPTIONS -W -Wall)
98
+ endif()
99
+
100
+ set(TARGETS fstd fstd_shared fstd_static)
101
+ foreach(TARGET ${TARGETS})
102
+ # Apply standard warning options
103
+ target_compile_options(${TARGET} PRIVATE ${COMMON_COMPILE_OPTIONS})
104
+
105
+ # Apply optimizations based on build type
106
+ if (CMAKE_BUILD_TYPE_LOWER STREQUAL "release")
107
+ if(MSVC)
108
+ target_compile_options(${TARGET} PRIVATE /O2)
109
+ else()
110
+ target_compile_options(${TARGET} PRIVATE -O2)
111
+ endif()
112
+ elseif (CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
113
+ if(MSVC)
114
+ target_compile_options(${TARGET} PRIVATE /Od /Zi /DDEBUG)
115
+ else()
116
+ target_compile_options(${TARGET} PRIVATE -O0 -g -DDEBUG)
117
+ endif()
118
+ endif()
119
+ endforeach()
120
+
121
+
122
+ # ===================== AUTO-FALLBACK INDEPENDENT SYSTEM FINDERS =====================
123
+ include(FetchContent)
124
+
125
+ macro(find_shared_or_fetch NAME REPO TAG SUBDIR)
126
+ set(USE_SYSTEM_LIB FALSE)
127
+ if(UNIX AND NOT APPLE)
128
+ find_library(${NAME}_SYSTEM_SHARED NAMES ${NAME} PATHS /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu)
129
+ if(${NAME}_SYSTEM_SHARED MATCHES "\\.so$|\\.so\\.")
130
+ set(USE_SYSTEM_LIB TRUE)
131
+ endif()
132
+ else()
133
+ find_package(${NAME} QUIET)
134
+ if(${NAME}_FOUND)
135
+ set(USE_SYSTEM_LIB TRUE)
136
+ endif()
137
+ endif()
138
+
139
+ if(USE_SYSTEM_LIB)
140
+ message(STATUS "--> Using system-provided shared library for: ${NAME}")
141
+ if(${NAME} STREQUAL "pybind11")
142
+ if(NOT TARGET pybind11::pybind11)
143
+ add_library(pybind11::pybind11 ALIAS pybind11)
144
+ endif()
145
+ else()
146
+ if(NOT TARGET ${NAME}::${NAME} AND TARGET ${NAME})
147
+ # If the system target is an ALIAS, unpack the real target behind it
148
+ get_target_property(REAL_SYS_TARGET ${NAME} ALIASED_TARGET)
149
+ if(REAL_SYS_TARGET)
150
+ add_library(${NAME}::${NAME} ALIAS ${REAL_SYS_TARGET})
151
+ else()
152
+ add_library(${NAME}::${NAME} ALIAS ${NAME})
153
+ endif()
154
+ elseif(NOT TARGET ${NAME}::${NAME})
155
+ add_library(${NAME}_system INTERFACE IMPORTED)
156
+ target_link_libraries(${NAME}_system INTERFACE ${${NAME}_SYSTEM_SHARED})
157
+ add_library(${NAME}::${NAME} ALIAS ${NAME}_system)
158
+ endif()
159
+ endif()
160
+ else()
161
+ message(STATUS "--> System library missing or lacks -fPIC for ${NAME}. Compiling via FetchContent from GitHub...")
162
+ if("${SUBDIR}" STREQUAL "")
163
+ FetchContent_Declare(${NAME} GIT_REPOSITORY ${REPO} GIT_TAG ${TAG})
164
+ else()
165
+ FetchContent_Declare(${NAME} GIT_REPOSITORY ${REPO} GIT_TAG ${TAG} SOURCE_SUBDIR ${SUBDIR})
166
+ endif()
167
+ FetchContent_MakeAvailable(${NAME})
168
+ endif()
169
+ endmacro()
170
+
171
+ # pybind11 for python binding
172
+ if(BUILD_PYTHON_BINDING)
173
+ find_shared_or_fetch(pybind11 "https://github.com/pybind/pybind11.git" "v3.0.4" "")
174
+ endif()
175
+
176
+ # 1. indicators (progress bar)
177
+ find_shared_or_fetch(indicators "https://github.com/p-ranav/indicators.git" "v2.3" "")
178
+
179
+ # 2. nlohmann_json (JSON)
180
+ find_shared_or_fetch(nlohmann_json "https://github.com/nlohmann/json.git" "v3.12.0" "")
181
+
182
+ # 3. spdlog (log)
183
+ find_shared_or_fetch(spdlog "https://github.com/gabime/spdlog.git" "v1.17.0" "")
184
+
185
+ # 4. fmt
186
+ find_shared_or_fetch(fmt "https://github.com/fmtlib/fmt.git" "12.1.0" "")
187
+
188
+ # 5. CLI11 (Command line parser)
189
+ find_shared_or_fetch(CLI11 "https://github.com/CLIUtils/CLI11.git" "v2.6.2" "")
190
+
191
+ # 6. zstd (compression)
192
+ set(ZSTD_BUILD_PROGRAMS OFF CACHE BOOL "" FORCE)
193
+ set(ZSTD_BUILD_SHARED OFF CACHE BOOL "" FORCE)
194
+ set(ZSTD_BUILD_STATIC ON CACHE BOOL "" FORCE)
195
+
196
+ # Force macOS to fall back cleanly if Homebrew target linking drops dictionary symbols
197
+ if(APPLE)
198
+ find_package(zstd QUIET)
199
+ if(zstd_FOUND)
200
+ # Verify if an absolute target definition or a raw variable link is available
201
+ if(TARGET zstd::libzstd_shared)
202
+ set(ZSTD_LIB_TARGET zstd::libzstd_shared)
203
+ elseif(TARGET zstd::libzstd_static)
204
+ set(ZSTD_LIB_TARGET zstd::libzstd_static)
205
+ else()
206
+ # Absolute fallback to Homebrew's framework library directory explicitly
207
+ find_library(ZSTD_MAC_LIB NAMES zstd PATHS /opt/homebrew/lib /usr/local/lib)
208
+ if(ZSTD_MAC_LIB)
209
+ add_library(zstd_mac_fallback INTERFACE IMPORTED)
210
+ target_link_libraries(zstd_mac_fallback INTERFACE ${ZSTD_MAC_LIB})
211
+ set(ZSTD_LIB_TARGET zstd_mac_fallback)
212
+ endif()
213
+ endif()
214
+
215
+ # Bind the localized workspace target to our namespace wrapper
216
+ if(NOT TARGET zstd::zstd AND ZSTD_LIB_TARGET)
217
+ add_library(zstd::zstd INTERFACE IMPORTED)
218
+ target_link_libraries(zstd::zstd INTERFACE ${ZSTD_LIB_TARGET})
219
+ set(zstd_RESOLVED TRUE)
220
+ endif()
221
+ endif()
222
+ endif()
223
+
224
+ # Fall back to standard macro tracking for Linux/Ubuntu builds or unresolved Mac systems
225
+ if(NOT zstd_RESOLVED)
226
+ find_shared_or_fetch(zstd "https://github.com/facebook/zstd.git" "v1.5.7" "build/cmake")
227
+ if(NOT TARGET zstd::zstd)
228
+ if(TARGET zstd)
229
+ add_library(zstd::zstd ALIAS zstd)
230
+ elseif(TARGET libzstd_static)
231
+ get_target_property(REAL_ZSTD_TARGET libzstd_static ALIASED_TARGET)
232
+ if(REAL_ZSTD_TARGET)
233
+ add_library(zstd::zstd ALIAS ${REAL_ZSTD_TARGET})
234
+ else()
235
+ add_library(zstd::zstd ALIAS libzstd_static)
236
+ endif()
237
+ endif()
238
+ endif()
239
+ endif()
240
+
241
+ # 7. pcre2 (regex)
242
+ set(PCRE2_BUILD_PCRE2GREP OFF CACHE BOOL "" FORCE)
243
+ set(PCRE2_BUILD_TESTS OFF CACHE BOOL "" FORCE)
244
+ set(PCRE2_BUILD_PCRE2_8 ON CACHE BOOL "Build 8-bit PCRE2 library" FORCE)
245
+
246
+ set(pcre2_RESOLVED FALSE)
247
+
248
+ # Force macOS to fall back cleanly if Homebrew target linking drops 8-bit symbols
249
+ if(APPLE)
250
+ find_package(pcre2 QUIET)
251
+ find_package(PCRE2 QUIET) # Check both capitalization variants
252
+
253
+ if(pcre2_FOUND OR PCRE2_FOUND)
254
+ if(TARGET pcre2::8bit)
255
+ set(PCRE2_LIB_TARGET pcre2::8bit)
256
+ elseif(TARGET PCRE2::8BIT)
257
+ set(PCRE2_LIB_TARGET PCRE2::8BIT)
258
+ else()
259
+ # Explicit physical fallback to Homebrew's framework library directory
260
+ find_library(PCRE2_MAC_LIB NAMES pcre2-8 pcre2 PATHS /opt/homebrew/lib /usr/local/lib)
261
+ if(PCRE2_MAC_LIB)
262
+ add_library(pcre2_mac_fallback INTERFACE IMPORTED)
263
+ target_link_libraries(pcre2_mac_fallback INTERFACE ${PCRE2_MAC_LIB})
264
+ set(PCRE2_LIB_TARGET pcre2_mac_fallback)
265
+ endif()
266
+ endif()
267
+
268
+ # Bind the localized workspace target to our namespace wrapper
269
+ if(NOT TARGET pcre2::pcre2 AND PCRE2_LIB_TARGET)
270
+ add_library(pcre2::pcre2 INTERFACE IMPORTED)
271
+ target_link_libraries(pcre2::pcre2 INTERFACE ${PCRE2_LIB_TARGET})
272
+ set(pcre2_RESOLVED TRUE)
273
+ endif()
274
+ endif()
275
+ endif()
276
+
277
+ # Fall back to standard macro tracking for Linux/Ubuntu builds or unresolved Mac systems
278
+ if(NOT pcre2_RESOLVED)
279
+ find_shared_or_fetch(pcre2 "https://github.com/PhilipHazel/pcre2.git" "pcre2-10.47" "")
280
+ if(NOT TARGET pcre2::pcre2)
281
+ if(TARGET pcre2-8)
282
+ get_target_property(REAL_PCRE2_TARGET pcre2-8 ALIASED_TARGET)
283
+ if(REAL_PCRE2_TARGET)
284
+ add_library(pcre2::pcre2 ALIAS ${REAL_PCRE2_TARGET})
285
+ else()
286
+ add_library(pcre2::pcre2 ALIAS pcre2-8)
287
+ endif()
288
+ elseif(TARGET PCRE2::8BIT)
289
+ add_library(pcre2::pcre2 ALIAS PCRE2::8BIT)
290
+ endif()
291
+ endif()
292
+ endif()
293
+
294
+ # Link cross-platform dynamic system fallback dependencies
295
+ foreach(TARGET ${TARGETS})
296
+ target_link_libraries(${TARGET} PRIVATE
297
+ spdlog::spdlog
298
+ fmt::fmt
299
+ nlohmann_json::nlohmann_json
300
+ indicators::indicators
301
+ CLI11::CLI11
302
+ zstd::zstd
303
+ pcre2::pcre2
304
+ )
305
+ endforeach()
306
+ # ============================================================================
307
+
308
+ # ===================== Google Test Configuration =====================
309
+ find_package(GTest QUIET)
310
+ if(GTest_FOUND)
311
+ message(STATUS "Found system-installed GTest, using it.")
312
+ else()
313
+ message(STATUS "GTest not found, downloading from source...")
314
+ FetchContent_Declare(
315
+ googletest
316
+ GIT_REPOSITORY https://github.com/google/googletest.git
317
+ GIT_TAG v1.17.0
318
+ EXCLUDE_FROM_ALL
319
+ )
320
+ set(gtest_build_tests OFF CACHE BOOL "" FORCE)
321
+ set(gmock_build_tests OFF CACHE BOOL "" FORCE)
322
+ FetchContent_MakeAvailable(googletest)
323
+ endif()
324
+
325
+ # Include test directory
326
+ add_subdirectory(tests)
327
+ # ============================================================================
328
+
329
+ # ===================== Coverage (Linux only) =====================
330
+ if (CMAKE_BUILD_TYPE_LOWER STREQUAL "coverage" AND UNIX AND NOT APPLE)
331
+ foreach(TARGET ${TARGETS})
332
+ target_compile_options(${TARGET} PRIVATE --coverage)
333
+ target_link_libraries(${TARGET} PRIVATE --coverage)
334
+ endforeach()
335
+
336
+ add_custom_target(coverage
337
+ COMMAND lcov --base-directory ${CMAKE_SOURCE_DIR} --directory ${CMAKE_BINARY_DIR} --capture --output-file CodeCoverage.info --ignore-errors graph --rc lcov_branch_coverage=1
338
+ COMMAND lcov --remove CodeCoverage.info '/Library/*' '/usr/*' '*/test/*' --output-file CodeCoverage.info.cleaned --rc lcov_branch_coverage=1
339
+ COMMAND genhtml --branch-coverage CodeCoverage.info.cleaned -o CodeCoverageReport --rc lcov_branch_coverage=1
340
+ DEPENDS fstd
341
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
342
+ COMMENT "Generating code coverage report"
343
+ )
344
+ endif()
345
+
346
+ # ===================== gperf (Linux only) =====================
347
+ if (CMAKE_BUILD_TYPE_LOWER STREQUAL "gperf" AND UNIX AND NOT APPLE)
348
+ foreach(TARGET ${TARGETS})
349
+ target_link_libraries(${TARGET} PRIVATE -lprofiler)
350
+ endforeach()
351
+ endif()
352
+
353
+ # ===================== Install Configuration =====================
354
+ # Install executable
355
+ install(TARGETS fstd
356
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
357
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
358
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
359
+ )
360
+
361
+ # Install libraries
362
+ install(TARGETS fstd_shared fstd_static
363
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
364
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
365
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
366
+ )
367
+
368
+ # Install headers
369
+ install(DIRECTORY ${FSTD_INCLUDE_DIR}/fstd ${FSTD_INCLUDE_DIR}/fstlib
370
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
371
+ FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
372
+ )
373
+
374
+ # ================= Build Python Binding =================
375
+ if(BUILD_PYTHON_BINDING)
376
+ add_subdirectory(python)
377
+ endif()
378
+ # =========================================================
379
+
380
+ # ===================== Uninstall Target =====================
381
+ if(NOT TARGET uninstall)
382
+ configure_file(
383
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
384
+ "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
385
+ IMMEDIATE @ONLY
386
+ )
387
+
388
+ add_custom_target(uninstall
389
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake
390
+ COMMENT "Uninstalling fstd..."
391
+ )
392
+ endif()
fstd-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MouJieQin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
fstd-0.1.0/MANIFEST.in ADDED
@@ -0,0 +1,25 @@
1
+ # 顶层CMake、许可、文档
2
+ include CMakeLists.txt
3
+ include cmake_uninstall.cmake.in
4
+ include LICENSE
5
+ include README.md
6
+ include prior_suffix.json
7
+
8
+ # CLI主程序源码
9
+ recursive-include src *.cpp *.h *.hpp
10
+
11
+ # C++库源码+头文件
12
+ recursive-include lib *.h *.hpp *.cpp
13
+
14
+ # Python绑定CMake与源码
15
+ recursive-include python *.h *.hpp *.cpp CMakeLists.txt
16
+
17
+ # 测试目录(可选,保留则加)
18
+ recursive-include tests *.cpp CMakeLists.txt *.txt
19
+
20
+ # Python包代码
21
+ recursive-include fstd *.py *.pyi
22
+
23
+ # 排除构建缓存、编译产物
24
+ global-exclude build/* build_ext/* dist/* *.egg-info *.o *.a *.so *.dylib *.pyd
25
+ global-exclude __pycache__ *.pyc