Closed gitmp01 closed 3 years ago
Supporting explicit toolchain (e.g. cargo +nightly) is something i've wanted to do but haven't had a use for. That said, I think it should be a new option on CargoExtension (and local.properities).
E.g. add val toolchain: String?
after https://github.com/mozilla/rust-android-gradle/blob/16a12c2dd20fb9a7bc35cf6c5f813f65b49d775d/plugin/src/main/kotlin/com/nishtahir/CargoExtension.kt#L44 or around there.
Then add something here like https://github.com/mozilla/rust-android-gradle/blob/master/plugin/src/main/kotlin/com/nishtahir/CargoExtension.kt#L74 `
val rustupToolchain: String
get() {
return getProperty("rustup.toolchain", "RUST_ANDROID_GRADLE_RUSTUP_TOOLCHAIN") ?: toolchain
}
This would allow:
cargo {
toolchain = 'nightly'
// ...
}
in build.gradle, as well as overriding the build.gradle by putting it in local.properties
or the environment.
Then you need to use it in the file where you found the build line.
Wrinkles here are:
+toolchain
(it's a rustup feature)So it's important that if no custom toolchain gets provided, we don't change the environment or arguments we pass to cargo.
(note: this is just typed into github, so the code might not work)
Ah, I just noticed the vscode calls the rustup toolchains 'channels' (rust.channel) which would likely avoid the confusion around all the other sorts of toolchains around here. That said I could go either way, but we should probably be clear what the toolchain is for.
That'd be ok by me, I've only seen here that they are using the term toolchain.
Re the changes, I've made what you just said on a fork of mine. I can make a PR and discuss further changes over there if it is fine for you.
Here the branch if you want to have a look at it https://github.com/gitmp01/rust-android-gradle/tree/rustup-toolchain-spec
gradle cargoBuild
fails withSwitching rustup toolchain doesn't seem to solve the problem neither, (
rustup default nightly
).I've temporary solved changing this line CargoBuildTask.kt#L81 to
If everybody is fine with that, I can export the toolchain parameter to an environment variable named
RUSTUP_TOOLCHAIN
and make a PR.