From be3e1fb2ef4df54025ef90e0c67ea260e176e853 Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Mon, 9 Feb 2026 19:51:17 -0800 Subject: [PATCH] fix(build): restore smbus/smbus_sbs for Linux board targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit (6b8fd11) gated smbus and smbus_sbs behind PX4_PLATFORM=="nuttx" to prevent clang-tidy errors on SITL, but these libraries depend on device::I2C which has a POSIX implementation (posix/I2C.cpp). Linux boards like bluerobotics_navigator (armhf) and emlid_navio2 (aarch64) enable CONFIG_DRIVERS_BATT_SMBUS, which depends on drivers__smbus — causing CMake to fail with "non-existent target". Move smbus and smbus_sbs back to unconditional add_subdirectory() so they are available on all platforms. Keep mcp_common gated behind NuttX since it includes px4_platform/gpio/mcp.hpp (NuttX-only GPIO headers). Re-add src/lib/drivers/smbus to the Makefile clang-tidy exclude list since the SITL compilation database lacks the I2C platform headers needed for analysis. Signed-off-by: Ramon Roche --- Makefile | 5 +++-- src/lib/drivers/CMakeLists.txt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 684f4767be..fb97276b52 100644 --- a/Makefile +++ b/Makefile @@ -497,14 +497,15 @@ px4_sitl_default-clang: # - Test code (allowed looser style) # - Example code (educational, not production) # - Vendored third-party code (e.g., CMSIS_5) -# - NuttX-only drivers excluded at CMake level (mcp_common, smbus); GPIO excluded here +# - NuttX-only drivers excluded at CMake level (mcp_common); I2C-dependent libs excluded here (smbus) +# - GPIO excluded here (NuttX platform headers) # - Emscripten failsafe web build: source path + Unity build path (failsafe_test.dir) # because CMake Unity Builds merge sources into a generated .cxx under build/ # # To add manual exclusions, append to CLANG_TIDY_EXCLUDE_EXTRA below. # Submodules are automatically excluded - no action needed when adding new ones. CLANG_TIDY_SUBMODULES := $(shell git config --file .gitmodules --get-regexp path | awk '{print $$2}' | tr '\n' '|' | sed 's/|$$//') -CLANG_TIDY_EXCLUDE_EXTRA := src/systemcmds/tests|src/examples|src/modules/gyro_fft/CMSIS_5|src/drivers/gpio|src/modules/commander/failsafe/emscripten|failsafe_test\.dir +CLANG_TIDY_EXCLUDE_EXTRA := src/systemcmds/tests|src/examples|src/modules/gyro_fft/CMSIS_5|src/lib/drivers/smbus|src/drivers/gpio|src/modules/commander/failsafe/emscripten|failsafe_test\.dir CLANG_TIDY_EXCLUDE := $(CLANG_TIDY_SUBMODULES)|$(CLANG_TIDY_EXCLUDE_EXTRA) clang-tidy: px4_sitl_default-clang diff --git a/src/lib/drivers/CMakeLists.txt b/src/lib/drivers/CMakeLists.txt index 6ece18c65e..051b40ab0c 100644 --- a/src/lib/drivers/CMakeLists.txt +++ b/src/lib/drivers/CMakeLists.txt @@ -38,8 +38,9 @@ add_subdirectory(led) add_subdirectory(magnetometer) add_subdirectory(rangefinder) +add_subdirectory(smbus) +add_subdirectory(smbus_sbs) + if (${PX4_PLATFORM} STREQUAL "nuttx") add_subdirectory(mcp_common) - add_subdirectory(smbus) - add_subdirectory(smbus_sbs) endif()