diff options
author | 2025-01-09 16:53:58 -0800 | |
---|---|---|
committer | 2025-01-09 16:53:58 -0800 | |
commit | b55a41c70da076b970f695a0cf8a379bbd16a103 (patch) | |
tree | 2f08a7ccb457de90ef8f29bb99a3ce718705728c /filesystem/android_device.go | |
parent | 7724344371e60245c1ab00f75c213712e0e2036d (diff) |
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
Diffstat (limited to 'filesystem/android_device.go')
-rw-r--r-- | filesystem/android_device.go | 30 |
1 files changed, 26 insertions, 4 deletions
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 { |