From 7165cfedaa125f2c896a21c75099d108a11cd288 Mon Sep 17 00:00:00 2001 From: gsk <171930433@qq.com> Date: Wed, 13 Mar 2024 22:41:32 +0800 Subject: [PATCH] =?UTF-8?q?using=20Protobuf=5FIMPORT=5FDIRS=20=E5=8F=98?= =?UTF-8?q?=E9=87=8F,=E6=8C=87=E5=AE=9Aimprot=E7=9A=84=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 6 ++++++ src/example/CMakeLists.txt | 24 +++++++++++++----------- src/example/base.proto | 3 --- src/example/proto_to_struct.proto | 22 ---------------------- 4 files changed, 19 insertions(+), 36 deletions(-) delete mode 100644 src/example/proto_to_struct.proto diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fed83345..548c05cb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,5 +42,11 @@ if(CMAKE_PROJECT_NAME STREQUAL "yaLanTingLibs") # if ylt is top-level project endif() +set(Protobuf_IMPORT_DIRS +${CMAKE_CURRENT_LIST_DIR}/src/protoc-plugin +) + + + # add_subdirectory(src/protoc-plugin) add_subdirectory(src/example) diff --git a/src/example/CMakeLists.txt b/src/example/CMakeLists.txt index 4511fdebb..3fe71064d 100644 --- a/src/example/CMakeLists.txt +++ b/src/example/CMakeLists.txt @@ -12,20 +12,20 @@ find_package(OpenCV REQUIRED COMPONENTS core) # generate .pb.cc .pb.h protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS -proto_to_struct.proto -base.proto -imu.proto -gnss.proto -state.proto -chasis.proto -perception.proto -pointcloud.proto -image.proto + ../protoc-plugin/proto_to_struct.proto + base.proto + imu.proto + gnss.proto + state.proto + chasis.proto + perception.proto + pointcloud.proto + image.proto ) protobuf_generate_python(PROTO_PYTHON_SRCS - proto_to_struct.proto + ../protoc-plugin/proto_to_struct.proto base.proto imu.proto gnss.proto @@ -45,7 +45,8 @@ chasis.proto perception.proto OPTION "namespace=inner_struct,converter_namespace=converter") -add_executable(struct_pb_tutorial tutorial.cpp zpointcloud.cpp zimage.cpp +add_executable(struct_pb_tutorial tutorial.cpp + zpointcloud.cpp zimage.cpp ${PROTO_SRCS} ${PROTO_HDRS} ${PROTO_STRUCT_SRCS} @@ -59,6 +60,7 @@ target_link_libraries(struct_pb_tutorial protobuf::libprotobuf ) target_include_directories(struct_pb_tutorial PUBLIC + ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR} ${PCL_INCLUDE_DIRS} diff --git a/src/example/base.proto b/src/example/base.proto index 98a5f1d3b..e7f843ff9 100644 --- a/src/example/base.proto +++ b/src/example/base.proto @@ -3,9 +3,6 @@ package inner_class; import "proto_to_struct.proto"; -// import "google/protobuf/descriptor.proto"; - - option(write_eigen_helper) = true; enum ZFrameType{ diff --git a/src/example/proto_to_struct.proto b/src/example/proto_to_struct.proto deleted file mode 100644 index 97fabd262..000000000 --- a/src/example/proto_to_struct.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -import "google/protobuf/descriptor.proto"; - -extend google.protobuf.FileOptions { - // 当前message是否解析 - bool write_eigen_helper = 20000; - bool write_pcl_helper = 20001; -} - -extend google.protobuf.MessageOptions { - // 当前message是否解析 - string eigen_typename = 20100; - string pcl_typename = 20101; -} - -extend google.protobuf.FieldOptions { - // 当前message是否解析 - bool inherits_from = 20200; - int32 fix_size = 20201; // 生成固定长度的数组 -} -