Add support for SBOM generation in soong-only builds
Add an alternative way of collecting metadata in soong-only build, which
is initially done in make.
Bug: 398039178
Test: presubmits
Test: lunch aosp_cf_x86_64_phone-trunk_staging-eng && m && m sbom
Change-Id: I94476db21cf9eac8be7693043f2cd7a2b1bcd8a6
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 005dc34..c49e536 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -19,6 +19,7 @@
"fmt"
"path/filepath"
"slices"
+ "sort"
"strings"
"sync/atomic"
@@ -274,6 +275,31 @@
a.setVbmetaPhonyTargets(ctx)
a.distFiles(ctx)
+
+ android.SetProvider(ctx, android.AndroidDeviceInfoProvider, android.AndroidDeviceInfo{
+ Main_device: android.Bool(a.deviceProps.Main_device),
+ })
+
+ if proptools.String(a.partitionProps.Super_partition_name) != "" {
+ buildComplianceMetadata(ctx, superPartitionDepTag, filesystemDepTag)
+ } else {
+ buildComplianceMetadata(ctx, filesystemDepTag)
+ }
+}
+
+func buildComplianceMetadata(ctx android.ModuleContext, tags ...blueprint.DependencyTag) {
+ filesContained := make([]string, 0)
+ for _, tag := range tags {
+ ctx.VisitDirectDepsProxyWithTag(tag, func(m android.ModuleProxy) {
+ if complianceMetadataInfo, ok := android.OtherModuleProvider(ctx, m, android.ComplianceMetadataProvider); ok {
+ filesContained = append(filesContained, complianceMetadataInfo.GetFilesContained()...)
+ }
+ })
+ }
+ sort.Strings(filesContained)
+
+ complianceMetadataInfo := ctx.ComplianceMetadataInfo()
+ complianceMetadataInfo.SetFilesContained(filesContained)
}
// Returns a list of modules that are installed, which are collected from the dependency