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