diff options
author | svidyuk <svidyuk@yandex-team.com> | 2024-03-25 09:18:05 +0300 |
---|---|---|
committer | svidyuk <svidyuk@yandex-team.com> | 2024-03-25 09:29:00 +0300 |
commit | b2b8b2195825882c94e71bcb70a7bfafc228ac8f (patch) | |
tree | 6e563745b22375b3e151ab8485c33aeb8483725d | |
parent | 0a74d9d059ebfa32ace6a732a0540796f9665dc5 (diff) | |
download | ydb-b2b8b2195825882c94e71bcb70a7bfafc228ac8f.tar.gz |
Revert commit rXXXXXX,Add vanilla_protobuf attribute and logic in cmake generator
389945f5aaf18f3cb06fcee6c6bd14b39f0beeed
-rw-r--r-- | build/export_generators/hardcoded-cmake/cmake/protobuf.cmake | 90 | ||||
-rw-r--r-- | build/export_generators/hardcoded-cmake/root_cmake_lists.jinja | 5 |
2 files changed, 50 insertions, 45 deletions
diff --git a/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake b/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake index 4588ad4ff5f..a445e8b7d21 100644 --- a/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake +++ b/build/export_generators/hardcoded-cmake/cmake/protobuf.cmake @@ -21,34 +21,9 @@ function(target_proto_outs Tgt) ) endfunction() -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() - - 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() - - 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() +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) get_property(ProtocExtraOutsSuf TARGET ${Tgt} PROPERTY PROTOC_EXTRA_OUTS) foreach(proto ${ARGN}) @@ -64,38 +39,73 @@ function(target_messages Tgt Scope UseStyleguide UseEvent2Cpp) list(TRANSFORM ProtocExtraOutsSuf PREPEND ${OutputDir}/${OutputBase} OUTPUT_VARIABLE ProtocExtraOuts) add_custom_command( OUTPUT - ${OutputDir}/${OutputBase}${ext_c} - ${OutputDir}/${OutputBase}${ext_h} + ${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>>,;>" - ${protoc_styleguide_plugin} - ${protoc_event2cpp_plugin} + --plugin=protoc-gen-cpp_styleguide=${cpp_styleguide_bin} "$<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> ${protoc_dependency} ${cpp_styleguide_dependency} - ${event2cpp_dependency} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND_EXPAND_LISTS ) target_sources(${Tgt} ${Scope} - ${OutputDir}/${OutputBase}${ext_c} ${OutputDir}/${OutputBase}${ext_h} + ${OutputDir}/${OutputBase}.pb.cc ${OutputDir}/${OutputBase}.pb.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}) + 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) + + 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}.ev.pb.cc + ${OutputDir}/${OutputBase}.ev.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} + --plugin=protoc-gen-event2cpp=${event2cpp_bin} + "$<JOIN:$<TARGET_GENEX_EVAL:${Tgt},$<TARGET_PROPERTY:${Tgt},PROTOC_OPTS>>,;>" + ${protoRel} + DEPENDS + ${proto} + $<TARGET_PROPERTY:${Tgt},PROTOC_DEPS> + ${protoc_dependency} + ${cpp_styleguide_dependency} + ${event2cpp_dependency} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMAND_EXPAND_LISTS + ) + target_sources(${Tgt} ${Scope} + ${OutputDir}/${OutputBase}.ev.pb.cc ${OutputDir}/${OutputBase}.ev.pb.h + ${ProtocExtraOuts} + ) + endforeach() endfunction() diff --git a/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja b/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja index d98b691fe97..5c564061ef5 100644 --- a/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja +++ b/build/export_generators/hardcoded-cmake/root_cmake_lists.jinja @@ -39,11 +39,6 @@ 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) %} |