Remove lint outputs to prevent showing old lint results on error

The lint rules dumped the text output file to stdout on error.  If the
lint binary exited without updating the output file it would show old
results.

Remove the output files before running lint, and only dump the text
output file if it exists.

Bug: 181681346
Test: m lint-check
Change-Id: I4fa962b1212e8715f234912a9a5e049d5c1540e8
This commit is contained in:
Colin Cross
2021-03-04 10:01:34 -08:00
parent 00d93b143f
commit 5c113d13eb

View File

@@ -313,6 +313,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())
rule.Command().Text("mkdir -p").Flag(cacheDir.String()).Flag(homeDir.String())
rule.Command().Text("rm -f").Output(html).Output(text).Output(xml)
var annotationsZipPath, apiVersionsXMLPath android.Path
if ctx.Config().AlwaysUsePrebuiltSdks() {
@@ -361,7 +362,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
}
}
cmd.Text("|| (").Text("cat").Input(text).Text("; exit 7)").Text(")")
cmd.Text("|| (").Text("if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit 7)").Text(")")
rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String())