This commit is contained in:
2025-12-08 01:18:13 +05:30
commit 3ed23336e2
56 changed files with 7103 additions and 0 deletions

97
CMake/FindDeps.cmake Normal file
View File

@ -0,0 +1,97 @@
include(FetchContent)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=int-conversion")
add_compile_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
FetchContent_Declare(
httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG v0.28.0
SYSTEM
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.12.0
SYSTEM
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
glaze
GIT_REPOSITORY https://github.com/stephenberry/glaze.git
GIT_TAG v6.1.0
SYSTEM
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
simdjson
GIT_REPOSITORY https://github.com/simdjson/simdjson.git
GIT_TAG v4.2.2
SYSTEM
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
ZLIB
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.3.1
SYSTEM
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
zstd
GIT_REPOSITORY https://github.com/facebook/zstd.git
GIT_TAG v1.5.7
SOURCE_SUBDIR build/cmake
SYSTEM
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
mimalloc
GIT_REPOSITORY https://github.com/microsoft/mimalloc.git
GIT_TAG v3.0.10
SYSTEM
EXCLUDE_FROM_ALL
PATCH_COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=<SOURCE_DIR>
-P ${CMAKE_CURRENT_SOURCE_DIR}/CMake/PatchMimalloc.cmake
)
FetchContent_Declare(
tl-expected
GIT_REPOSITORY https://github.com/TartanLlama/expected.git
GIT_TAG v1.3.1
SYSTEM
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
unordered_dense
GIT_REPOSITORY https://github.com/martinus/unordered_dense.git
GIT_TAG v4.8.1
SYSTEM
EXCLUDE_FROM_ALL
)
set(MI_BUILD_SHARED ON CACHE BOOL "" FORCE)
set(MI_BUILD_STATIC ON CACHE BOOL "" FORCE)
set(MI_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(EXPECTED_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(HTTPLIB_REQUIRE_OPENSSL OFF CACHE BOOL "" FORCE)
set(HTTPLIB_REQUIRE_ZLIB OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(httplib nlohmann_json glaze simdjson ZLIB zstd mimalloc tl-expected unordered_dense)
if(NOT TARGET ZLIB::ZLIB)
add_library(ZLIB::ZLIB ALIAS zlibstatic)
endif()
find_package(OpenSSL REQUIRED)

25
CMake/PatchMimalloc.cmake Normal file
View File

@ -0,0 +1,25 @@
# Get the file path from the command line argument
set(TARGET_FILE "${SOURCE_DIR}/src/prim/windows/prim.c")
# Read the file
file(READ "${TARGET_FILE}" FILE_CONTENT)
# Check if the patch is already applied
string(FIND "${FILE_CONTENT}" "struct _TEB* const teb" ALREADY_PATCHED)
if(ALREADY_PATCHED EQUAL -1)
message(STATUS "Patching mimalloc source: ${TARGET_FILE}")
# Perform the replacement
string(REPLACE
"_TEB* const teb = NtCurrentTeb()"
"struct _TEB* const teb = NtCurrentTeb()"
FILE_CONTENT
"${FILE_CONTENT}"
)
# Write the file back only if changes were made
file(WRITE "${TARGET_FILE}" "${FILE_CONTENT}")
else()
message(STATUS "mimalloc source is already patched. Skipping.")
endif()