Create compliance-metadata/$product/installed_files.stamp in soong-only

This file will have an implicit dep on the installed files of the main
android_device. Any changes to installed files will trigger rebuild of
sbom

Bug: 394096939
Test: m nothing --soong-only
Test: verified that
out/soong/compliance-metadata/aosp_cf_x86_64_phone/installed_files.stamp
exists in the generated ninja file

Change-Id: I3c2eb17cf01ddc9630a39fb8662cc346ce60470b
diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go
index 1175c42..c06715a 100644
--- a/filesystem/android_device_product_out.go
+++ b/filesystem/android_device_product_out.go
@@ -36,6 +36,7 @@
 	filesystemInfos := a.getFsInfos(ctx)
 
 	var deps android.Paths
+	var depsNoImg android.Paths // subset of deps without any img files. used for sbom creation.
 
 	for _, partition := range android.SortedKeys(filesystemInfos) {
 		info := filesystemInfos[partition]
@@ -86,6 +87,7 @@
 				ctx.Phony(info.ModuleName, fip.FullInstallPath)
 				ctx.Phony(partition, fip.FullInstallPath)
 				deps = append(deps, fip.FullInstallPath)
+				depsNoImg = append(depsNoImg, fip.FullInstallPath)
 				ctx.Phony("sync_"+partition, fip.FullInstallPath)
 				ctx.Phony("sync", fip.FullInstallPath)
 			}
@@ -94,6 +96,8 @@
 		deps = append(deps, imgInstallPath)
 	}
 
+	a.createComplianceMetadataTimestamp(ctx, depsNoImg)
+
 	// List all individual files to be copied to PRODUCT_OUT here
 	if a.deviceProps.Bootloader != nil {
 		bootloaderInstallPath := android.PathForModuleInPartitionInstall(ctx, "", "bootloader")
@@ -176,6 +180,17 @@
 	return copyToProductOutTimestamp
 }
 
+// createComplianceMetadataTimestampForSoongOnly creates a timestamp file in m --soong-only
+// this timestamp file depends on installed files of the main `android_device`.
+// Any changes to installed files of the main `android_device` will retrigger SBOM generation
+func (a *androidDevice) createComplianceMetadataTimestamp(ctx android.ModuleContext, installedFiles android.Paths) {
+	ctx.Build(pctx, android.BuildParams{
+		Rule:      android.Touch,
+		Implicits: installedFiles,
+		Output:    android.PathForOutput(ctx, "compliance-metadata", ctx.Config().DeviceProduct(), "installed_files.stamp"),
+	})
+}
+
 // Returns a mapping from partition type -> FilesystemInfo. This includes filesystems that are
 // nested inside of other partitions, such as the partitions inside super.img, or ramdisk inside
 // of boot.