pw_rust#
Pigweed AI summary: The Rust support in Pigweed is experimental and split between Bazel and GN support. Bazel supports a rich set of targets for both host and target builds, while GN only supports building a single host binary using standard libraries. Third-party crates are vendored in the third_party/rust_crates repository and can only be referenced through the Bazel build. The embedded_hello example can be built and run using the specified commands. Windows builds are currently unsupported in GN.
Rust support in pigweed is highly experimental. Currently functionality is split between Bazel and GN support.
Bazel#
Pigweed AI summary: The Bazel support for Rust is based on rules_rust and offers a wide range of targets for host and target builds. The embedded_hello example can be built for lm3s6965evb and microbit QEMU machines using specific commands.
Bazel support is based on rules_rust and supports a rich set of targets for both host and target builds.
Building and Running the Embedded Example#
Pigweed AI summary: This paragraph explains how to build and run the "embedded_hello" example for both the "lm3s6965evb" and "microbit" QEMU machines using specific commands. The commands include using "bazel build" and "qemu-system-arm" with the appropriate platform specified. The output of running the example should display the message "Hello, Pigweed!"
The embedded_hello
example can be built for both the lm3s6965evb
and microbit
QEMU machines. The example can be built and run using
the following commands where PLATFORM
is one of lm3s6965evb
or
microbit
.
$ bazel build //pw_rust/examples/embedded_hello:hello \
--platforms //pw_build/platforms:${PLATFORM} \
$ qemu-system-arm \
-machine ${PLATFORM} \
-nographic \
-semihosting-config enable=on,target=native \
-kernel ./bazel-bin/pw_rust/examples/embedded_hello/hello
Hello, Pigweed!
GN#
Pigweed AI summary: The GN tool currently only supports building a single host binary using standard libraries, and Windows builds are not supported. To build Rust targets, the pw_rust_ENABLE_EXPERIMENTAL_BUILD flag must be enabled, and the "hello" example can be built and run using the ninja command.
In GN, currently only building a single host binary using the standard libraries is supported. Windows builds are currently unsupported.
Building#
Pigweed AI summary: To build the sample rust targets, you need to enable the experimental build by using the command "pw_rust_ENABLE_EXPERIMENTAL_BUILD=true". Once enabled, you can build and run the "hello" example using the commands "ninja -C out host_clang_debug/obj/pw_rust/example/bin/hello" and "./out/host_clang_debug/obj/pw_rust/examples/host_executable/bin/hello".
To build the sample rust targets, you need to enable
pw_rust_ENABLE_EXPERIMENTAL_BUILD
:
$ gn gen out --args="pw_rust_ENABLE_EXPERIMENTAL_BUILD=true"
Once that is set, you can build and run the hello
example:
$ ninja -C out host_clang_debug/obj/pw_rust/example/bin/hello
$ ./out/host_clang_debug/obj/pw_rust/examples/host_executable/bin/hello
Hello, Pigweed!
Third Party Crates#
Pigweed AI summary: Third party crates are stored in the third_party/rust_crates repository and can only be referenced through the bazel build.
Thrid party crates are vendored in the third_party/rust_crates respository. Currently referencing these is only supported through the bazel build.