@@ -8,19 +8,26 @@ annotation class AndroidRustDslMarker
88@AndroidRustDslMarker
99@Suppress(" unused" )
1010open class AndroidRustExtension : AndroidRustConfiguration () {
11+ /* *
12+ * Specify minimum supported rust version.
13+ *
14+ * Plugin will automatically use `rustup update` command to
15+ * update rust version in case installed versions is not high enough.
16+ */
1117 var minimumSupportedRustVersion = " "
12- var modules = mutableMapOf<String , AndroidRustModule >()
1318
1419 /* *
15- * Disable IDE ABI injection optimization.
16- * When true, all requested ABIs will be built regardless of IDE deployment target.
17- * When false (default), only the IDE target ABI will be built to speed up development builds.
20+ * Configuration map of all rust libraries to build.
1821 *
19- * Set to true if you experience "library not found" errors when running from Android Studio.
20- * See: https://github.com/MatrixDev/GradleAndroidRustPlugin/issues/3
22+ * Keys of this map are rust crates names.
2123 */
22- var disableAbiOptimization = false
24+ var modules = mutableMapOf< String , AndroidRustModule >()
2325
26+ /* *
27+ * Configure rust module/library to build.
28+ *
29+ * @param name Rust crate name.
30+ */
2431 fun module (name : String , configure : AndroidRustModule .() -> Unit ) {
2532 modules.getOrPut(name, ::AndroidRustModule ).configure()
2633 }
@@ -29,17 +36,33 @@ open class AndroidRustExtension : AndroidRustConfiguration() {
2936@AndroidRustDslMarker
3037@Suppress(" unused" )
3138class AndroidRustModule : AndroidRustConfiguration () {
39+ /* *
40+ * Path to the rust project folder.
41+ *
42+ * This is the folder containing `Cargo.toml` file.
43+ */
3244 lateinit var path: File
3345
46+ /* *
47+ * All supported build type configurations.
48+ *
49+ * Keys of this map should correspond to this project's build variants.
50+ */
3451 var buildTypes = hashMapOf(
3552 " debug" to AndroidRustBuildType ().also {
3653 it.profile = " dev"
3754 },
3855 " release" to AndroidRustBuildType ().also {
3956 it.profile = " release"
57+ it.disableAbiOptimization = true
4058 },
4159 )
4260
61+ /* *
62+ * Configure rust build options.
63+ *
64+ * @param name this project's build variant.
65+ */
4366 fun buildType (name : String , configure : AndroidRustBuildType .() -> Unit ) {
4467 buildTypes.getOrPut(name, ::AndroidRustBuildType ).configure()
4568 }
@@ -52,7 +75,32 @@ class AndroidRustBuildType : AndroidRustConfiguration()
5275@AndroidRustDslMarker
5376@Suppress(" unused" )
5477open class AndroidRustConfiguration {
78+ /* *
79+ * Rust profile (dev, release, etc.).
80+ *
81+ * See: https://doc.rust-lang.org/cargo/reference/profiles.html
82+ */
5583 var profile = " "
84+
85+ /* *
86+ * List of ABIs to build.
87+ */
5688 var targets = listOf<String >()
89+
90+ /* *
91+ * Run tests after the build.
92+ *
93+ * This will run `cargo test` command and check its result.
94+ */
5795 var runTests: Boolean? = null
96+
97+ /* *
98+ * Disable IDE ABI injection optimization.
99+ * - When `true`, all requested ABIs will be built regardless of IDE deployment target.
100+ * - When `false` (default), only the IDE target ABI will be built to speed up development builds.
101+ *
102+ * Set to `true` if you experience "library not found" errors when running from Android Studio.
103+ * See: https://github.com/MatrixDev/GradleAndroidRustPlugin/issues/3
104+ */
105+ var disableAbiOptimization: Boolean? = null
58106}
0 commit comments