Skip to content

Commit 99d2de6

Browse files
no1wudixiaoxiang781216
authored andcommitted
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 <[email protected]>
1 parent cc33924 commit 99d2de6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: cmake/nuttx_add_rust.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ function(nuttx_add_rust)
150150
add_custom_command(
151151
OUTPUT ${RUST_LIB_PATH}
152152
COMMAND
153+
${CMAKE_COMMAND} -E env
154+
NUTTX_INCLUDE_DIR=${PROJECT_SOURCE_DIR}/include:${CMAKE_BINARY_DIR}/include:${CMAKE_BINARY_DIR}/include/arch
153155
cargo build --${RUST_PROFILE} -Zbuild-std=std,panic_abort
154156
${RUST_DEBUG_FLAGS} --manifest-path ${CRATE_PATH}/Cargo.toml --target
155157
${RUST_TARGET} --target-dir ${RUST_BUILD_DIR}

Diff for: tools/Rust.mk

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,17 @@ endef
8989

9090
ifeq ($(CONFIG_DEBUG_FULLOPT),y)
9191
define RUST_CARGO_BUILD
92-
cargo build --release -Zbuild-std=std,panic_abort \
92+
NUTTX_INCLUDE_DIR=$(TOPDIR)/include:$(TOPDIR)/include/arch \
93+
cargo build --release -Zbuild-std=std,panic_abort \
9394
-Zbuild-std-features=panic_immediate_abort \
9495
--manifest-path $(2)/$(1)/Cargo.toml \
9596
--target $(call RUST_TARGET_TRIPLE)
9697
endef
9798
else
9899
define RUST_CARGO_BUILD
99100
@echo "Building Rust code with cargo..."
100-
cargo build -Zbuild-std=std,panic_abort \
101+
NUTTX_INCLUDE_DIR=$(TOPDIR)/include:$(TOPDIR)/include/arch \
102+
cargo build -Zbuild-std=std,panic_abort \
101103
--manifest-path $(2)/$(1)/Cargo.toml \
102104
--target $(call RUST_TARGET_TRIPLE)
103105
endef

0 commit comments

Comments
 (0)