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
Author: Chatting and opening your mind Review: Hu...
Where are the opportunities for Douyin? Basically...
Do you have the same or similar feelings: The And...
Many copywriters like to pay attention to Durex’s...
As we enter the second half of the Internet era, ...
Now many friends have opened accounts on Douyin. ...
Bytedance Qianchuan is an e-commerce advertising ...
Recently, the key project of the Chinese Academy ...
Author: Duan Yuechu Your browser does not support...
The world is so busy, no one will waste one more ...
In the summer of 2013, a nondescript post appeare...
The world of questions has completely come alive....
After releasing the iPhone 7, Apple's latest m...
Apple has been on vacation, and it feels like we ...