हमारा सुझाव है कि 27 मार्च, 2025 से AOSP को बनाने और उसमें योगदान देने के लिए, aosp-main
के बजाय android-latest-release
का इस्तेमाल करें. ज़्यादा जानकारी के लिए, AOSP में हुए बदलाव लेख पढ़ें.
बाइनरी मॉड्यूल
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
rust_binary
मॉड्यूल टाइप का इस्तेमाल करके, Rust बाइनरी बनाई जा सकती हैं. उदाहरण के लिए:
rust_binary {
name: "hello_rust",
srcs: ["src/hello_rust.rs"],
}
इसी तरह, सिर्फ़ होस्ट के लिए उपलब्ध मॉड्यूल देने के लिए, rust_binary_host
का इस्तेमाल किया जा सकता है.
अहम rust_binary प्रॉपर्टी
अहम सामान्य प्रॉपर्टी के अलावा, ये प्रॉपर्टी भी ज़रूरी हैं या rust_binary
मॉड्यूल टाइप के हिसाब से खास व्यवहार दिखाती हैं:
- static_executable: इस बाइनरी को स्टैटिक बाइनरी के तौर पर बनाता है. साथ ही, इससे यह भी पता चलता है कि
prefer_rlib
, true
है. पूरी तरह से स्टैटिक एक्सीक्यूटेबल, सिर्फ़ Bionic टारगेट के लिए बनाए जा सकते हैं. नॉन-बायोनिक टारगेट के लिए, इसका मतलब सिर्फ़ यह है कि prefer_rlib
true
है, लेकिन यह अब भी libc
और libdl
को डाइनैमिक तौर पर लिंक करता है.
- prefer_rlib: डिवाइस टारगेट के लिए डिफ़ॉल्ट रूप से
rlib
लिंकेज चुनने के लिए, rustlibs
लिंकेज को बदलता है. साथ ही, डिवाइस टारगेट पर libstd
को rlib
के तौर पर लिंक करता है. ध्यान दें कि होस्ट टारगेट के लिए, यह डिफ़ॉल्ट व्यवहार है और इससे उन पर कोई असर नहीं पड़ता.
लिंकेज
डिफ़ॉल्ट रूप से, डिवाइसों को टारगेट करने वाले rust_binary
मॉड्यूल, libstd
के साथ हमेशा डाइनैमिक तौर पर लिंक रहते हैं. साथ ही, rustlibs
में दी गई डिपेंडेंसी के लिए, डिफ़ॉल्ट रूप से dylib
लाइब्रेरी को प्राथमिकता दी जाएगी. ऐसा तब तक होगा, जब तक prefer_rlib
true
नहीं है. अगर आपको पूरी तरह से स्टैटिक बाइनरी की ज़रूरत है, तो static_executable
प्रॉपर्टी देखें.
होस्ट मॉड्यूल हमेशा libstd
के साथ स्टैटिक तौर पर लिंक होते हैं. साथ ही, डिफ़ॉल्ट रूप से rustlibs
में दी गई डिपेंडेंसी के लिए rlib
लाइब्रेरी को प्राथमिकता देते हैं.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-07-27 (UTC) को अपडेट किया गया."],[],[],null,["# Binary modules\n\nRust binaries can be produced using the `rust_binary` module type; for example: \n\n rust_binary {\n name: \"hello_rust\",\n srcs: [\"src/hello_rust.rs\"],\n }\n\nSimilarly, you can use `rust_binary_host` to provide a host-only\nmodule.\n\nNotable rust_binary properties\n------------------------------\n\nIn addition to the [Important common properties](/docs/setup/build/rust/building-rust-modules/android-rust-modules#important-common-properties),\nthe following properties are also either important, or exhibit unique behavior\nspecific to the `rust_binary` module type:\n\n- **static_executable** : Builds this binary as a static binary, and implies `prefer_rlib` is `true`. Fully static executables can only be produced for bionic targets. For non-bionic targets, this implies only that `prefer_rlib` is `true`, but it still links `libc` and `libdl` dynamically.\n- **prefer_rlib** : Changes the `rustlibs` linkage to select the `rlib` linkage by default for device targets, and links `libstd` as an `rlib` on device targets. Note that this is the default behavior for host targets, and has no impact on them.\n\nLinkage\n-------\n\nBy default, `rust_binary` modules that are targeting devices are always linked\ndynamically against `libstd` and by default will prefer `dylib` libraries for\ndependencies listed in `rustlibs` unless `prefer_rlib` is `true`. If fully\nstatic binaries are required, see the `static_executable` property.\n\nHost modules are always linked statically against `libstd` and\nby default prefer `rlib` libraries for dependencies that are listed in\n`rustlibs`."]]