Build android_device by default in soong-only builds
This makes it so that `m --soong-only` builds all the partition
images and copies them to TARGET_OUT. (except for super.img and
userdata.img, which are still in progress)
Bug: 376727180
Test: m --soong-only, ls out/target/product/vsoc_x86_64/
Change-Id: If564869c13f2a427e1f6496199aa1b7808ab2f53
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index ae7755f..d341a0c 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -16,6 +16,7 @@
import (
"strings"
+ "sync/atomic"
"android/soong/android"
@@ -79,6 +80,8 @@
return module
}
+var numAutogeneratedAndroidDevicesOnceKey android.OnceKey = android.NewOnceKey("num_auto_generated_anroid_devices")
+
type partitionDepTagType struct {
blueprint.BaseDependencyTag
}
@@ -190,15 +193,34 @@
a.copyFilesToProductOut(ctx)
- out := android.PathForModuleOut(ctx, "out")
+ allImagesStamp := android.PathForModuleOut(ctx, "all_images_stamp")
ctx.Build(pctx, android.BuildParams{
Rule: android.Touch,
- Output: out,
+ Output: allImagesStamp,
Implicits: deps,
Validation: a.copyToProductOutTimestamp,
})
- ctx.SetOutputFiles(android.Paths{out}, "")
- ctx.CheckbuildFile(out)
+ ctx.SetOutputFiles(android.Paths{allImagesStamp}, "")
+ ctx.CheckbuildFile(allImagesStamp)
+
+ if ctx.OtherModuleIsAutoGenerated(ctx.Module()) {
+ numAutogeneratedAndroidDevices := ctx.Config().Once(numAutogeneratedAndroidDevicesOnceKey, func() interface{} {
+ return &atomic.Int32{}
+ }).(*atomic.Int32)
+ total := numAutogeneratedAndroidDevices.Add(1)
+ if total > 1 {
+ // There should only be 1 autogenerated android_device module. That one will be
+ // made the default thing to build in soong-only builds.
+ ctx.ModuleErrorf("There cannot be more than 1 autogenerated android_device module")
+ }
+ }
+
+ if !ctx.Config().KatiEnabled() && ctx.OtherModuleIsAutoGenerated(ctx.Module()) {
+ // In soong-only builds, build this module by default.
+ // This is the analogue to this make code:
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/main.mk;l=1396;drc=6595459cdd8164a6008335f6372c9f97b9094060
+ ctx.Phony("droidcore-unbundled", allImagesStamp)
+ }
}
type targetFilesZipCopy struct {