aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authordimdim11 <dimdim11@yandex-team.com>2024-03-21 17:31:46 +0300
committerdimdim11 <dimdim11@yandex-team.com>2024-03-21 18:13:49 +0300
commita3786143c42fa67f7f22e8258d17985ca35b13de (patch)
treedfff4696511abe4a1fc92ef2dd07528bf1b4599f /build
parentb2e858b03f5a3a6209ff4803af9f464ba01a47aa (diff)
downloadydb-a3786143c42fa67f7f22e8258d17985ca35b13de.tar.gz
Add vanilla_protobuf attribute and logic in cmake generator
Add vanilla_protobuf attribute and logic in cmake generator 4019392e1b6894819bd2ea0a1601539803f333e8
Diffstat (limited to 'build')
-rw-r--r--build/export_generators/hardcoded-cmake/cmake/protobuf.cmake90
-rw-r--r--build/export_generators/hardcoded-cmake/root_cmake_lists.jinja5
2 files changed, 45 insertions, 50 deletions
diff --git a/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake b/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake
index a445e8b7d2..4588ad4ff5 100644
--- a/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake
+++ b/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake
@@ -21,53 +21,34 @@ function(target_proto_outs Tgt)
)
endfunction()
-function(target_proto_messages Tgt Scope)
- get_built_tool_path(protoc_bin protoc_dependency contrib/tools/protoc/bin protoc)
- get_built_tool_path(cpp_styleguide_bin cpp_styleguide_dependency contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide)
+function(target_messages Tgt Scope UseStyleguide UseEvent2Cpp)
+ if (vanilla_protobuf STREQUAL "yes")
+ set(protoc_bin ${PROJECT_BINARY_DIR}/bin/protoc${CMAKE_EXECUTABLE_SUFFIX})
+ set(protoc_dependency "")
+ set(UseStyleguide "no") # cpp_styleguide can't compile with vanilla protobuf
+ else()
+ get_built_tool_path(protoc_bin protoc_dependency "contrib/tools/protoc/bin" "protoc")
+ endif()
- get_property(ProtocExtraOutsSuf TARGET ${Tgt} PROPERTY PROTOC_EXTRA_OUTS)
- foreach(proto ${ARGN})
- if(proto MATCHES ${PROJECT_BINARY_DIR})
- file(RELATIVE_PATH protoRel ${PROJECT_BINARY_DIR} ${proto})
- elseif (proto MATCHES ${PROJECT_SOURCE_DIR})
- file(RELATIVE_PATH protoRel ${PROJECT_SOURCE_DIR} ${proto})
- else()
- set(protoRel ${proto})
- endif()
- get_filename_component(OutputBase ${protoRel} NAME_WLE)
- get_filename_component(OutputDir ${PROJECT_BINARY_DIR}/${protoRel} DIRECTORY)
- list(TRANSFORM ProtocExtraOutsSuf PREPEND ${OutputDir}/${OutputBase} OUTPUT_VARIABLE ProtocExtraOuts)
- add_custom_command(
- OUTPUT
- ${OutputDir}/${OutputBase}.pb.cc
- ${OutputDir}/${OutputBase}.pb.h
- ${ProtocExtraOuts}
- COMMAND ${protoc_bin}
- ${COMMON_PROTOC_FLAGS}
- "-I$<JOIN:$<TARGET_GENEX_EVAL:${Tgt},$<TARGET_PROPERTY:${Tgt},PROTO_ADDINCL>>,;-I>"
- "$<JOIN:$<TARGET_GENEX_EVAL:${Tgt},$<TARGET_PROPERTY:${Tgt},PROTO_OUTS>>,;>"
- --plugin=protoc-gen-cpp_styleguide=${cpp_styleguide_bin}
- "$<JOIN:$<TARGET_GENEX_EVAL:${Tgt},$<TARGET_PROPERTY:${Tgt},PROTOC_OPTS>>,;>"
- ${protoRel}
- DEPENDS
- ${proto}
- $<TARGET_PROPERTY:${Tgt},PROTOC_DEPS>
- ${protoc_dependency}
- ${cpp_styleguide_dependency}
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- COMMAND_EXPAND_LISTS
- )
- target_sources(${Tgt} ${Scope}
- ${OutputDir}/${OutputBase}.pb.cc ${OutputDir}/${OutputBase}.pb.h
- ${ProtocExtraOuts}
- )
- endforeach()
-endfunction()
+ if (UseStyleguide STREQUAL "yes")
+ get_built_tool_path(cpp_styleguide_bin cpp_styleguide_dependency "contrib/tools/protoc/plugins/cpp_styleguide" "cpp_styleguide")
+ set(protoc_styleguide_plugin --plugin=protoc-gen-cpp_styleguide=${cpp_styleguide_bin})
+ else()
+ set(protoc_styleguide_plugin "")
+ set(cpp_styleguide_dependency "")
+ endif()
-function(target_ev_messages Tgt Scope)
- get_built_tool_path(protoc_bin protoc_dependency contrib/tools/protoc/bin protoc)
- get_built_tool_path(cpp_styleguide_bin cpp_styleguide_dependency contrib/tools/protoc/plugins/cpp_styleguide cpp_styleguide)
- get_built_tool_path(event2cpp_bin event2cpp_dependency tools/event2cpp/bin event2cpp)
+ if (UseEvent2Cpp STREQUAL "yes")
+ get_built_tool_path(event2cpp_bin event2cpp_dependency "tools/event2cpp/bin" "event2cpp")
+ set(protoc_event2cpp_plugin --plugin=protoc-gen-event2cpp=${event2cpp_bin})
+ set(ext_h ".ev.pb.h")
+ set(ext_c ".ev.pb.cc")
+ else()
+ set(protoc_event2cpp_plugin "")
+ set(event2cpp_dependency "")
+ set(ext_h ".pb.h")
+ set(ext_c ".pb.cc")
+ endif()
get_property(ProtocExtraOutsSuf TARGET ${Tgt} PROPERTY PROTOC_EXTRA_OUTS)
foreach(proto ${ARGN})
@@ -83,17 +64,18 @@ function(target_ev_messages Tgt Scope)
list(TRANSFORM ProtocExtraOutsSuf PREPEND ${OutputDir}/${OutputBase} OUTPUT_VARIABLE ProtocExtraOuts)
add_custom_command(
OUTPUT
- ${OutputDir}/${OutputBase}.ev.pb.cc
- ${OutputDir}/${OutputBase}.ev.pb.h
+ ${OutputDir}/${OutputBase}${ext_c}
+ ${OutputDir}/${OutputBase}${ext_h}
${ProtocExtraOuts}
COMMAND ${protoc_bin}
${COMMON_PROTOC_FLAGS}
"-I$<JOIN:$<TARGET_GENEX_EVAL:${Tgt},$<TARGET_PROPERTY:${Tgt},PROTO_ADDINCL>>,;-I>"
"$<JOIN:$<TARGET_GENEX_EVAL:${Tgt},$<TARGET_PROPERTY:${Tgt},PROTO_OUTS>>,;>"
- --plugin=protoc-gen-cpp_styleguide=${cpp_styleguide_bin}
- --plugin=protoc-gen-event2cpp=${event2cpp_bin}
+ ${protoc_styleguide_plugin}
+ ${protoc_event2cpp_plugin}
"$<JOIN:$<TARGET_GENEX_EVAL:${Tgt},$<TARGET_PROPERTY:${Tgt},PROTOC_OPTS>>,;>"
${protoRel}
+ COMMAND sed -s -i 's/final :/:/g' ${OutputDir}/${OutputBase}${ext_c} ${OutputDir}/${OutputBase}${ext_h}
DEPENDS
${proto}
$<TARGET_PROPERTY:${Tgt},PROTOC_DEPS>
@@ -104,8 +86,16 @@ function(target_ev_messages Tgt Scope)
COMMAND_EXPAND_LISTS
)
target_sources(${Tgt} ${Scope}
- ${OutputDir}/${OutputBase}.ev.pb.cc ${OutputDir}/${OutputBase}.ev.pb.h
+ ${OutputDir}/${OutputBase}${ext_c} ${OutputDir}/${OutputBase}${ext_h}
${ProtocExtraOuts}
)
endforeach()
endfunction()
+
+function(target_proto_messages Tgt Scope)
+ target_messages(${Tgt} ${Scope} "yes" "no" ${ARGN})
+endfunction()
+
+function(target_ev_messages Tgt Scope)
+ target_messages(${Tgt} ${Scope} "yes" "yes" ${ARGN})
+endfunction()
diff --git a/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja b/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja
index 5c564061ef..d98b691fe9 100644
--- a/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja
+++ b/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja
@@ -39,6 +39,11 @@ else()
CONF "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}"
)
endif(){% endif %}
+
+{%- if vanilla_protobuf %}
+set(vanilla_protobuf "yes")
+{%- endif -%}
+
{% set platforms_count = platform_names|length -%}
{% if platforms_count > 0 -%}
{% for i in range(platforms_count) %}