Since 2019, the Android team has been working on introducing the Rust programming language to AOSP (Android Open Source Project) as a memory-safe alternative to platform native code development. Recently, Google further elaborated on the integration of Rust into AOSP in a blog post.
The blog content points out that, like any large project, introducing a new language requires careful consideration. For Android, an important aspect is to evaluate how to best integrate Rust into Android's build system. According to the Android team, there are many challenges in integrating Rust into large projects; for example, abandoning Cargo and using the Rust compiler rustc directly may risk isolating the organization from the broader Rust community. The team also said that when crates developed for Android can benefit the Rust community, they hope to release them as independent crates. They believe that Rust's success in Android depends on minimizing the divide between Android and the entire Rust community, and hope that the Rust community can benefit from Android's participation. Rust provides Cargo as the default build system and package manager, which collects dependencies and calls rustc (Rust compiler) to build the target crate (Rust package). In Android, Soong replaces this role and calls rustc directly. The reasons are:
"Using the Rust compiler directly allows us to avoid these issues and is consistent with how we compile all other code in AOSP," said Ivan Lozano from the Android team. "It provides the most control over the build process and simplifies integration with Android's existing build system. However, because Cargo usage is so ingrained in the Rust crate ecosystem, avoiding Cargo poses some challenges and affects many other build system decisions." In addition, as to why proc_macros is supported instead of build.rs scripts, the team explained that this is because build.rs code is written as one-time code, while proc_macros defines reusable functions in the compiler, which may be more useful to the Rust community. And proc_macros is usually better maintained and has more upstream reviews, which makes it easier to handle and enter the sandbox during the code review process. The Android team also revealed that they plan to add documentation on how to define and use Rust modules in Soong to source.android.com in the near future. They hope that Android's support for Rust will continue to grow along with the Rust ecosystem, and hope to continue to participate in discussions about how to integrate Rust into existing build systems. This article is reproduced from OSCHINA Title of this article: Google reveals more about integrating Rust into Android This article address: https://www.oschina.net/news/141612/integrating-rust-into-android-open |
<<: WeChat will stop opening the App technical service for Mini Programs after May 19
According to industry insiders, mini programs wil...
Should you keep your electric water heater on all...
Zebra AI Class is an intelligent education platfo...
"The more sour the fruit tastes, the higher ...
Business Korea reported that Samsung will showcas...
Amazon and Netflix have been competing fiercely i...
Elma Jashim, a recent college graduate, was looki...
“Prerequisites for offline events : Small events:...
Recently, there has been a sudden increase in deb...
Produced by: Science Popularization China Author:...
This article takes the mainstream payment system ...
All gatherings of people formed because of content...
[[385362]] Friends who have used Android phones s...
Plato once said: "The constant goal of all h...