Include stubs type in metalava.rsp filename

Currently, metalava.rsp filepath for both the everything and the
exportable stubs type are identical, which may lead to incremental build
issues. This change resolves such issue by including the stubs type in
the metalava.rsp filename.

These files cannot be modified as ".../everything/metalava.rsp" and
".../exportable/metalava.rsp" as `FlagWithRspFileInputList(...)`
enforces the rsp filepath to be outside of the outdir, which is
".../everything/" and ".../exportable/", respectively. Thus, this change
continues to generate the rsp file to be generated in the module outdir,
but modifies the name of the rsp files as "everything.metalava.rsp" and
"exportable.metalava.rsp".

This change also simplifies the parameters in metalavaCmd(...) for the
simplicity of the method parameters.

Test: m nothing and inspect output for the everything and the exportable stubs
Bug: 336360490
Change-Id: Ifd4e89ef69808e79ea720199677585f0217f7c1c
This commit is contained in:
Jihoon Kang 2024-04-22 21:17:12 +00:00
parent 2ddb22ce99
commit 421c1cd796

View file

@ -708,8 +708,8 @@ func metalavaUseRbe(ctx android.ModuleContext) bool {
return ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_METALAVA")
}
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
srcJarList android.Path, bootclasspath, classpath classpath, homeDir android.WritablePath) *android.RuleBuilderCommand {
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs android.Paths,
srcJarList android.Path, homeDir android.WritablePath, params stubsCommandConfigParams) *android.RuleBuilderCommand {
rule.Command().Text("rm -rf").Flag(homeDir.String())
rule.Command().Text("mkdir -p").Flag(homeDir.String())
@ -739,14 +739,14 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
cmd.BuiltTool("metalava").ImplicitTool(ctx.Config().HostJavaToolPath(ctx, "metalava.jar")).
Flag(config.JavacVmFlags).
Flag(config.MetalavaAddOpens).
FlagWithArg("--java-source ", javaVersion.String()).
FlagWithRspFileInputList("@", android.PathForModuleOut(ctx, "metalava.rsp"), srcs).
FlagWithArg("--java-source ", params.javaVersion.String()).
FlagWithRspFileInputList("@", android.PathForModuleOut(ctx, fmt.Sprintf("%s.metalava.rsp", params.stubsType.String())), srcs).
FlagWithInput("@", srcJarList)
// Metalava does not differentiate between bootclasspath and classpath and has not done so for
// years, so it is unlikely to change any time soon.
combinedPaths := append(([]android.Path)(nil), bootclasspath.Paths()...)
combinedPaths = append(combinedPaths, classpath.Paths()...)
combinedPaths := append(([]android.Path)(nil), params.deps.bootClasspath.Paths()...)
combinedPaths = append(combinedPaths, params.deps.classpath.Paths()...)
if len(combinedPaths) > 0 {
cmd.FlagWithInputList("--classpath ", combinedPaths, ":")
}
@ -827,8 +827,7 @@ func (d *Droidstubs) commonMetalavaStubCmd(ctx android.ModuleContext, rule *andr
srcJarList := zipSyncCmd(ctx, rule, params.srcJarDir, d.Javadoc.srcJars)
homeDir := android.PathForModuleOut(ctx, params.stubConfig.stubsType.String(), "home")
cmd := metalavaCmd(ctx, rule, params.stubConfig.javaVersion, d.Javadoc.srcFiles, srcJarList,
params.stubConfig.deps.bootClasspath, params.stubConfig.deps.classpath, homeDir)
cmd := metalavaCmd(ctx, rule, d.Javadoc.srcFiles, srcJarList, homeDir, params.stubConfig)
cmd.Implicits(d.Javadoc.implicits)
d.stubsFlags(ctx, cmd, params.stubsDir, params.stubConfig.stubsType, params.stubConfig.checkApi)