Skip to content

Returned util and library #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
28 changes: 12 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ set(YDB-CPP-SDK_AVAILABLE_COMPONENTS "" CACHE INTERNAL "")
set(YDB-CPP-SDK_COMPONENT_TARGETS "" CACHE INTERNAL "")
file(READ "src/client/resources/ydb_sdk_version.txt" YDB_SDK_VERSION)

file(MAKE_DIRECTORY ${YDB_SDK_BINARY_DIR}/ydb-cpp-sdk)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

list(APPEND CMAKE_MODULE_PATH ${YDB_SDK_SOURCE_DIR}/cmake)
include_directories(${YDB_SDK_SOURCE_DIR} ${YDB_SDK_SOURCE_DIR}/include ${YDB_SDK_BINARY_DIR})

if (YDB_SDK_INSTALL)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
endif()

include(cmake/global_flags.cmake)
include(cmake/global_vars.cmake)
Expand All @@ -37,28 +32,29 @@ include(cmake/protobuf.cmake)
include(cmake/testing.cmake)
include(cmake/external_libs.cmake)

if (YDB_SDK_TESTS)
enable_testing()
endif()

add_subdirectory(tools)
add_subdirectory(contrib)
add_subdirectory(contrib/libs)
add_subdirectory(library/cpp)
add_subdirectory(src)
add_subdirectory(util)

_ydb_sdk_validate_public_headers()

if (YDB_SDK_EXAMPLES)
add_subdirectory(examples)
endif()

if (YDB_SDK_TESTS)
enable_testing()
add_subdirectory(tests/unit)
add_subdirectory(tests/integration)
endif()

if (YDB_SDK_INSTALL)
_ydb_sdk_directory_install(DIRECTORY ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
_ydb_sdk_directory_install(DIRECTORY ${YDB_SDK_BINARY_DIR}/ydb-cpp-sdk
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN "*.h"
)
_ydb_sdk_install_headers(${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ydb-cpp-sdk-targets
FILE ydb-cpp-sdk-targets.cmake
CONFIGURATIONS RELEASE
Expand Down
76 changes: 75 additions & 1 deletion cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function(resources Tgt Output)
list(APPEND ResourcesList ${Key})
endforeach()

get_built_tool_path(rescompiler_bin tools/rescompiler/bin rescompiler)
get_built_tool_path(rescompiler_bin tools/rescompiler rescompiler)

add_custom_command(
OUTPUT ${Output}
Expand All @@ -179,3 +179,77 @@ function(_ydb_sdk_make_client_component CmpName Tgt)
set(YDB-CPP-SDK_AVAILABLE_COMPONENTS ${YDB-CPP-SDK_AVAILABLE_COMPONENTS} ${CmpName} CACHE INTERNAL "")
set(YDB-CPP-SDK_COMPONENT_TARGETS ${YDB-CPP-SDK_COMPONENT_TARGETS} ${Tgt} CACHE INTERNAL "")
endfunction()

function(_ydb_sdk_add_library Tgt)
cmake_parse_arguments(ARG
"INTERFACE" "" ""
${ARGN}
)

set(libraryMode "")
set(includeMode "PUBLIC")
if (ARG_INTERFACE)
set(libraryMode "INTERFACE")
set(includeMode "INTERFACE")
endif()
add_library(${Tgt} ${libraryMode})
target_include_directories(${Tgt} ${includeMode}
$<BUILD_INTERFACE:${YDB_SDK_SOURCE_DIR}>
$<BUILD_INTERFACE:${YDB_SDK_BINARY_DIR}>
$<BUILD_INTERFACE:${YDB_SDK_SOURCE_DIR}/include>
)
endfunction()

function(_ydb_sdk_validate_public_headers)
file(GLOB_RECURSE allHeaders RELATIVE ${YDB_SDK_SOURCE_DIR}/include ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk/*)
file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/public_headers.txt specialHeaders)
file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/protos_public_headers.txt protosHeaders)
if (NOT MSVC)
list(REMOVE_ITEM specialHeaders library/cpp/deprecated/atomic/atomic_win.h)
endif()
list(APPEND allHeaders ${specialHeaders})
file(COPY ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk DESTINATION ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include)
foreach(path ${specialHeaders})
get_filename_component(relPath ${path} DIRECTORY)
file(COPY ${YDB_SDK_SOURCE_DIR}/${path}
DESTINATION ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include/${relPath}
)
endforeach()

add_custom_target(make_validate_proto_headers
COMMAND ${CMAKE_COMMAND} -E
WORKING_DIRECTORY ${YDB_SDK_BINARY_DIR}
)
foreach(path ${protosHeaders})
get_filename_component(relPath ${path} DIRECTORY)
add_custom_command(OUTPUT ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include/${path}
COMMAND ${CMAKE_COMMAND} -E
copy "${path}" "__validate_headers_dir/include/${relPath}"
DEPENDS "${path}"
WORKING_DIRECTORY ${YDB_SDK_BINARY_DIR}
)
endforeach()

list(REMOVE_ITEM allHeaders
library/cpp/threading/future/core/future-inl.h
library/cpp/threading/future/wait/wait-inl.h
library/cpp/yt/misc/guid-inl.h
)

set(targetHeaders ${allHeaders})
list(APPEND targetHeaders ${protosHeaders})
list(TRANSFORM targetHeaders PREPEND "${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include/")

list(TRANSFORM allHeaders PREPEND "#include <")
list(TRANSFORM allHeaders APPEND ">")
list(JOIN allHeaders "\n" fileContent)

file(WRITE ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/main.cpp ${fileContent})

add_library(validate_public_interface MODULE
${YDB_SDK_BINARY_DIR}/__validate_headers_dir/main.cpp
${targetHeaders}
)
target_include_directories(validate_public_interface PUBLIC ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include)
endfunction()

7 changes: 0 additions & 7 deletions cmake/global_vars.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@

# This file was generated by the build system used internally in the Yandex monorepo.
# Only simple modifications are allowed (adding source-files to targets, adding simple properties
# like target_include_directories). These modifications will be ported to original
# ya.make files by maintainers. Any complex modifications which can't be ported back to the
# original buildsystem will not be accepted.


if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(YASM_FLAGS -f elf64 -D UNIX -D _x86_64_ -D_YASM_ -g dwarf2)
set(RAGEL_FLAGS -L -I ${YDB_SDK_SOURCE_DIR}/)
Expand Down
33 changes: 32 additions & 1 deletion cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function(_ydb_sdk_install_targets)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
INCLUDES DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}
${CMAKE_INSTALL_INCLUDEDIR}/__ydb_sdk_special_headers
)
endfunction()

Expand Down Expand Up @@ -54,3 +56,32 @@ function(_ydb_sdk_directory_install)
endif()
endif()
endfunction()

function(_ydb_sdk_install_headers ArgIncludeDir)
if (NOT ${YDB_SDK_INSTALL})
return()
endif()
_ydb_sdk_directory_install(DIRECTORY ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk
DESTINATION ${ArgIncludeDir}
)

file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/public_headers.txt PublicHeaders)
file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/protos_public_headers.txt ProtosPublicHeaders)
if (NOT MSVC)
list(REMOVE_ITEM PublicHeaders library/cpp/deprecated/atomic/atomic_win.h)
endif()
foreach(HeaderPath ${PublicHeaders})
get_filename_component(RelInstallPath ${HeaderPath} DIRECTORY)
_ydb_sdk_directory_install(FILES
${YDB_SDK_SOURCE_DIR}/${HeaderPath}
DESTINATION ${ArgIncludeDir}/__ydb_sdk_special_headers/${RelInstallPath}
)
endforeach()
foreach(HeaderPath ${ProtosPublicHeaders})
get_filename_component(RelInstallPath ${HeaderPath} DIRECTORY)
_ydb_sdk_directory_install(FILES
${YDB_SDK_BINARY_DIR}/${HeaderPath}
DESTINATION ${ArgIncludeDir}/__ydb_sdk_special_headers/${RelInstallPath}
)
endforeach()
endfunction()
2 changes: 1 addition & 1 deletion cmake/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function(_ydb_sdk_gen_proto_messages Tgt Scope Grpc)
endfunction()

function(_ydb_sdk_init_proto_library_impl Tgt USE_API_COMMON_PROTOS)
add_library(${Tgt})
_ydb_sdk_add_library(${Tgt})
target_link_libraries(${Tgt} PUBLIC
protobuf::libprotobuf
)
Expand Down
24 changes: 24 additions & 0 deletions cmake/protos_public_headers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
src/api/grpc/draft/ydb_datastreams_v1.grpc.pb.h
src/api/grpc/draft/ydb_datastreams_v1.pb.h
src/api/grpc/ydb_topic_v1.grpc.pb.h
src/api/grpc/ydb_topic_v1.pb.h
src/api/protos/annotations/validation.pb.h
src/api/protos/draft/datastreams.pb.h
src/api/protos/ydb_common.pb.h
src/api/protos/ydb_federation_discovery.pb.h
src/api/protos/ydb_operation.pb.h
src/api/protos/ydb_value.pb.h
src/api/protos/ydb_query.pb.h
src/api/protos/ydb_topic.pb.h
src/api/protos/ydb_table.pb.h
src/api/protos/ydb_scheme.pb.h
src/api/protos/ydb_query_stats.pb.h
src/api/protos/ydb_import.pb.h
src/api/protos/ydb_formats.pb.h
src/api/protos/ydb_issue_message.pb.h
src/api/protos/ydb_export.pb.h
src/api/protos/ydb_coordination.pb.h
src/api/protos/ydb_status_codes.pb.h
src/api/protos/draft/ydb_replication.pb.h
src/library/operation_id/protos/operation_id.pb.h
src/library/yql/public/issue/protos/issue_severity.pb.h
Loading
Loading