fix(zenoh): stop the build writing generated files into the source tree (#27904)

* fix(zenoh): generate the topic catalog into the build tree

Kconfig.topics is fully generated from the uORB message set, but the build
regenerated it into the source tree at configure time. Building any Zenoh
board therefore left the working tree dirty whenever the message set had
changed since the file was last committed (the catalog is board-config
dependent, so it drifts easily).

Generate the catalog into the build directory in cmake/kconfig.cmake, before
Kconfig is parsed, and source it from there via ZENOH_KCONFIG_TOPICS. It is
generated board-independently from every message so it no longer depends on
the msg-gating Kconfig symbols it is sourced alongside; the per-board factory
still gates which topics are actually compiled. Drop the committed catalog.

* chore(zenoh): bump zenoh-pico to the build-tree header fix

Moves zenoh-pico's generated config.h/zenoh-pico.h/library.json out of its
own source tree and into the build tree, so building no longer dirties the
submodule.

Gated on PX4/zenoh-pico#2: the pointer currently references the fix branch on
a fork and must be moved to the merged commit before this is ready.

* bump zenoh-pico
This commit is contained in:
Jacob Dahl
2026-07-15 12:12:09 -06:00
committed by GitHub
parent e96159c217
commit b11e615810
6 changed files with 45 additions and 1302 deletions

View File

@@ -13,6 +13,39 @@ set(DEFCONFIG_PATH ${PYTHON_EXECUTABLE} -m defconfig CACHE INTERNAL "defconfig p
set(SAVEDEFCONFIG_PATH ${PYTHON_EXECUTABLE} -m savedefconfig CACHE INTERNAL "savedefconfig program" FORCE)
set(GENCONFIG_PATH ${PYTHON_EXECUTABLE} -m genconfig CACHE INTERNAL "genconfig program" FORCE)
# ---------------------------------------------------------------------------
# Zenoh publisher/subscriber topic catalog
#
# src/modules/zenoh/Kconfig sources this file to expose one config option per
# uORB topic. It is fully generated from the message set, so it is a build
# artifact rather than source: generate it into the build tree here, before
# Kconfig is parsed, and let Kconfig source it from there via the
# ZENOH_KCONFIG_TOPICS environment variable. The build never writes it into the
# source tree.
#
# The catalog is intentionally board-independent: it is generated from every
# message rather than the per-board subset, so it does not depend on the
# msg-gating Kconfig symbols it is sourced alongside (which would be circular).
# The per-board Zenoh factory (generated in msg/CMakeLists.txt) is what actually
# gates which topics get compiled in; a cataloged-but-unbuilt topic is inert.
# ---------------------------------------------------------------------------
set(ZENOH_KCONFIG_TOPICS ${PX4_BINARY_DIR}/src/modules/zenoh/Kconfig.topics)
file(GLOB zenoh_catalog_msg_files
${PX4_SOURCE_DIR}/msg/*.msg
${PX4_SOURCE_DIR}/msg/versioned/*.msg
)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/zenoh/px_generate_zenoh_topic_files.py
--zenoh-config
-f ${zenoh_catalog_msg_files}
-o ${PX4_BINARY_DIR}/src/modules/zenoh/
-e ${PX4_SOURCE_DIR}/Tools/zenoh/templates/zenoh
RESULT_VARIABLE zenoh_kconfig_result
)
if(NOT zenoh_kconfig_result EQUAL 0)
message(FATAL_ERROR "Failed to generate Zenoh Kconfig.topics catalog (${zenoh_kconfig_result})")
endif()
set(COMMON_KCONFIG_ENV_SETTINGS
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
KCONFIG_CONFIG=${BOARD_CONFIG}
@@ -26,6 +59,9 @@ set(COMMON_KCONFIG_ENV_SETTINGS
ARCHITECTURE=${CMAKE_SYSTEM_PROCESSOR}
ROMFSROOT=${config_romfs_root}
BASE_DEFCONFIG=${BOARD_CONFIG}
# Absolute path to the generated Zenoh topic catalog, sourced by
# src/modules/zenoh/Kconfig via source "$(ZENOH_KCONFIG_TOPICS)".
ZENOH_KCONFIG_TOPICS=${ZENOH_KCONFIG_TOPICS}
)
set(config_user_list)

View File

@@ -260,6 +260,5 @@ The PX4 ROS 2 Interface Library is not compatible with ROS 2 Humble and earlier,
ERROR [zenoh] Could not create a subscriber for type ***
```
When it happens, check if `src/modules/zenoh/Kconfig.topics` has unstaged changes.
If there are any it means that new uorb topics have been added and the previous build updated the `Kconfig.topics` file accordingly.
Please perform a clean build so that the new `Kconfig.topics` can be used.
This usually means the firmware was built with a different set of uORB topics than the peer expects.
The Zenoh topic catalog (`Kconfig.topics`) is generated automatically at configure time into the build directory, so performing a clean build picks up any newly added or changed topics.

View File

@@ -591,13 +591,9 @@ if(CONFIG_LIB_CDRSTREAM)
endif()
if(CONFIG_MODULES_ZENOH)
# Update kconfig file for topics
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/zenoh/px_generate_zenoh_topic_files.py
--zenoh-config
-f ${msg_files}
-o ${PX4_SOURCE_DIR}/src/modules/zenoh/
-e ${PX4_SOURCE_DIR}/Tools/zenoh/templates/zenoh
)
# The Zenoh Kconfig.topics catalog is generated into the build tree in
# cmake/kconfig.cmake (it must exist before Kconfig is parsed). Here we only
# generate the per-board publisher/subscriber factory.
add_custom_command(
OUTPUT
${PX4_BINARY_DIR}/src/modules/zenoh/uorb_pubsub_factory.hpp

View File

@@ -91,4 +91,6 @@ if MODULES_ZENOH
endif
rsource "Kconfig.topics"
# Kconfig.topics is generated into the build tree (see cmake/kconfig.cmake), not
# committed to source. It is sourced here by absolute path via an env variable.
source "$(ZENOH_KCONFIG_TOPICS)"

File diff suppressed because it is too large Load Diff