diff --git a/src/android.md b/src/android.md index 68444603..8ffef976 100644 --- a/src/android.md +++ b/src/android.md @@ -1,10 +1,25 @@ # Welcome to Rust in Android -Rust is supported for native platform development on Android. This means that -you can write new operating system services in Rust, as well as extending -existing services. +Rust is supported for system software on Android. This means that +you can write new services, libraries, drivers or even firmware in Rust +(or improve existing code as needed). > We will attempt to call Rust from one of your own projects today. So try to > find a little corner of your code base where we can move some lines of code to > Rust. The fewer dependencies and "exotic" types the better. Something that > parses some raw bytes would be ideal. + +
+ +The speaker may mention any of the following given the increased use of Rust +in Android: + +- Service example: [DNS over HTTP](https://security.googleblog.com/2022/07/dns-over-http3-in-android.html) + +- Libraries: [Rutabaga Virtual Graphics Interface](https://crosvm.dev/book/appendix/rutabaga_gfx.html) + +- Kernel Drivers: [Binder](https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-0-08ba9197f637@google.com/) + +- Firmware: [pKVM firmware](https://security.googleblog.com/2023/10/bare-metal-rust-in-android.html) + +
diff --git a/src/android/build-rules.md b/src/android/build-rules.md index a451e804..40aea21c 100644 --- a/src/android/build-rules.md +++ b/src/android/build-rules.md @@ -3,7 +3,7 @@ The Android build system (Soong) supports Rust via a number of modules: | Module Type | Description | -|-------------------|----------------------------------------------------------------------------------------------------| +| ----------------- | -------------------------------------------------------------------------------------------------- | | `rust_binary` | Produces a Rust binary. | | `rust_library` | Produces a Rust library, and provides both `rlib` and `dylib` variants. | | `rust_ffi` | Produces a Rust C library usable by `cc` modules, and provides both static and shared variants. | @@ -14,3 +14,21 @@ The Android build system (Soong) supports Rust via a number of modules: | `rust_bindgen` | Generates source and produces a Rust library containing Rust bindings to C libraries. | We will look at `rust_binary` and `rust_library` next. + +
+ +Additional items speaker may mention: + +- cargo is not optimized for multi-language repos, and also downloads packages from the internet. + +- For compliance and performance, Android must have crates in-tree. It must also interop with C/C++/Java code. Soong fills that gap. + +- Soong has many similarities to Bazel, which is the open-source variant of Blaze (used in google3). + +- There is a plan to transition [Android](https://source.android.com/docs/setup/build/bazel/introduction), [ChromeOS](https://chromium.googlesource.com/chromiumos/bazel/), and [Fuchsia](https://source.android.com/docs/setup/build/bazel/introduction) to Bazel. + +- Learning Bazel-like build rules is useful for all Rust OS developers. + +- Fun fact: Data from Star Trek is a Soong-type Android. + +
diff --git a/src/android/setup.md b/src/android/setup.md index 407e75c5..5e539f0a 100644 --- a/src/android/setup.md +++ b/src/android/setup.md @@ -1,7 +1,7 @@ # Setup -We will be using an Android Virtual Device to test our code. Make sure you have -access to one or create a new one with: +We will be using a Cuttlefish Android Virtual Device to test our code. Make sure you +have access to one or create a new one with: ```shell source build/envsetup.sh @@ -11,3 +11,13 @@ acloud create Please see the [Android Developer Codelab](https://source.android.com/docs/setup/start) for details. + +
+ +Key points: + +- Cuttlefish is a reference Android device designed to work on generic Linux desktops. MacOS support is also planned. + +- The Cuttlefish system image maintains high fidelity to real devices, and is the ideal emulator to run many Rust use cases. + +