Skip to content

Commit

Permalink
Some Android and MCU doc (#5286)
Browse files Browse the repository at this point in the history
MCU: Add missing info for software renderer
Android: Add some more details for dev env setup
  • Loading branch information
WilstonOreo committed May 22, 2024
1 parent 86b5686 commit 23f7a78
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
22 changes: 19 additions & 3 deletions api/rs/slint/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,35 @@
//!
//! ## Building and Deploying
//!
//! Building a Rust application requires the target toolchain to be installed. You can install it via `rustup`. For example, to target AArch64 Android, use the following command:
//!
//! ```sh
//! rustup target add aarch64-linux-android
//! ```
//!
//! Make sure that you have the Android NDK and SDK installed and set up in your development environment.
//! For detailed instructions on how to set up the Android NDK and SDK, please refer to the [Android Developer's guide](https://developer.android.com/studio/projects/install-ndk).
//! The following environment variables need to be set:
//! * `ANDROID_HOME`: The directory in which your Android SDK is located. Usually `$HOME/Android/Sdk`.
//! * `ANDROID_NDK_ROOT`: The directory in which your Android NDK is located. Usually `$HOME/Android/Sdk/ndk/${NDK_VERSION}`. ${NDK_VERSION} is the version of the NDK you have installed.
//! * `JAVA_HOME`: The directory in which your Java compiler (`javac`) is located. This variable is optional if a `javac` is found in your `$PATH`.
//! Otherwise you can set `JAVA_HOME` to the `javac` installation shipped with Android Studio in `android-studio/jbr`.
//!
//! To build and deploy your application, we suggest the usage of [cargo-apk](https://github.com/rust-mobile/cargo-apk),
//! a cargo subcommand that allows you to build, sign, and deploy Android APKs made in Rust.
//!
//! You can install it and use it with the following command:
//!
//! ```sh
//! cargo install cargo-apk
//! ```
//!
//! Build and run your application with the following command:
//!
//! ```sh
//! cargo apk run --target aarch64-linux-android --lib
//! ```
//!
//! Please ensure that you have the Android NDK and SDK installed and properly set up in your development environment for the above command to work as expected.
//! For detailed instructions on how to set up the Android NDK and SDK, please refer to the [Android Developer's guide](https://developer.android.com/studio/projects/install-ndk).
//! The `ANDROID_HOME` and `ANDROID_NDK_ROOT` environment variable need to be set to the right path.
//!
//! Note Slint does not require a specific build tool and can work with others, such as [xbuild](https://github.com/rust-mobile/xbuild).

Expand Down
3 changes: 2 additions & 1 deletion api/rs/slint/mcu.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Start by adding a dependency to the `slint` and the `slint-build` crates to your
Start with the `slint` crate like this:

```sh
cargo add slint@1.6.0 --no-default-features --features "compat-1-2 unsafe-single-threaded libm"
cargo add slint@1.6.0 --no-default-features --features "compat-1-2 unsafe-single-threaded libm renderer-software"
```

The default features of the `slint` crate are tailored towards hosted environments and includes the "std" feature. In bare metal environments,
Expand All @@ -43,6 +43,7 @@ In the snippet above, three features are selected:
feature changes Slint to use unsafe static for storage. This way, you guarantee to use Slint API only from a single thread, and not from interrupt handlers.
* `libm`: We select this feature to enable the use of the [libm](https://crates.io/crates/libm) crate to provide traits and functions for floating point arithmetic.
They're typically provided by the Rust Standard Library (std), but that's not available in bare metal environments.
* `renderer-software`: We select this feature to use Slint's built-in software renderer.

It might be necessary to enable the [Feature resolver version 2](https://doc.rust-lang.org/cargo/reference/features.html#feature-resolver-version-2)
in your Cargo.toml if you notice that your dependencies are attempting to build with `std` support even when disabled.
Expand Down

0 comments on commit 23f7a78

Please sign in to comment.