Start BLAKE3 integration

This commit is contained in:
BoloniniD 2022-01-06 18:27:55 +03:00
parent 7e36c95376
commit fc5cd6dd83
7 changed files with 53 additions and 7 deletions

1
.gitmodules vendored
View File

@ -253,3 +253,4 @@
[submodule "contrib/BLAKE3"]
path = contrib/BLAKE3
url = https://github.com/BoloniniD/BLAKE3.git
branch = RustFFI-compat

View File

@ -46,6 +46,7 @@ include (cmake/target.cmake)
include (cmake/tools.cmake)
include (cmake/analysis.cmake)
include (cmake/git_status.cmake)
include (cmake/build_rust_lib.cmake)
# Ignore export() since we don't use it,
# but it gets broken with a global targets via link_libraries()
@ -95,6 +96,14 @@ if (ENABLE_CHECK_HEAVY_BUILDS)
set (CMAKE_CXX_COMPILER_LAUNCHER prlimit --as=${RLIMIT_AS} --data=${RLIMIT_DATA} --cpu=${RLIMIT_CPU} ${CMAKE_CXX_COMPILER_LAUNCHER})
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CARGO_RELEASE_FLAG "" CACHE INTERNAL "")
set(TARGET_DIR "debug" CACHE INTERNAL "")
else ()
set(CARGO_RELEASE_FLAG "--release" CACHE INTERNAL "")
set(TARGET_DIR "release" CACHE INTERNAL "")
endif ()
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "None")
set (CMAKE_BUILD_TYPE "RelWithDebInfo")
message (STATUS "CMAKE_BUILD_TYPE is not set, set to default = ${CMAKE_BUILD_TYPE}")

39
cmake/build_rust_lib.cmake Executable file
View File

@ -0,0 +1,39 @@
function(build_cargo target_name project_dir)
set(output_library ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_DIR}/lib${target_name}.a)
file(GLOB sources ${project_dir}/src/**/*.rs)
set(compile_message "Compiling ${target_name}")
if(CARGO_RELEASE_FLAG STREQUAL "--release")
set(compile_message "${compile_message} in release mode")
endif()
add_custom_command(
COMMENT ${compile_message}
COMMAND env CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} cargo build ${CARGO_RELEASE_FLAG}
COMMAND cp ${output_library} ${CMAKE_CURRENT_BINARY_DIR}
OUTPUT ${output_library}
WORKING_DIRECTORY ${project_dir})
if(NOT TARGET ${target_name}-target)
add_custom_target(${target_name}-target ALL DEPENDS ${output_library})
endif()
set_property(
TARGET ${target_name}-target
APPEND PROPERTY
INTERFACE_DEPENDENCIES ${output_library}
)
set_target_properties(${target_name}-target PROPERTIES LOCATION ${output_library})
add_library(${target_name} STATIC IMPORTED GLOBAL)
add_dependencies(${target_name} ${target_name}-target)
set_target_properties(${target_name}
PROPERTIES
IMPORTED_LOCATION ${output_library}
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/include/)
endfunction()

2
contrib/BLAKE3 vendored

@ -1 +1 @@
Subproject commit f1ebb28eb95652f92ec2c2f7763deca41b69d0fd
Subproject commit 9f2ac62d469bab150b6be7e05bf06b793d8d80cb

View File

@ -1,6 +0,0 @@
set (LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/BLAKE3)
add_library (BLAKE3 ${SRCS})
target_include_directories(BLAKE3 ${LIBRARY_DIR}/include)

View File

@ -21,6 +21,8 @@ endif()
set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL 1)
add_subdirectory (BLAKE3)
add_subdirectory (abseil-cpp-cmake)
add_subdirectory (magic-enum-cmake)
add_subdirectory (boost-cmake)

View File

@ -175,6 +175,7 @@ function clone_submodules
contrib/NuRaft
contrib/jemalloc
contrib/replxx
contrib/BLAKE3
)
git submodule sync