From 54124c8c5bfb4d37bf6bf842fb5afc3480f4f503 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 21 Feb 2025 14:46:02 -0800 Subject: Dist proguard zips in soong-only builds Fixes: 395160816 Test: Manually Change-Id: I3ef77edb006565e4d5c7fff28e71823eb3035bb4 --- filesystem/android_device.go | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'filesystem/android_device.go') diff --git a/filesystem/android_device.go b/filesystem/android_device.go index 3b8bf9381..fef4aeb43 100644 --- a/filesystem/android_device.go +++ b/filesystem/android_device.go @@ -97,6 +97,10 @@ type androidDevice struct { deviceProps DeviceProperties allImagesZip android.Path + + proguardDictZip android.Path + proguardDictMapping android.Path + proguardUsageZip android.Path } func AndroidDeviceFactory() android.Module { @@ -293,22 +297,32 @@ func (a *androidDevice) allInstalledModules(ctx android.ModuleContext) []android return ret } +func insertBeforeExtension(file, insertion string) string { + ext := filepath.Ext(file) + return strings.TrimSuffix(file, ext) + insertion + ext +} + func (a *androidDevice) distFiles(ctx android.ModuleContext) { - if !ctx.Config().KatiEnabled() { - if proptools.Bool(a.deviceProps.Main_device) { - fsInfoMap := a.getFsInfos(ctx) - for _, partition := range android.SortedKeys(fsInfoMap) { - fsInfo := fsInfoMap[partition] - if fsInfo.InstalledFiles.Json != nil { - ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Json) - } - if fsInfo.InstalledFiles.Txt != nil { - ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Txt) - } + if !ctx.Config().KatiEnabled() && proptools.Bool(a.deviceProps.Main_device) { + fsInfoMap := a.getFsInfos(ctx) + for _, partition := range android.SortedKeys(fsInfoMap) { + fsInfo := fsInfoMap[partition] + if fsInfo.InstalledFiles.Json != nil { + ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Json) + } + if fsInfo.InstalledFiles.Txt != nil { + ctx.DistForGoal("droidcore-unbundled", fsInfo.InstalledFiles.Txt) } } - } + namePrefix := "" + if ctx.Config().HasDeviceProduct() { + namePrefix = ctx.Config().DeviceProduct() + "-" + } + ctx.DistForGoalWithFilename("droidcore-unbundled", a.proguardDictZip, namePrefix+insertBeforeExtension(a.proguardDictZip.Base(), "-FILE_NAME_TAG_PLACEHOLDER")) + ctx.DistForGoalWithFilename("droidcore-unbundled", a.proguardDictMapping, namePrefix+insertBeforeExtension(a.proguardDictMapping.Base(), "-FILE_NAME_TAG_PLACEHOLDER")) + ctx.DistForGoalWithFilename("droidcore-unbundled", a.proguardUsageZip, namePrefix+insertBeforeExtension(a.proguardUsageZip.Base(), "-FILE_NAME_TAG_PLACEHOLDER")) + } } func (a *androidDevice) MakeVars(ctx android.MakeVarsModuleContext) { @@ -361,6 +375,10 @@ func (a *androidDevice) buildProguardZips(ctx android.ModuleContext, allInstalle dictZipBuilder.Build("proguard_dict_zip", "Building proguard dictionary zip") dictMappingBuilder.Build("proguard_dict_mapping_proto", "Building proguard mapping proto") usageZipBuilder.Build("proguard_usage_zip", "Building proguard usage zip") + + a.proguardDictZip = dictZip + a.proguardDictMapping = dictMapping + a.proguardUsageZip = usageZip } // Helper structs for target_files.zip creation -- cgit v1.2.3-59-g8ed1b