Add explicit rspfile argument to RuleBuilderCommand.FlagWithRspFileInputList

Using $out.rsp as the rsp file adds extra complexity around keeping
the $ unescaped.  Make callers to FlagWithRspFileInputList provide
an explicit path for the rsp file instead.

Bug: 182612695
Test: rule_builder_test.go
Change-Id: I3f531d80c1efa8a9d09aac0a63790c5b11a9f0c6
diff --git a/java/lint.go b/java/lint.go
index 9f677db..fccd1a5 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -220,7 +220,9 @@
 		// Insert a second rule to write out the list of resources to a file.
 		resourcesList = android.PathForModuleOut(ctx, "lint", "resources.list")
 		resListRule := android.NewRuleBuilder(pctx, ctx)
-		resListRule.Command().Text("cp").FlagWithRspFileInputList("", l.resources).Output(resourcesList)
+		resListRule.Command().Text("cp").
+			FlagWithRspFileInputList("", resourcesList.ReplaceExtension(ctx, "rsp"), l.resources).
+			Output(resourcesList)
 		resListRule.Build("lint_resources_list", "lint resources list")
 		trackRSPDependency(l.resources, resourcesList)
 	}
@@ -241,7 +243,10 @@
 	// TODO(ccross): some of the files in l.srcs are generated sources and should be passed to
 	// lint separately.
 	srcsList := android.PathForModuleOut(ctx, "lint", "srcs.list")
-	rule.Command().Text("cp").FlagWithRspFileInputList("", l.srcs).Output(srcsList)
+	srcsListRsp := android.PathForModuleOut(ctx, "lint-srcs.list.rsp")
+	rule.Command().Text("cp").
+		FlagWithRspFileInputList("", srcsListRsp, l.srcs).
+		Output(srcsList)
 	trackRSPDependency(l.srcs, srcsList)
 
 	cmd := rule.Command().
@@ -635,7 +640,7 @@
 	rule.Command().BuiltTool("soong_zip").
 		FlagWithOutput("-o ", outputPath).
 		FlagWithArg("-C ", android.PathForIntermediates(ctx).String()).
-		FlagWithRspFileInputList("-r ", paths)
+		FlagWithRspFileInputList("-r ", outputPath.ReplaceExtension(ctx, "rsp"), paths)
 
 	rule.Build(outputPath.Base(), outputPath.Base())
 }