mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 19:32:36 +08:00
uorb: compress format definitions
Reduces flash usage by ~16KB. - compress formats at build-time into a single string with all formats - then at runtime iteratively decompress using https://github.com/atomicobject/heatshrink
This commit is contained in:
committed by
Thomas Stastny
parent
142e44c418
commit
1ad5a9de08
+41
-4
@@ -253,6 +253,7 @@ set(msg_source_out_path ${CMAKE_CURRENT_BINARY_DIR}/topics_sources)
|
||||
set(uorb_headers)
|
||||
set(uorb_sources)
|
||||
set(uorb_ucdr_headers)
|
||||
set(uorb_json_files)
|
||||
foreach(msg_file ${msg_files})
|
||||
get_filename_component(msg ${msg_file} NAME_WE)
|
||||
|
||||
@@ -264,11 +265,9 @@ foreach(msg_file ${msg_files})
|
||||
list(APPEND uorb_headers ${msg_out_path}/${msg}.h)
|
||||
list(APPEND uorb_sources ${msg_source_out_path}/${msg}.cpp)
|
||||
list(APPEND uorb_ucdr_headers ${ucdr_out_path}/${msg}.h)
|
||||
list(APPEND uorb_json_files ${msg_source_out_path}/${msg}.json)
|
||||
endforeach()
|
||||
|
||||
# set parent scope msg_files for other modules to consume (eg topic_listener)
|
||||
set(msg_files ${msg_files} PARENT_SCOPE)
|
||||
|
||||
# Generate uORB headers
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
@@ -292,6 +291,44 @@ add_custom_command(
|
||||
)
|
||||
add_custom_target(uorb_headers DEPENDS ${uorb_headers})
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${uorb_json_files}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
|
||||
--json
|
||||
-f ${msg_files}
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-o ${msg_source_out_path}
|
||||
-e ${PX4_SOURCE_DIR}/Tools/msg/templates/uorb
|
||||
DEPENDS
|
||||
${msg_files}
|
||||
${PX4_SOURCE_DIR}/Tools/msg/templates/uorb/msg.json.em
|
||||
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
|
||||
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_helper.py
|
||||
COMMENT "Generating uORB json files"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(uorb_json_files DEPENDS ${uorb_json_files})
|
||||
|
||||
set(uorb_message_fields_cpp_file ${msg_source_out_path}/uORBMessageFieldsGenerated.cpp)
|
||||
set(uorb_message_fields_header_file ${msg_out_path}/uORBMessageFieldsGenerated.hpp)
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${uorb_message_fields_cpp_file}
|
||||
${uorb_message_fields_header_file}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_compressed_fields.py
|
||||
-f ${uorb_json_files}
|
||||
--source-output-file ${uorb_message_fields_cpp_file}
|
||||
--header-output-file ${uorb_message_fields_header_file}
|
||||
DEPENDS
|
||||
uorb_json_files
|
||||
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_compressed_fields.py
|
||||
COMMENT "Generating uORB compressed fields"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Generate microcdr headers
|
||||
add_custom_command(
|
||||
OUTPUT ${uorb_ucdr_headers}
|
||||
@@ -334,7 +371,7 @@ add_custom_command(
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_library(uorb_msgs ${uorb_headers} ${msg_out_path}/uORBTopics.hpp ${uorb_sources} ${msg_source_out_path}/uORBTopics.cpp)
|
||||
add_library(uorb_msgs ${uorb_headers} ${msg_out_path}/uORBTopics.hpp ${uorb_sources} ${msg_source_out_path}/uORBTopics.cpp ${uorb_message_fields_cpp_file})
|
||||
target_link_libraries(uorb_msgs PRIVATE m)
|
||||
add_dependencies(uorb_msgs prebuild_targets uorb_headers)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user