Use generics for DepSets
Use Go's generics for DepSets so they don't require a type-specific
wrapper and reflection.
Test: depsets_test.go
Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
diff --git a/cc/cc.go b/cc/cc.go
index 3484000..a7fda2d 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -150,7 +150,7 @@
StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
// Transitive static library dependencies of static libraries for use in ordering.
- TranstiveStaticLibrariesForOrdering *android.DepSet
+ TranstiveStaticLibrariesForOrdering *android.DepSet[android.Path]
// Paths to .o files
Objs Objects
@@ -3549,8 +3549,8 @@
// to match the topological order of the dependency tree, including any static analogues of
// direct shared libraries. It returns the ordered static dependencies, and an android.DepSet
// of the transitive dependencies.
-func orderStaticModuleDeps(staticDeps []StaticLibraryInfo, sharedDeps []SharedLibraryInfo) (ordered android.Paths, transitive *android.DepSet) {
- transitiveStaticLibsBuilder := android.NewDepSetBuilder(android.TOPOLOGICAL)
+func orderStaticModuleDeps(staticDeps []StaticLibraryInfo, sharedDeps []SharedLibraryInfo) (ordered android.Paths, transitive *android.DepSet[android.Path]) {
+ transitiveStaticLibsBuilder := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL)
var staticPaths android.Paths
for _, staticDep := range staticDeps {
staticPaths = append(staticPaths, staticDep.StaticLibrary)
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 701c3bb..2635b8f 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2700,8 +2700,8 @@
variant := "android_arm64_armv8-a_static"
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
- actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
- TransitiveStaticLibrariesForOrdering.ToList().RelativeToTop()
+ actual := android.Paths(ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
+ TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b", "d"})
if !reflect.DeepEqual(actual, expected) {
@@ -2736,8 +2736,8 @@
variant := "android_arm64_armv8-a_static"
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
- actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
- TransitiveStaticLibrariesForOrdering.ToList().RelativeToTop()
+ actual := android.Paths(ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
+ TransitiveStaticLibrariesForOrdering.ToList()).RelativeToTop()
expected := GetOutputPaths(ctx, variant, []string{"a", "c", "b"})
if !reflect.DeepEqual(actual, expected) {
diff --git a/cc/library.go b/cc/library.go
index 47df53e..aec6433 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -892,7 +892,7 @@
// TODO(b/190524881): Include transitive static libraries in this provider to support
// static libraries with deps.
- TransitiveStaticLibrariesForOrdering: android.NewDepSetBuilder(android.TOPOLOGICAL).
+ TransitiveStaticLibrariesForOrdering: android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).
Direct(outputFilePath).
Build(),
})
@@ -1649,7 +1649,7 @@
Objects: library.objects,
WholeStaticLibsFromPrebuilts: library.wholeStaticLibsFromPrebuilts,
- TransitiveStaticLibrariesForOrdering: android.NewDepSetBuilder(android.TOPOLOGICAL).
+ TransitiveStaticLibrariesForOrdering: android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).
Direct(outputFile).
Transitive(deps.TranstiveStaticLibrariesForOrdering).
Build(),
@@ -1794,7 +1794,7 @@
library.coverageOutputFile = transformCoverageFilesToZip(ctx, objs, library.getLibName(ctx))
library.linkSAbiDumpFiles(ctx, objs, fileName, unstrippedOutputFile)
- var transitiveStaticLibrariesForOrdering *android.DepSet
+ var transitiveStaticLibrariesForOrdering *android.DepSet[android.Path]
if static := ctx.GetDirectDepsWithTag(staticVariantTag); len(static) > 0 {
s := ctx.OtherModuleProvider(static[0], StaticLibraryInfoProvider).(StaticLibraryInfo)
transitiveStaticLibrariesForOrdering = s.TransitiveStaticLibrariesForOrdering
diff --git a/cc/linkable.go b/cc/linkable.go
index 976a382..19e6501 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -345,7 +345,7 @@
TableOfContents android.OptionalPath
// should be obtained from static analogue
- TransitiveStaticLibrariesForOrdering *android.DepSet
+ TransitiveStaticLibrariesForOrdering *android.DepSet[android.Path]
}
var SharedLibraryInfoProvider = blueprint.NewProvider(SharedLibraryInfo{})
@@ -387,7 +387,7 @@
// This isn't the actual transitive DepSet, shared library dependencies have been
// converted into static library analogues. It is only used to order the static
// library dependencies that were specified for the current module.
- TransitiveStaticLibrariesForOrdering *android.DepSet
+ TransitiveStaticLibrariesForOrdering *android.DepSet[android.Path]
}
var StaticLibraryInfoProvider = blueprint.NewProvider(StaticLibraryInfo{})
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index 1d15cf8..d3a0a00 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -113,7 +113,7 @@
ndk.libraryDecorator.flagExporter.setProvider(ctx)
if ndk.static() {
- depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(lib).Build()
+ depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(lib).Build()
ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: lib,
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 44cd0d7..a4ca590 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -140,7 +140,7 @@
}
if p.static() {
- depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(in).Build()
+ depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(in).Build()
ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: in,
@@ -508,7 +508,7 @@
h.module.outputFile = android.OptionalPathForPath(outputPath)
- depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(outputPath).Build()
+ depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(outputPath).Build()
ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: outputPath,
TransitiveStaticLibrariesForOrdering: depSet,
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index bb6e257..a5729df 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -499,7 +499,7 @@
}
if p.static() {
- depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(in).Build()
+ depSet := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL).Direct(in).Build()
ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
StaticLibrary: in,