Skip to content

Commit d47c399

Browse files
authored
Returned util and library (#283)
1 parent 8c54519 commit d47c399

File tree

3,037 files changed

+111766
-86947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,037 files changed

+111766
-86947
lines changed

CMakeLists.txt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,10 @@ set(YDB-CPP-SDK_AVAILABLE_COMPONENTS "" CACHE INTERNAL "")
1818
set(YDB-CPP-SDK_COMPONENT_TARGETS "" CACHE INTERNAL "")
1919
file(READ "src/client/resources/ydb_sdk_version.txt" YDB_SDK_VERSION)
2020

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

2324
list(APPEND CMAKE_MODULE_PATH ${YDB_SDK_SOURCE_DIR}/cmake)
24-
include_directories(${YDB_SDK_SOURCE_DIR} ${YDB_SDK_SOURCE_DIR}/include ${YDB_SDK_BINARY_DIR})
25-
26-
if (YDB_SDK_INSTALL)
27-
include(GNUInstallDirs)
28-
include(CMakePackageConfigHelpers)
29-
endif()
3025

3126
include(cmake/global_flags.cmake)
3227
include(cmake/global_vars.cmake)
@@ -37,28 +32,29 @@ include(cmake/protobuf.cmake)
3732
include(cmake/testing.cmake)
3833
include(cmake/external_libs.cmake)
3934

35+
if (YDB_SDK_TESTS)
36+
enable_testing()
37+
endif()
38+
4039
add_subdirectory(tools)
41-
add_subdirectory(contrib)
40+
add_subdirectory(contrib/libs)
41+
add_subdirectory(library/cpp)
4242
add_subdirectory(src)
43+
add_subdirectory(util)
44+
45+
_ydb_sdk_validate_public_headers()
4346

4447
if (YDB_SDK_EXAMPLES)
4548
add_subdirectory(examples)
4649
endif()
4750

4851
if (YDB_SDK_TESTS)
49-
enable_testing()
5052
add_subdirectory(tests/unit)
5153
add_subdirectory(tests/integration)
5254
endif()
5355

5456
if (YDB_SDK_INSTALL)
55-
_ydb_sdk_directory_install(DIRECTORY ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk
56-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
57-
)
58-
_ydb_sdk_directory_install(DIRECTORY ${YDB_SDK_BINARY_DIR}/ydb-cpp-sdk
59-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
60-
PATTERN "*.h"
61-
)
57+
_ydb_sdk_install_headers(${CMAKE_INSTALL_INCLUDEDIR})
6258
install(EXPORT ydb-cpp-sdk-targets
6359
FILE ydb-cpp-sdk-targets.cmake
6460
CONFIGURATIONS RELEASE

cmake/common.cmake

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function(resources Tgt Output)
163163
list(APPEND ResourcesList ${Key})
164164
endforeach()
165165

166-
get_built_tool_path(rescompiler_bin tools/rescompiler/bin rescompiler)
166+
get_built_tool_path(rescompiler_bin tools/rescompiler rescompiler)
167167

168168
add_custom_command(
169169
OUTPUT ${Output}
@@ -179,3 +179,77 @@ function(_ydb_sdk_make_client_component CmpName Tgt)
179179
set(YDB-CPP-SDK_AVAILABLE_COMPONENTS ${YDB-CPP-SDK_AVAILABLE_COMPONENTS} ${CmpName} CACHE INTERNAL "")
180180
set(YDB-CPP-SDK_COMPONENT_TARGETS ${YDB-CPP-SDK_COMPONENT_TARGETS} ${Tgt} CACHE INTERNAL "")
181181
endfunction()
182+
183+
function(_ydb_sdk_add_library Tgt)
184+
cmake_parse_arguments(ARG
185+
"INTERFACE" "" ""
186+
${ARGN}
187+
)
188+
189+
set(libraryMode "")
190+
set(includeMode "PUBLIC")
191+
if (ARG_INTERFACE)
192+
set(libraryMode "INTERFACE")
193+
set(includeMode "INTERFACE")
194+
endif()
195+
add_library(${Tgt} ${libraryMode})
196+
target_include_directories(${Tgt} ${includeMode}
197+
$<BUILD_INTERFACE:${YDB_SDK_SOURCE_DIR}>
198+
$<BUILD_INTERFACE:${YDB_SDK_BINARY_DIR}>
199+
$<BUILD_INTERFACE:${YDB_SDK_SOURCE_DIR}/include>
200+
)
201+
endfunction()
202+
203+
function(_ydb_sdk_validate_public_headers)
204+
file(GLOB_RECURSE allHeaders RELATIVE ${YDB_SDK_SOURCE_DIR}/include ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk/*)
205+
file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/public_headers.txt specialHeaders)
206+
file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/protos_public_headers.txt protosHeaders)
207+
if (NOT MSVC)
208+
list(REMOVE_ITEM specialHeaders library/cpp/deprecated/atomic/atomic_win.h)
209+
endif()
210+
list(APPEND allHeaders ${specialHeaders})
211+
file(COPY ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk DESTINATION ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include)
212+
foreach(path ${specialHeaders})
213+
get_filename_component(relPath ${path} DIRECTORY)
214+
file(COPY ${YDB_SDK_SOURCE_DIR}/${path}
215+
DESTINATION ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include/${relPath}
216+
)
217+
endforeach()
218+
219+
add_custom_target(make_validate_proto_headers
220+
COMMAND ${CMAKE_COMMAND} -E
221+
WORKING_DIRECTORY ${YDB_SDK_BINARY_DIR}
222+
)
223+
foreach(path ${protosHeaders})
224+
get_filename_component(relPath ${path} DIRECTORY)
225+
add_custom_command(OUTPUT ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include/${path}
226+
COMMAND ${CMAKE_COMMAND} -E
227+
copy "${path}" "__validate_headers_dir/include/${relPath}"
228+
DEPENDS "${path}"
229+
WORKING_DIRECTORY ${YDB_SDK_BINARY_DIR}
230+
)
231+
endforeach()
232+
233+
list(REMOVE_ITEM allHeaders
234+
library/cpp/threading/future/core/future-inl.h
235+
library/cpp/threading/future/wait/wait-inl.h
236+
library/cpp/yt/misc/guid-inl.h
237+
)
238+
239+
set(targetHeaders ${allHeaders})
240+
list(APPEND targetHeaders ${protosHeaders})
241+
list(TRANSFORM targetHeaders PREPEND "${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include/")
242+
243+
list(TRANSFORM allHeaders PREPEND "#include <")
244+
list(TRANSFORM allHeaders APPEND ">")
245+
list(JOIN allHeaders "\n" fileContent)
246+
247+
file(WRITE ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/main.cpp ${fileContent})
248+
249+
add_library(validate_public_interface MODULE
250+
${YDB_SDK_BINARY_DIR}/__validate_headers_dir/main.cpp
251+
${targetHeaders}
252+
)
253+
target_include_directories(validate_public_interface PUBLIC ${YDB_SDK_BINARY_DIR}/__validate_headers_dir/include)
254+
endfunction()
255+

cmake/global_vars.cmake

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11

2-
# This file was generated by the build system used internally in the Yandex monorepo.
3-
# Only simple modifications are allowed (adding source-files to targets, adding simple properties
4-
# like target_include_directories). These modifications will be ported to original
5-
# ya.make files by maintainers. Any complex modifications which can't be ported back to the
6-
# original buildsystem will not be accepted.
7-
8-
92
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
103
set(YASM_FLAGS -f elf64 -D UNIX -D _x86_64_ -D_YASM_ -g dwarf2)
114
set(RAGEL_FLAGS -L -I ${YDB_SDK_SOURCE_DIR}/)

cmake/install.cmake

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ function(_ydb_sdk_install_targets)
2222
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
2323
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
2424
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
25-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
25+
INCLUDES DESTINATION
26+
${CMAKE_INSTALL_INCLUDEDIR}
27+
${CMAKE_INSTALL_INCLUDEDIR}/__ydb_sdk_special_headers
2628
)
2729
endfunction()
2830

@@ -54,3 +56,32 @@ function(_ydb_sdk_directory_install)
5456
endif()
5557
endif()
5658
endfunction()
59+
60+
function(_ydb_sdk_install_headers ArgIncludeDir)
61+
if (NOT ${YDB_SDK_INSTALL})
62+
return()
63+
endif()
64+
_ydb_sdk_directory_install(DIRECTORY ${YDB_SDK_SOURCE_DIR}/include/ydb-cpp-sdk
65+
DESTINATION ${ArgIncludeDir}
66+
)
67+
68+
file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/public_headers.txt PublicHeaders)
69+
file(STRINGS ${YDB_SDK_SOURCE_DIR}/cmake/protos_public_headers.txt ProtosPublicHeaders)
70+
if (NOT MSVC)
71+
list(REMOVE_ITEM PublicHeaders library/cpp/deprecated/atomic/atomic_win.h)
72+
endif()
73+
foreach(HeaderPath ${PublicHeaders})
74+
get_filename_component(RelInstallPath ${HeaderPath} DIRECTORY)
75+
_ydb_sdk_directory_install(FILES
76+
${YDB_SDK_SOURCE_DIR}/${HeaderPath}
77+
DESTINATION ${ArgIncludeDir}/__ydb_sdk_special_headers/${RelInstallPath}
78+
)
79+
endforeach()
80+
foreach(HeaderPath ${ProtosPublicHeaders})
81+
get_filename_component(RelInstallPath ${HeaderPath} DIRECTORY)
82+
_ydb_sdk_directory_install(FILES
83+
${YDB_SDK_BINARY_DIR}/${HeaderPath}
84+
DESTINATION ${ArgIncludeDir}/__ydb_sdk_special_headers/${RelInstallPath}
85+
)
86+
endforeach()
87+
endfunction()

cmake/protobuf.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function(_ydb_sdk_gen_proto_messages Tgt Scope Grpc)
4949
endfunction()
5050

5151
function(_ydb_sdk_init_proto_library_impl Tgt USE_API_COMMON_PROTOS)
52-
add_library(${Tgt})
52+
_ydb_sdk_add_library(${Tgt})
5353
target_link_libraries(${Tgt} PUBLIC
5454
protobuf::libprotobuf
5555
)

cmake/protos_public_headers.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
src/api/grpc/draft/ydb_datastreams_v1.grpc.pb.h
2+
src/api/grpc/draft/ydb_datastreams_v1.pb.h
3+
src/api/grpc/ydb_topic_v1.grpc.pb.h
4+
src/api/grpc/ydb_topic_v1.pb.h
5+
src/api/protos/annotations/validation.pb.h
6+
src/api/protos/draft/datastreams.pb.h
7+
src/api/protos/ydb_common.pb.h
8+
src/api/protos/ydb_federation_discovery.pb.h
9+
src/api/protos/ydb_operation.pb.h
10+
src/api/protos/ydb_value.pb.h
11+
src/api/protos/ydb_query.pb.h
12+
src/api/protos/ydb_topic.pb.h
13+
src/api/protos/ydb_table.pb.h
14+
src/api/protos/ydb_scheme.pb.h
15+
src/api/protos/ydb_query_stats.pb.h
16+
src/api/protos/ydb_import.pb.h
17+
src/api/protos/ydb_formats.pb.h
18+
src/api/protos/ydb_issue_message.pb.h
19+
src/api/protos/ydb_export.pb.h
20+
src/api/protos/ydb_coordination.pb.h
21+
src/api/protos/ydb_status_codes.pb.h
22+
src/api/protos/draft/ydb_replication.pb.h
23+
src/library/operation_id/protos/operation_id.pb.h
24+
src/library/yql/public/issue/protos/issue_severity.pb.h

0 commit comments

Comments
 (0)