Allow users to enable local incremental Rust builds

This CL allows users to set the SOONG_RUSTC_INCREMENTAL environment
variable to enable incremental Rust builds.  The out/soong/rustc
directory is used for intermediate artifacts.

Test: m rust
Change-Id: Ica2587c30596325b7d3e82d8e3c1d610b92718b8
This commit is contained in:
Chris Wailes 2021-12-03 17:17:28 -08:00
parent 23d5d986fe
commit d9781fd67e

View file

@ -216,6 +216,13 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
// Suppress an implicit sysroot
rustcFlags = append(rustcFlags, "--sysroot=/dev/null")
// Enable incremental compilation if requested by user
if ctx.Config().IsEnvTrue("SOONG_RUSTC_INCREMENTAL") {
incrementalPath := android.PathForOutput(ctx, "rustc").String()
rustcFlags = append(rustcFlags, "-C incremental="+incrementalPath)
}
// Collect linker flags
linkFlags = append(linkFlags, flags.GlobalLinkFlags...)
linkFlags = append(linkFlags, flags.LinkFlags...)