tool to send fw with usb using protbuf

This commit is contained in:
2024-02-03 02:53:22 +01:00
parent d1306d9fc2
commit 62f8d6db29
3 changed files with 159 additions and 1 deletions

20
tools/CMakeLists.txt Normal file
View File

@@ -0,0 +1,20 @@
# Specify the .proto file
set(PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../proto)
set(PROTO_FILE ${PROTO_SRC_DIR}/firmware.proto)
# Specify where you want to generate the python code
set(PYTHON_OUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Specify the include directory
set(PROTO_INC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../lib/nanopb/generator/proto)
# Add the command to generate the python code
add_custom_command(
OUTPUT ${PYTHON_OUT_DIR}/firmware_pb2.py
COMMAND protoc --python_out=${PYTHON_OUT_DIR} --proto_path=${PROTO_SRC_DIR}:${PROTO_INC_DIR} ${PROTO_FILE} ${PROTO_INC_DIR}/nanopb.proto
DEPENDS ${PROTO_FILE}
)
# Add the generated python code to a custom target
add_custom_target(GeneratePythonProtobufCode ALL DEPENDS ${PYTHON_OUT_DIR}/firmware_pb2.py)