From 6102d19f5308e09da55aee211c3e7a03f0d7d6f7 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 10 May 2024 16:42:45 +0200 Subject: protobuf (dropped) --- .gitmodules | 5 +++++ client/CMakeLists.txt | 17 +++++++++++++++-- client/lib | 1 + lib/protobuf | 1 + proto/puzbusv1.proto | 4 ++-- 5 files changed, 24 insertions(+), 4 deletions(-) create mode 120000 client/lib create mode 160000 lib/protobuf diff --git a/.gitmodules b/.gitmodules index fc98963..0ba4c4e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,8 @@ url = https://github.com/FreeRTOS/FreeRTOS-Kernel branch = V11.1.0 shallow = true +[submodule "protobuf"] + path = lib/protobuf + url = https://github.com/protocolbuffers/protobuf + branch = v25.3 + shallow = true diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 9e433b1..eae4c66 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -4,11 +4,24 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) -include(../proto/include.cmake) - project(puzzlebox_client C CXX) +find_package(Protobuf REQUIRED) + add_executable(main main.cpp + ../proto/puzbusv1.proto + ) + +set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--copy-dt-needed-entries") +set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--copy-dt-needed-entries") +set(CMAKE_STATIC_LINKER_FLAGS "-Wl,--copy-dt-needed-entries") + +protobuf_generate( + APPEND_PATH + TARGET main + IMPORT_DIRS ../proto/ ) +target_link_libraries(main PRIVATE protobuf::libprotobuf) +target_include_directories(main PRIVATE "$") diff --git a/client/lib b/client/lib new file mode 120000 index 0000000..dc598c5 --- /dev/null +++ b/client/lib @@ -0,0 +1 @@ +../lib \ No newline at end of file diff --git a/lib/protobuf b/lib/protobuf new file mode 160000 index 0000000..4a2aef5 --- /dev/null +++ b/lib/protobuf @@ -0,0 +1 @@ +Subproject commit 4a2aef570deb2bfb8927426558701e8bfc26f2a4 diff --git a/proto/puzbusv1.proto b/proto/puzbusv1.proto index 6b4fa52..2358135 100644 --- a/proto/puzbusv1.proto +++ b/proto/puzbusv1.proto @@ -1,11 +1,11 @@ -syntax = "proto2"; +syntax = "proto3"; package puzbus; message I2CMsg { // 32-bit is the smallest integer format supported by protobuf, even though // we only need 7-10 bits for the I2C address. - required uint32 address = 1; + uint32 address = 1; optional bytes data = 2; } -- cgit v1.2.3