mozilla / rust-android-gradle

Apache License 2.0
1.03k stars 67 forks source link

Support CARGO_TARGET_DIR environment variable #9

Closed thomcc closed 4 years ago

thomcc commented 4 years ago

Cargo supports letting you specify a single directory for use for all projects via the CARGO_TARGET_DIR environment variable.

See this reddit post for a reason someone might want to do this (I had 170GB in various target files across my machine), although I've heard it can to speed up build times too, since it improves dep cache hits.

I think we would just want to change https://github.com/mozilla/rust-android-gradle/blob/fcea23838ca8d95bc5e6caff504dfcf605b2e323/plugin/src/main/kotlin/com/nishtahir/CargoBuildTask.kt#L31, but

  1. I haven't tested this, and maybe it's a little more complex.
  2. It's unclear to me what should happen if both targetDirectory and that variable is specified. I kind of think that the variable should take precedence, as it's what cargo will actually use. But, maybe there's a use case for targetDirectory that I'm missing.