Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 1 | // Copyright (C) 2024 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package fsgen |
| 16 | |
| 17 | import ( |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 18 | "fmt" |
| 19 | "slices" |
Jihoon Kang | 3a8759c | 2024-11-08 19:35:09 +0000 | [diff] [blame] | 20 | "strings" |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 21 | "sync" |
| 22 | |
mrziwang | e5b1bb3 | 2024-11-05 15:51:40 -0800 | [diff] [blame] | 23 | "android/soong/android" |
| 24 | |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 25 | "github.com/google/blueprint/proptools" |
| 26 | ) |
| 27 | |
| 28 | func RegisterCollectFileSystemDepsMutators(ctx android.RegisterMutatorsContext) { |
| 29 | ctx.BottomUp("fs_collect_deps", collectDepsMutator).MutatesGlobalState() |
| 30 | ctx.BottomUp("fs_set_deps", setDepsMutator) |
| 31 | } |
| 32 | |
| 33 | var fsGenStateOnceKey = android.NewOnceKey("FsGenState") |
| 34 | var fsGenRemoveOverridesOnceKey = android.NewOnceKey("FsGenRemoveOverrides") |
| 35 | |
| 36 | // Map of partition module name to its partition that may be generated by Soong. |
| 37 | // Note that it is not guaranteed that all modules returned by this function are successfully |
| 38 | // created. |
| 39 | func getAllSoongGeneratedPartitionNames(config android.Config, partitions []string) map[string]string { |
| 40 | ret := map[string]string{} |
| 41 | for _, partition := range partitions { |
| 42 | ret[generatedModuleNameForPartition(config, partition)] = partition |
| 43 | } |
| 44 | return ret |
| 45 | } |
| 46 | |
| 47 | type depCandidateProps struct { |
| 48 | Namespace string |
| 49 | Multilib string |
| 50 | Arch []android.ArchType |
| 51 | } |
| 52 | |
| 53 | // Map of module name to depCandidateProps |
| 54 | type multilibDeps map[string]*depCandidateProps |
| 55 | |
| 56 | // Information necessary to generate the filesystem modules, including details about their |
| 57 | // dependencies |
| 58 | type FsGenState struct { |
| 59 | // List of modules in `PRODUCT_PACKAGES` and `PRODUCT_PACKAGES_DEBUG` |
| 60 | depCandidates []string |
| 61 | // Map of names of partition to the information of modules to be added as deps |
| 62 | fsDeps map[string]*multilibDeps |
| 63 | // List of name of partitions to be generated by the filesystem_creator module |
| 64 | soongGeneratedPartitions []string |
| 65 | // Mutex to protect the fsDeps |
| 66 | fsDepsMutex sync.Mutex |
| 67 | // Map of _all_ soong module names to their corresponding installation properties |
| 68 | moduleToInstallationProps map[string]installationProperties |
Jihoon Kang | 0d7b011 | 2024-11-13 20:44:05 +0000 | [diff] [blame^] | 69 | // List of prebuilt_* modules that are autogenerated. |
| 70 | generatedPrebuiltEtcModuleNames []string |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | type installationProperties struct { |
| 74 | Required []string |
| 75 | Overrides []string |
| 76 | } |
| 77 | |
| 78 | func defaultDepCandidateProps(config android.Config) *depCandidateProps { |
| 79 | return &depCandidateProps{ |
| 80 | Namespace: ".", |
| 81 | Arch: []android.ArchType{config.BuildArch}, |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func generatedPartitions(ctx android.LoadHookContext) []string { |
Cole Faust | 76a6e95 | 2024-11-07 16:56:45 -0800 | [diff] [blame] | 86 | generatedPartitions := []string{"system", "ramdisk"} |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 87 | if ctx.DeviceConfig().SystemExtPath() == "system_ext" { |
| 88 | generatedPartitions = append(generatedPartitions, "system_ext") |
| 89 | } |
| 90 | if ctx.DeviceConfig().BuildingVendorImage() && ctx.DeviceConfig().VendorPath() == "vendor" { |
| 91 | generatedPartitions = append(generatedPartitions, "vendor") |
| 92 | } |
| 93 | if ctx.DeviceConfig().BuildingProductImage() && ctx.DeviceConfig().ProductPath() == "product" { |
| 94 | generatedPartitions = append(generatedPartitions, "product") |
| 95 | } |
| 96 | if ctx.DeviceConfig().BuildingOdmImage() && ctx.DeviceConfig().OdmPath() == "odm" { |
| 97 | generatedPartitions = append(generatedPartitions, "odm") |
| 98 | } |
mrziwang | 23ba876 | 2024-11-07 16:21:53 -0800 | [diff] [blame] | 99 | if ctx.DeviceConfig().BuildingUserdataImage() && ctx.DeviceConfig().UserdataPath() == "data" { |
| 100 | generatedPartitions = append(generatedPartitions, "userdata") |
| 101 | } |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 102 | if ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.BuildingSystemDlkmImage { |
| 103 | generatedPartitions = append(generatedPartitions, "system_dlkm") |
| 104 | } |
Spandan Das | 5b493cd | 2024-11-07 20:55:56 +0000 | [diff] [blame] | 105 | if ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.BuildingVendorDlkmImage { |
| 106 | generatedPartitions = append(generatedPartitions, "vendor_dlkm") |
| 107 | } |
| 108 | if ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.BuildingOdmDlkmImage { |
| 109 | generatedPartitions = append(generatedPartitions, "odm_dlkm") |
| 110 | } |
| 111 | |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 112 | return generatedPartitions |
| 113 | } |
| 114 | |
Jihoon Kang | 04f12c9 | 2024-11-12 23:03:08 +0000 | [diff] [blame] | 115 | func createFsGenState(ctx android.LoadHookContext, generatedPrebuiltEtcModuleNames []string, avbpubkeyGenerated bool) *FsGenState { |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 116 | return ctx.Config().Once(fsGenStateOnceKey, func() interface{} { |
| 117 | partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse |
| 118 | candidates := android.FirstUniqueStrings(android.Concat(partitionVars.ProductPackages, partitionVars.ProductPackagesDebug)) |
| 119 | candidates = android.Concat(candidates, generatedPrebuiltEtcModuleNames) |
| 120 | |
Jihoon Kang | 04f12c9 | 2024-11-12 23:03:08 +0000 | [diff] [blame] | 121 | fsGenState := FsGenState{ |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 122 | depCandidates: candidates, |
| 123 | fsDeps: map[string]*multilibDeps{ |
| 124 | // These additional deps are added according to the cuttlefish system image bp. |
| 125 | "system": { |
| 126 | "com.android.apex.cts.shim.v1_prebuilt": defaultDepCandidateProps(ctx.Config()), |
| 127 | "dex_bootjars": defaultDepCandidateProps(ctx.Config()), |
| 128 | "framework_compatibility_matrix.device.xml": defaultDepCandidateProps(ctx.Config()), |
| 129 | "init.environ.rc-soong": defaultDepCandidateProps(ctx.Config()), |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 130 | "libcompiler_rt": defaultDepCandidateProps(ctx.Config()), |
| 131 | "libdmabufheap": defaultDepCandidateProps(ctx.Config()), |
| 132 | "libgsi": defaultDepCandidateProps(ctx.Config()), |
| 133 | "llndk.libraries.txt": defaultDepCandidateProps(ctx.Config()), |
| 134 | "logpersist.start": defaultDepCandidateProps(ctx.Config()), |
| 135 | "update_engine_sideload": defaultDepCandidateProps(ctx.Config()), |
| 136 | }, |
| 137 | "vendor": { |
| 138 | "fs_config_files_vendor": defaultDepCandidateProps(ctx.Config()), |
| 139 | "fs_config_dirs_vendor": defaultDepCandidateProps(ctx.Config()), |
| 140 | generatedModuleName(ctx.Config(), "vendor-build.prop"): defaultDepCandidateProps(ctx.Config()), |
| 141 | }, |
| 142 | "odm": { |
| 143 | // fs_config_* files are automatically installed for all products with odm partitions. |
| 144 | // https://cs.android.com/android/_/android/platform/build/+/e4849e87ab660b59a6501b3928693db065ee873b:tools/fs_config/Android.mk;l=34;drc=8d6481b92c4b4e9b9f31a61545b6862090fcc14b;bpv=1;bpt=0 |
| 145 | "fs_config_files_odm": defaultDepCandidateProps(ctx.Config()), |
| 146 | "fs_config_dirs_odm": defaultDepCandidateProps(ctx.Config()), |
| 147 | }, |
| 148 | "product": {}, |
| 149 | "system_ext": { |
| 150 | // VNDK apexes are automatically included. |
| 151 | // This hardcoded list will need to be updated if `PRODUCT_EXTRA_VNDK_VERSIONS` is updated. |
| 152 | // https://cs.android.com/android/_/android/platform/build/+/adba533072b00c53ac0f198c550a3cbd7a00e4cd:core/main.mk;l=984;bpv=1;bpt=0;drc=174db7b179592cf07cbfd2adb0119486fda911e7 |
| 153 | "com.android.vndk.v30": defaultDepCandidateProps(ctx.Config()), |
| 154 | "com.android.vndk.v31": defaultDepCandidateProps(ctx.Config()), |
| 155 | "com.android.vndk.v32": defaultDepCandidateProps(ctx.Config()), |
| 156 | "com.android.vndk.v33": defaultDepCandidateProps(ctx.Config()), |
| 157 | "com.android.vndk.v34": defaultDepCandidateProps(ctx.Config()), |
| 158 | }, |
Spandan Das | 912d26b | 2024-11-06 19:35:17 +0000 | [diff] [blame] | 159 | "userdata": {}, |
| 160 | "system_dlkm": { |
| 161 | // these are phony required deps of the phony fs_config_dirs_nonsystem |
| 162 | "fs_config_dirs_system_dlkm": defaultDepCandidateProps(ctx.Config()), |
| 163 | "fs_config_files_system_dlkm": defaultDepCandidateProps(ctx.Config()), |
| 164 | // build props are automatically added to `ALL_DEFAULT_INSTALLED_MODULES` |
| 165 | "system_dlkm-build.prop": defaultDepCandidateProps(ctx.Config()), |
| 166 | }, |
Spandan Das | 5b493cd | 2024-11-07 20:55:56 +0000 | [diff] [blame] | 167 | "vendor_dlkm": { |
| 168 | "fs_config_dirs_vendor_dlkm": defaultDepCandidateProps(ctx.Config()), |
| 169 | "fs_config_files_vendor_dlkm": defaultDepCandidateProps(ctx.Config()), |
| 170 | "vendor_dlkm-build.prop": defaultDepCandidateProps(ctx.Config()), |
| 171 | }, |
| 172 | "odm_dlkm": { |
| 173 | "fs_config_dirs_odm_dlkm": defaultDepCandidateProps(ctx.Config()), |
| 174 | "fs_config_files_odm_dlkm": defaultDepCandidateProps(ctx.Config()), |
| 175 | "odm_dlkm-build.prop": defaultDepCandidateProps(ctx.Config()), |
| 176 | }, |
Cole Faust | 76a6e95 | 2024-11-07 16:56:45 -0800 | [diff] [blame] | 177 | "ramdisk": {}, |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 178 | }, |
Jihoon Kang | 0d7b011 | 2024-11-13 20:44:05 +0000 | [diff] [blame^] | 179 | fsDepsMutex: sync.Mutex{}, |
| 180 | moduleToInstallationProps: map[string]installationProperties{}, |
| 181 | generatedPrebuiltEtcModuleNames: generatedPrebuiltEtcModuleNames, |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 182 | } |
Jihoon Kang | 04f12c9 | 2024-11-12 23:03:08 +0000 | [diff] [blame] | 183 | |
| 184 | if avbpubkeyGenerated { |
| 185 | (*fsGenState.fsDeps["product"])["system_other_avbpubkey"] = defaultDepCandidateProps(ctx.Config()) |
| 186 | } |
| 187 | |
| 188 | return &fsGenState |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 189 | }).(*FsGenState) |
| 190 | } |
| 191 | |
| 192 | func checkDepModuleInMultipleNamespaces(mctx android.BottomUpMutatorContext, foundDeps multilibDeps, module string, partitionName string) { |
| 193 | otherNamespace := mctx.Namespace().Path |
| 194 | if val, found := foundDeps[module]; found && otherNamespace != "." && !android.InList(val.Namespace, []string{".", otherNamespace}) { |
| 195 | mctx.ModuleErrorf("found in multiple namespaces(%s and %s) when including in %s partition", val.Namespace, otherNamespace, partitionName) |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | func appendDepIfAppropriate(mctx android.BottomUpMutatorContext, deps *multilibDeps, installPartition string) { |
Jihoon Kang | 81aeb9e | 2024-11-05 00:22:35 +0000 | [diff] [blame] | 200 | moduleName := mctx.ModuleName() |
| 201 | checkDepModuleInMultipleNamespaces(mctx, *deps, moduleName, installPartition) |
| 202 | if _, ok := (*deps)[moduleName]; ok { |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 203 | // Prefer the namespace-specific module over the platform module |
| 204 | if mctx.Namespace().Path != "." { |
Jihoon Kang | 81aeb9e | 2024-11-05 00:22:35 +0000 | [diff] [blame] | 205 | (*deps)[moduleName].Namespace = mctx.Namespace().Path |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 206 | } |
Jihoon Kang | 81aeb9e | 2024-11-05 00:22:35 +0000 | [diff] [blame] | 207 | (*deps)[moduleName].Arch = append((*deps)[moduleName].Arch, mctx.Module().Target().Arch.ArchType) |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 208 | } else { |
| 209 | multilib, _ := mctx.Module().DecodeMultilib(mctx) |
Jihoon Kang | 81aeb9e | 2024-11-05 00:22:35 +0000 | [diff] [blame] | 210 | (*deps)[moduleName] = &depCandidateProps{ |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 211 | Namespace: mctx.Namespace().Path, |
| 212 | Multilib: multilib, |
| 213 | Arch: []android.ArchType{mctx.Module().Target().Arch.ArchType}, |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | func collectDepsMutator(mctx android.BottomUpMutatorContext) { |
Cole Faust | 76a6e95 | 2024-11-07 16:56:45 -0800 | [diff] [blame] | 219 | m := mctx.Module() |
| 220 | if m.Target().Os.Class != android.Device { |
| 221 | return |
| 222 | } |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 223 | fsGenState := mctx.Config().Get(fsGenStateOnceKey).(*FsGenState) |
| 224 | |
Cole Faust | 76a6e95 | 2024-11-07 16:56:45 -0800 | [diff] [blame] | 225 | fsGenState.fsDepsMutex.Lock() |
| 226 | defer fsGenState.fsDepsMutex.Unlock() |
| 227 | |
| 228 | if slices.Contains(fsGenState.depCandidates, mctx.ModuleName()) { |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 229 | installPartition := m.PartitionTag(mctx.DeviceConfig()) |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 230 | // Only add the module as dependency when: |
| 231 | // - its enabled |
| 232 | // - its namespace is included in PRODUCT_SOONG_NAMESPACES |
| 233 | if m.Enabled(mctx) && m.ExportedToMake() { |
| 234 | appendDepIfAppropriate(mctx, fsGenState.fsDeps[installPartition], installPartition) |
| 235 | } |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 236 | } |
| 237 | // store the map of module to (required,overrides) even if the module is not in PRODUCT_PACKAGES. |
| 238 | // the module might be installed transitively. |
Cole Faust | 76a6e95 | 2024-11-07 16:56:45 -0800 | [diff] [blame] | 239 | if m.Enabled(mctx) && m.ExportedToMake() { |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 240 | fsGenState.moduleToInstallationProps[m.Name()] = installationProperties{ |
| 241 | Required: m.RequiredModuleNames(mctx), |
| 242 | Overrides: m.Overrides(), |
| 243 | } |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
| 247 | type depsStruct struct { |
| 248 | Deps []string |
| 249 | } |
| 250 | |
| 251 | type multilibDepsStruct struct { |
| 252 | Common depsStruct |
| 253 | Lib32 depsStruct |
| 254 | Lib64 depsStruct |
| 255 | Both depsStruct |
| 256 | Prefer32 depsStruct |
| 257 | } |
| 258 | |
| 259 | type packagingPropsStruct struct { |
| 260 | High_priority_deps []string |
| 261 | Deps []string |
| 262 | Multilib multilibDepsStruct |
| 263 | } |
| 264 | |
| 265 | func fullyQualifiedModuleName(moduleName, namespace string) string { |
| 266 | if namespace == "." { |
| 267 | return moduleName |
| 268 | } |
| 269 | return fmt.Sprintf("//%s:%s", namespace, moduleName) |
| 270 | } |
| 271 | |
| 272 | func getBitness(archTypes []android.ArchType) (ret []string) { |
| 273 | for _, archType := range archTypes { |
| 274 | if archType.Multilib == "" { |
| 275 | ret = append(ret, android.COMMON_VARIANT) |
| 276 | } else { |
| 277 | ret = append(ret, archType.Bitness()) |
| 278 | } |
| 279 | } |
| 280 | return ret |
| 281 | } |
| 282 | |
| 283 | func setDepsMutator(mctx android.BottomUpMutatorContext) { |
| 284 | removeOverriddenDeps(mctx) |
| 285 | fsGenState := mctx.Config().Get(fsGenStateOnceKey).(*FsGenState) |
| 286 | fsDeps := fsGenState.fsDeps |
| 287 | soongGeneratedPartitionMap := getAllSoongGeneratedPartitionNames(mctx.Config(), fsGenState.soongGeneratedPartitions) |
| 288 | m := mctx.Module() |
| 289 | if partition, ok := soongGeneratedPartitionMap[m.Name()]; ok { |
Jihoon Kang | 0d7b011 | 2024-11-13 20:44:05 +0000 | [diff] [blame^] | 290 | depsStruct := generateDepStruct(*fsDeps[partition], fsGenState.generatedPrebuiltEtcModuleNames) |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 291 | if err := proptools.AppendMatchingProperties(m.GetProperties(), depsStruct, nil); err != nil { |
| 292 | mctx.ModuleErrorf(err.Error()) |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | // removeOverriddenDeps collects PRODUCT_PACKAGES and (transitive) required deps. |
| 298 | // it then removes any modules which appear in `overrides` of the above list. |
| 299 | func removeOverriddenDeps(mctx android.BottomUpMutatorContext) { |
| 300 | mctx.Config().Once(fsGenRemoveOverridesOnceKey, func() interface{} { |
| 301 | fsGenState := mctx.Config().Get(fsGenStateOnceKey).(*FsGenState) |
| 302 | fsDeps := fsGenState.fsDeps |
| 303 | overridden := map[string]bool{} |
| 304 | allDeps := []string{} |
| 305 | |
| 306 | // Step 1: Initialization: Append PRODUCT_PACKAGES to the queue |
| 307 | for _, fsDep := range fsDeps { |
| 308 | for depName, _ := range *fsDep { |
| 309 | allDeps = append(allDeps, depName) |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // Step 2: Process the queue, and add required modules to the queue. |
| 314 | i := 0 |
| 315 | for { |
| 316 | if i == len(allDeps) { |
| 317 | break |
| 318 | } |
| 319 | depName := allDeps[i] |
| 320 | for _, overrides := range fsGenState.moduleToInstallationProps[depName].Overrides { |
| 321 | overridden[overrides] = true |
| 322 | } |
| 323 | // add required dep to the queue. |
| 324 | allDeps = append(allDeps, fsGenState.moduleToInstallationProps[depName].Required...) |
| 325 | i += 1 |
| 326 | } |
| 327 | |
| 328 | // Step 3: Delete all the overridden modules. |
| 329 | for overridden, _ := range overridden { |
| 330 | for partition, _ := range fsDeps { |
| 331 | delete(*fsDeps[partition], overridden) |
| 332 | } |
| 333 | } |
| 334 | return nil |
| 335 | }) |
| 336 | } |
| 337 | |
| 338 | var HighPriorityDeps = []string{} |
| 339 | |
Jihoon Kang | 3a8759c | 2024-11-08 19:35:09 +0000 | [diff] [blame] | 340 | func isHighPriorityDep(depName string) bool { |
| 341 | for _, highPriorityDeps := range HighPriorityDeps { |
| 342 | if strings.HasPrefix(depName, highPriorityDeps) { |
| 343 | return true |
| 344 | } |
| 345 | } |
| 346 | return false |
| 347 | } |
| 348 | |
Jihoon Kang | 0d7b011 | 2024-11-13 20:44:05 +0000 | [diff] [blame^] | 349 | func generateDepStruct(deps map[string]*depCandidateProps, highPriorityDeps []string) *packagingPropsStruct { |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 350 | depsStruct := packagingPropsStruct{} |
| 351 | for depName, depProps := range deps { |
| 352 | bitness := getBitness(depProps.Arch) |
| 353 | fullyQualifiedDepName := fullyQualifiedModuleName(depName, depProps.Namespace) |
Jihoon Kang | 0d7b011 | 2024-11-13 20:44:05 +0000 | [diff] [blame^] | 354 | if android.InList(depName, highPriorityDeps) { |
Jihoon Kang | add2bb2 | 2024-11-05 22:29:34 +0000 | [diff] [blame] | 355 | depsStruct.High_priority_deps = append(depsStruct.High_priority_deps, fullyQualifiedDepName) |
| 356 | } else if android.InList("32", bitness) && android.InList("64", bitness) { |
| 357 | // If both 32 and 64 bit variants are enabled for this module |
| 358 | switch depProps.Multilib { |
| 359 | case string(android.MultilibBoth): |
| 360 | depsStruct.Multilib.Both.Deps = append(depsStruct.Multilib.Both.Deps, fullyQualifiedDepName) |
| 361 | case string(android.MultilibCommon), string(android.MultilibFirst): |
| 362 | depsStruct.Deps = append(depsStruct.Deps, fullyQualifiedDepName) |
| 363 | case "32": |
| 364 | depsStruct.Multilib.Lib32.Deps = append(depsStruct.Multilib.Lib32.Deps, fullyQualifiedDepName) |
| 365 | case "64", "darwin_universal": |
| 366 | depsStruct.Multilib.Lib64.Deps = append(depsStruct.Multilib.Lib64.Deps, fullyQualifiedDepName) |
| 367 | case "prefer32", "first_prefer32": |
| 368 | depsStruct.Multilib.Prefer32.Deps = append(depsStruct.Multilib.Prefer32.Deps, fullyQualifiedDepName) |
| 369 | default: |
| 370 | depsStruct.Multilib.Both.Deps = append(depsStruct.Multilib.Both.Deps, fullyQualifiedDepName) |
| 371 | } |
| 372 | } else if android.InList("64", bitness) { |
| 373 | // If only 64 bit variant is enabled |
| 374 | depsStruct.Multilib.Lib64.Deps = append(depsStruct.Multilib.Lib64.Deps, fullyQualifiedDepName) |
| 375 | } else if android.InList("32", bitness) { |
| 376 | // If only 32 bit variant is enabled |
| 377 | depsStruct.Multilib.Lib32.Deps = append(depsStruct.Multilib.Lib32.Deps, fullyQualifiedDepName) |
| 378 | } else { |
| 379 | // If only common variant is enabled |
| 380 | depsStruct.Multilib.Common.Deps = append(depsStruct.Multilib.Common.Deps, fullyQualifiedDepName) |
| 381 | } |
| 382 | } |
| 383 | depsStruct.Deps = android.SortedUniqueStrings(depsStruct.Deps) |
| 384 | depsStruct.Multilib.Lib32.Deps = android.SortedUniqueStrings(depsStruct.Multilib.Lib32.Deps) |
| 385 | depsStruct.Multilib.Lib64.Deps = android.SortedUniqueStrings(depsStruct.Multilib.Lib64.Deps) |
| 386 | depsStruct.Multilib.Prefer32.Deps = android.SortedUniqueStrings(depsStruct.Multilib.Prefer32.Deps) |
| 387 | depsStruct.Multilib.Both.Deps = android.SortedUniqueStrings(depsStruct.Multilib.Both.Deps) |
| 388 | depsStruct.Multilib.Common.Deps = android.SortedUniqueStrings(depsStruct.Multilib.Common.Deps) |
| 389 | |
| 390 | return &depsStruct |
| 391 | } |