File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
plugin/src/main/kotlin/com/nishtahir Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -410,6 +410,31 @@ On Linux,
410
410
env RUST_ANDROID_GRADLE_CARGO_COMMAND=$HOME /.cargo/bin/cargo ./gradlew ...
411
411
```
412
412
413
+ ## Specifying Rust channel
414
+
415
+ Rust is released to three different "channels": stable, beta, and nightly (see
416
+ https://rust-lang.github.io/rustup/concepts/channels.html ). The ` rustup ` tool, which is how most
417
+ people install Rust, allows multiple channels to be installed simultaneously and to specify which
418
+ channel to use by invoking ` cargo +channel ... ` .
419
+
420
+ In order of preference, the plugin determines what channel to invoke ` cargo ` with by:
421
+
422
+ 1 . the value of ` cargo { rustupChannel = "..." } ` , if non-empty
423
+ 1 . ` rust.rustupChannel ` in ` ${rootDir}/local.properties `
424
+ 1 . the environment variable ` RUST_ANDROID_GRADLE_RUSTUP_CHANNEL `
425
+ 1 . the default, no channel specified (which ` cargo ` installed via ` rustup ` generally defaults to the
426
+ ` stable ` channel)
427
+
428
+ The channel should be recognized by ` cargo ` installed via ` rustup ` , i.e.:
429
+ - ` "stable" `
430
+ - ` "beta" `
431
+ - ` "nightly" `
432
+
433
+ A single leading ` '+' ` will be stripped, if present.
434
+
435
+ (Note that Cargo installed by a method other than ` rustup ` will generally not understand ` +channel `
436
+ and builds will likely fail.)
437
+
413
438
## Passing arguments to cargo
414
439
415
440
The plugin passes project properties named like ` RUST_ANDROID_GRADLE_target_..._KEY=VALUE ` through
Original file line number Diff line number Diff line change @@ -78,7 +78,16 @@ open class CargoBuildTask : DefaultTask() {
78
78
standardOutput = System .out
79
79
workingDir = File (project.project.projectDir, cargoExtension.module!! )
80
80
81
- val theCommandLine = mutableListOf (cargoExtension.cargoCommand, " build" );
81
+ val theCommandLine = mutableListOf (cargoExtension.cargoCommand)
82
+
83
+ if (! cargoExtension.rustupChannel.isEmpty()) {
84
+ val hasPlusSign = cargoExtension.rustupChannel.startsWith(" +" )
85
+ val maybePlusSign = if (! hasPlusSign) " +" else " "
86
+
87
+ theCommandLine.add(maybePlusSign + cargoExtension.rustupChannel)
88
+ }
89
+
90
+ theCommandLine.add(" build" )
82
91
83
92
// Respect `verbose` if it is set; otherwise, log if asked to
84
93
// with `--info` or `--debug` from the command line.
Original file line number Diff line number Diff line change @@ -83,6 +83,15 @@ open class CargoExtension {
83
83
}
84
84
}
85
85
86
+ var rustupChannel: String = " "
87
+ get() {
88
+ return if (! field.isEmpty()) {
89
+ field
90
+ } else {
91
+ getProperty(" rust.rustupChannel" , " RUST_ANDROID_GRADLE_RUSTUP_CHANNEL" ) ? : " "
92
+ }
93
+ }
94
+
86
95
var pythonCommand: String = " "
87
96
get() {
88
97
return if (! field.isEmpty()) {
You can’t perform that action at this time.
0 commit comments