From b55a41c70da076b970f695a0cf8a379bbd16a103 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 9 Jan 2025 16:53:58 -0800 Subject: 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 --- filesystem/android_device.go | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'filesystem/android_device.go') diff --git a/filesystem/android_device.go b/filesystem/android_device.go index ae7755f93..d341a0c21 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -16,6 +16,7 @@ package filesystem import ( "strings" + "sync/atomic" "android/soong/android" @@ -79,6 +80,8 @@ func AndroidDeviceFactory() android.Module { return module } +var numAutogeneratedAndroidDevicesOnceKey android.OnceKey = android.NewOnceKey("num_auto_generated_anroid_devices") + type partitionDepTagType struct { blueprint.BaseDependencyTag } @@ -190,15 +193,34 @@ func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) { 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 { -- cgit v1.2.3-59-g8ed1b