Skip to content

apps/rust: Add dependencies for Rust cargo in make builds#3522

Merged
acassis merged 1 commit into
apache:masterfrom
toku-mac:add_rust_depends_make
Jun 4, 2026
Merged

apps/rust: Add dependencies for Rust cargo in make builds#3522
acassis merged 1 commit into
apache:masterfrom
toku-mac:add_rust_depends_make

Conversation

@toku-mac
Copy link
Copy Markdown
Contributor

@toku-mac toku-mac commented Jun 4, 2026

Summary

This updates the Rust example Makefiles so Cargo builds participate in normal Make dependency tracking.

The change adds a RUST_CARGO_SRCS helper in tools/Rust.mk to collect crate input files. The hello and slint Rust examples now use that file list as prerequisites for their generated static libraries.

The examples also hook the generated Rust library into both context and all.
As a result, editing Rust sources, manifests, build scripts, causes Cargo to rebuild when make is run again.

Testing

I confirm that changes are verified on local setup and works as intended:

  • Build Host(s): OS (macOS 26.5), CPU(Apple M1), compiler(Apple clang version 21.0.0)
  • Target(s): arch(sim)
  • Ensure your PATH environment variable is properly configured to allow execution of: menuconfig, olddefconfig, savedefconfig, and setconfig.
  • Use the Rust toolchain version prior to nightly-2026-04-29 to avoid errors related to lib/rustlib/src/rust/library/std/src/sys/net/connection/socket/unix.rs.

Configuration and Build:

make distclean
./tools/configure.sh sim:nsh
make menuconfig
# Quit using the `Q` command.

printf 'CONFIG_SYSTEM_TIME64=y
CONFIG_FS_LARGEFILE=y
CONFIG_TLS_NELEM=16
CONFIG_DEV_URANDOM=y
CONFIG_EXAMPLES_HELLO_RUST_CARGO=y
CONFIG_EXAMPLES_HELLO_RUST_CARGO_STACKSIZE=8192
' >> .config

make olddefconfig
make

LN: platform/board to /Users/toku/nuttxspace/apps/platform/dummy
Register: gpio
Register: hello
Register: hello_rust_cargo
Register: dd
Register: dumpstack
Register: nsh
Register: sh
Register: ostest
CP:  /Users/toku/nuttxspace/nuttx/include/nuttx/config.h
CP:  /Users/toku/nuttxspace/nuttx/include/nuttx/fs/hostfs.h
Building Rust code with cargo...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.26s
LD:  nuttx
ld: warning: -ld_classic is deprecated and will be removed in a future release
ld: warning: -ld_classic is deprecated and will be removed in a future release

PR verification Self-Check

  • My PR adheres to Contributing Guidelines and Documentation (git commit title and message, coding standard, etc).
  • My PR is ready for review and can be safely merged into a codebase.

Add a Rust make helper that collects crate input files, and use it for
the Rust hello and slint examples.

This makes the generated Rust static libraries depend on the crate
sources, manifests, build scripts. Hook the libraries into both context
and all, so re-running make after editing Rust inputs rebuilds the crate.

Signed-off-by: Shoji Tokunaga <toku@mac.com>
@acassis acassis merged commit 840c2f3 into apache:master Jun 4, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants