| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 1 | // Copyright 2019 Google Inc. All rights reserved. | 
|  | 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 cc | 
|  | 16 |  | 
|  | 17 | import ( | 
|  | 18 | "path/filepath" | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 19 |  | 
|  | 20 | "android/soong/android" | 
| Martin Stjernholm | cd07bce | 2020-03-10 22:37:59 +0000 | [diff] [blame] | 21 |  | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 22 | "github.com/google/blueprint" | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 23 | "github.com/google/blueprint/proptools" | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 24 | ) | 
|  | 25 |  | 
|  | 26 | // This file contains support for using cc library modules within an sdk. | 
|  | 27 |  | 
| Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 28 | var sharedLibrarySdkMemberType = &librarySdkMemberType{ | 
|  | 29 | SdkMemberTypeBase: android.SdkMemberTypeBase{ | 
| Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 30 | PropertyName:          "native_shared_libs", | 
|  | 31 | SupportsSdk:           true, | 
|  | 32 | HostOsDependent:       true, | 
|  | 33 | SupportedLinkageNames: []string{"shared"}, | 
| Alyssa Ketpreechasawat | 59ec0fa | 2024-07-04 19:51:17 +0000 | [diff] [blame] | 34 | StripDisabled:         true, | 
| Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 35 | }, | 
|  | 36 | prebuiltModuleType: "cc_prebuilt_library_shared", | 
| Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 37 | } | 
|  | 38 |  | 
|  | 39 | var staticLibrarySdkMemberType = &librarySdkMemberType{ | 
|  | 40 | SdkMemberTypeBase: android.SdkMemberTypeBase{ | 
| Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 41 | PropertyName:          "native_static_libs", | 
|  | 42 | SupportsSdk:           true, | 
|  | 43 | HostOsDependent:       true, | 
|  | 44 | SupportedLinkageNames: []string{"static"}, | 
| Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 45 | }, | 
|  | 46 | prebuiltModuleType: "cc_prebuilt_library_static", | 
| Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 47 | } | 
|  | 48 |  | 
| Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 49 | var staticAndSharedLibrarySdkMemberType = &librarySdkMemberType{ | 
|  | 50 | SdkMemberTypeBase: android.SdkMemberTypeBase{ | 
| Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 51 | PropertyName:           "native_libs", | 
|  | 52 | OverridesPropertyNames: map[string]bool{"native_shared_libs": true, "native_static_libs": true}, | 
|  | 53 | SupportsSdk:            true, | 
|  | 54 | HostOsDependent:        true, | 
|  | 55 | SupportedLinkageNames:  []string{"static", "shared"}, | 
| Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 56 | }, | 
|  | 57 | prebuiltModuleType: "cc_prebuilt_library", | 
| Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 58 | } | 
|  | 59 |  | 
| Paul Duffin | 255f18e | 2019-12-13 11:22:16 +0000 | [diff] [blame] | 60 | func init() { | 
|  | 61 | // Register sdk member types. | 
| Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 62 | android.RegisterSdkMemberType(sharedLibrarySdkMemberType) | 
|  | 63 | android.RegisterSdkMemberType(staticLibrarySdkMemberType) | 
| Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 64 | android.RegisterSdkMemberType(staticAndSharedLibrarySdkMemberType) | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 65 | } | 
|  | 66 |  | 
|  | 67 | type librarySdkMemberType struct { | 
| Paul Duffin | 255f18e | 2019-12-13 11:22:16 +0000 | [diff] [blame] | 68 | android.SdkMemberTypeBase | 
|  | 69 |  | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 70 | prebuiltModuleType string | 
|  | 71 |  | 
| Martin Stjernholm | cd07bce | 2020-03-10 22:37:59 +0000 | [diff] [blame] | 72 | noOutputFiles bool // True if there are no srcs files. | 
|  | 73 |  | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 74 | } | 
|  | 75 |  | 
| Paul Duffin | 296701e | 2021-07-14 10:29:36 +0100 | [diff] [blame] | 76 | func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) { | 
| Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 77 | // The base set of targets which does not include native bridge targets. | 
|  | 78 | defaultTargets := ctx.MultiTargets() | 
|  | 79 |  | 
|  | 80 | // The lazily created list of native bridge targets. | 
|  | 81 | var includeNativeBridgeTargets []android.Target | 
|  | 82 |  | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 83 | for _, lib := range names { | 
| Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 84 | targets := defaultTargets | 
|  | 85 |  | 
|  | 86 | // If native bridge support is required in the sdk snapshot then add native bridge targets to | 
|  | 87 | // the basic list of targets that are required. | 
|  | 88 | nativeBridgeSupport := ctx.RequiresTrait(lib, nativeBridgeSdkTrait) | 
|  | 89 | if nativeBridgeSupport && ctx.Device() { | 
|  | 90 | // If not already computed then compute the list of native bridge targets. | 
|  | 91 | if includeNativeBridgeTargets == nil { | 
|  | 92 | includeNativeBridgeTargets = append([]android.Target{}, defaultTargets...) | 
|  | 93 | allAndroidTargets := ctx.Config().Targets[android.Android] | 
|  | 94 | for _, possibleNativeBridgeTarget := range allAndroidTargets { | 
|  | 95 | if possibleNativeBridgeTarget.NativeBridge == android.NativeBridgeEnabled { | 
|  | 96 | includeNativeBridgeTargets = append(includeNativeBridgeTargets, possibleNativeBridgeTarget) | 
|  | 97 | } | 
|  | 98 | } | 
|  | 99 | } | 
|  | 100 |  | 
|  | 101 | // Include the native bridge targets as well. | 
|  | 102 | targets = includeNativeBridgeTargets | 
|  | 103 | } | 
| Paul Duffin | b1f0f2a | 2021-09-09 17:06:07 +0100 | [diff] [blame] | 104 |  | 
|  | 105 | // memberDependency encapsulates information about the dependencies to add for this member. | 
|  | 106 | type memberDependency struct { | 
|  | 107 | // The targets to depend upon. | 
|  | 108 | targets []android.Target | 
|  | 109 |  | 
|  | 110 | // Additional image variations to depend upon, is either nil for no image variation or | 
|  | 111 | // contains a single image variation. | 
|  | 112 | imageVariations []blueprint.Variation | 
|  | 113 | } | 
|  | 114 |  | 
|  | 115 | // Extract the name and version from the module name. | 
|  | 116 | name, version := StubsLibNameAndVersion(lib) | 
|  | 117 | if version == "" { | 
|  | 118 | version = "latest" | 
|  | 119 | } | 
|  | 120 |  | 
|  | 121 | // Compute the set of dependencies to add. | 
|  | 122 | var memberDependencies []memberDependency | 
|  | 123 | if ctx.Host() { | 
|  | 124 | // Host does not support image variations so add a dependency without any. | 
|  | 125 | memberDependencies = append(memberDependencies, memberDependency{ | 
|  | 126 | targets: targets, | 
|  | 127 | }) | 
|  | 128 | } else { | 
|  | 129 | // Otherwise, this is targeting the device so add a dependency on the core image variation | 
|  | 130 | // (image:""). | 
|  | 131 | memberDependencies = append(memberDependencies, memberDependency{ | 
|  | 132 | imageVariations: []blueprint.Variation{{Mutator: "image", Variation: android.CoreVariation}}, | 
|  | 133 | targets:         targets, | 
|  | 134 | }) | 
| Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 135 |  | 
| Paul Duffin | 12a0a31 | 2021-09-15 17:25:10 +0100 | [diff] [blame] | 136 | // If required add additional dependencies on the image:ramdisk variants. | 
|  | 137 | if ctx.RequiresTrait(lib, ramdiskImageRequiredSdkTrait) { | 
|  | 138 | memberDependencies = append(memberDependencies, memberDependency{ | 
|  | 139 | imageVariations: []blueprint.Variation{{Mutator: "image", Variation: android.RamdiskVariation}}, | 
|  | 140 | // Only add a dependency on the first target as that is the only one which will have an | 
|  | 141 | // image:ramdisk variant. | 
|  | 142 | targets: targets[:1], | 
|  | 143 | }) | 
|  | 144 | } | 
|  | 145 |  | 
| Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 146 | // If required add additional dependencies on the image:recovery variants. | 
|  | 147 | if ctx.RequiresTrait(lib, recoveryImageRequiredSdkTrait) { | 
|  | 148 | memberDependencies = append(memberDependencies, memberDependency{ | 
|  | 149 | imageVariations: []blueprint.Variation{{Mutator: "image", Variation: android.RecoveryVariation}}, | 
|  | 150 | // Only add a dependency on the first target as that is the only one which will have an | 
|  | 151 | // image:recovery variant. | 
|  | 152 | targets: targets[:1], | 
|  | 153 | }) | 
|  | 154 | } | 
| Paul Duffin | b1f0f2a | 2021-09-09 17:06:07 +0100 | [diff] [blame] | 155 | } | 
|  | 156 |  | 
|  | 157 | // For each dependency in the list add dependencies on the targets with the correct variations. | 
|  | 158 | for _, dependency := range memberDependencies { | 
|  | 159 | // For each target add a dependency on the target with any additional dependencies. | 
|  | 160 | for _, target := range dependency.targets { | 
|  | 161 | // Get the variations for the target. | 
|  | 162 | variations := target.Variations() | 
|  | 163 |  | 
|  | 164 | // Add any additional dependencies needed. | 
|  | 165 | variations = append(variations, dependency.imageVariations...) | 
|  | 166 |  | 
| Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 167 | if mt.SupportedLinkageNames == nil { | 
| Paul Duffin | b1f0f2a | 2021-09-09 17:06:07 +0100 | [diff] [blame] | 168 | // No link types are supported so add a dependency directly. | 
|  | 169 | ctx.AddFarVariationDependencies(variations, dependencyTag, name) | 
|  | 170 | } else { | 
|  | 171 | // Otherwise, add a dependency on each supported link type in turn. | 
| Liz Kammer | 96320df | 2022-05-12 20:40:00 -0400 | [diff] [blame] | 172 | for _, linkType := range mt.SupportedLinkageNames { | 
| Paul Duffin | b1f0f2a | 2021-09-09 17:06:07 +0100 | [diff] [blame] | 173 | libVariations := append(variations, | 
|  | 174 | blueprint.Variation{Mutator: "link", Variation: linkType}) | 
|  | 175 | // If this is for the device and a shared link type then add a dependency onto the | 
|  | 176 | // appropriate version specific variant of the module. | 
|  | 177 | if ctx.Device() && linkType == "shared" { | 
|  | 178 | libVariations = append(libVariations, | 
|  | 179 | blueprint.Variation{Mutator: "version", Variation: version}) | 
|  | 180 | } | 
|  | 181 | ctx.AddFarVariationDependencies(libVariations, dependencyTag, name) | 
| Colin Cross | a717db7 | 2020-10-23 14:53:06 -0700 | [diff] [blame] | 182 | } | 
| Paul Duffin | 91756d2 | 2020-02-21 16:29:57 +0000 | [diff] [blame] | 183 | } | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 184 | } | 
|  | 185 | } | 
|  | 186 | } | 
|  | 187 | } | 
|  | 188 |  | 
|  | 189 | func (mt *librarySdkMemberType) IsInstance(module android.Module) bool { | 
| Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 190 | // Check the module to see if it can be used with this module type. | 
|  | 191 | if m, ok := module.(*Module); ok { | 
|  | 192 | for _, allowableMemberType := range m.sdkMemberTypes { | 
|  | 193 | if allowableMemberType == mt { | 
|  | 194 | return true | 
|  | 195 | } | 
|  | 196 | } | 
|  | 197 | } | 
|  | 198 |  | 
|  | 199 | return false | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 200 | } | 
|  | 201 |  | 
| Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 202 | func (mt *librarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule { | 
|  | 203 | pbm := ctx.SnapshotBuilder().AddPrebuiltModule(member, mt.prebuiltModuleType) | 
| Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 204 |  | 
|  | 205 | ccModule := member.Variants()[0].(*Module) | 
|  | 206 |  | 
| Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 207 | if ctx.RequiresTrait(nativeBridgeSdkTrait) { | 
|  | 208 | pbm.AddProperty("native_bridge_supported", true) | 
|  | 209 | } | 
|  | 210 |  | 
| Paul Duffin | 12a0a31 | 2021-09-15 17:25:10 +0100 | [diff] [blame] | 211 | if ctx.RequiresTrait(ramdiskImageRequiredSdkTrait) { | 
|  | 212 | pbm.AddProperty("ramdisk_available", true) | 
|  | 213 | } | 
|  | 214 |  | 
| Paul Duffin | 6369622 | 2021-09-06 10:28:34 +0100 | [diff] [blame] | 215 | if ctx.RequiresTrait(recoveryImageRequiredSdkTrait) { | 
| Paul Duffin | d6abaa7 | 2020-09-07 16:39:22 +0100 | [diff] [blame] | 216 | pbm.AddProperty("recovery_available", true) | 
|  | 217 | } | 
|  | 218 |  | 
| Paul Duffin | d1edbd4 | 2020-08-13 19:45:31 +0100 | [diff] [blame] | 219 | if proptools.Bool(ccModule.VendorProperties.Vendor_available) { | 
|  | 220 | pbm.AddProperty("vendor_available", true) | 
|  | 221 | } | 
|  | 222 |  | 
| Justin Yun | ebcf0c5 | 2021-01-08 18:00:19 +0900 | [diff] [blame] | 223 | if proptools.Bool(ccModule.VendorProperties.Odm_available) { | 
|  | 224 | pbm.AddProperty("odm_available", true) | 
|  | 225 | } | 
|  | 226 |  | 
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 227 | if proptools.Bool(ccModule.VendorProperties.Product_available) { | 
|  | 228 | pbm.AddProperty("product_available", true) | 
|  | 229 | } | 
|  | 230 |  | 
| Paul Duffin | 0c394f3 | 2020-03-05 14:09:58 +0000 | [diff] [blame] | 231 | sdkVersion := ccModule.SdkVersion() | 
|  | 232 | if sdkVersion != "" { | 
|  | 233 | pbm.AddProperty("sdk_version", sdkVersion) | 
|  | 234 | } | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 235 |  | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 236 | stl := ccModule.stl.Properties.Stl | 
|  | 237 | if stl != nil { | 
| Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 238 | pbm.AddProperty("stl", proptools.String(stl)) | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 239 | } | 
| Martin Stjernholm | 47ed352 | 2020-06-17 22:52:25 +0100 | [diff] [blame] | 240 |  | 
|  | 241 | if lib, ok := ccModule.linker.(*libraryDecorator); ok { | 
|  | 242 | uhs := lib.Properties.Unique_host_soname | 
|  | 243 | if uhs != nil { | 
|  | 244 | pbm.AddProperty("unique_host_soname", proptools.Bool(uhs)) | 
|  | 245 | } | 
|  | 246 | } | 
|  | 247 |  | 
| Paul Duffin | 0174d8d | 2020-03-11 18:42:08 +0000 | [diff] [blame] | 248 | return pbm | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 249 | } | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 250 |  | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 251 | func (mt *librarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties { | 
|  | 252 | return &nativeLibInfoProperties{memberType: mt} | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 253 | } | 
|  | 254 |  | 
|  | 255 | func isGeneratedHeaderDirectory(p android.Path) bool { | 
|  | 256 | _, gen := p.(android.WritablePath) | 
| Colin Cross | 8ff1058 | 2023-12-07 13:10:56 -0800 | [diff] [blame] | 257 | return gen | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 258 | } | 
|  | 259 |  | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 260 | type includeDirsProperty struct { | 
|  | 261 | // Accessor to retrieve the paths | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 262 | pathsGetter func(libInfo *nativeLibInfoProperties) android.Paths | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 263 |  | 
|  | 264 | // The name of the property in the prebuilt library, "" means there is no property. | 
|  | 265 | propertyName string | 
|  | 266 |  | 
|  | 267 | // The directory within the snapshot directory into which items should be copied. | 
|  | 268 | snapshotDir string | 
|  | 269 |  | 
|  | 270 | // True if the items on the path should be copied. | 
|  | 271 | copy bool | 
|  | 272 |  | 
|  | 273 | // True if the paths represent directories, files if they represent files. | 
|  | 274 | dirs bool | 
| Paul Duffin | 74fc190 | 2020-01-23 11:45:03 +0000 | [diff] [blame] | 275 | } | 
|  | 276 |  | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 277 | var includeDirProperties = []includeDirsProperty{ | 
|  | 278 | { | 
|  | 279 | // ExportedIncludeDirs lists directories that contains some header files to be | 
|  | 280 | // copied into a directory in the snapshot. The snapshot directories must be added to | 
|  | 281 | // the export_include_dirs property in the prebuilt module in the snapshot. | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 282 | pathsGetter:  func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.ExportedIncludeDirs }, | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 283 | propertyName: "export_include_dirs", | 
|  | 284 | snapshotDir:  nativeIncludeDir, | 
|  | 285 | copy:         true, | 
|  | 286 | dirs:         true, | 
|  | 287 | }, | 
|  | 288 | { | 
|  | 289 | // ExportedSystemIncludeDirs lists directories that contains some system header files to | 
|  | 290 | // be copied into a directory in the snapshot. The snapshot directories must be added to | 
|  | 291 | // the export_system_include_dirs property in the prebuilt module in the snapshot. | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 292 | pathsGetter:  func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.ExportedSystemIncludeDirs }, | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 293 | propertyName: "export_system_include_dirs", | 
|  | 294 | snapshotDir:  nativeIncludeDir, | 
|  | 295 | copy:         true, | 
|  | 296 | dirs:         true, | 
|  | 297 | }, | 
|  | 298 | { | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 299 | // ExportedGeneratedIncludeDirs lists directories that contains some header files | 
|  | 300 | // that are explicitly listed in the ExportedGeneratedHeaders property. So, the contents | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 301 | // of these directories do not need to be copied, but these directories do need adding to | 
|  | 302 | // the export_include_dirs property in the prebuilt module in the snapshot. | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 303 | pathsGetter:  func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.ExportedGeneratedIncludeDirs }, | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 304 | propertyName: "export_include_dirs", | 
|  | 305 | snapshotDir:  nativeGeneratedIncludeDir, | 
|  | 306 | copy:         false, | 
|  | 307 | dirs:         true, | 
|  | 308 | }, | 
|  | 309 | { | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 310 | // ExportedGeneratedHeaders lists header files that are in one of the directories | 
|  | 311 | // specified in ExportedGeneratedIncludeDirs must be copied into the snapshot. | 
|  | 312 | // As they are in a directory in ExportedGeneratedIncludeDirs they do not need adding to a | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 313 | // property in the prebuilt module in the snapshot. | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 314 | pathsGetter:  func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.ExportedGeneratedHeaders }, | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 315 | propertyName: "", | 
|  | 316 | snapshotDir:  nativeGeneratedIncludeDir, | 
|  | 317 | copy:         true, | 
|  | 318 | dirs:         false, | 
|  | 319 | }, | 
|  | 320 | } | 
|  | 321 |  | 
|  | 322 | // Add properties that may, or may not, be arch specific. | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 323 | func addPossiblyArchSpecificProperties(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, libInfo *nativeLibInfoProperties, outputProperties android.BpPropertySet) { | 
|  | 324 |  | 
| Martin Stjernholm | b024957 | 2020-09-15 02:32:35 +0100 | [diff] [blame] | 325 | outputProperties.AddProperty("sanitize", &libInfo.Sanitize) | 
| Martin Stjernholm | fbb486f | 2020-08-21 18:43:51 +0100 | [diff] [blame] | 326 |  | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 327 | // Copy the generated library to the snapshot and add a reference to it in the .bp module. | 
|  | 328 | if libInfo.outputFile != nil { | 
|  | 329 | nativeLibraryPath := nativeLibraryPathFor(libInfo) | 
|  | 330 | builder.CopyToSnapshot(libInfo.outputFile, nativeLibraryPath) | 
|  | 331 | outputProperties.AddProperty("srcs", []string{nativeLibraryPath}) | 
|  | 332 | } | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 333 |  | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 334 | if len(libInfo.SharedLibs) > 0 { | 
|  | 335 | outputProperties.AddPropertyWithTag("shared_libs", libInfo.SharedLibs, builder.SdkMemberReferencePropertyTag(false)) | 
|  | 336 | } | 
|  | 337 |  | 
| Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 338 | // SystemSharedLibs needs to be propagated if it's a list, even if it's empty, | 
|  | 339 | // so check for non-nil instead of nonzero length. | 
|  | 340 | if libInfo.SystemSharedLibs != nil { | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 341 | outputProperties.AddPropertyWithTag("system_shared_libs", libInfo.SystemSharedLibs, builder.SdkMemberReferencePropertyTag(false)) | 
|  | 342 | } | 
|  | 343 |  | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 344 | // Map from property name to the include dirs to add to the prebuilt module in the snapshot. | 
|  | 345 | includeDirs := make(map[string][]string) | 
|  | 346 |  | 
|  | 347 | // Iterate over each include directory property, copying files and collating property | 
|  | 348 | // values where necessary. | 
|  | 349 | for _, propertyInfo := range includeDirProperties { | 
|  | 350 | // Calculate the base directory in the snapshot into which the files will be copied. | 
| Paul Duffin | 96f1832 | 2021-09-03 17:53:38 +0100 | [diff] [blame] | 351 | // lib.archSubDir is "" for common properties. | 
|  | 352 | targetDir := filepath.Join(libInfo.OsPrefix(), libInfo.archSubDir, propertyInfo.snapshotDir) | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 353 |  | 
|  | 354 | propertyName := propertyInfo.propertyName | 
|  | 355 |  | 
|  | 356 | // Iterate over each path in one of the include directory properties. | 
|  | 357 | for _, path := range propertyInfo.pathsGetter(libInfo) { | 
| Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 358 | inputPath := path.String() | 
|  | 359 |  | 
|  | 360 | // Map the input path to a snapshot relative path. The mapping is independent of the module | 
|  | 361 | // that references them so that if multiple modules within the same snapshot export the same | 
|  | 362 | // header files they end up in the same place in the snapshot and so do not get duplicated. | 
|  | 363 | targetRelativePath := inputPath | 
|  | 364 | if isGeneratedHeaderDirectory(path) { | 
|  | 365 | // Remove everything up to the .intermediates/ from the generated output directory to | 
|  | 366 | // leave a module relative path. | 
|  | 367 | base := android.PathForIntermediates(sdkModuleContext, "") | 
|  | 368 | targetRelativePath = android.Rel(sdkModuleContext, base.String(), inputPath) | 
|  | 369 | } | 
|  | 370 |  | 
|  | 371 | snapshotRelativePath := filepath.Join(targetDir, targetRelativePath) | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 372 |  | 
|  | 373 | // Copy the files/directories when necessary. | 
|  | 374 | if propertyInfo.copy { | 
|  | 375 | if propertyInfo.dirs { | 
|  | 376 | // When copying a directory glob and copy all the headers within it. | 
|  | 377 | // TODO(jiyong) copy headers having other suffixes | 
| Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 378 | headers, _ := sdkModuleContext.GlobWithDeps(inputPath+"/**/*.h", nil) | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 379 | for _, file := range headers { | 
|  | 380 | src := android.PathForSource(sdkModuleContext, file) | 
| Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 381 |  | 
|  | 382 | // The destination path in the snapshot is constructed from the snapshot relative path | 
|  | 383 | // of the input directory and the input directory relative path of the header file. | 
|  | 384 | inputRelativePath := android.Rel(sdkModuleContext, inputPath, file) | 
|  | 385 | dest := filepath.Join(snapshotRelativePath, inputRelativePath) | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 386 | builder.CopyToSnapshot(src, dest) | 
|  | 387 | } | 
|  | 388 | } else { | 
| Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 389 | // Otherwise, just copy the file to its snapshot relative path. | 
|  | 390 | builder.CopyToSnapshot(path, snapshotRelativePath) | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 391 | } | 
|  | 392 | } | 
|  | 393 |  | 
|  | 394 | // Only directories are added to a property. | 
|  | 395 | if propertyInfo.dirs { | 
| Paul Duffin | 42dd4e6 | 2021-02-22 11:35:24 +0000 | [diff] [blame] | 396 | includeDirs[propertyName] = append(includeDirs[propertyName], snapshotRelativePath) | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 397 | } | 
|  | 398 | } | 
| Paul Duffin | 74fc190 | 2020-01-23 11:45:03 +0000 | [diff] [blame] | 399 | } | 
| Paul Duffin | 64f54b0 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 400 |  | 
|  | 401 | // Add the collated include dir properties to the output. | 
| Cole Faust | 18994c7 | 2023-02-28 16:02:16 -0800 | [diff] [blame] | 402 | for _, property := range android.SortedKeys(includeDirs) { | 
| Colin Cross | 2c03361 | 2020-09-11 15:44:31 -0700 | [diff] [blame] | 403 | outputProperties.AddProperty(property, includeDirs[property]) | 
| Paul Duffin | 74fc190 | 2020-01-23 11:45:03 +0000 | [diff] [blame] | 404 | } | 
| Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 405 |  | 
| Martin Stjernholm | 618b671 | 2020-09-24 16:53:04 +0100 | [diff] [blame] | 406 | if len(libInfo.StubsVersions) > 0 { | 
| Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 407 | stubsSet := outputProperties.AddPropertySet("stubs") | 
| Martin Stjernholm | 618b671 | 2020-09-24 16:53:04 +0100 | [diff] [blame] | 408 | stubsSet.AddProperty("versions", libInfo.StubsVersions) | 
| Spandan Das | e20c56c | 2024-07-23 21:34:24 +0000 | [diff] [blame] | 409 | // The symbol file will be copied next to the Android.bp file | 
|  | 410 | stubsSet.AddProperty("symbol_file", libInfo.StubsSymbolFilePath.Base()) | 
|  | 411 | builder.CopyToSnapshot(libInfo.StubsSymbolFilePath, libInfo.StubsSymbolFilePath.Base()) | 
| Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 412 | } | 
| Paul Duffin | 74fc190 | 2020-01-23 11:45:03 +0000 | [diff] [blame] | 413 | } | 
|  | 414 |  | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 415 | const ( | 
|  | 416 | nativeIncludeDir          = "include" | 
|  | 417 | nativeGeneratedIncludeDir = "include_gen" | 
|  | 418 | nativeStubDir             = "lib" | 
|  | 419 | ) | 
|  | 420 |  | 
|  | 421 | // path to the native library. Relative to <sdk_root>/<api_dir> | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 422 | func nativeLibraryPathFor(lib *nativeLibInfoProperties) string { | 
| Paul Duffin | 96f1832 | 2021-09-03 17:53:38 +0100 | [diff] [blame] | 423 | return filepath.Join(lib.OsPrefix(), lib.archSubDir, | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 424 | nativeStubDir, lib.outputFile.Base()) | 
|  | 425 | } | 
|  | 426 |  | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 427 | // nativeLibInfoProperties represents properties of a native lib | 
|  | 428 | // | 
|  | 429 | // The exported (capitalized) fields will be examined and may be changed during common value extraction. | 
|  | 430 | // The unexported fields will be left untouched. | 
|  | 431 | type nativeLibInfoProperties struct { | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 432 | android.SdkMemberPropertiesBase | 
|  | 433 |  | 
|  | 434 | memberType *librarySdkMemberType | 
|  | 435 |  | 
| Paul Duffin | 96f1832 | 2021-09-03 17:53:38 +0100 | [diff] [blame] | 436 | // archSubDir is the subdirectory within the OS directory in the sdk snapshot into which arch | 
|  | 437 | // specific files will be copied. | 
|  | 438 | // | 
|  | 439 | // It is not exported since any value other than "" is always going to be arch specific. | 
|  | 440 | // This is "" for non-arch specific common properties. | 
|  | 441 | archSubDir string | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 442 |  | 
| Paul Duffin | 5efd198 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 443 | // The list of possibly common exported include dirs. | 
|  | 444 | // | 
|  | 445 | // This field is exported as its contents may not be arch specific. | 
| Paul Duffin | 864e1b4 | 2020-05-06 10:23:19 +0100 | [diff] [blame] | 446 | ExportedIncludeDirs android.Paths `android:"arch_variant"` | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 447 |  | 
| Paul Duffin | 5efd198 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 448 | // The list of arch specific exported generated include dirs. | 
|  | 449 | // | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 450 | // This field is exported as its contents may not be arch specific, e.g. protos. | 
|  | 451 | ExportedGeneratedIncludeDirs android.Paths `android:"arch_variant"` | 
| Paul Duffin | 5efd198 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 452 |  | 
|  | 453 | // The list of arch specific exported generated header files. | 
|  | 454 | // | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 455 | // This field is exported as its contents may not be arch specific, e.g. protos. | 
|  | 456 | ExportedGeneratedHeaders android.Paths `android:"arch_variant"` | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 457 |  | 
| Paul Duffin | 5efd198 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 458 | // The list of possibly common exported system include dirs. | 
|  | 459 | // | 
|  | 460 | // This field is exported as its contents may not be arch specific. | 
| Paul Duffin | 864e1b4 | 2020-05-06 10:23:19 +0100 | [diff] [blame] | 461 | ExportedSystemIncludeDirs android.Paths `android:"arch_variant"` | 
| Paul Duffin | 5efd198 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 462 |  | 
|  | 463 | // The list of possibly common exported flags. | 
|  | 464 | // | 
|  | 465 | // This field is exported as its contents may not be arch specific. | 
| Paul Duffin | 864e1b4 | 2020-05-06 10:23:19 +0100 | [diff] [blame] | 466 | ExportedFlags []string `android:"arch_variant"` | 
| Paul Duffin | 5efd198 | 2020-02-20 14:33:54 +0000 | [diff] [blame] | 467 |  | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 468 | // The set of shared libraries | 
|  | 469 | // | 
|  | 470 | // This field is exported as its contents may not be arch specific. | 
| Paul Duffin | 864e1b4 | 2020-05-06 10:23:19 +0100 | [diff] [blame] | 471 | SharedLibs []string `android:"arch_variant"` | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 472 |  | 
| Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 473 | // The set of system shared libraries. Note nil and [] are semantically | 
|  | 474 | // distinct - see BaseLinkerProperties.System_shared_libs. | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 475 | // | 
|  | 476 | // This field is exported as its contents may not be arch specific. | 
| Paul Duffin | 864e1b4 | 2020-05-06 10:23:19 +0100 | [diff] [blame] | 477 | SystemSharedLibs []string `android:"arch_variant"` | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 478 |  | 
| Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 479 | // The specific stubs version for the lib variant, or empty string if stubs | 
|  | 480 | // are not in use. | 
| Paul Duffin | 7a1f7f3 | 2020-05-04 15:32:08 +0100 | [diff] [blame] | 481 | // | 
| Martin Stjernholm | 618b671 | 2020-09-24 16:53:04 +0100 | [diff] [blame] | 482 | // Marked 'ignored-on-host' as the AllStubsVersions() from which this is | 
|  | 483 | // initialized is not set on host and the stubs.versions property which this | 
|  | 484 | // is written to does not vary by arch so cannot be android specific. | 
|  | 485 | StubsVersions []string `sdk:"ignored-on-host"` | 
| Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 486 |  | 
| Spandan Das | e20c56c | 2024-07-23 21:34:24 +0000 | [diff] [blame] | 487 | // The symbol file containing the APIs exported by this library. | 
|  | 488 | StubsSymbolFilePath android.Path `sdk:"ignored-on-host"` | 
|  | 489 |  | 
| Martin Stjernholm | b024957 | 2020-09-15 02:32:35 +0100 | [diff] [blame] | 490 | // Value of SanitizeProperties.Sanitize. Several - but not all - of these | 
|  | 491 | // affect the expanded variants. All are propagated to avoid entangling the | 
|  | 492 | // sanitizer logic with the snapshot generation. | 
|  | 493 | Sanitize SanitizeUserProps `android:"arch_variant"` | 
| Martin Stjernholm | fbb486f | 2020-08-21 18:43:51 +0100 | [diff] [blame] | 494 |  | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 495 | // outputFile is not exported as it is always arch specific. | 
|  | 496 | outputFile android.Path | 
|  | 497 | } | 
|  | 498 |  | 
| Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 499 | func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { | 
| Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 500 | addOutputFile := true | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 501 | ccModule := variant.(*Module) | 
|  | 502 |  | 
| Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 503 | if s := ccModule.sanitize; s != nil { | 
|  | 504 | // We currently do not capture sanitizer flags for libs with sanitizers | 
|  | 505 | // enabled, because they may vary among variants that cannot be represented | 
|  | 506 | // in the input blueprint files. In particular, sanitizerDepsMutator enables | 
|  | 507 | // various sanitizers on dependencies, but in many cases only on static | 
|  | 508 | // ones, and we cannot specify sanitizer flags at the link type level (i.e. | 
|  | 509 | // in StaticOrSharedProperties). | 
|  | 510 | if s.isUnsanitizedVariant() { | 
|  | 511 | // This still captures explicitly disabled sanitizers, which may be | 
|  | 512 | // necessary to avoid cyclic dependencies. | 
|  | 513 | p.Sanitize = s.Properties.Sanitize | 
|  | 514 | } else { | 
|  | 515 | // Do not add the output file to the snapshot if we don't represent it | 
|  | 516 | // properly. | 
|  | 517 | addOutputFile = false | 
|  | 518 | } | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 519 | } | 
|  | 520 |  | 
| Colin Cross | 313aa54 | 2023-12-13 13:47:44 -0800 | [diff] [blame] | 521 | exportedInfo, _ := android.OtherModuleProvider(ctx.SdkModuleContext(), variant, FlagExporterInfoProvider) | 
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 522 |  | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 523 | // Separate out the generated include dirs (which are arch specific) from the | 
|  | 524 | // include dirs (which may not be). | 
|  | 525 | exportedIncludeDirs, exportedGeneratedIncludeDirs := android.FilterPathListPredicate( | 
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 526 | exportedInfo.IncludeDirs, isGeneratedHeaderDirectory) | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 527 |  | 
| Paul Duffin | 93b750e | 2019-11-19 19:44:10 +0000 | [diff] [blame] | 528 | target := ccModule.Target() | 
|  | 529 | p.archSubDir = target.Arch.ArchType.String() | 
|  | 530 | if target.NativeBridge == android.NativeBridgeEnabled { | 
|  | 531 | p.archSubDir += "_native_bridge" | 
|  | 532 | } | 
| Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 533 |  | 
|  | 534 | // Make sure that the include directories are unique. | 
|  | 535 | p.ExportedIncludeDirs = android.FirstUniquePaths(exportedIncludeDirs) | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 536 | p.ExportedGeneratedIncludeDirs = android.FirstUniquePaths(exportedGeneratedIncludeDirs) | 
| Paul Duffin | ab5467d | 2020-06-18 16:31:04 +0100 | [diff] [blame] | 537 |  | 
|  | 538 | // Take a copy before filtering out duplicates to avoid changing the slice owned by the | 
|  | 539 | // ccModule. | 
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 540 | dirs := append(android.Paths(nil), exportedInfo.SystemIncludeDirs...) | 
| Paul Duffin | ab5467d | 2020-06-18 16:31:04 +0100 | [diff] [blame] | 541 | p.ExportedSystemIncludeDirs = android.FirstUniquePaths(dirs) | 
| Paul Duffin | 9b76c0b | 2020-03-12 10:24:35 +0000 | [diff] [blame] | 542 |  | 
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 543 | p.ExportedFlags = exportedInfo.Flags | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 544 | if ccModule.linker != nil { | 
|  | 545 | specifiedDeps := specifiedDeps{} | 
|  | 546 | specifiedDeps = ccModule.linker.linkerSpecifiedDeps(specifiedDeps) | 
|  | 547 |  | 
| Colin Cross | 31076b3 | 2020-10-23 17:22:06 -0700 | [diff] [blame] | 548 | if lib := ccModule.library; lib != nil { | 
|  | 549 | if !lib.hasStubsVariants() { | 
|  | 550 | // Propagate dynamic dependencies for implementation libs, but not stubs. | 
|  | 551 | p.SharedLibs = specifiedDeps.sharedLibs | 
|  | 552 | } else { | 
|  | 553 | // TODO(b/169373910): 1. Only output the specific version (from | 
|  | 554 | // ccModule.StubsVersion()) if the module is versioned. 2. Ensure that all | 
|  | 555 | // the versioned stub libs are retained in the prebuilt tree; currently only | 
|  | 556 | // the stub corresponding to ccModule.StubsVersion() is. | 
|  | 557 | p.StubsVersions = lib.allStubsVersions() | 
| Spandan Das | e20c56c | 2024-07-23 21:34:24 +0000 | [diff] [blame] | 558 | if lib.buildStubs() && ccModule.stubsSymbolFilePath() == nil { | 
|  | 559 | ctx.ModuleErrorf("Could not determine symbol_file") | 
|  | 560 | } else { | 
|  | 561 | p.StubsSymbolFilePath = ccModule.stubsSymbolFilePath() | 
|  | 562 | } | 
| Colin Cross | 31076b3 | 2020-10-23 17:22:06 -0700 | [diff] [blame] | 563 | } | 
| Martin Stjernholm | cc330d6 | 2020-04-21 20:45:35 +0100 | [diff] [blame] | 564 | } | 
| Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 565 | p.SystemSharedLibs = specifiedDeps.systemSharedLibs | 
|  | 566 | } | 
| Paul Duffin | 7a7d067 | 2021-02-17 12:17:40 +0000 | [diff] [blame] | 567 | p.ExportedGeneratedHeaders = exportedInfo.GeneratedHeaders | 
| Martin Stjernholm | c5dd4f7 | 2020-04-01 20:38:01 +0100 | [diff] [blame] | 568 |  | 
| Martin Stjernholm | 59e0c7a | 2020-10-28 23:38:33 +0000 | [diff] [blame] | 569 | if !p.memberType.noOutputFiles && addOutputFile { | 
|  | 570 | p.outputFile = getRequiredMemberOutputFile(ctx, ccModule) | 
| Martin Stjernholm | fbb486f | 2020-08-21 18:43:51 +0100 | [diff] [blame] | 571 | } | 
| Paul Duffin | 88f2fbe | 2020-02-27 16:00:53 +0000 | [diff] [blame] | 572 | } | 
|  | 573 |  | 
| Paul Duffin | 712993c | 2020-05-05 14:11:57 +0100 | [diff] [blame] | 574 | func getRequiredMemberOutputFile(ctx android.SdkMemberContext, ccModule *Module) android.Path { | 
|  | 575 | var path android.Path | 
|  | 576 | outputFile := ccModule.OutputFile() | 
|  | 577 | if outputFile.Valid() { | 
|  | 578 | path = outputFile.Path() | 
|  | 579 | } else { | 
|  | 580 | ctx.SdkModuleContext().ModuleErrorf("member variant %s does not have a valid output file", ccModule) | 
|  | 581 | } | 
|  | 582 | return path | 
|  | 583 | } | 
|  | 584 |  | 
| Paul Duffin | 3a4eb50 | 2020-03-19 16:11:18 +0000 | [diff] [blame] | 585 | func (p *nativeLibInfoProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { | 
|  | 586 | addPossiblyArchSpecificProperties(ctx.SdkModuleContext(), ctx.SnapshotBuilder(), p, propertySet) | 
| Paul Duffin | 2f6bc09 | 2019-12-13 10:40:56 +0000 | [diff] [blame] | 587 | } |