diff --git a/rust/builder.go b/rust/builder.go index d1d10122b..8b5a2bb36 100644 --- a/rust/builder.go +++ b/rust/builder.go @@ -42,14 +42,14 @@ var ( _ = pctx.SourcePathVariable("clippyCmd", "${config.RustBin}/clippy-driver") clippyDriver = pctx.AndroidStaticRule("clippy", blueprint.RuleParams{ - Command: "$clippyCmd " + + Command: "$envVars $clippyCmd " + // Because clippy-driver uses rustc as backend, we need to have some output even during the linting. // Use the metadata output as it has the smallest footprint. "--emit metadata -o $out $in ${libFlags} " + "$rustcFlags $clippyFlags", CommandDeps: []string{"$clippyCmd"}, }, - "rustcFlags", "libFlags", "clippyFlags") + "rustcFlags", "libFlags", "clippyFlags", "envVars") zip = pctx.AndroidStaticRule("zip", blueprint.RuleParams{ @@ -199,25 +199,6 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl output.coverageFile = gcnoFile } - if flags.Clippy { - clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy") - ctx.Build(pctx, android.BuildParams{ - Rule: clippyDriver, - Description: "clippy " + main.Rel(), - Output: clippyFile, - ImplicitOutputs: nil, - Inputs: inputs, - Implicits: implicits, - Args: map[string]string{ - "rustcFlags": strings.Join(rustcFlags, " "), - "libFlags": strings.Join(libFlags, " "), - "clippyFlags": strings.Join(flags.ClippyFlags, " "), - }, - }) - // Declare the clippy build as an implicit dependency of the original crate. - implicits = append(implicits, clippyFile) - } - if len(deps.SrcDeps) > 0 { moduleGenDir := android.PathForModuleOut(ctx, "out/") var outputs android.WritablePaths @@ -243,6 +224,26 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl envVars = append(envVars, "OUT_DIR=$$PWD/"+moduleGenDir.String()) } + if flags.Clippy { + clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy") + ctx.Build(pctx, android.BuildParams{ + Rule: clippyDriver, + Description: "clippy " + main.Rel(), + Output: clippyFile, + ImplicitOutputs: nil, + Inputs: inputs, + Implicits: implicits, + Args: map[string]string{ + "rustcFlags": strings.Join(rustcFlags, " "), + "libFlags": strings.Join(libFlags, " "), + "clippyFlags": strings.Join(flags.ClippyFlags, " "), + "envVars": strings.Join(envVars, " "), + }, + }) + // Declare the clippy build as an implicit dependency of the original crate. + implicits = append(implicits, clippyFile) + } + ctx.Build(pctx, android.BuildParams{ Rule: rustc, Description: "rustc " + main.Rel(),