tools: Export NUTTX_INCLUDE_DIR for Rust builds

Set NUTTX_INCLUDE_DIR in the Rust build commands to include the necessary directories for proper compilation.
* Ensured correct include paths for Rust projects
* Improved build reliability for Rust components

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2025-03-05 19:57:11 +08:00 committed by Xiang Xiao
parent cc3392452a
commit 99d2de6540
2 changed files with 6 additions and 2 deletions

View file

@ -150,6 +150,8 @@ function(nuttx_add_rust)
add_custom_command(
OUTPUT ${RUST_LIB_PATH}
COMMAND
${CMAKE_COMMAND} -E env
NUTTX_INCLUDE_DIR=${PROJECT_SOURCE_DIR}/include:${CMAKE_BINARY_DIR}/include:${CMAKE_BINARY_DIR}/include/arch
cargo build --${RUST_PROFILE} -Zbuild-std=std,panic_abort
${RUST_DEBUG_FLAGS} --manifest-path ${CRATE_PATH}/Cargo.toml --target
${RUST_TARGET} --target-dir ${RUST_BUILD_DIR}

View file

@ -89,7 +89,8 @@ endef
ifeq ($(CONFIG_DEBUG_FULLOPT),y)
define RUST_CARGO_BUILD
cargo build --release -Zbuild-std=std,panic_abort \
NUTTX_INCLUDE_DIR=$(TOPDIR)/include:$(TOPDIR)/include/arch \
cargo build --release -Zbuild-std=std,panic_abort \
-Zbuild-std-features=panic_immediate_abort \
--manifest-path $(2)/$(1)/Cargo.toml \
--target $(call RUST_TARGET_TRIPLE)
@ -97,7 +98,8 @@ endef
else
define RUST_CARGO_BUILD
@echo "Building Rust code with cargo..."
cargo build -Zbuild-std=std,panic_abort \
NUTTX_INCLUDE_DIR=$(TOPDIR)/include:$(TOPDIR)/include/arch \
cargo build -Zbuild-std=std,panic_abort \
--manifest-path $(2)/$(1)/Cargo.toml \
--target $(call RUST_TARGET_TRIPLE)
endef