Include kernel and dtb.img information in SBOM built in soong-only
Bug: 401366170
Bug: 401366536
Test: presubmits
Change-Id: I4a3e6834b02b6bbe2d83d90e5f0c7cc0bc2582f5
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index a616ee0..931adfd 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -294,18 +294,26 @@
}
func buildComplianceMetadata(ctx android.ModuleContext, tags ...blueprint.DependencyTag) {
+ // Collect metadata from deps
filesContained := make([]string, 0)
+ prebuiltFilesCopied := 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()...)
+ prebuiltFilesCopied = append(prebuiltFilesCopied, complianceMetadataInfo.GetPrebuiltFilesCopied()...)
}
})
}
- sort.Strings(filesContained)
-
+ // Merge to module's ComplianceMetadataInfo
complianceMetadataInfo := ctx.ComplianceMetadataInfo()
+ filesContained = append(filesContained, complianceMetadataInfo.GetFilesContained()...)
+ sort.Strings(filesContained)
complianceMetadataInfo.SetFilesContained(filesContained)
+
+ prebuiltFilesCopied = append(prebuiltFilesCopied, complianceMetadataInfo.GetPrebuiltFilesCopied()...)
+ sort.Strings(prebuiltFilesCopied)
+ complianceMetadataInfo.SetPrebuiltFilesCopied(prebuiltFilesCopied)
}
// Returns a list of modules that are installed, which are collected from the dependency
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index 2bf0d59..c06c200 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -201,7 +201,8 @@
return
}
- unsignedOutput := b.buildBootImage(ctx, b.getKernelPath(ctx))
+ kernelPath := b.getKernelPath(ctx)
+ unsignedOutput := b.buildBootImage(ctx, kernelPath)
output := unsignedOutput
if proptools.Bool(b.properties.Use_avb) {
@@ -212,7 +213,7 @@
case "default":
output = b.signImage(ctx, unsignedOutput)
case "make_legacy":
- output = b.addAvbFooter(ctx, unsignedOutput, b.getKernelPath(ctx))
+ output = b.addAvbFooter(ctx, unsignedOutput, kernelPath)
default:
ctx.PropertyErrorf("avb_mode", `Unknown value for avb_mode, expected "default" or "make_legacy", got: %q`, *b.properties.Avb_mode)
}
@@ -235,10 +236,11 @@
}
// Set BootimgInfo for building target_files.zip
+ dtbPath := b.getDtbPath(ctx)
android.SetProvider(ctx, BootimgInfoProvider, BootimgInfo{
Cmdline: b.properties.Cmdline,
- Kernel: b.getKernelPath(ctx),
- Dtb: b.getDtbPath(ctx),
+ Kernel: kernelPath,
+ Dtb: dtbPath,
Bootconfig: b.getBootconfigPath(ctx),
Output: output,
})
@@ -265,6 +267,16 @@
})
// Dump compliance metadata
+ complianceMetadataInfo := ctx.ComplianceMetadataInfo()
+ prebuiltFilesCopied := make([]string, 0)
+ if kernelPath != nil {
+ prebuiltFilesCopied = append(prebuiltFilesCopied, kernelPath.String()+":kernel")
+ }
+ if dtbPath != nil {
+ prebuiltFilesCopied = append(prebuiltFilesCopied, dtbPath.String()+":dtb.img")
+ }
+ complianceMetadataInfo.SetPrebuiltFilesCopied(prebuiltFilesCopied)
+
if ramdisk := proptools.String(b.properties.Ramdisk_module); ramdisk != "" {
buildComplianceMetadata(ctx, bootimgRamdiskDep)
}