Merge "Convert more stored WritablePaths to Paths" into main

This commit is contained in:
Colin Cross
2024-08-16 22:16:56 +00:00
committed by Gerrit Code Review
2 changed files with 24 additions and 19 deletions

View File

@@ -1154,8 +1154,9 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if Bool(a.properties.Jetifier) { if Bool(a.properties.Jetifier) {
inputFile := a.aarPath inputFile := a.aarPath
a.aarPath = android.PathForModuleOut(ctx, "jetifier", aarName) jetifierPath := android.PathForModuleOut(ctx, "jetifier", aarName)
TransformJetifier(ctx, a.aarPath.(android.WritablePath), inputFile) TransformJetifier(ctx, jetifierPath, inputFile)
a.aarPath = jetifierPath
} }
jarName := ctx.ModuleName() + ".jar" jarName := ctx.ModuleName() + ".jar"
@@ -1306,11 +1307,12 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
addMissingOptionalUsesLibsFromDep(ctx, module, &a.usesLibrary) addMissingOptionalUsesLibsFromDep(ctx, module, &a.usesLibrary)
}) })
var implementationJarFile android.OutputPath var implementationJarFile android.Path
if len(staticJars) > 0 { if len(staticJars) > 0 {
combineJars := append(android.Paths{classpathFile}, staticJars...) combineJars := append(android.Paths{classpathFile}, staticJars...)
implementationJarFile = android.PathForModuleOut(ctx, "combined", jarName).OutputPath combinedImplementationJar := android.PathForModuleOut(ctx, "combined", jarName).OutputPath
TransformJarsToJar(ctx, implementationJarFile, "combine", combineJars, android.OptionalPath{}, false, nil, nil) TransformJarsToJar(ctx, combinedImplementationJar, "combine", combineJars, android.OptionalPath{}, false, nil, nil)
implementationJarFile = combinedImplementationJar
} else { } else {
implementationJarFile = classpathFile implementationJarFile = classpathFile
} }
@@ -1329,7 +1331,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
implementationAndResourcesJar := implementationJarFile implementationAndResourcesJar := implementationJarFile
if resourceJarFile != nil { if resourceJarFile != nil {
jars := android.Paths{resourceJarFile, implementationAndResourcesJar} jars := android.Paths{resourceJarFile, implementationAndResourcesJar}
combinedJar := android.PathForModuleOut(ctx, "withres", jarName).OutputPath combinedJar := android.PathForModuleOut(ctx, "withres", jarName)
TransformJarsToJar(ctx, combinedJar, "for resources", jars, android.OptionalPath{}, TransformJarsToJar(ctx, combinedJar, "for resources", jars, android.OptionalPath{},
false, nil, nil) false, nil, nil)
implementationAndResourcesJar = combinedJar implementationAndResourcesJar = combinedJar

View File

@@ -2664,43 +2664,46 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Always pass the input jars to TransformJarsToJar, even if there is only a single jar, we need the output // Always pass the input jars to TransformJarsToJar, even if there is only a single jar, we need the output
// file of the module to be named jarName. // file of the module to be named jarName.
outputFile := android.PathForModuleOut(ctx, "combined", jarName) var outputFile android.Path
combinedImplementationJar := android.PathForModuleOut(ctx, "combined", jarName)
implementationJars := append(slices.Clone(jars), staticJars...) implementationJars := append(slices.Clone(jars), staticJars...)
TransformJarsToJar(ctx, outputFile, "combine prebuilt implementation jars", implementationJars, android.OptionalPath{}, TransformJarsToJar(ctx, combinedImplementationJar, "combine prebuilt implementation jars", implementationJars, android.OptionalPath{},
false, j.properties.Exclude_files, j.properties.Exclude_dirs) false, j.properties.Exclude_files, j.properties.Exclude_dirs)
outputFile = combinedImplementationJar
// If no dependencies have separate header jars then there is no need to create a separate // If no dependencies have separate header jars then there is no need to create a separate
// header jar for this module. // header jar for this module.
reuseImplementationJarAsHeaderJar := slices.Equal(staticJars, staticHeaderJars) reuseImplementationJarAsHeaderJar := slices.Equal(staticJars, staticHeaderJars)
var headerOutputFile android.ModuleOutPath var headerJar android.Path
if reuseImplementationJarAsHeaderJar { if reuseImplementationJarAsHeaderJar {
headerOutputFile = outputFile headerJar = outputFile
} else { } else {
headerJars := append(slices.Clone(jars), staticHeaderJars...) headerJars := append(slices.Clone(jars), staticHeaderJars...)
headerOutputFile = android.PathForModuleOut(ctx, "turbine-combined", jarName) headerOutputFile := android.PathForModuleOut(ctx, "turbine-combined", jarName)
TransformJarsToJar(ctx, headerOutputFile, "combine prebuilt header jars", headerJars, android.OptionalPath{}, TransformJarsToJar(ctx, headerOutputFile, "combine prebuilt header jars", headerJars, android.OptionalPath{},
false, j.properties.Exclude_files, j.properties.Exclude_dirs) false, j.properties.Exclude_files, j.properties.Exclude_dirs)
headerJar = headerOutputFile
} }
if Bool(j.properties.Jetifier) { if Bool(j.properties.Jetifier) {
inputFile := outputFile jetifierOutputFile := android.PathForModuleOut(ctx, "jetifier", jarName)
outputFile = android.PathForModuleOut(ctx, "jetifier", jarName) TransformJetifier(ctx, jetifierOutputFile, outputFile)
TransformJetifier(ctx, outputFile, inputFile) outputFile = jetifierOutputFile
if !reuseImplementationJarAsHeaderJar { if !reuseImplementationJarAsHeaderJar {
headerInputFile := headerOutputFile jetifierHeaderJar := android.PathForModuleOut(ctx, "jetifier-headers", jarName)
headerOutputFile = android.PathForModuleOut(ctx, "jetifier-headers", jarName) TransformJetifier(ctx, jetifierHeaderJar, headerJar)
TransformJetifier(ctx, headerOutputFile, headerInputFile) headerJar = jetifierHeaderJar
} else { } else {
headerOutputFile = outputFile headerJar = outputFile
} }
} }
// Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource. // Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource.
// Also strip the relative path from the header output file so that the reuseImplementationJarAsHeaderJar check // Also strip the relative path from the header output file so that the reuseImplementationJarAsHeaderJar check
// in a module that depends on this module considers them equal. // in a module that depends on this module considers them equal.
j.combinedHeaderFile = headerOutputFile.WithoutRel() j.combinedHeaderFile = headerJar.WithoutRel()
j.combinedImplementationFile = outputFile.WithoutRel() j.combinedImplementationFile = outputFile.WithoutRel()
j.maybeInstall(ctx, jarName, outputFile) j.maybeInstall(ctx, jarName, outputFile)