From 1432a58ad85d48e6f71c527aa46ac74e35d69f95 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 5 Mar 2025 19:57:11 +0800 Subject: [PATCH 1/2] 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 --- cmake/nuttx_add_rust.cmake | 2 ++ tools/Rust.mk | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/nuttx_add_rust.cmake b/cmake/nuttx_add_rust.cmake index 742bc3be5dc..97ecdcec73a 100644 --- a/cmake/nuttx_add_rust.cmake +++ b/cmake/nuttx_add_rust.cmake @@ -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} diff --git a/tools/Rust.mk b/tools/Rust.mk index 337d323ddf0..9a77ae57bbd 100644 --- a/tools/Rust.mk +++ b/tools/Rust.mk @@ -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 From d62b9216b5d8962425ed95477c1a0833612f5e19 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 5 Mar 2025 22:15:35 +0800 Subject: [PATCH 2/2] examples/rust/slint: Update nuttx crate branch from master to main and fix pixel format check. Changed the NUTTX dependency branch to 'main' for consistency with repository updates. Updated pixel format check to use FB_FMT_RGB16_565 for better clarity and accuracy. Signed-off-by: Huang Qi --- examples/rust/slint/Cargo.toml | 2 +- examples/rust/slint/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/rust/slint/Cargo.toml b/examples/rust/slint/Cargo.toml index 4600f2220b2..af585ceb15d 100644 --- a/examples/rust/slint/Cargo.toml +++ b/examples/rust/slint/Cargo.toml @@ -18,7 +18,7 @@ opt-level = 'z' [dependencies] libc = "0.2" slint = { version = "1.9", default-features = false, features = ["compat-1-2", "renderer-software", "libm", "unsafe-single-threaded"] } -nuttx = { git = "https://github.com/no1wudi/nuttx-rs.git", branch = "master" } +nuttx = { git = "https://github.com/no1wudi/nuttx-rs.git", branch = "main" } [build-dependencies] slint-build = { version = "1.9" } diff --git a/examples/rust/slint/src/lib.rs b/examples/rust/slint/src/lib.rs index 043274cbc64..7f81ce29cd3 100644 --- a/examples/rust/slint/src/lib.rs +++ b/examples/rust/slint/src/lib.rs @@ -94,7 +94,7 @@ pub extern "C" fn slint_main() { println!("{:?}", planeinfo); println!("{:?}", videoinfo); - if videoinfo.fmt != Format::RGB565 as u8 { + if videoinfo.fmt != FB_FMT_RGB16_565 as u8 { println!("Unsupported pixel format, only RGB565 is supported for now"); return; }