diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/Android.bp | 4 | ||||
-rw-r--r-- | java/aar.go | 89 | ||||
-rw-r--r-- | java/app.go | 6 | ||||
-rw-r--r-- | java/base.go | 130 | ||||
-rw-r--r-- | java/bootclasspath_fragment.go | 2 | ||||
-rw-r--r-- | java/code_metadata_test.go | 115 | ||||
-rw-r--r-- | java/device_host_converter.go | 26 | ||||
-rw-r--r-- | java/dex.go | 18 | ||||
-rw-r--r-- | java/java.go | 72 | ||||
-rw-r--r-- | java/lint.go | 37 | ||||
-rw-r--r-- | java/platform_bootclasspath.go | 4 | ||||
-rw-r--r-- | java/robolectric.go | 2 | ||||
-rw-r--r-- | java/system_modules.go | 11 | ||||
-rw-r--r-- | java/test_spec_test.go | 122 |
14 files changed, 168 insertions, 470 deletions
diff --git a/java/Android.bp b/java/Android.bp index 1101d7a33..885e6825a 100644 --- a/java/Android.bp +++ b/java/Android.bp @@ -7,6 +7,7 @@ bootstrap_go_package { pkgPath: "android/soong/java", deps: [ "blueprint", + "blueprint-depset", "blueprint-pathtools", "soong", "soong-aconfig", @@ -15,7 +16,6 @@ bootstrap_go_package { "soong-dexpreopt", "soong-genrule", "soong-java-config", - "soong-testing", "soong-provenance", "soong-python", "soong-remoteexec", @@ -86,7 +86,6 @@ bootstrap_go_package { "app_import_test.go", "app_set_test.go", "app_test.go", - "code_metadata_test.go", "container_test.go", "bootclasspath_fragment_test.go", "device_host_converter_test.go", @@ -117,7 +116,6 @@ bootstrap_go_package { "sdk_version_test.go", "system_modules_test.go", "systemserver_classpath_fragment_test.go", - "test_spec_test.go", ], pluginFor: ["soong_build"], visibility: ["//visibility:public"], diff --git a/java/aar.go b/java/aar.go index 41cc24a0d..66ca00af8 100644 --- a/java/aar.go +++ b/java/aar.go @@ -25,14 +25,15 @@ import ( "android/soong/dexpreopt" "github.com/google/blueprint" + "github.com/google/blueprint/depset" "github.com/google/blueprint/proptools" ) type AndroidLibraryDependency interface { ExportPackage() android.Path - ResourcesNodeDepSet() *android.DepSet[*resourcesNode] - RRODirsDepSet() *android.DepSet[rroDir] - ManifestsDepSet() *android.DepSet[android.Path] + ResourcesNodeDepSet() depset.DepSet[*resourcesNode] + RRODirsDepSet() depset.DepSet[rroDir] + ManifestsDepSet() depset.DepSet[android.Path] SetRROEnforcedForDependent(enforce bool) IsRROEnforced(ctx android.BaseModuleContext) bool } @@ -136,9 +137,9 @@ type aapt struct { aaptProperties aaptProperties - resourcesNodesDepSet *android.DepSet[*resourcesNode] - rroDirsDepSet *android.DepSet[rroDir] - manifestsDepSet *android.DepSet[android.Path] + resourcesNodesDepSet depset.DepSet[*resourcesNode] + rroDirsDepSet depset.DepSet[rroDir] + manifestsDepSet depset.DepSet[android.Path] manifestValues struct { applicationId string @@ -232,15 +233,15 @@ func (a *aapt) filterProduct() string { func (a *aapt) ExportPackage() android.Path { return a.exportPackage } -func (a *aapt) ResourcesNodeDepSet() *android.DepSet[*resourcesNode] { +func (a *aapt) ResourcesNodeDepSet() depset.DepSet[*resourcesNode] { return a.resourcesNodesDepSet } -func (a *aapt) RRODirsDepSet() *android.DepSet[rroDir] { +func (a *aapt) RRODirsDepSet() depset.DepSet[rroDir] { return a.rroDirsDepSet } -func (a *aapt) ManifestsDepSet() *android.DepSet[android.Path] { +func (a *aapt) ManifestsDepSet() depset.DepSet[android.Path] { return a.manifestsDepSet } @@ -639,7 +640,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio a.extraAaptPackagesFile = extraPackages a.rTxt = rTxt a.splits = splits - a.resourcesNodesDepSet = android.NewDepSetBuilder[*resourcesNode](android.TOPOLOGICAL). + a.resourcesNodesDepSet = depset.NewBuilder[*resourcesNode](depset.TOPOLOGICAL). Direct(&resourcesNode{ resPackage: a.exportPackage, manifest: a.manifestPath, @@ -651,10 +652,10 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio usedResourceProcessor: a.useResourceProcessorBusyBox(ctx), }). Transitive(staticResourcesNodesDepSet).Build() - a.rroDirsDepSet = android.NewDepSetBuilder[rroDir](android.TOPOLOGICAL). + a.rroDirsDepSet = depset.NewBuilder[rroDir](depset.TOPOLOGICAL). Direct(rroDirs...). Transitive(staticRRODirsDepSet).Build() - a.manifestsDepSet = android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL). + a.manifestsDepSet = depset.NewBuilder[android.Path](depset.TOPOLOGICAL). Direct(a.manifestPath). DirectSlice(additionalManifests). Transitive(staticManifestsDepSet).Build() @@ -773,8 +774,8 @@ func (t transitiveAarDeps) assets() android.Paths { // aaptLibs collects libraries from dependencies and sdk_version and converts them into paths func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoaderContexts dexpreopt.ClassLoaderContextMap, usesLibrary *usesLibrary) ( - staticResourcesNodes, sharedResourcesNodes *android.DepSet[*resourcesNode], staticRRODirs *android.DepSet[rroDir], - staticManifests *android.DepSet[android.Path], sharedLibs android.Paths, flags []string) { + staticResourcesNodes, sharedResourcesNodes depset.DepSet[*resourcesNode], staticRRODirs depset.DepSet[rroDir], + staticManifests depset.DepSet[android.Path], sharedLibs android.Paths, flags []string) { if classLoaderContexts == nil { // Not all callers need to compute class loader context, those who don't just pass nil. @@ -787,10 +788,10 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, sharedLibs = append(sharedLibs, sdkDep.jars...) } - var staticResourcesNodeDepSets []*android.DepSet[*resourcesNode] - var sharedResourcesNodeDepSets []*android.DepSet[*resourcesNode] - rroDirsDepSetBuilder := android.NewDepSetBuilder[rroDir](android.TOPOLOGICAL) - manifestsDepSetBuilder := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL) + var staticResourcesNodeDepSets []depset.DepSet[*resourcesNode] + var sharedResourcesNodeDepSets []depset.DepSet[*resourcesNode] + rroDirsDepSetBuilder := depset.NewBuilder[rroDir](depset.TOPOLOGICAL) + manifestsDepSetBuilder := depset.NewBuilder[android.Path](depset.TOPOLOGICAL) ctx.VisitDirectDeps(func(module android.Module) { depTag := ctx.OtherModuleDependencyTag(module) @@ -834,9 +835,9 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, // dependencies) the highest priority dependency is listed first, but for resources the highest priority // dependency has to be listed last. This is also inconsistent with the way manifests from the same // transitive dependencies are merged. - staticResourcesNodes = android.NewDepSet(android.TOPOLOGICAL, nil, + staticResourcesNodes = depset.New(depset.TOPOLOGICAL, nil, android.ReverseSliceInPlace(staticResourcesNodeDepSets)) - sharedResourcesNodes = android.NewDepSet(android.TOPOLOGICAL, nil, + sharedResourcesNodes = depset.New(depset.TOPOLOGICAL, nil, android.ReverseSliceInPlace(sharedResourcesNodeDepSets)) staticRRODirs = rroDirsDepSetBuilder.Build() @@ -1064,8 +1065,8 @@ type AARImport struct { rTxt android.Path rJar android.Path - resourcesNodesDepSet *android.DepSet[*resourcesNode] - manifestsDepSet *android.DepSet[android.Path] + resourcesNodesDepSet depset.DepSet[*resourcesNode] + manifestsDepSet depset.DepSet[android.Path] hideApexVariantFromMake bool @@ -1111,15 +1112,15 @@ var _ AndroidLibraryDependency = (*AARImport)(nil) func (a *AARImport) ExportPackage() android.Path { return a.exportPackage } -func (a *AARImport) ResourcesNodeDepSet() *android.DepSet[*resourcesNode] { +func (a *AARImport) ResourcesNodeDepSet() depset.DepSet[*resourcesNode] { return a.resourcesNodesDepSet } -func (a *AARImport) RRODirsDepSet() *android.DepSet[rroDir] { - return android.NewDepSet[rroDir](android.TOPOLOGICAL, nil, nil) +func (a *AARImport) RRODirsDepSet() depset.DepSet[rroDir] { + return depset.New[rroDir](depset.TOPOLOGICAL, nil, nil) } -func (a *AARImport) ManifestsDepSet() *android.DepSet[android.Path] { +func (a *AARImport) ManifestsDepSet() depset.DepSet[android.Path] { return a.manifestsDepSet } @@ -1233,13 +1234,13 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { proguardFlags := extractedAARDir.Join(ctx, "proguard.txt") transitiveProguardFlags, transitiveUnconditionalExportedFlags := collectDepProguardSpecInfo(ctx) android.SetProvider(ctx, ProguardSpecInfoProvider, ProguardSpecInfo{ - ProguardFlagsFiles: android.NewDepSet[android.Path]( - android.POSTORDER, + ProguardFlagsFiles: depset.New[android.Path]( + depset.POSTORDER, android.Paths{proguardFlags}, transitiveProguardFlags, ), - UnconditionallyExportedProguardFlags: android.NewDepSet[android.Path]( - android.POSTORDER, + UnconditionallyExportedProguardFlags: depset.New[android.Path]( + depset.POSTORDER, nil, transitiveUnconditionalExportedFlags, ), @@ -1320,7 +1321,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { aapt2ExtractExtraPackages(ctx, extraAaptPackagesFile, a.rJar) a.extraAaptPackagesFile = extraAaptPackagesFile - resourcesNodesDepSetBuilder := android.NewDepSetBuilder[*resourcesNode](android.TOPOLOGICAL) + resourcesNodesDepSetBuilder := depset.NewBuilder[*resourcesNode](depset.TOPOLOGICAL) resourcesNodesDepSetBuilder.Direct(&resourcesNode{ resPackage: a.exportPackage, manifest: a.manifest, @@ -1333,7 +1334,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { resourcesNodesDepSetBuilder.Transitive(staticResourcesNodesDepSet) a.resourcesNodesDepSet = resourcesNodesDepSetBuilder.Build() - manifestDepSetBuilder := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(a.manifest) + manifestDepSetBuilder := depset.NewBuilder[android.Path](depset.TOPOLOGICAL).Direct(a.manifest) manifestDepSetBuilder.Transitive(staticManifestsDepSet) a.manifestsDepSet = manifestDepSetBuilder.Build() @@ -1352,9 +1353,9 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { var staticJars android.Paths var staticHeaderJars android.Paths var staticResourceJars android.Paths - var transitiveStaticLibsHeaderJars []*android.DepSet[android.Path] - var transitiveStaticLibsImplementationJars []*android.DepSet[android.Path] - var transitiveStaticLibsResourceJars []*android.DepSet[android.Path] + var transitiveStaticLibsHeaderJars []depset.DepSet[android.Path] + var transitiveStaticLibsImplementationJars []depset.DepSet[android.Path] + var transitiveStaticLibsResourceJars []depset.DepSet[android.Path] ctx.VisitDirectDeps(func(module android.Module) { if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { @@ -1364,24 +1365,18 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { staticJars = append(staticJars, dep.ImplementationJars...) staticHeaderJars = append(staticHeaderJars, dep.HeaderJars...) staticResourceJars = append(staticResourceJars, dep.ResourceJars...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveStaticLibsHeaderJars = append(transitiveStaticLibsHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } - if dep.TransitiveStaticLibsImplementationJars != nil { - transitiveStaticLibsImplementationJars = append(transitiveStaticLibsImplementationJars, dep.TransitiveStaticLibsImplementationJars) - } - if dep.TransitiveStaticLibsResourceJars != nil { - transitiveStaticLibsResourceJars = append(transitiveStaticLibsResourceJars, dep.TransitiveStaticLibsResourceJars) - } + transitiveStaticLibsHeaderJars = append(transitiveStaticLibsHeaderJars, dep.TransitiveStaticLibsHeaderJars) + transitiveStaticLibsImplementationJars = append(transitiveStaticLibsImplementationJars, dep.TransitiveStaticLibsImplementationJars) + transitiveStaticLibsResourceJars = append(transitiveStaticLibsResourceJars, dep.TransitiveStaticLibsResourceJars) } } addCLCFromDep(ctx, module, a.classLoaderContexts) addMissingOptionalUsesLibsFromDep(ctx, module, &a.usesLibrary) }) - completeStaticLibsHeaderJars := android.NewDepSet(android.PREORDER, android.Paths{classpathFile}, transitiveStaticLibsHeaderJars) - completeStaticLibsImplementationJars := android.NewDepSet(android.PREORDER, android.Paths{classpathFile}, transitiveStaticLibsImplementationJars) - completeStaticLibsResourceJars := android.NewDepSet(android.PREORDER, nil, transitiveStaticLibsResourceJars) + completeStaticLibsHeaderJars := depset.New(depset.PREORDER, android.Paths{classpathFile}, transitiveStaticLibsHeaderJars) + completeStaticLibsImplementationJars := depset.New(depset.PREORDER, android.Paths{classpathFile}, transitiveStaticLibsImplementationJars) + completeStaticLibsResourceJars := depset.New(depset.PREORDER, nil, transitiveStaticLibsResourceJars) var implementationJarFile android.Path var combineJars android.Paths diff --git a/java/app.go b/java/app.go index addbc28b0..e01a2ba7b 100644 --- a/java/app.go +++ b/java/app.go @@ -22,9 +22,8 @@ import ( "path/filepath" "strings" - "android/soong/testing" - "github.com/google/blueprint" + "github.com/google/blueprint/depset" "github.com/google/blueprint/proptools" "android/soong/android" @@ -227,7 +226,7 @@ func (a *AndroidApp) IsInstallable() bool { return Bool(a.properties.Installable) } -func (a *AndroidApp) ResourcesNodeDepSet() *android.DepSet[*resourcesNode] { +func (a *AndroidApp) ResourcesNodeDepSet() depset.DepSet[*resourcesNode] { return a.aapt.resourcesNodesDepSet } @@ -1443,7 +1442,6 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_common_data)...) a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_data)...) a.data = append(a.data, android.PathsForModuleSrc(ctx, a.testProperties.Device_first_prefer32_data)...) - android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ InstalledFiles: a.data, OutputFile: a.OutputFile(), diff --git a/java/base.go b/java/base.go index 3927c6194..07899d1f9 100644 --- a/java/base.go +++ b/java/base.go @@ -24,6 +24,7 @@ import ( "strings" "github.com/google/blueprint" + "github.com/google/blueprint/depset" "github.com/google/blueprint/pathtools" "github.com/google/blueprint/proptools" @@ -483,7 +484,7 @@ type Module struct { srcJarDeps android.Paths // the source files of this module and all its static dependencies - transitiveSrcFiles *android.DepSet[android.Path] + transitiveSrcFiles depset.DepSet[android.Path] // jar file containing implementation classes and resources including static library // dependencies @@ -1289,7 +1290,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{ HeaderJars: android.PathsIfNonNil(j.headerJarFile), LocalHeaderJars: localHeaderJars, - TransitiveStaticLibsHeaderJars: android.NewDepSet(android.PREORDER, localHeaderJars, transitiveStaticLibsHeaderJars), + TransitiveStaticLibsHeaderJars: depset.New(depset.PREORDER, localHeaderJars, transitiveStaticLibsHeaderJars), TransitiveLibsHeaderJarsForR8: j.transitiveLibsHeaderJarsForR8, TransitiveStaticLibsHeaderJarsForR8: j.transitiveStaticLibsHeaderJarsForR8, AidlIncludeDirs: j.exportAidlIncludeDirs, @@ -1552,7 +1553,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath localResourceJars = append(localResourceJars, servicesJar) } - completeStaticLibsResourceJars := android.NewDepSet(android.PREORDER, localResourceJars, deps.transitiveStaticLibsResourceJars) + completeStaticLibsResourceJars := depset.New(depset.PREORDER, localResourceJars, deps.transitiveStaticLibsResourceJars) var combinedResourceJar android.Path var resourceJars android.Paths @@ -1579,7 +1580,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath // classes.jar. If there is only one input jar this step will be skipped. var outputFile android.Path - completeStaticLibsImplementationJars := android.NewDepSet(android.PREORDER, localImplementationJars, deps.transitiveStaticLibsImplementationJars) + completeStaticLibsImplementationJars := depset.New(depset.PREORDER, localImplementationJars, deps.transitiveStaticLibsImplementationJars) var jars android.Paths if ctx.Config().UseTransitiveJarsInClasspath() { @@ -1609,7 +1610,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath Input: jars[0], Output: copiedJar, }) - completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, android.Paths{copiedJar}, nil) + completeStaticLibsImplementationJars = depset.New(depset.PREORDER, android.Paths{copiedJar}, nil) outputFile = copiedJar } else { outputFile = jars[0] @@ -1625,7 +1626,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath jarjarFile, jarjarred := j.jarjarIfNecessary(ctx, outputFile, jarName, "") if jarjarred { localImplementationJars = android.Paths{jarjarFile} - completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, localImplementationJars, nil) + completeStaticLibsImplementationJars = depset.New(depset.PREORDER, localImplementationJars, nil) } outputFile = jarjarFile @@ -1635,7 +1636,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath combinedResourceJar = resourceJarJarFile if jarjarred { localResourceJars = android.Paths{resourceJarJarFile} - completeStaticLibsResourceJars = android.NewDepSet(android.PREORDER, localResourceJars, nil) + completeStaticLibsResourceJars = depset.New(depset.PREORDER, localResourceJars, nil) } } @@ -1653,14 +1654,14 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath TransformRavenizer(ctx, ravenizerOutput, ravenizerInput, ravenizerArgs) outputFile = ravenizerOutput localImplementationJars = android.Paths{ravenizerOutput} - completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, localImplementationJars, nil) + completeStaticLibsImplementationJars = depset.New(depset.PREORDER, localImplementationJars, nil) if combinedResourceJar != nil { ravenizerInput = combinedResourceJar ravenizerOutput = android.PathForModuleOut(ctx, "ravenizer", "resources", jarName) TransformRavenizer(ctx, ravenizerOutput, ravenizerInput, ravenizerArgs) combinedResourceJar = ravenizerOutput localResourceJars = android.Paths{ravenizerOutput} - completeStaticLibsResourceJars = android.NewDepSet(android.PREORDER, localResourceJars, nil) + completeStaticLibsResourceJars = depset.New(depset.PREORDER, localResourceJars, nil) } } @@ -1675,7 +1676,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath }) outputFile = apiMapperFile localImplementationJars = android.Paths{apiMapperFile} - completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, localImplementationJars, nil) + completeStaticLibsImplementationJars = depset.New(depset.PREORDER, localImplementationJars, nil) } // Check package restrictions if necessary. @@ -1698,7 +1699,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath }) outputFile = packageCheckOutputFile localImplementationJars = android.Paths{packageCheckOutputFile} - completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, localImplementationJars, nil) + completeStaticLibsImplementationJars = depset.New(depset.PREORDER, localImplementationJars, nil) // Check packages and create a timestamp file when complete. CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages) @@ -1736,7 +1737,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath if j.shouldInstrument(ctx) { instrumentedOutputFile := j.instrument(ctx, flags, outputFile, jarName, specs) - completeStaticLibsImplementationJarsToCombine = android.NewDepSet(android.PREORDER, android.Paths{instrumentedOutputFile}, nil) + completeStaticLibsImplementationJarsToCombine = depset.New(depset.PREORDER, android.Paths{instrumentedOutputFile}, nil) outputFile = instrumentedOutputFile } @@ -1915,7 +1916,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath RepackagedHeaderJars: android.PathsIfNonNil(repackagedHeaderJarFile), LocalHeaderJars: localHeaderJars, - TransitiveStaticLibsHeaderJars: android.NewDepSet(android.PREORDER, localHeaderJars, transitiveStaticLibsHeaderJars), + TransitiveStaticLibsHeaderJars: depset.New(depset.PREORDER, localHeaderJars, transitiveStaticLibsHeaderJars), TransitiveStaticLibsImplementationJars: completeStaticLibsImplementationJars, TransitiveStaticLibsResourceJars: completeStaticLibsResourceJars, @@ -1944,17 +1945,15 @@ func (j *Module) useCompose(ctx android.BaseModuleContext) bool { return android.InList("androidx.compose.runtime_runtime", j.staticLibs(ctx)) } -func collectDepProguardSpecInfo(ctx android.ModuleContext) (transitiveProguardFlags, transitiveUnconditionalExportedFlags []*android.DepSet[android.Path]) { +func collectDepProguardSpecInfo(ctx android.ModuleContext) (transitiveProguardFlags, transitiveUnconditionalExportedFlags []depset.DepSet[android.Path]) { ctx.VisitDirectDeps(func(m android.Module) { depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider) depTag := ctx.OtherModuleDependencyTag(m) - if depProguardInfo.UnconditionallyExportedProguardFlags != nil { - transitiveUnconditionalExportedFlags = append(transitiveUnconditionalExportedFlags, depProguardInfo.UnconditionallyExportedProguardFlags) - transitiveProguardFlags = append(transitiveProguardFlags, depProguardInfo.UnconditionallyExportedProguardFlags) - } + transitiveUnconditionalExportedFlags = append(transitiveUnconditionalExportedFlags, depProguardInfo.UnconditionallyExportedProguardFlags) + transitiveProguardFlags = append(transitiveProguardFlags, depProguardInfo.UnconditionallyExportedProguardFlags) - if depTag == staticLibTag && depProguardInfo.ProguardFlagsFiles != nil { + if depTag == staticLibTag { transitiveProguardFlags = append(transitiveProguardFlags, depProguardInfo.ProguardFlagsFiles) } }) @@ -1976,13 +1975,13 @@ func (j *Module) collectProguardSpecInfo(ctx android.ModuleContext) ProguardSpec return ProguardSpecInfo{ Export_proguard_flags_files: exportUnconditionally, - ProguardFlagsFiles: android.NewDepSet[android.Path]( - android.POSTORDER, + ProguardFlagsFiles: depset.New[android.Path]( + depset.POSTORDER, proguardFlagsForThisModule, transitiveProguardFlags, ), - UnconditionallyExportedProguardFlags: android.NewDepSet[android.Path]( - android.POSTORDER, + UnconditionallyExportedProguardFlags: depset.New[android.Path]( + depset.POSTORDER, directUnconditionalExportedFlags, transitiveUnconditionalExportedFlags, ), @@ -2074,7 +2073,7 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars // one input jar this step will be skipped. var jars android.Paths if ctx.Config().UseTransitiveJarsInClasspath() { - depSet := android.NewDepSet(android.PREORDER, localHeaderJars, deps.transitiveStaticLibsHeaderJars) + depSet := depset.New(depset.PREORDER, localHeaderJars, deps.transitiveStaticLibsHeaderJars) jars = depSet.ToList() } else { jars = append(slices.Clone(localHeaderJars), deps.staticHeaderJars...) @@ -2104,9 +2103,9 @@ func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags, type providesTransitiveHeaderJarsForR8 struct { // set of header jars for all transitive libs deps - transitiveLibsHeaderJarsForR8 *android.DepSet[android.Path] + transitiveLibsHeaderJarsForR8 depset.DepSet[android.Path] // set of header jars for all transitive static libs deps - transitiveStaticLibsHeaderJarsForR8 *android.DepSet[android.Path] + transitiveStaticLibsHeaderJarsForR8 depset.DepSet[android.Path] } // collectTransitiveHeaderJarsForR8 visits direct dependencies and collects all transitive libs and static_libs @@ -2116,8 +2115,8 @@ type providesTransitiveHeaderJarsForR8 struct { func (j *providesTransitiveHeaderJarsForR8) collectTransitiveHeaderJarsForR8(ctx android.ModuleContext) { directLibs := android.Paths{} directStaticLibs := android.Paths{} - transitiveLibs := []*android.DepSet[android.Path]{} - transitiveStaticLibs := []*android.DepSet[android.Path]{} + transitiveLibs := []depset.DepSet[android.Path]{} + transitiveStaticLibs := []depset.DepSet[android.Path]{} ctx.VisitDirectDeps(func(module android.Module) { // don't add deps of the prebuilt version of the same library if ctx.ModuleName() == android.RemoveOptionalPrebuiltPrefix(module.Name()) { @@ -2136,17 +2135,12 @@ func (j *providesTransitiveHeaderJarsForR8) collectTransitiveHeaderJarsForR8(ctx return } - if dep.TransitiveLibsHeaderJarsForR8 != nil { - transitiveLibs = append(transitiveLibs, dep.TransitiveLibsHeaderJarsForR8) - } - if dep.TransitiveStaticLibsHeaderJarsForR8 != nil { - transitiveStaticLibs = append(transitiveStaticLibs, dep.TransitiveStaticLibsHeaderJarsForR8) - } - + transitiveLibs = append(transitiveLibs, dep.TransitiveLibsHeaderJarsForR8) + transitiveStaticLibs = append(transitiveStaticLibs, dep.TransitiveStaticLibsHeaderJarsForR8) } }) - j.transitiveLibsHeaderJarsForR8 = android.NewDepSet(android.POSTORDER, directLibs, transitiveLibs) - j.transitiveStaticLibsHeaderJarsForR8 = android.NewDepSet(android.POSTORDER, directStaticLibs, transitiveStaticLibs) + j.transitiveLibsHeaderJarsForR8 = depset.New(depset.POSTORDER, directLibs, transitiveLibs) + j.transitiveStaticLibsHeaderJarsForR8 = depset.New(depset.POSTORDER, directStaticLibs, transitiveStaticLibs) } func (j *Module) HeaderJars() android.Paths { @@ -2246,19 +2240,17 @@ func (j *Module) JacocoReportClassesFile() android.Path { } func (j *Module) collectTransitiveSrcFiles(ctx android.ModuleContext, mine android.Paths) { - var fromDeps []*android.DepSet[android.Path] + var fromDeps []depset.DepSet[android.Path] ctx.VisitDirectDeps(func(module android.Module) { tag := ctx.OtherModuleDependencyTag(module) if tag == staticLibTag { if depInfo, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { - if depInfo.TransitiveSrcFiles != nil { - fromDeps = append(fromDeps, depInfo.TransitiveSrcFiles) - } + fromDeps = append(fromDeps, depInfo.TransitiveSrcFiles) } } }) - j.transitiveSrcFiles = android.NewDepSet(android.POSTORDER, mine, fromDeps) + j.transitiveSrcFiles = depset.New(depset.POSTORDER, mine, fromDeps) } func (j *Module) IsInstallable() bool { @@ -2392,12 +2384,12 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { j.collectTransitiveHeaderJarsForR8(ctx) - var transitiveBootClasspathHeaderJars []*android.DepSet[android.Path] - var transitiveClasspathHeaderJars []*android.DepSet[android.Path] - var transitiveJava9ClasspathHeaderJars []*android.DepSet[android.Path] - var transitiveStaticJarsHeaderLibs []*android.DepSet[android.Path] - var transitiveStaticJarsImplementationLibs []*android.DepSet[android.Path] - var transitiveStaticJarsResourceLibs []*android.DepSet[android.Path] + var transitiveBootClasspathHeaderJars []depset.DepSet[android.Path] + var transitiveClasspathHeaderJars []depset.DepSet[android.Path] + var transitiveJava9ClasspathHeaderJars []depset.DepSet[android.Path] + var transitiveStaticJarsHeaderLibs []depset.DepSet[android.Path] + var transitiveStaticJarsImplementationLibs []depset.DepSet[android.Path] + var transitiveStaticJarsResourceLibs []depset.DepSet[android.Path] ctx.VisitDirectDeps(func(module android.Module) { otherName := ctx.OtherModuleName(module) @@ -2431,9 +2423,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { switch tag { case bootClasspathTag: deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveBootClasspathHeaderJars = append(transitiveBootClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } + transitiveBootClasspathHeaderJars = append(transitiveBootClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) case sdkLibTag, libTag, instrumentationForTag: if _, ok := module.(*Plugin); ok { ctx.ModuleErrorf("a java_plugin (%s) cannot be used as a libs dependency", otherName) @@ -2448,14 +2438,10 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { addPlugins(&deps, dep.ExportedPlugins, dep.ExportedPluginClasses...) deps.disableTurbine = deps.disableTurbine || dep.ExportedPluginDisableTurbine - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } + transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) case java9LibTag: deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveJava9ClasspathHeaderJars = append(transitiveJava9ClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } + transitiveJava9ClasspathHeaderJars = append(transitiveJava9ClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) case staticLibTag: if _, ok := module.(*Plugin); ok { ctx.ModuleErrorf("a java_plugin (%s) cannot be used as a static_libs dependency", otherName) @@ -2472,16 +2458,10 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { deps.disableTurbine = deps.disableTurbine || dep.ExportedPluginDisableTurbine deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.AconfigIntermediateCacheOutputPaths...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) - transitiveStaticJarsHeaderLibs = append(transitiveStaticJarsHeaderLibs, dep.TransitiveStaticLibsHeaderJars) - } - if dep.TransitiveStaticLibsImplementationJars != nil { - transitiveStaticJarsImplementationLibs = append(transitiveStaticJarsImplementationLibs, dep.TransitiveStaticLibsImplementationJars) - } - if dep.TransitiveStaticLibsResourceJars != nil { - transitiveStaticJarsResourceLibs = append(transitiveStaticJarsResourceLibs, dep.TransitiveStaticLibsResourceJars) - } + transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) + transitiveStaticJarsHeaderLibs = append(transitiveStaticJarsHeaderLibs, dep.TransitiveStaticLibsHeaderJars) + transitiveStaticJarsImplementationLibs = append(transitiveStaticJarsImplementationLibs, dep.TransitiveStaticLibsImplementationJars) + transitiveStaticJarsResourceLibs = append(transitiveStaticJarsResourceLibs, dep.TransitiveStaticLibsResourceJars) case pluginTag: if plugin, ok := module.(*Plugin); ok { if plugin.pluginProperties.Processor_class != nil { @@ -2535,14 +2515,14 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { deps.classpath = append(deps.classpath, dep.Srcs()...) deps.dexClasspath = append(deps.classpath, dep.Srcs()...) transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, - android.NewDepSet(android.PREORDER, dep.Srcs(), nil)) + depset.New(depset.PREORDER, dep.Srcs(), nil)) case staticLibTag: checkProducesJars(ctx, dep) deps.classpath = append(deps.classpath, dep.Srcs()...) deps.staticJars = append(deps.staticJars, dep.Srcs()...) deps.staticHeaderJars = append(deps.staticHeaderJars, dep.Srcs()...) - depHeaderJars := android.NewDepSet(android.PREORDER, dep.Srcs(), nil) + depHeaderJars := depset.New(depset.PREORDER, dep.Srcs(), nil) transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, depHeaderJars) transitiveStaticJarsHeaderLibs = append(transitiveStaticJarsHeaderLibs, depHeaderJars) transitiveStaticJarsImplementationLibs = append(transitiveStaticJarsImplementationLibs, depHeaderJars) @@ -2559,10 +2539,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { // then add its libs to the bootclasspath. if sm, ok := android.OtherModuleProvider(ctx, module, SystemModulesProvider); ok { deps.bootClasspath = append(deps.bootClasspath, sm.HeaderJars...) - if sm.TransitiveStaticLibsHeaderJars != nil { - transitiveBootClasspathHeaderJars = append(transitiveBootClasspathHeaderJars, - sm.TransitiveStaticLibsHeaderJars) - } + transitiveBootClasspathHeaderJars = append(transitiveBootClasspathHeaderJars, + sm.TransitiveStaticLibsHeaderJars) } else { ctx.PropertyErrorf("boot classpath dependency %q does not provide SystemModulesProvider", ctx.OtherModuleName(module)) @@ -2598,11 +2576,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { deps.transitiveStaticLibsResourceJars = transitiveStaticJarsResourceLibs if ctx.Config().UseTransitiveJarsInClasspath() { - depSet := android.NewDepSet(android.PREORDER, nil, transitiveClasspathHeaderJars) + depSet := depset.New(depset.PREORDER, nil, transitiveClasspathHeaderJars) deps.classpath = depSet.ToList() - depSet = android.NewDepSet(android.PREORDER, nil, transitiveBootClasspathHeaderJars) + depSet = depset.New(depset.PREORDER, nil, transitiveBootClasspathHeaderJars) deps.bootClasspath = depSet.ToList() - depSet = android.NewDepSet(android.PREORDER, nil, transitiveJava9ClasspathHeaderJars) + depSet = depset.New(depset.PREORDER, nil, transitiveJava9ClasspathHeaderJars) deps.java9Classpath = depSet.ToList() } diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 4fcd40bd3..1a3368057 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -23,7 +23,6 @@ import ( "android/soong/android" "android/soong/dexpreopt" - "android/soong/testing" "github.com/google/blueprint/proptools" @@ -524,7 +523,6 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo if ctx.Module() != ctx.FinalModule() { b.HideFromMake() } - android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) } // getProfileProviderApex returns the name of the apex that provides a boot image profile, or an diff --git a/java/code_metadata_test.go b/java/code_metadata_test.go deleted file mode 100644 index 9dc9a2262..000000000 --- a/java/code_metadata_test.go +++ /dev/null @@ -1,115 +0,0 @@ -package java - -import ( - "strings" - "testing" - - "android/soong/android" - soongTesting "android/soong/testing" - "android/soong/testing/code_metadata_internal_proto" - - "google.golang.org/protobuf/proto" -) - -func TestCodeMetadata(t *testing.T) { - bp := `code_metadata { - name: "module-name", - teamId: "12345", - code: [ - "foo", - ] - } - - java_sdk_library { - name: "foo", - srcs: ["a.java"], - }` - result := runCodeMetadataTest(t, android.FixtureExpectsNoErrors, bp) - - module := result.ModuleForTests("module-name", "") - - // Check that the provider has the right contents - data, _ := android.OtherModuleProvider(result, module.Module(), soongTesting.CodeMetadataProviderKey) - if !strings.HasSuffix( - data.IntermediatePath.String(), "/intermediateCodeMetadata.pb", - ) { - t.Errorf( - "Missing intermediates path in provider: %s", - data.IntermediatePath.String(), - ) - } - - metadata := android.ContentFromFileRuleForTests(t, result.TestContext, - module.Output(data.IntermediatePath.String())) - - metadataList := make([]*code_metadata_internal_proto.CodeMetadataInternal_TargetOwnership, 0, 2) - teamId := "12345" - bpFilePath := "Android.bp" - targetName := "foo" - srcFile := []string{"a.java"} - expectedMetadataProto := code_metadata_internal_proto.CodeMetadataInternal_TargetOwnership{ - TrendyTeamId: &teamId, - TargetName: &targetName, - Path: &bpFilePath, - SourceFiles: srcFile, - } - metadataList = append(metadataList, &expectedMetadataProto) - - CodeMetadataMetadata := code_metadata_internal_proto.CodeMetadataInternal{TargetOwnershipList: metadataList} - protoData, _ := proto.Marshal(&CodeMetadataMetadata) - expectedMetadata := string(protoData) - - if metadata != expectedMetadata { - t.Errorf( - "Retrieved metadata: %s is not equal to expectedMetadata: %s", metadata, - expectedMetadata, - ) - } - - // Tests for all_test_spec singleton. - singleton := result.SingletonForTests("all_code_metadata") - rule := singleton.Rule("all_code_metadata_rule") - prebuiltOs := result.Config.PrebuiltOS() - expectedCmd := "out/soong/host/" + prebuiltOs + "/bin/metadata -rule code_metadata -inputFile out/soong/all_code_metadata_paths.rsp -outputFile out/soong/ownership/all_code_metadata.pb" - expectedOutputFile := "out/soong/ownership/all_code_metadata.pb" - expectedInputFile := "out/soong/.intermediates/module-name/intermediateCodeMetadata.pb" - if !strings.Contains( - strings.TrimSpace(rule.Output.String()), - expectedOutputFile, - ) { - t.Errorf( - "Retrieved singletonOutputFile: %s is not equal to expectedSingletonOutputFile: %s", - rule.Output.String(), expectedOutputFile, - ) - } - - if !strings.Contains( - strings.TrimSpace(rule.Inputs[0].String()), - expectedInputFile, - ) { - t.Errorf( - "Retrieved singletonInputFile: %s is not equal to expectedSingletonInputFile: %s", - rule.Inputs[0].String(), expectedInputFile, - ) - } - - if !strings.Contains( - strings.TrimSpace(rule.RuleParams.Command), - expectedCmd, - ) { - t.Errorf( - "Retrieved cmd: %s doesn't contain expectedCmd: %s", - rule.RuleParams.Command, expectedCmd, - ) - } -} -func runCodeMetadataTest( - t *testing.T, errorHandler android.FixtureErrorHandler, bp string, -) *android.TestResult { - return android.GroupFixturePreparers( - soongTesting.PrepareForTestWithTestingBuildComponents, prepareForJavaTest, - PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("foo"), - ). - ExtendWithErrorHandler(errorHandler). - RunTestWithBp(t, bp) -} diff --git a/java/device_host_converter.go b/java/device_host_converter.go index 3f4e3cda0..bfacea6da 100644 --- a/java/device_host_converter.go +++ b/java/device_host_converter.go @@ -20,6 +20,8 @@ import ( "android/soong/android" "android/soong/dexpreopt" + + "github.com/google/blueprint/depset" ) type DeviceHostConverter struct { @@ -96,9 +98,9 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont ctx.PropertyErrorf("libs", "at least one dependency is required") } - var transitiveHeaderJars []*android.DepSet[android.Path] - var transitiveImplementationJars []*android.DepSet[android.Path] - var transitiveResourceJars []*android.DepSet[android.Path] + var transitiveHeaderJars []depset.DepSet[android.Path] + var transitiveImplementationJars []depset.DepSet[android.Path] + var transitiveResourceJars []depset.DepSet[android.Path] ctx.VisitDirectDepsWithTag(deviceHostConverterDepTag, func(m android.Module) { if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok { @@ -110,15 +112,9 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont d.srcJarArgs = append(d.srcJarArgs, dep.SrcJarArgs...) d.srcJarDeps = append(d.srcJarDeps, dep.SrcJarDeps...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveHeaderJars = append(transitiveHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } - if dep.TransitiveStaticLibsImplementationJars != nil { - transitiveImplementationJars = append(transitiveImplementationJars, dep.TransitiveStaticLibsImplementationJars) - } - if dep.TransitiveStaticLibsResourceJars != nil { - transitiveResourceJars = append(transitiveResourceJars, dep.TransitiveStaticLibsResourceJars) - } + transitiveHeaderJars = append(transitiveHeaderJars, dep.TransitiveStaticLibsHeaderJars) + transitiveImplementationJars = append(transitiveImplementationJars, dep.TransitiveStaticLibsImplementationJars) + transitiveResourceJars = append(transitiveResourceJars, dep.TransitiveStaticLibsResourceJars) } else { ctx.PropertyErrorf("libs", "module %q cannot be used as a dependency", ctx.OtherModuleName(m)) } @@ -147,9 +143,9 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{ HeaderJars: d.headerJars, LocalHeaderJars: d.headerJars, - TransitiveStaticLibsHeaderJars: android.NewDepSet(android.PREORDER, nil, transitiveHeaderJars), - TransitiveStaticLibsImplementationJars: android.NewDepSet(android.PREORDER, nil, transitiveImplementationJars), - TransitiveStaticLibsResourceJars: android.NewDepSet(android.PREORDER, nil, transitiveResourceJars), + TransitiveStaticLibsHeaderJars: depset.New(depset.PREORDER, nil, transitiveHeaderJars), + TransitiveStaticLibsImplementationJars: depset.New(depset.PREORDER, nil, transitiveImplementationJars), + TransitiveStaticLibsResourceJars: depset.New(depset.PREORDER, nil, transitiveResourceJars), ImplementationAndResourcesJars: d.implementationAndResourceJars, ImplementationJars: d.implementationJars, ResourceJars: d.resourceJars, diff --git a/java/dex.go b/java/dex.go index f4b53f00a..1f71aee1a 100644 --- a/java/dex.go +++ b/java/dex.go @@ -324,20 +324,16 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams) r8Deps = append(r8Deps, flags.dexClasspath...) transitiveStaticLibsLookupMap := map[android.Path]bool{} - if d.transitiveStaticLibsHeaderJarsForR8 != nil { - for _, jar := range d.transitiveStaticLibsHeaderJarsForR8.ToList() { - transitiveStaticLibsLookupMap[jar] = true - } + for _, jar := range d.transitiveStaticLibsHeaderJarsForR8.ToList() { + transitiveStaticLibsLookupMap[jar] = true } transitiveHeaderJars := android.Paths{} - if d.transitiveLibsHeaderJarsForR8 != nil { - for _, jar := range d.transitiveLibsHeaderJarsForR8.ToList() { - if _, ok := transitiveStaticLibsLookupMap[jar]; ok { - // don't include a lib if it is already packaged in the current JAR as a static lib - continue - } - transitiveHeaderJars = append(transitiveHeaderJars, jar) + for _, jar := range d.transitiveLibsHeaderJarsForR8.ToList() { + if _, ok := transitiveStaticLibsLookupMap[jar]; ok { + // don't include a lib if it is already packaged in the current JAR as a static lib + continue } + transitiveHeaderJars = append(transitiveHeaderJars, jar) } transitiveClasspath := classpath(transitiveHeaderJars) r8Flags = append(r8Flags, transitiveClasspath.FormJavaClassPath("-libraryjars")) diff --git a/java/java.go b/java/java.go index 679714858..f8b781df3 100644 --- a/java/java.go +++ b/java/java.go @@ -26,9 +26,9 @@ import ( "strings" "android/soong/remoteexec" - "android/soong/testing" "github.com/google/blueprint" + "github.com/google/blueprint/depset" "github.com/google/blueprint/proptools" "android/soong/android" @@ -242,10 +242,10 @@ type ProguardSpecInfo struct { // TransitiveDepsProguardSpecFiles is a depset of paths to proguard flags files that are exported from // all transitive deps. This list includes all proguard flags files from transitive static dependencies, // and all proguard flags files from transitive libs dependencies which set `export_proguard_spec: true`. - ProguardFlagsFiles *android.DepSet[android.Path] + ProguardFlagsFiles depset.DepSet[android.Path] // implementation detail to store transitive proguard flags files from exporting shared deps - UnconditionallyExportedProguardFlags *android.DepSet[android.Path] + UnconditionallyExportedProguardFlags depset.DepSet[android.Path] } var ProguardSpecInfoProvider = blueprint.NewProvider[ProguardSpecInfo]() @@ -260,19 +260,19 @@ type JavaInfo struct { RepackagedHeaderJars android.Paths // set of header jars for all transitive libs deps - TransitiveLibsHeaderJarsForR8 *android.DepSet[android.Path] + TransitiveLibsHeaderJarsForR8 depset.DepSet[android.Path] // set of header jars for all transitive static libs deps - TransitiveStaticLibsHeaderJarsForR8 *android.DepSet[android.Path] + TransitiveStaticLibsHeaderJarsForR8 depset.DepSet[android.Path] // depset of header jars for this module and all transitive static dependencies - TransitiveStaticLibsHeaderJars *android.DepSet[android.Path] + TransitiveStaticLibsHeaderJars depset.DepSet[android.Path] // depset of implementation jars for this module and all transitive static dependencies - TransitiveStaticLibsImplementationJars *android.DepSet[android.Path] + TransitiveStaticLibsImplementationJars depset.DepSet[android.Path] // depset of resource jars for this module and all transitive static dependencies - TransitiveStaticLibsResourceJars *android.DepSet[android.Path] + TransitiveStaticLibsResourceJars depset.DepSet[android.Path] // ImplementationAndResourceJars is a list of jars that contain the implementations of classes // in the module as well as any resources included in the module. @@ -300,7 +300,7 @@ type JavaInfo struct { SrcJarDeps android.Paths // The source files of this module and all its transitive static dependencies. - TransitiveSrcFiles *android.DepSet[android.Path] + TransitiveSrcFiles depset.DepSet[android.Path] // ExportedPlugins is a list of paths that should be used as annotation processors for any // module that depends on this module. @@ -586,9 +586,9 @@ type deps struct { disableTurbine bool - transitiveStaticLibsHeaderJars []*android.DepSet[android.Path] - transitiveStaticLibsImplementationJars []*android.DepSet[android.Path] - transitiveStaticLibsResourceJars []*android.DepSet[android.Path] + transitiveStaticLibsHeaderJars []depset.DepSet[android.Path] + transitiveStaticLibsImplementationJars []depset.DepSet[android.Path] + transitiveStaticLibsResourceJars []depset.DepSet[android.Path] } func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer) { @@ -1557,7 +1557,6 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { } j.Test.generateAndroidBuildActionsWithConfig(ctx, configs) - android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) android.SetProvider(ctx, tradefed.BaseTestProviderKey, tradefed.BaseTestProviderData{ InstalledFiles: j.data, OutputFile: j.outputFile, @@ -1573,7 +1572,6 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { checkMinSdkVersionMts(ctx, j.MinSdkVersion(ctx)) j.generateAndroidBuildActionsWithConfig(ctx, nil) - android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) } func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, configs []tradefed.Config) { @@ -2415,8 +2413,8 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{ HeaderJars: android.PathsIfNonNil(al.stubsJar), LocalHeaderJars: android.PathsIfNonNil(al.stubsJar), - TransitiveStaticLibsHeaderJars: android.NewDepSet(android.PREORDER, android.PathsIfNonNil(al.stubsJar), nil), - TransitiveStaticLibsImplementationJars: android.NewDepSet(android.PREORDER, android.PathsIfNonNil(al.stubsJar), nil), + TransitiveStaticLibsHeaderJars: depset.New(depset.PREORDER, android.PathsIfNonNil(al.stubsJar), nil), + TransitiveStaticLibsImplementationJars: depset.New(depset.PREORDER, android.PathsIfNonNil(al.stubsJar), nil), ImplementationAndResourcesJars: android.PathsIfNonNil(al.stubsJar), ImplementationJars: android.PathsIfNonNil(al.stubsJar), AidlIncludeDirs: android.Paths{}, @@ -2680,11 +2678,11 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { var flags javaBuilderFlags - var transitiveClasspathHeaderJars []*android.DepSet[android.Path] - var transitiveBootClasspathHeaderJars []*android.DepSet[android.Path] - var transitiveStaticLibsHeaderJars []*android.DepSet[android.Path] - var transitiveStaticLibsImplementationJars []*android.DepSet[android.Path] - var transitiveStaticLibsResourceJars []*android.DepSet[android.Path] + var transitiveClasspathHeaderJars []depset.DepSet[android.Path] + var transitiveBootClasspathHeaderJars []depset.DepSet[android.Path] + var transitiveStaticLibsHeaderJars []depset.DepSet[android.Path] + var transitiveStaticLibsImplementationJars []depset.DepSet[android.Path] + var transitiveStaticLibsResourceJars []depset.DepSet[android.Path] j.collectTransitiveHeaderJarsForR8(ctx) var staticJars android.Paths @@ -2697,29 +2695,19 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { case libTag, sdkLibTag: flags.classpath = append(flags.classpath, dep.HeaderJars...) flags.dexClasspath = append(flags.dexClasspath, dep.HeaderJars...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } + transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) case staticLibTag: flags.classpath = append(flags.classpath, dep.HeaderJars...) staticJars = append(staticJars, dep.ImplementationJars...) staticResourceJars = append(staticResourceJars, dep.ResourceJars...) staticHeaderJars = append(staticHeaderJars, dep.HeaderJars...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) - transitiveStaticLibsHeaderJars = append(transitiveStaticLibsHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } - if dep.TransitiveStaticLibsImplementationJars != nil { - transitiveStaticLibsImplementationJars = append(transitiveStaticLibsImplementationJars, dep.TransitiveStaticLibsImplementationJars) - } - if dep.TransitiveStaticLibsResourceJars != nil { - transitiveStaticLibsResourceJars = append(transitiveStaticLibsResourceJars, dep.TransitiveStaticLibsResourceJars) - } + transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) + transitiveStaticLibsHeaderJars = append(transitiveStaticLibsHeaderJars, dep.TransitiveStaticLibsHeaderJars) + transitiveStaticLibsImplementationJars = append(transitiveStaticLibsImplementationJars, dep.TransitiveStaticLibsImplementationJars) + transitiveStaticLibsResourceJars = append(transitiveStaticLibsResourceJars, dep.TransitiveStaticLibsResourceJars) case bootClasspathTag: flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveBootClasspathHeaderJars = append(transitiveBootClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } + transitiveBootClasspathHeaderJars = append(transitiveBootClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars) } } else if _, ok := android.OtherModuleProvider(ctx, module, SdkLibraryInfoProvider); ok { switch tag { @@ -2744,9 +2732,9 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { false, j.properties.Exclude_files, j.properties.Exclude_dirs) localStrippedJars := android.Paths{localCombinedHeaderJar} - completeStaticLibsHeaderJars := android.NewDepSet(android.PREORDER, localStrippedJars, transitiveStaticLibsHeaderJars) - completeStaticLibsImplementationJars := android.NewDepSet(android.PREORDER, localStrippedJars, transitiveStaticLibsImplementationJars) - completeStaticLibsResourceJars := android.NewDepSet(android.PREORDER, nil, transitiveStaticLibsResourceJars) + completeStaticLibsHeaderJars := depset.New(depset.PREORDER, localStrippedJars, transitiveStaticLibsHeaderJars) + completeStaticLibsImplementationJars := depset.New(depset.PREORDER, localStrippedJars, transitiveStaticLibsImplementationJars) + completeStaticLibsResourceJars := depset.New(depset.PREORDER, nil, transitiveStaticLibsResourceJars) // 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. @@ -2807,8 +2795,8 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { // Enabling jetifier requires modifying classes from transitive dependencies, disable transitive // classpath and use the combined header jar instead. - completeStaticLibsHeaderJars = android.NewDepSet(android.PREORDER, android.Paths{headerJar}, nil) - completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, android.Paths{outputFile}, nil) + completeStaticLibsHeaderJars = depset.New(depset.PREORDER, android.Paths{headerJar}, nil) + completeStaticLibsImplementationJars = depset.New(depset.PREORDER, android.Paths{outputFile}, nil) } implementationJarFile := outputFile diff --git a/java/lint.go b/java/lint.go index 2cbefc3bb..ac90e19ba 100644 --- a/java/lint.go +++ b/java/lint.go @@ -20,6 +20,7 @@ import ( "strings" "github.com/google/blueprint" + "github.com/google/blueprint/depset" "github.com/google/blueprint/proptools" "android/soong/android" @@ -101,19 +102,19 @@ type linter struct { } type LintDepSets struct { - HTML, Text, XML, Baseline *android.DepSet[android.Path] + HTML, Text, XML, Baseline depset.DepSet[android.Path] } type LintDepSetsBuilder struct { - HTML, Text, XML, Baseline *android.DepSetBuilder[android.Path] + HTML, Text, XML, Baseline *depset.Builder[android.Path] } func NewLintDepSetBuilder() LintDepSetsBuilder { return LintDepSetsBuilder{ - HTML: android.NewDepSetBuilder[android.Path](android.POSTORDER), - Text: android.NewDepSetBuilder[android.Path](android.POSTORDER), - XML: android.NewDepSetBuilder[android.Path](android.POSTORDER), - Baseline: android.NewDepSetBuilder[android.Path](android.POSTORDER), + HTML: depset.NewBuilder[android.Path](depset.POSTORDER), + Text: depset.NewBuilder[android.Path](depset.POSTORDER), + XML: depset.NewBuilder[android.Path](depset.POSTORDER), + Baseline: depset.NewBuilder[android.Path](depset.POSTORDER), } } @@ -128,18 +129,10 @@ func (l LintDepSetsBuilder) Direct(html, text, xml android.Path, baseline androi } func (l LintDepSetsBuilder) Transitive(info *LintInfo) LintDepSetsBuilder { - if info.TransitiveHTML != nil { - l.HTML.Transitive(info.TransitiveHTML) - } - if info.TransitiveText != nil { - l.Text.Transitive(info.TransitiveText) - } - if info.TransitiveXML != nil { - l.XML.Transitive(info.TransitiveXML) - } - if info.TransitiveBaseline != nil { - l.Baseline.Transitive(info.TransitiveBaseline) - } + l.HTML.Transitive(info.TransitiveHTML) + l.Text.Transitive(info.TransitiveText) + l.XML.Transitive(info.TransitiveXML) + l.Baseline.Transitive(info.TransitiveBaseline) return l } @@ -204,10 +197,10 @@ type LintInfo struct { XML android.Path ReferenceBaseline android.Path - TransitiveHTML *android.DepSet[android.Path] - TransitiveText *android.DepSet[android.Path] - TransitiveXML *android.DepSet[android.Path] - TransitiveBaseline *android.DepSet[android.Path] + TransitiveHTML depset.DepSet[android.Path] + TransitiveText depset.DepSet[android.Path] + TransitiveXML depset.DepSet[android.Path] + TransitiveBaseline depset.DepSet[android.Path] } func (l *linter) enabled() bool { diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 5bb77542c..acfc7745e 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -191,9 +191,7 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo var transitiveSrcFiles android.Paths for _, module := range append(allModules, implLibModule...) { if depInfo, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { - if depInfo.TransitiveSrcFiles != nil { - transitiveSrcFiles = append(transitiveSrcFiles, depInfo.TransitiveSrcFiles.ToList()...) - } + transitiveSrcFiles = append(transitiveSrcFiles, depInfo.TransitiveSrcFiles.ToList()...) } } jarArgs := resourcePathsToJarArgs(transitiveSrcFiles) diff --git a/java/robolectric.go b/java/robolectric.go index e6f80ac37..5f46267f9 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -19,7 +19,6 @@ import ( "android/soong/android" "android/soong/java/config" - "android/soong/testing" "android/soong/tradefed" "github.com/google/blueprint/proptools" @@ -243,7 +242,6 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) } r.installFile = ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...) - android.SetProvider(ctx, testing.TestModuleProviderKey, testing.TestModuleProviderData{}) } func generateSameDirRoboTestConfigJar(ctx android.ModuleContext, outputFile android.ModuleOutPath) { diff --git a/java/system_modules.go b/java/system_modules.go index d9430b25e..e955aec15 100644 --- a/java/system_modules.go +++ b/java/system_modules.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/google/blueprint" + "github.com/google/blueprint/depset" "github.com/google/blueprint/proptools" "android/soong/android" @@ -129,7 +130,7 @@ type SystemModulesProviderInfo struct { OutputDirDeps android.Paths // depset of header jars for this module and all transitive static dependencies - TransitiveStaticLibsHeaderJars *android.DepSet[android.Path] + TransitiveStaticLibsHeaderJars depset.DepSet[android.Path] } var SystemModulesProvider = blueprint.NewProvider[*SystemModulesProviderInfo]() @@ -152,13 +153,11 @@ type SystemModulesProperties struct { func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) { var jars android.Paths - var transitiveStaticLibsHeaderJars []*android.DepSet[android.Path] + var transitiveStaticLibsHeaderJars []depset.DepSet[android.Path] ctx.VisitDirectDepsWithTag(systemModulesLibsTag, func(module android.Module) { if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { jars = append(jars, dep.HeaderJars...) - if dep.TransitiveStaticLibsHeaderJars != nil { - transitiveStaticLibsHeaderJars = append(transitiveStaticLibsHeaderJars, dep.TransitiveStaticLibsHeaderJars) - } + transitiveStaticLibsHeaderJars = append(transitiveStaticLibsHeaderJars, dep.TransitiveStaticLibsHeaderJars) } }) @@ -168,7 +167,7 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte HeaderJars: jars, OutputDir: system.outputDir, OutputDirDeps: system.outputDeps, - TransitiveStaticLibsHeaderJars: android.NewDepSet(android.PREORDER, nil, transitiveStaticLibsHeaderJars), + TransitiveStaticLibsHeaderJars: depset.New(depset.PREORDER, nil, transitiveStaticLibsHeaderJars), }) } diff --git a/java/test_spec_test.go b/java/test_spec_test.go deleted file mode 100644 index f0a5fdb4b..000000000 --- a/java/test_spec_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package java - -import ( - "strings" - "testing" - - "android/soong/android" - soongTesting "android/soong/testing" - "android/soong/testing/test_spec_proto" - "google.golang.org/protobuf/proto" -) - -func TestTestSpec(t *testing.T) { - bp := `test_spec { - name: "module-name", - teamId: "12345", - tests: [ - "java-test-module-name-one", - "java-test-module-name-two" - ] - } - - java_test { - name: "java-test-module-name-one", - } - - java_test { - name: "java-test-module-name-two", - }` - result := runTestSpecTest(t, android.FixtureExpectsNoErrors, bp) - - module := result.ModuleForTests("module-name", "") - - // Check that the provider has the right contents - data, _ := android.OtherModuleProvider(result, module.Module(), soongTesting.TestSpecProviderKey) - if !strings.HasSuffix( - data.IntermediatePath.String(), "/intermediateTestSpecMetadata.pb", - ) { - t.Errorf( - "Missing intermediates path in provider: %s", - data.IntermediatePath.String(), - ) - } - - metadata := android.ContentFromFileRuleForTests(t, result.TestContext, - module.Output(data.IntermediatePath.String())) - - metadataList := make([]*test_spec_proto.TestSpec_OwnershipMetadata, 0, 2) - teamId := "12345" - bpFilePath := "Android.bp" - targetNames := []string{ - "java-test-module-name-one", "java-test-module-name-two", - } - - for _, test := range targetNames { - targetName := test - metadata := test_spec_proto.TestSpec_OwnershipMetadata{ - TrendyTeamId: &teamId, - TargetName: &targetName, - Path: &bpFilePath, - } - metadataList = append(metadataList, &metadata) - } - testSpecMetadata := test_spec_proto.TestSpec{OwnershipMetadataList: metadataList} - protoData, _ := proto.Marshal(&testSpecMetadata) - expectedMetadata := string(protoData) - - if metadata != expectedMetadata { - t.Errorf( - "Retrieved metadata: %s doesn't contain expectedMetadata: %s", metadata, - expectedMetadata, - ) - } - - // Tests for all_test_spec singleton. - singleton := result.SingletonForTests("all_test_specs") - rule := singleton.Rule("all_test_specs_rule") - prebuiltOs := result.Config.PrebuiltOS() - expectedCmd := "out/soong/host/" + prebuiltOs + "/bin/metadata -rule test_spec -inputFile out/soong/all_test_spec_paths.rsp -outputFile out/soong/ownership/all_test_specs.pb" - expectedOutputFile := "out/soong/ownership/all_test_specs.pb" - expectedInputFile := "out/soong/.intermediates/module-name/intermediateTestSpecMetadata.pb" - if !strings.Contains( - strings.TrimSpace(rule.Output.String()), - expectedOutputFile, - ) { - t.Errorf( - "Retrieved singletonOutputFile: %s is not equal to expectedSingletonOutputFile: %s", - rule.Output.String(), expectedOutputFile, - ) - } - - if !strings.Contains( - strings.TrimSpace(rule.Inputs[0].String()), - expectedInputFile, - ) { - t.Errorf( - "Retrieved singletonInputFile: %s is not equal to expectedSingletonInputFile: %s", - rule.Inputs[0].String(), expectedInputFile, - ) - } - - if !strings.Contains( - strings.TrimSpace(rule.RuleParams.Command), - expectedCmd, - ) { - t.Errorf( - "Retrieved cmd: %s is not equal to expectedCmd: %s", - rule.RuleParams.Command, expectedCmd, - ) - } -} - -func runTestSpecTest( - t *testing.T, errorHandler android.FixtureErrorHandler, bp string, -) *android.TestResult { - return android.GroupFixturePreparers( - soongTesting.PrepareForTestWithTestingBuildComponents, - PrepareForIntegrationTestWithJava, - ). - ExtendWithErrorHandler(errorHandler). - RunTestWithBp(t, bp) -} |