Rust 二进制文件
让我们从一个简单的应用程序开始。在 AOSP 签出的根目录下,创建以下文件:
hello_rust/Android.bp:
1. rust_binary {
2. name: "hello_rust",
3. crate_name: "hello_rust",
4. srcs: ["src/main.rs"],
5. }
hello_rust/src/main.rs:
1. //! Rust demo.
3. /// Prints a greeting to standard output.
4. fn main() {
5. println!("Hello from Rust!");
6. }
你现在可以构建、推送和运行二进制文件:
1. m hello_rust
2. adb push "$ANDROID_PRODUCT_OUT/system/bin/hello_rust" /data/local/tmp
3. adb shell /data/local/tmp/hello_rust
1. Hello from Rust!
