๋Ÿฌ์ŠคํŠธ ๋ฐ”์ด๋„ˆ๋ฆฌ

๊ฐ„๋‹จํ•œ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ์‹œ์ž‘ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. AOSP ์ฒดํฌ์•„์›ƒ์˜ ๋ฃจํŠธ์—์„œ ๋‹ค์Œ ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค:

hello_rust/Android.bp:

rust_binary {
    name: "hello_rust",
    crate_name: "hello_rust",
    srcs: ["src/main.rs"],
}

hello_rust/src/main.rs:

//! Rust ๋ฐ๋ชจ์ž…๋‹ˆ๋‹ค.

/// ์ธ์‚ฌ๋ง์„ ํ‘œ์ค€ ์ถœ๋ ฅ์œผ๋กœ ์ธ์‡„ํ•ฉ๋‹ˆ๋‹ค.
fn main() {
    println!("Hello from Rust!");
}

๊ทธ๋Ÿฐ ๋‹ค์Œ, ์ด ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๋นŒ๋“œํ•˜๊ณ , ๊ฐ€์ƒ ๋””๋ฐ”์ด์Šค์— ๋„ฃ๊ณ , ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

m hello_rust
adb push "$ANDROID_PRODUCT_OUT/system/bin/hello_rust" /data/local/tmp
adb shell /data/local/tmp/hello_rust
Hello from Rust!