Merge "Generate phony targets for partitions" into main
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 7e31f0e..3e2f61f 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -15,6 +15,7 @@
 package filesystem
 
 import (
+	"fmt"
 	"strings"
 	"sync/atomic"
 
@@ -221,6 +222,8 @@
 
 	// Checkbuilding it causes soong to make a phony, so you can say `m <module name>`
 	ctx.CheckbuildFile(allImagesStamp)
+
+	a.setVbmetaPhonyTargets(ctx)
 }
 
 // Helper structs for target_files.zip creation
@@ -406,3 +409,20 @@
 	}
 	return fsInfo
 }
+
+func (a *androidDevice) setVbmetaPhonyTargets(ctx android.ModuleContext) {
+	if !proptools.Bool(a.deviceProps.Main_device) {
+		return
+	}
+
+	if !ctx.Config().KatiEnabled() {
+		for _, vbmetaPartitionName := range a.partitionProps.Vbmeta_partitions {
+			img := ctx.GetDirectDepProxyWithTag(vbmetaPartitionName, filesystemDepTag)
+			if provider, ok := android.OtherModuleProvider(ctx, img, vbmetaPartitionProvider); ok {
+				// make generates `vbmetasystemimage` phony target instead of `vbmeta_systemimage` phony target.
+				partitionName := strings.ReplaceAll(provider.Name, "_", "")
+				ctx.Phony(fmt.Sprintf("%simage", partitionName), provider.Output)
+			}
+		}
+	}
+}
diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go
index 916c45a..a6177e3 100644
--- a/filesystem/android_device_product_out.go
+++ b/filesystem/android_device_product_out.go
@@ -16,6 +16,7 @@
 
 import (
 	"android/soong/android"
+	"fmt"
 
 	"github.com/google/blueprint"
 	"github.com/google/blueprint/proptools"
@@ -72,10 +73,13 @@
 			},
 		})
 
-		// Make it so doing `m <moduleName>` or `m <partitionType>` will copy the files to
+		// Make it so doing `m <moduleName>` or `m <partitionType>image` will copy the files to
 		// PRODUCT_OUT
 		ctx.Phony(info.ModuleName, dirStamp, imgInstallPath)
-		ctx.Phony(partition, dirStamp, imgInstallPath)
+		if partition == "system_ext" {
+			partition = "systemext"
+		}
+		ctx.Phony(fmt.Sprintf("%simage", partition), dirStamp, imgInstallPath)
 
 		deps = append(deps, imgInstallPath, dirStamp)
 	}