Android 中的 Rust IDE 支援功能仰賴 rust-analyzer。rust-analyzer
是 IDE 用來瞭解程式碼結構,並提供程式碼補全或跳至定義等功能的語言伺服器通訊協定。在開始之前,請先搜尋
rust-analyzer QuickStart 說明文件
使用 rust-analyzer
通訊協定的 IDE 或編輯器。
Android 提供的設定可讓 rust-analyzer
瞭解
Android Rust 模組的建構方式。相關說明請參閱 Soong 產生的檔案
rust-project.json
。對於 Visual Studio Code 等部分 IDE,此檔案是由 aidegen
使用 -l r
選項引數 (用於選取 Rust 做為語言) 產生。如果您使用其他 IDE,請使用下列程式碼手動產生 rust-project.json
檔案:
// Generates rust-project.json in out/soong/
SOONG_GEN_RUST_PROJECT=1 m nothing
// Creates a symbolic link
ln -s $ANDROID_BUILD_TOP/out/soong/rust-project.json $ANDROID_BUILD_TOP
rust-analyzer
預先建構的穩定版本可在樹狀結構中取得:
prebuilts/rust/linux-x86/stable/rust-analyzer。