From bae62bee7d981b02a68d4fc401bcf1e815616cea Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Tue, 21 Jul 2020 13:28:27 -0400 Subject: [PATCH] Provide generated sources to clippy. clippy was not being provided generated sources previously, so it would error out on being unable to locate the sources. Test: Clippy no longer errors out on generated sources. Bug: 161748694 Change-Id: I85907327ca40c82a9520e0c0dbd643bfba6b7315 --- rust/builder.go | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) 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(),