Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1 | // Copyright (C) 2018 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 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 15 | // package apex implements build rules for creating the APEX files which are container for |
| 16 | // lower-level system components. See https://source.android.com/devices/tech/ota/apex |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 17 | package apex |
| 18 | |
| 19 | import ( |
| 20 | "fmt" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 21 | "path/filepath" |
Jiyong Park | ab3ceb3 | 2018-10-10 14:05:29 +0900 | [diff] [blame] | 22 | "sort" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 23 | "strings" |
| 24 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 25 | "github.com/google/blueprint" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 26 | "github.com/google/blueprint/bootstrap" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 27 | "github.com/google/blueprint/proptools" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 28 | |
| 29 | "android/soong/android" |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 30 | "android/soong/bpf" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 31 | "android/soong/cc" |
| 32 | prebuilt_etc "android/soong/etc" |
| 33 | "android/soong/java" |
| 34 | "android/soong/python" |
| 35 | "android/soong/sh" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 36 | ) |
| 37 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 38 | func init() { |
| 39 | android.RegisterModuleType("apex", BundleFactory) |
| 40 | android.RegisterModuleType("apex_test", testApexBundleFactory) |
| 41 | android.RegisterModuleType("apex_vndk", vndkApexBundleFactory) |
| 42 | android.RegisterModuleType("apex_defaults", defaultsFactory) |
| 43 | android.RegisterModuleType("prebuilt_apex", PrebuiltFactory) |
| 44 | android.RegisterModuleType("override_apex", overrideApexFactory) |
| 45 | android.RegisterModuleType("apex_set", apexSetFactory) |
| 46 | |
| 47 | android.PreDepsMutators(RegisterPreDepsMutators) |
| 48 | android.PostDepsMutators(RegisterPostDepsMutators) |
| 49 | } |
| 50 | |
| 51 | func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { |
| 52 | ctx.TopDown("apex_vndk", apexVndkMutator).Parallel() |
| 53 | ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel() |
| 54 | } |
| 55 | |
| 56 | func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { |
| 57 | ctx.TopDown("apex_deps", apexDepsMutator).Parallel() |
| 58 | ctx.BottomUp("apex_unique", apexUniqueVariationsMutator).Parallel() |
| 59 | ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator).Parallel() |
| 60 | ctx.BottomUp("apex_test_for", apexTestForMutator).Parallel() |
| 61 | ctx.BottomUp("apex", apexMutator).Parallel() |
| 62 | ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel() |
| 63 | ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel() |
| 64 | ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel() |
| 65 | } |
| 66 | |
| 67 | type apexBundleProperties struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 68 | // Json manifest file describing meta info of this APEX bundle. Refer to |
| 69 | // system/apex/proto/apex_manifest.proto for the schema. Default: "apex_manifest.json" |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 70 | Manifest *string `android:"path"` |
| 71 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 72 | // AndroidManifest.xml file used for the zip container of this APEX bundle. If unspecified, |
| 73 | // a default one is automatically generated. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 74 | AndroidManifest *string `android:"path"` |
| 75 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 76 | // Canonical name of this APEX bundle. Used to determine the path to the activated APEX on |
| 77 | // device (/apex/<apex_name>). If unspecified, follows the name property. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 78 | Apex_name *string |
| 79 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 80 | // Determines the file contexts file for setting the security contexts to files in this APEX |
| 81 | // bundle. For platform APEXes, this should points to a file under /system/sepolicy Default: |
| 82 | // /system/sepolicy/apex/<module_name>_file_contexts. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 83 | File_contexts *string `android:"path"` |
| 84 | |
| 85 | ApexNativeDependencies |
| 86 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 87 | Multilib apexMultilibProperties |
| 88 | |
| 89 | // List of java libraries that are embedded inside this APEX bundle. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 90 | Java_libs []string |
| 91 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 92 | // List of prebuilt files that are embedded inside this APEX bundle. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 93 | Prebuilts []string |
| 94 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 95 | // List of BPF programs inside this APEX bundle. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 96 | Bpfs []string |
| 97 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 98 | // Name of the apex_key module that provides the private key to sign this APEX bundle. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 99 | Key *string |
| 100 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 101 | // Specifies the certificate and the private key to sign the zip container of this APEX. If |
| 102 | // this is "foo", foo.x509.pem and foo.pk8 under PRODUCT_DEFAULT_DEV_CERTIFICATE are used |
| 103 | // as the certificate and the private key, respectively. If this is ":module", then the |
| 104 | // certificate and the private key are provided from the android_app_certificate module |
| 105 | // named "module". |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 106 | Certificate *string |
| 107 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 108 | // The minimum SDK version that this APEX must support at minimum. This is usually set to |
| 109 | // the SDK version that the APEX was first introduced. |
| 110 | Min_sdk_version *string |
| 111 | |
| 112 | // Whether this APEX is considered updatable or not. When set to true, this will enforce |
| 113 | // additional rules for making sure that the APEX is truly updatable. To be updatable, |
| 114 | // min_sdk_version should be set as well. This will also disable the size optimizations like |
| 115 | // symlinking to the system libs. Default is false. |
| 116 | Updatable *bool |
| 117 | |
| 118 | // Whether this APEX is installable to one of the partitions like system, vendor, etc. |
| 119 | // Default: true. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 120 | Installable *bool |
| 121 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 122 | // For native libraries and binaries, use the vendor variant instead of the core (platform) |
| 123 | // variant. Default is false. DO NOT use this for APEXes that are installed to the system or |
| 124 | // system_ext partition. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 125 | Use_vendor *bool |
| 126 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 127 | // If set true, VNDK libs are considered as stable libs and are not included in this APEX. |
| 128 | // Should be only used in non-system apexes (e.g. vendor: true). Default is false. |
| 129 | Use_vndk_as_stable *bool |
| 130 | |
| 131 | // List of SDKs that are used to build this APEX. A reference to an SDK should be either |
| 132 | // `name#version` or `name` which is an alias for `name#current`. If left empty, |
| 133 | // `platform#current` is implied. This value affects all modules included in this APEX. In |
| 134 | // other words, they are also built with the SDKs specified here. |
| 135 | Uses_sdks []string |
| 136 | |
| 137 | // The type of APEX to build. Controls what the APEX payload is. Either 'image', 'zip' or |
| 138 | // 'both'. When set to image, contents are stored in a filesystem image inside a zip |
| 139 | // container. When set to zip, contents are stored in a zip container directly. This type is |
| 140 | // mostly for host-side debugging. When set to both, the two types are both built. Default |
| 141 | // is 'image'. |
| 142 | Payload_type *string |
| 143 | |
| 144 | // The type of filesystem to use when the payload_type is 'image'. Either 'ext4' or 'f2fs'. |
| 145 | // Default 'ext4'. |
| 146 | Payload_fs_type *string |
| 147 | |
| 148 | // For telling the APEX to ignore special handling for system libraries such as bionic. |
| 149 | // Default is false. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 150 | Ignore_system_library_special_case *bool |
| 151 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 152 | // Whenever apex_payload.img of the APEX should include dm-verity hashtree. Should be only |
| 153 | // used in tests. |
| 154 | Test_only_no_hashtree *bool |
| 155 | |
| 156 | // Whenever apex_payload.img of the APEX should not be dm-verity signed. Should be only |
| 157 | // used in tests. |
| 158 | Test_only_unsigned_payload *bool |
| 159 | |
| 160 | IsCoverageVariant bool `blueprint:"mutated"` |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 161 | |
| 162 | // List of sanitizer names that this APEX is enabled for |
| 163 | SanitizerNames []string `blueprint:"mutated"` |
| 164 | |
| 165 | PreventInstall bool `blueprint:"mutated"` |
| 166 | |
| 167 | HideFromMake bool `blueprint:"mutated"` |
| 168 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 169 | // Internal package method for this APEX. When payload_type is image, this can be either |
| 170 | // imageApex or flattenedApex depending on Config.FlattenApex(). When payload_type is zip, |
| 171 | // this becomes zipApex. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 172 | ApexType apexPackaging `blueprint:"mutated"` |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | type ApexNativeDependencies struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 176 | // List of native libraries that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 177 | Native_shared_libs []string |
| 178 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 179 | // List of JNI libraries that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 180 | Jni_libs []string |
| 181 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 182 | // List of native executables that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 183 | Binaries []string |
| 184 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 185 | // List of native tests that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 186 | Tests []string |
| 187 | } |
| 188 | |
| 189 | type apexMultilibProperties struct { |
| 190 | // Native dependencies whose compile_multilib is "first" |
| 191 | First ApexNativeDependencies |
| 192 | |
| 193 | // Native dependencies whose compile_multilib is "both" |
| 194 | Both ApexNativeDependencies |
| 195 | |
| 196 | // Native dependencies whose compile_multilib is "prefer32" |
| 197 | Prefer32 ApexNativeDependencies |
| 198 | |
| 199 | // Native dependencies whose compile_multilib is "32" |
| 200 | Lib32 ApexNativeDependencies |
| 201 | |
| 202 | // Native dependencies whose compile_multilib is "64" |
| 203 | Lib64 ApexNativeDependencies |
| 204 | } |
| 205 | |
| 206 | type apexTargetBundleProperties struct { |
| 207 | Target struct { |
| 208 | // Multilib properties only for android. |
| 209 | Android struct { |
| 210 | Multilib apexMultilibProperties |
| 211 | } |
| 212 | |
| 213 | // Multilib properties only for host. |
| 214 | Host struct { |
| 215 | Multilib apexMultilibProperties |
| 216 | } |
| 217 | |
| 218 | // Multilib properties only for host linux_bionic. |
| 219 | Linux_bionic struct { |
| 220 | Multilib apexMultilibProperties |
| 221 | } |
| 222 | |
| 223 | // Multilib properties only for host linux_glibc. |
| 224 | Linux_glibc struct { |
| 225 | Multilib apexMultilibProperties |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 230 | // These properties can be used in override_apex to override the corresponding properties in the |
| 231 | // base apex. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 232 | type overridableProperties struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 233 | // List of APKs that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 234 | Apps []string |
| 235 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 236 | // List of runtime resource overlays (RROs) that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 237 | Rros []string |
| 238 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 239 | // Names of modules to be overridden. Listed modules can only be other binaries (in Make or |
| 240 | // Soong). This does not completely prevent installation of the overridden binaries, but if |
| 241 | // both binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will |
| 242 | // be removed from PRODUCT_PACKAGES. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 243 | Overrides []string |
| 244 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 245 | // Logging parent value. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 246 | Logging_parent string |
| 247 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 248 | // Apex Container package name. Override value for attribute package:name in |
| 249 | // AndroidManifest.xml |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 250 | Package_name string |
| 251 | |
| 252 | // A txt file containing list of files that are allowed to be included in this APEX. |
| 253 | Allowed_files *string `android:"path"` |
| 254 | } |
| 255 | |
| 256 | type apexBundle struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 257 | // Inherited structs |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 258 | android.ModuleBase |
| 259 | android.DefaultableModuleBase |
| 260 | android.OverridableModuleBase |
| 261 | android.SdkBase |
| 262 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 263 | // Properties |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 264 | properties apexBundleProperties |
| 265 | targetProperties apexTargetBundleProperties |
| 266 | overridableProperties overridableProperties |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 267 | vndkProperties apexVndkProperties // only for apex_vndk modules |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 268 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 269 | /////////////////////////////////////////////////////////////////////////////////////////// |
| 270 | // Inputs |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 271 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 272 | // Keys for apex_paylaod.img |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 273 | public_key_file android.Path |
| 274 | private_key_file android.Path |
| 275 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 276 | // Cert/priv-key for the zip container |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 277 | container_certificate_file android.Path |
| 278 | container_private_key_file android.Path |
| 279 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 280 | // Flags for special variants of APEX |
| 281 | testApex bool |
| 282 | vndkApex bool |
| 283 | artApex bool |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 284 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 285 | // Tells whether this variant of the APEX bundle is the primary one or not. Only the primary |
| 286 | // one gets installed to the device. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 287 | primaryApexType bool |
| 288 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 289 | // Suffix of module name in Android.mk ".flattened", ".apex", ".zipapex", or "" |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 290 | suffix string |
| 291 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 292 | // File system type of apex_payload.img |
| 293 | payloadFsType fsType |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 294 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 295 | // Whether to create symlink to the system file instead of having a file inside the apex or |
| 296 | // not |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 297 | linkToSystemLib bool |
| 298 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 299 | // List of files to be included in this APEX. This is filled in the first part of |
| 300 | // GenerateAndroidBuildActions. |
| 301 | filesInfo []apexFile |
| 302 | |
| 303 | // List of other module names that should be installed when this APEX gets installed. |
| 304 | requiredDeps []string |
| 305 | |
| 306 | /////////////////////////////////////////////////////////////////////////////////////////// |
| 307 | // Outputs (final and intermediates) |
| 308 | |
| 309 | // Processed apex manifest in JSONson format (for Q) |
| 310 | manifestJsonOut android.WritablePath |
| 311 | |
| 312 | // Processed apex manifest in PB format (for R+) |
| 313 | manifestPbOut android.WritablePath |
| 314 | |
| 315 | // Processed file_contexts files |
| 316 | fileContexts android.WritablePath |
| 317 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 318 | // Struct holding the merged notice file paths in different formats |
| 319 | mergedNotices android.NoticeOutputs |
| 320 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 321 | // The built APEX file. This is the main product. |
| 322 | outputFile android.WritablePath |
| 323 | |
| 324 | // The built APEX file in app bundle format. This file is not directly installed to the |
| 325 | // device. For an APEX, multiple app bundles are created each of which is for a specific ABI |
| 326 | // like arm, arm64, x86, etc. Then they are processed again (outside of the Android build |
| 327 | // system) to be merged into a single app bundle file that Play accepts. See |
| 328 | // vendor/google/build/build_unbundled_mainline_module.sh for more detail. |
| 329 | bundleModuleFile android.WritablePath |
| 330 | |
| 331 | // Target path to install this APEX. Usually out/target/product/<device>/<partition>/apex. |
| 332 | installDir android.InstallPath |
| 333 | |
| 334 | // List of commands to create symlinks for backward compatibility. These commands will be |
| 335 | // attached as LOCAL_POST_INSTALL_CMD to apex package itself (for unflattened build) or |
| 336 | // apex_manifest (for flattened build) so that compat symlinks are always installed |
| 337 | // regardless of TARGET_FLATTEN_APEX setting. |
| 338 | compatSymlinks []string |
| 339 | |
| 340 | // Text file having the list of individual files that are included in this APEX. Used for |
| 341 | // debugging purpose. |
| 342 | installedFilesFile android.WritablePath |
| 343 | |
| 344 | // List of module names that this APEX is including (to be shown via *-deps-info target). |
| 345 | // Used for debugging purpose. |
| 346 | android.ApexBundleDepsInfo |
| 347 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 348 | // Optional list of lint report zip files for apexes that contain java or app modules |
| 349 | lintReports android.Paths |
| 350 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 351 | prebuiltFileToDelete string |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 352 | } |
| 353 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 354 | // apexFileClass represents a type of file that can be included in APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 355 | type apexFileClass int |
| 356 | |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 357 | const ( |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 358 | app apexFileClass = iota |
| 359 | appSet |
| 360 | etc |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 361 | goBinary |
| 362 | javaSharedLib |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 363 | nativeExecutable |
| 364 | nativeSharedLib |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 365 | nativeTest |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 366 | pyBinary |
| 367 | shBinary |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 368 | ) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 369 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 370 | // apexFile represents a file in an APEX bundle. This is created during the first half of |
| 371 | // GenerateAndroidBuildActions by traversing the dependencies of the APEX. Then in the second half |
| 372 | // of the function, this is used to create commands that copies the files into a staging directory, |
| 373 | // where they are packaged into the APEX file. This struct is also used for creating Make modules |
| 374 | // for each of the files in case when the APEX is flattened. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 375 | type apexFile struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 376 | // buildFile is put in the installDir inside the APEX. |
| 377 | builtFile android.Path |
| 378 | noticeFiles android.Paths |
| 379 | installDir string |
| 380 | customStem string |
| 381 | symlinks []string // additional symlinks |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 382 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 383 | // Info for Android.mk Module name of `module` in AndroidMk. Note the generated AndroidMk |
| 384 | // module for apexFile is named something like <AndroidMk module name>.<apex name>[<apex |
| 385 | // suffix>] |
| 386 | androidMkModuleName string // becomes LOCAL_MODULE |
| 387 | class apexFileClass // becomes LOCAL_MODULE_CLASS |
| 388 | moduleDir string // becomes LOCAL_PATH |
| 389 | requiredModuleNames []string // becomes LOCAL_REQUIRED_MODULES |
| 390 | targetRequiredModuleNames []string // becomes LOCAL_TARGET_REQUIRED_MODULES |
| 391 | hostRequiredModuleNames []string // becomes LOCAL_HOST_REQUIRED_MODULES |
| 392 | dataPaths []android.DataPath // becomes LOCAL_TEST_DATA |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 393 | |
| 394 | jacocoReportClassesFile android.Path // only for javalibs and apps |
| 395 | lintDepSets java.LintDepSets // only for javalibs and apps |
| 396 | certificate java.Certificate // only for apps |
| 397 | overriddenPackageName string // only for apps |
| 398 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 399 | transitiveDep bool |
| 400 | isJniLib bool |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 401 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 402 | // TODO(jiyong): remove this |
| 403 | module android.Module |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 404 | } |
| 405 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 406 | // TODO(jiyong): shorten the arglist using an option struct |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 407 | func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile { |
| 408 | ret := apexFile{ |
| 409 | builtFile: builtFile, |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 410 | installDir: installDir, |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 411 | androidMkModuleName: androidMkModuleName, |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 412 | class: class, |
| 413 | module: module, |
| 414 | } |
| 415 | if module != nil { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 416 | ret.noticeFiles = module.NoticeFiles() |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 417 | ret.moduleDir = ctx.OtherModuleDir(module) |
| 418 | ret.requiredModuleNames = module.RequiredModuleNames() |
| 419 | ret.targetRequiredModuleNames = module.TargetRequiredModuleNames() |
| 420 | ret.hostRequiredModuleNames = module.HostRequiredModuleNames() |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 421 | } |
| 422 | return ret |
| 423 | } |
| 424 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 425 | func (af *apexFile) ok() bool { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 426 | return af.builtFile != nil && af.builtFile.String() != "" |
| 427 | } |
| 428 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 429 | // apexRelativePath returns the relative path of the given path from the install directory of this |
| 430 | // apexFile. |
| 431 | // TODO(jiyong): rename this |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 432 | func (af *apexFile) apexRelativePath(path string) string { |
| 433 | return filepath.Join(af.installDir, path) |
| 434 | } |
| 435 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 436 | // path returns path of this apex file relative to the APEX root |
| 437 | func (af *apexFile) path() string { |
| 438 | return af.apexRelativePath(af.stem()) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 439 | } |
| 440 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 441 | // stem returns the base filename of this apex file |
| 442 | func (af *apexFile) stem() string { |
| 443 | if af.customStem != "" { |
| 444 | return af.customStem |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 445 | } |
| 446 | return af.builtFile.Base() |
| 447 | } |
| 448 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 449 | // symlinkPaths returns paths of the symlinks (if any) relative to the APEX root |
| 450 | func (af *apexFile) symlinkPaths() []string { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 451 | var ret []string |
| 452 | for _, symlink := range af.symlinks { |
| 453 | ret = append(ret, af.apexRelativePath(symlink)) |
| 454 | } |
| 455 | return ret |
| 456 | } |
| 457 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 458 | // availableToPlatform tests whether this apexFile is from a module that can be installed to the |
| 459 | // platform. |
| 460 | func (af *apexFile) availableToPlatform() bool { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 461 | if af.module == nil { |
| 462 | return false |
| 463 | } |
| 464 | if am, ok := af.module.(android.ApexModule); ok { |
| 465 | return am.AvailableFor(android.AvailableToPlatform) |
| 466 | } |
| 467 | return false |
| 468 | } |
| 469 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 470 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 471 | // Mutators |
| 472 | // |
| 473 | // Brief description about mutators for APEX. The following three mutators are the most important |
| 474 | // ones. |
| 475 | // |
| 476 | // 1) DepsMutator: from the properties like native_shared_libs, java_libs, etc., modules are added |
| 477 | // to the (direct) dependencies of this APEX bundle. |
| 478 | // |
| 479 | // 2) apexDepsMutator: this is a post-deps mutator, so runs after DepsMutator. Its goal is to |
| 480 | // collect modules that are direct and transitive dependencies of each APEX bundle. The collected |
| 481 | // modules are marked as being included in the APEX via BuildForApex(). |
| 482 | // |
| 483 | // 3) apexMutator: this is a post-deps mutator that runs after apexDepsMutator. For each module that |
| 484 | // are marked by the apexDepsMutator, apex variations are created using CreateApexVariations(). |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 485 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 486 | type dependencyTag struct { |
| 487 | blueprint.BaseDependencyTag |
| 488 | name string |
| 489 | |
| 490 | // Determines if the dependent will be part of the APEX payload. Can be false for the |
| 491 | // dependencies to the signing key module, etc. |
| 492 | payload bool |
| 493 | } |
| 494 | |
| 495 | var ( |
| 496 | androidAppTag = dependencyTag{name: "androidApp", payload: true} |
| 497 | bpfTag = dependencyTag{name: "bpf", payload: true} |
| 498 | certificateTag = dependencyTag{name: "certificate"} |
| 499 | executableTag = dependencyTag{name: "executable", payload: true} |
| 500 | javaLibTag = dependencyTag{name: "javaLib", payload: true} |
| 501 | jniLibTag = dependencyTag{name: "jniLib", payload: true} |
| 502 | keyTag = dependencyTag{name: "key"} |
| 503 | prebuiltTag = dependencyTag{name: "prebuilt", payload: true} |
| 504 | rroTag = dependencyTag{name: "rro", payload: true} |
| 505 | sharedLibTag = dependencyTag{name: "sharedLib", payload: true} |
| 506 | testForTag = dependencyTag{name: "test for"} |
| 507 | testTag = dependencyTag{name: "test", payload: true} |
| 508 | ) |
| 509 | |
| 510 | // TODO(jiyong): shorten this function signature |
| 511 | func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeModules ApexNativeDependencies, target android.Target, imageVariation string) { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 512 | binVariations := target.Variations() |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 513 | libVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"}) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 514 | |
| 515 | if ctx.Device() { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 516 | binVariations = append(binVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation}) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 517 | libVariations = append(libVariations, |
| 518 | blueprint.Variation{Mutator: "image", Variation: imageVariation}, |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 519 | blueprint.Variation{Mutator: "version", Variation: ""}, // "" is the non-stub variant |
| 520 | ) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 521 | } |
| 522 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 523 | // Use *FarVariation* to be able to depend on modules having conflicting variations with |
| 524 | // this module. This is required since arch variant of an APEX bundle is 'common' but it is |
| 525 | // 'arm' or 'arm64' for native shared libs. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 526 | ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 527 | ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 528 | ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...) |
| 529 | ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 533 | if ctx.Device() { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 534 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil) |
| 535 | } else { |
| 536 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil) |
| 537 | if ctx.Os().Bionic() { |
| 538 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil) |
| 539 | } else { |
| 540 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil) |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 545 | // getImageVariation returns the image variant name for this apexBundle. In most cases, it's simply |
| 546 | // android.CoreVariation, but gets complicated for the vendor APEXes and the VNDK APEX. |
| 547 | func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) string { |
| 548 | deviceConfig := ctx.DeviceConfig() |
| 549 | if a.vndkApex { |
| 550 | return cc.VendorVariationPrefix + a.vndkVersion(deviceConfig) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 551 | } |
| 552 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 553 | var prefix string |
| 554 | var vndkVersion string |
| 555 | if deviceConfig.VndkVersion() != "" { |
| 556 | if proptools.Bool(a.properties.Use_vendor) { |
| 557 | prefix = cc.VendorVariationPrefix |
| 558 | vndkVersion = deviceConfig.PlatformVndkVersion() |
| 559 | } else if a.SocSpecific() || a.DeviceSpecific() { |
| 560 | prefix = cc.VendorVariationPrefix |
| 561 | vndkVersion = deviceConfig.VndkVersion() |
| 562 | } else if a.ProductSpecific() { |
| 563 | prefix = cc.ProductVariationPrefix |
| 564 | vndkVersion = deviceConfig.ProductVndkVersion() |
| 565 | } |
| 566 | } |
| 567 | if vndkVersion == "current" { |
| 568 | vndkVersion = deviceConfig.PlatformVndkVersion() |
| 569 | } |
| 570 | if vndkVersion != "" { |
| 571 | return prefix + vndkVersion |
| 572 | } |
| 573 | |
| 574 | return android.CoreVariation // The usual case |
| 575 | } |
| 576 | |
| 577 | func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 578 | // TODO(jiyong): move this kind of checks to GenerateAndroidBuildActions? |
| 579 | checkUseVendorProperty(ctx, a) |
| 580 | |
| 581 | // apexBundle is a multi-arch targets module. Arch variant of apexBundle is set to 'common'. |
| 582 | // arch-specific targets are enabled by the compile_multilib setting of the apex bundle. For |
| 583 | // each target os/architectures, appropriate dependencies are selected by their |
| 584 | // target.<os>.multilib.<type> groups and are added as (direct) dependencies. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 585 | targets := ctx.MultiTargets() |
| 586 | config := ctx.DeviceConfig() |
| 587 | imageVariation := a.getImageVariation(ctx) |
| 588 | |
| 589 | a.combineProperties(ctx) |
| 590 | |
| 591 | has32BitTarget := false |
| 592 | for _, target := range targets { |
| 593 | if target.Arch.ArchType.Multilib == "lib32" { |
| 594 | has32BitTarget = true |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 595 | } |
| 596 | } |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 597 | for i, target := range targets { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 598 | // Don't include artifacts for the host cross targets because there is no way for us |
| 599 | // to run those artifacts natively on host |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 600 | if target.HostCross { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 601 | continue |
| 602 | } |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 603 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 604 | var depsList []ApexNativeDependencies |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 605 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 606 | // Add native modules targeting both ABIs. When multilib.* is omitted for |
| 607 | // native_shared_libs/jni_libs/tests, it implies multilib.both |
| 608 | depsList = append(depsList, a.properties.Multilib.Both) |
| 609 | depsList = append(depsList, ApexNativeDependencies{ |
| 610 | Native_shared_libs: a.properties.Native_shared_libs, |
| 611 | Tests: a.properties.Tests, |
| 612 | Jni_libs: a.properties.Jni_libs, |
| 613 | Binaries: nil, |
| 614 | }) |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame] | 615 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 616 | // Add native modules targeting the first ABI When multilib.* is omitted for |
| 617 | // binaries, it implies multilib.first |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 618 | isPrimaryAbi := i == 0 |
| 619 | if isPrimaryAbi { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 620 | depsList = append(depsList, a.properties.Multilib.First) |
| 621 | depsList = append(depsList, ApexNativeDependencies{ |
| 622 | Native_shared_libs: nil, |
| 623 | Tests: nil, |
| 624 | Jni_libs: nil, |
| 625 | Binaries: a.properties.Binaries, |
| 626 | }) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 627 | } |
| 628 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 629 | // Add native modules targeting either 32-bit or 64-bit ABI |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 630 | switch target.Arch.ArchType.Multilib { |
| 631 | case "lib32": |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 632 | depsList = append(depsList, a.properties.Multilib.Lib32) |
| 633 | depsList = append(depsList, a.properties.Multilib.Prefer32) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 634 | case "lib64": |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 635 | depsList = append(depsList, a.properties.Multilib.Lib64) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 636 | if !has32BitTarget { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 637 | depsList = append(depsList, a.properties.Multilib.Prefer32) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 638 | } |
| 639 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 640 | |
| 641 | for _, d := range depsList { |
| 642 | addDependenciesForNativeModules(ctx, d, target, imageVariation) |
| 643 | } |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 644 | } |
| 645 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 646 | // For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device) |
| 647 | // regardless of the TARGET_PREFER_* setting. See b/144532908 |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 648 | archForPrebuiltEtc := config.Arches()[0] |
| 649 | for _, arch := range config.Arches() { |
| 650 | // Prefer 64-bit arch if there is any |
| 651 | if arch.ArchType.Multilib == "lib64" { |
| 652 | archForPrebuiltEtc = arch |
| 653 | break |
| 654 | } |
| 655 | } |
| 656 | ctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 657 | {Mutator: "os", Variation: ctx.Os().String()}, |
| 658 | {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, |
| 659 | }, prebuiltTag, a.properties.Prebuilts...) |
| 660 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 661 | // Common-arch dependencies come next |
| 662 | commonVariation := ctx.Config().AndroidCommonTarget.Variations() |
| 663 | ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...) |
| 664 | ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.properties.Bpfs...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 665 | |
| 666 | // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library. |
| 667 | if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 668 | ctx.AddFarVariationDependencies(commonVariation, javaLibTag, "jacocoagent") |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 669 | } |
| 670 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 671 | // Dependencies for signing |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 672 | if String(a.properties.Key) == "" { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 673 | ctx.PropertyErrorf("key", "missing") |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 674 | return |
| 675 | } |
| 676 | ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key)) |
| 677 | |
| 678 | cert := android.SrcIsModule(a.getCertString(ctx)) |
| 679 | if cert != "" { |
| 680 | ctx.AddDependency(ctx.Module(), certificateTag, cert) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 681 | // empty cert is not an error. Cert and private keys will be directly found under |
| 682 | // PRODUCT_DEFAULT_DEV_CERTIFICATE |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 683 | } |
| 684 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 685 | // Marks that this APEX (in fact all the modules in it) has to be built with the given SDKs. |
| 686 | // This field currently isn't used. |
| 687 | // TODO(jiyong): consider dropping this feature |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 688 | // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks |
| 689 | if len(a.properties.Uses_sdks) > 0 { |
| 690 | sdkRefs := []android.SdkRef{} |
| 691 | for _, str := range a.properties.Uses_sdks { |
| 692 | parsed := android.ParseSdkRef(ctx, str, "uses_sdks") |
| 693 | sdkRefs = append(sdkRefs, parsed) |
| 694 | } |
| 695 | a.BuildWithSdks(sdkRefs) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 696 | } |
| 697 | } |
| 698 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 699 | // DepsMutator for the overridden properties. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 700 | func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) { |
| 701 | if a.overridableProperties.Allowed_files != nil { |
| 702 | android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 703 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 704 | |
| 705 | commonVariation := ctx.Config().AndroidCommonTarget.Variations() |
| 706 | ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...) |
| 707 | ctx.AddFarVariationDependencies(commonVariation, rroTag, a.overridableProperties.Rros...) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 708 | } |
| 709 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 710 | type ApexBundleInfo struct { |
| 711 | Contents *android.ApexContents |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 712 | } |
| 713 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 714 | var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_deps") |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 715 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 716 | // apexDepsMutator is responsible for collecting modules that need to have apex variants. They are |
| 717 | // identified by doing a graph walk starting from an apexBundle. Basically, all the (direct and |
| 718 | // indirect) dependencies are collected. But a few types of modules that shouldn't be included in |
| 719 | // the apexBundle (e.g. stub libraries) are not collected. Note that a single module can be depended |
| 720 | // on by multiple apexBundles. In that case, the module is collected for all of the apexBundles. |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 721 | func apexDepsMutator(mctx android.TopDownMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 722 | if !mctx.Module().Enabled() { |
| 723 | return |
| 724 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 725 | |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 726 | a, ok := mctx.Module().(*apexBundle) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 727 | if !ok { |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 728 | return |
| 729 | } |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 730 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 731 | // The VNDK APEX is special. For the APEX, the membership is described in a very different |
| 732 | // way. There is no dependency from the VNDK APEX to the VNDK libraries. Instead, VNDK |
| 733 | // libraries are self-identified by their vndk.enabled properties. There is no need to run |
| 734 | // this mutator for the APEX as nothing will be collected. So, let's return fast. |
| 735 | if a.vndkApex { |
| 736 | return |
| 737 | } |
| 738 | |
| 739 | // Special casing for APEXes on non-system (e.g., vendor, odm, etc.) partitions. They are |
| 740 | // provided with a property named use_vndk_as_stable, which when set to true doesn't collect |
| 741 | // VNDK libraries as transitive dependencies. This option is useful for reducing the size of |
| 742 | // the non-system APEXes because the VNDK libraries won't be included (and duped) in the |
| 743 | // APEX, but shared across APEXes via the VNDK APEX. |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 744 | useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface()) |
| 745 | excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) |
| 746 | if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) { |
| 747 | mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes") |
| 748 | return |
| 749 | } |
| 750 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 751 | continueApexDepsWalk := func(child, parent android.Module) bool { |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 752 | am, ok := child.(android.ApexModule) |
| 753 | if !ok || !am.CanHaveApexVariants() { |
| 754 | return false |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 755 | } |
Paul Duffin | a37eca2 | 2020-07-22 13:00:54 +0100 | [diff] [blame] | 756 | if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) { |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 757 | return false |
| 758 | } |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 759 | if excludeVndkLibs { |
| 760 | if c, ok := child.(*cc.Module); ok && c.IsVndk() { |
| 761 | return false |
| 762 | } |
| 763 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 764 | // By default, all the transitive dependencies are collected, unless filtered out |
| 765 | // above. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 766 | return true |
| 767 | } |
| 768 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 769 | // Records whether a certain module is included in this apexBundle via direct dependency or |
| 770 | // inndirect dependency. |
| 771 | contents := make(map[string]android.ApexMembership) |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 772 | mctx.WalkDeps(func(child, parent android.Module) bool { |
| 773 | if !continueApexDepsWalk(child, parent) { |
| 774 | return false |
| 775 | } |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 776 | // If the parent is apexBundle, this child is directly depended. |
| 777 | _, directDep := parent.(*apexBundle) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 778 | depName := mctx.OtherModuleName(child) |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 779 | contents[depName] = contents[depName].Add(directDep) |
| 780 | return true |
| 781 | }) |
| 782 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 783 | // The membership information is saved for later access |
Jiyong Park | e4758ed | 2020-11-18 01:34:22 +0900 | [diff] [blame] | 784 | apexContents := android.NewApexContents(contents) |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 785 | mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{ |
| 786 | Contents: apexContents, |
| 787 | }) |
| 788 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 789 | // This is the main part of this mutator. Mark the collected dependencies that they need to |
| 790 | // be built for this apexBundle. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 791 | apexInfo := android.ApexInfo{ |
| 792 | ApexVariationName: mctx.ModuleName(), |
| 793 | MinSdkVersionStr: a.minSdkVersion(mctx).String(), |
| 794 | RequiredSdks: a.RequiredSdks(), |
| 795 | Updatable: a.Updatable(), |
| 796 | InApexes: []string{mctx.ModuleName()}, |
| 797 | ApexContents: []*android.ApexContents{apexContents}, |
| 798 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 799 | mctx.WalkDeps(func(child, parent android.Module) bool { |
| 800 | if !continueApexDepsWalk(child, parent) { |
| 801 | return false |
| 802 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 803 | child.(android.ApexModule).BuildForApex(apexInfo) // leave a mark! |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 804 | return true |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 805 | }) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 806 | } |
| 807 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 808 | // apexUniqueVariationsMutator checks if any dependencies use unique apex variations. If so, use |
| 809 | // unique apex variations for this module. See android/apex.go for more about unique apex variant. |
| 810 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | aede88c | 2020-08-11 12:17:01 -0700 | [diff] [blame] | 811 | func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { |
| 812 | if !mctx.Module().Enabled() { |
| 813 | return |
| 814 | } |
| 815 | if am, ok := mctx.Module().(android.ApexModule); ok { |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 816 | android.UpdateUniqueApexVariationsForDeps(mctx, am) |
| 817 | } |
| 818 | } |
| 819 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 820 | // apexTestForDepsMutator checks if this module is a test for an apex. If so, add a dependency on |
| 821 | // the apex in order to retrieve its contents later. |
| 822 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 823 | func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { |
| 824 | if !mctx.Module().Enabled() { |
| 825 | return |
| 826 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 827 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 828 | if testFor := am.TestFor(); len(testFor) > 0 { |
| 829 | mctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 830 | {Mutator: "os", Variation: am.Target().OsVariation()}, |
| 831 | {"arch", "common"}, |
| 832 | }, testForTag, testFor...) |
| 833 | } |
| 834 | } |
| 835 | } |
| 836 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 837 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 838 | func apexTestForMutator(mctx android.BottomUpMutatorContext) { |
| 839 | if !mctx.Module().Enabled() { |
| 840 | return |
| 841 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 842 | if _, ok := mctx.Module().(android.ApexModule); ok { |
| 843 | var contents []*android.ApexContents |
| 844 | for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) { |
| 845 | abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo) |
| 846 | contents = append(contents, abInfo.Contents) |
| 847 | } |
| 848 | mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{ |
| 849 | ApexContents: contents, |
| 850 | }) |
Colin Cross | aede88c | 2020-08-11 12:17:01 -0700 | [diff] [blame] | 851 | } |
| 852 | } |
| 853 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 854 | // markPlatformAvailability marks whether or not a module can be available to platform. A module |
| 855 | // cannot be available to platform if 1) it is explicitly marked as not available (i.e. |
| 856 | // "//apex_available:platform" is absent) or 2) it depends on another module that isn't (or can't |
| 857 | // be) available to platform |
| 858 | // TODO(jiyong): move this to android/apex.go? |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 859 | func markPlatformAvailability(mctx android.BottomUpMutatorContext) { |
| 860 | // Host and recovery are not considered as platform |
| 861 | if mctx.Host() || mctx.Module().InstallInRecovery() { |
| 862 | return |
| 863 | } |
| 864 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 865 | am, ok := mctx.Module().(android.ApexModule) |
| 866 | if !ok { |
| 867 | return |
| 868 | } |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 869 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 870 | availableToPlatform := am.AvailableFor(android.AvailableToPlatform) |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 871 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 872 | // If any of the dep is not available to platform, this module is also considered as being |
| 873 | // not available to platform even if it has "//apex_available:platform" |
| 874 | mctx.VisitDirectDeps(func(child android.Module) { |
| 875 | if !am.DepIsInSameApex(mctx, child) { |
| 876 | // if the dependency crosses apex boundary, don't consider it |
| 877 | return |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 878 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 879 | if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() { |
| 880 | availableToPlatform = false |
| 881 | // TODO(b/154889534) trigger an error when 'am' has |
| 882 | // "//apex_available:platform" |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 883 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 884 | }) |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 885 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 886 | // Exception 1: stub libraries and native bridge libraries are always available to platform |
| 887 | if cc, ok := mctx.Module().(*cc.Module); ok && |
| 888 | (cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) { |
| 889 | availableToPlatform = true |
| 890 | } |
| 891 | |
| 892 | // Exception 2: bootstrap bionic libraries are also always available to platform |
| 893 | if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) { |
| 894 | availableToPlatform = true |
| 895 | } |
| 896 | |
| 897 | if !availableToPlatform { |
| 898 | am.SetNotAvailableForPlatform() |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 899 | } |
| 900 | } |
| 901 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 902 | // apexMutator visits each module and creates apex variations if the module was marked in the |
| 903 | // previous run of apexDepsMutator. |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 904 | func apexMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 905 | if !mctx.Module().Enabled() { |
| 906 | return |
| 907 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 908 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 909 | // This is the usual path. |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 910 | if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 911 | android.CreateApexVariations(mctx, am) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 912 | return |
| 913 | } |
| 914 | |
| 915 | // apexBundle itself is mutated so that it and its dependencies have the same apex variant. |
| 916 | // TODO(jiyong): document the reason why the VNDK APEX is an exception here. |
| 917 | if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 918 | apexBundleName := mctx.ModuleName() |
| 919 | mctx.CreateVariations(apexBundleName) |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 920 | } else if o, ok := mctx.Module().(*OverrideApex); ok { |
| 921 | apexBundleName := o.GetOverriddenModuleName() |
| 922 | if apexBundleName == "" { |
| 923 | mctx.ModuleErrorf("base property is not set") |
| 924 | return |
| 925 | } |
| 926 | mctx.CreateVariations(apexBundleName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 927 | } |
| 928 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 929 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 930 | // See android.UpdateDirectlyInAnyApex |
| 931 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 932 | func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { |
| 933 | if !mctx.Module().Enabled() { |
| 934 | return |
| 935 | } |
| 936 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 937 | android.UpdateDirectlyInAnyApex(mctx, am) |
| 938 | } |
| 939 | } |
| 940 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 941 | // apexPackaging represents a specific packaging method for an APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 942 | type apexPackaging int |
| 943 | |
| 944 | const ( |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 945 | // imageApex is a packaging method where contents are included in a filesystem image which |
| 946 | // is then included in a zip container. This is the most typical way of packaging. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 947 | imageApex apexPackaging = iota |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 948 | |
| 949 | // zipApex is a packaging method where contents are directly included in the zip container. |
| 950 | // This is used for host-side testing - because the contents are easily accessible by |
| 951 | // unzipping the container. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 952 | zipApex |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 953 | |
| 954 | // flattendApex is a packaging method where contents are not included in the APEX file, but |
| 955 | // installed to /apex/<apexname> directory on the device. This packaging method is used for |
| 956 | // old devices where the filesystem-based APEX file can't be supported. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 957 | flattenedApex |
| 958 | ) |
| 959 | |
| 960 | const ( |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 961 | // File extensions of an APEX for different packaging methods |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 962 | imageApexSuffix = ".apex" |
| 963 | zipApexSuffix = ".zipapex" |
| 964 | flattenedSuffix = ".flattened" |
| 965 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 966 | // variant names each of which is for a packaging method |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 967 | imageApexType = "image" |
| 968 | zipApexType = "zip" |
| 969 | flattenedApexType = "flattened" |
| 970 | |
| 971 | ext4FsType = "ext4" |
| 972 | f2fsFsType = "f2fs" |
| 973 | ) |
| 974 | |
| 975 | // The suffix for the output "file", not the module |
| 976 | func (a apexPackaging) suffix() string { |
| 977 | switch a { |
| 978 | case imageApex: |
| 979 | return imageApexSuffix |
| 980 | case zipApex: |
| 981 | return zipApexSuffix |
| 982 | default: |
| 983 | panic(fmt.Errorf("unknown APEX type %d", a)) |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | func (a apexPackaging) name() string { |
| 988 | switch a { |
| 989 | case imageApex: |
| 990 | return imageApexType |
| 991 | case zipApex: |
| 992 | return zipApexType |
| 993 | default: |
| 994 | panic(fmt.Errorf("unknown APEX type %d", a)) |
| 995 | } |
| 996 | } |
| 997 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 998 | // apexFlattenedMutator creates one or more variations each of which is for a packaging method. |
| 999 | // TODO(jiyong): give a better name to this mutator |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 1000 | func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 1001 | if !mctx.Module().Enabled() { |
| 1002 | return |
| 1003 | } |
Sundong Ahn | e8fb724 | 2019-09-17 13:50:45 +0900 | [diff] [blame] | 1004 | if ab, ok := mctx.Module().(*apexBundle); ok { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1005 | var variants []string |
| 1006 | switch proptools.StringDefault(ab.properties.Payload_type, "image") { |
| 1007 | case "image": |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1008 | // This is the normal case. Note that both image and flattend APEXes are |
| 1009 | // created. The image type is installed to the system partition, while the |
| 1010 | // flattened APEX is (optionally) installed to the system_ext partition. |
| 1011 | // This is mostly for GSI which has to support wide range of devices. If GSI |
| 1012 | // is installed on a newer (APEX-capable) device, the image APEX in the |
| 1013 | // system will be used. However, if the same GSI is installed on an old |
| 1014 | // device which can't support image APEX, the flattened APEX in the |
| 1015 | // system_ext partion (which still is part of GSI) is used instead. |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1016 | variants = append(variants, imageApexType, flattenedApexType) |
| 1017 | case "zip": |
| 1018 | variants = append(variants, zipApexType) |
| 1019 | case "both": |
| 1020 | variants = append(variants, imageApexType, zipApexType, flattenedApexType) |
| 1021 | default: |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1022 | mctx.PropertyErrorf("payload_type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type) |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1023 | return |
| 1024 | } |
| 1025 | |
| 1026 | modules := mctx.CreateLocalVariations(variants...) |
| 1027 | |
| 1028 | for i, v := range variants { |
| 1029 | switch v { |
| 1030 | case imageApexType: |
| 1031 | modules[i].(*apexBundle).properties.ApexType = imageApex |
| 1032 | case zipApexType: |
| 1033 | modules[i].(*apexBundle).properties.ApexType = zipApex |
| 1034 | case flattenedApexType: |
| 1035 | modules[i].(*apexBundle).properties.ApexType = flattenedApex |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1036 | // See the comment above for why system_ext. |
Jooyung Han | 91df208 | 2019-11-20 01:49:42 +0900 | [diff] [blame] | 1037 | if !mctx.Config().FlattenApex() && ab.Platform() { |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 1038 | modules[i].(*apexBundle).MakeAsSystemExt() |
| 1039 | } |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1040 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 1041 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1042 | } else if _, ok := mctx.Module().(*OverrideApex); ok { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1043 | // payload_type is forcibly overridden to "image" |
| 1044 | // TODO(jiyong): is this the right decision? |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1045 | mctx.CreateVariations(imageApexType, flattenedApexType) |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 1046 | } |
| 1047 | } |
| 1048 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1049 | // checkUseVendorProperty checks if the use of `use_vendor` property is allowed for the given APEX. |
| 1050 | // When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__, |
| 1051 | // which may cause compatibility issues. (e.g. libbinder) Even though libbinder restricts its |
| 1052 | // availability via 'apex_available' property and relies on yet another macro |
| 1053 | // __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules to avoid |
| 1054 | // similar problems. |
| 1055 | func checkUseVendorProperty(ctx android.BottomUpMutatorContext, a *apexBundle) { |
| 1056 | if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) { |
| 1057 | ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true") |
| 1058 | } |
| 1059 | } |
| 1060 | |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 1061 | var ( |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1062 | useVendorAllowListKey = android.NewOnceKey("useVendorAllowList") |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 1063 | ) |
| 1064 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1065 | func useVendorAllowList(config android.Config) []string { |
| 1066 | return config.Once(useVendorAllowListKey, func() interface{} { |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 1067 | return []string{ |
| 1068 | // swcodec uses "vendor" variants for smaller size |
| 1069 | "com.android.media.swcodec", |
| 1070 | "test_com.android.media.swcodec", |
| 1071 | } |
| 1072 | }).([]string) |
| 1073 | } |
| 1074 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1075 | // setUseVendorAllowListForTest overrides useVendorAllowList and must be called before the first |
| 1076 | // call to useVendorAllowList() |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1077 | func setUseVendorAllowListForTest(config android.Config, allowList []string) { |
| 1078 | config.Once(useVendorAllowListKey, func() interface{} { |
| 1079 | return allowList |
Jooyung Han | dc78244 | 2019-11-01 03:14:38 +0900 | [diff] [blame] | 1080 | }) |
| 1081 | } |
| 1082 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1083 | var _ android.DepIsInSameApex = (*apexBundle)(nil) |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 1084 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1085 | // Implements android.DepInInSameApex |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 1086 | func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
| 1087 | // direct deps of an APEX bundle are all part of the APEX bundle |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1088 | // TODO(jiyong): shouldn't we look into the payload field of the dependencyTag? |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 1089 | return true |
| 1090 | } |
| 1091 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1092 | var _ android.OutputFileProducer = (*apexBundle)(nil) |
| 1093 | |
| 1094 | // Implements android.OutputFileProducer |
| 1095 | func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) { |
| 1096 | switch tag { |
Paul Duffin | 74f0559 | 2020-11-25 16:37:46 +0000 | [diff] [blame] | 1097 | case "", android.DefaultDistTag: |
| 1098 | // This is the default dist path. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1099 | return android.Paths{a.outputFile}, nil |
| 1100 | default: |
| 1101 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | var _ cc.Coverage = (*apexBundle)(nil) |
| 1106 | |
| 1107 | // Implements cc.Coverage |
| 1108 | func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { |
| 1109 | return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled() |
| 1110 | } |
| 1111 | |
| 1112 | // Implements cc.Coverage |
| 1113 | func (a *apexBundle) PreventInstall() { |
| 1114 | a.properties.PreventInstall = true |
| 1115 | } |
| 1116 | |
| 1117 | // Implements cc.Coverage |
| 1118 | func (a *apexBundle) HideFromMake() { |
| 1119 | a.properties.HideFromMake = true |
| 1120 | } |
| 1121 | |
| 1122 | // Implements cc.Coverage |
| 1123 | func (a *apexBundle) MarkAsCoverageVariant(coverage bool) { |
| 1124 | a.properties.IsCoverageVariant = coverage |
| 1125 | } |
| 1126 | |
| 1127 | // Implements cc.Coverage |
| 1128 | func (a *apexBundle) EnableCoverageIfNeeded() {} |
| 1129 | |
| 1130 | var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil) |
| 1131 | |
| 1132 | // Implements android.ApexBudleDepsInfoIntf |
| 1133 | func (a *apexBundle) Updatable() bool { |
| 1134 | return proptools.Bool(a.properties.Updatable) |
| 1135 | } |
| 1136 | |
| 1137 | // getCertString returns the name of the cert that should be used to sign this APEX. This is |
| 1138 | // basically from the "certificate" property, but could be overridden by the device config. |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 1139 | func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string { |
Jooyung Han | 27151d9 | 2019-12-16 17:45:32 +0900 | [diff] [blame] | 1140 | moduleName := ctx.ModuleName() |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1141 | // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the |
| 1142 | // OVERRIDE_* list, we check with the pseudo module name to see if its certificate is |
| 1143 | // overridden. |
Jooyung Han | 27151d9 | 2019-12-16 17:45:32 +0900 | [diff] [blame] | 1144 | if a.vndkApex { |
| 1145 | moduleName = vndkApexName |
| 1146 | } |
| 1147 | certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName) |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1148 | if overridden { |
Jaewoong Jung | acb6db3 | 2019-02-28 16:22:30 +0000 | [diff] [blame] | 1149 | return ":" + certificate |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1150 | } |
| 1151 | return String(a.properties.Certificate) |
| 1152 | } |
| 1153 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1154 | // See the installable property |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1155 | func (a *apexBundle) installable() bool { |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1156 | return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable)) |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1157 | } |
| 1158 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1159 | // See the test_only_no_hashtree property |
Nikita Ioffe | c72b5dd | 2019-12-07 17:30:22 +0000 | [diff] [blame] | 1160 | func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool { |
| 1161 | return proptools.Bool(a.properties.Test_only_no_hashtree) |
| 1162 | } |
| 1163 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1164 | // See the test_only_unsigned_payload property |
Dario Freni | ca91339 | 2020-04-27 18:21:11 +0100 | [diff] [blame] | 1165 | func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool { |
| 1166 | return proptools.Bool(a.properties.Test_only_unsigned_payload) |
| 1167 | } |
| 1168 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1169 | // These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its |
| 1170 | // members) can be sanitized, either forcibly, or by the global configuration. For some of the |
| 1171 | // sanitizers, extra dependencies can be forcibly added as well. |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1172 | |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1173 | func (a *apexBundle) EnableSanitizer(sanitizerName string) { |
| 1174 | if !android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1175 | a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName) |
| 1176 | } |
| 1177 | } |
| 1178 | |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1179 | func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool { |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1180 | if android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1181 | return true |
Jiyong Park | 235e67c | 2019-02-09 11:50:56 +0900 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | // Then follow the global setting |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1185 | globalSanitizerNames := []string{} |
| 1186 | if a.Host() { |
| 1187 | globalSanitizerNames = ctx.Config().SanitizeHost() |
| 1188 | } else { |
| 1189 | arches := ctx.Config().SanitizeDeviceArch() |
| 1190 | if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) { |
| 1191 | globalSanitizerNames = ctx.Config().SanitizeDevice() |
| 1192 | } |
| 1193 | } |
| 1194 | return android.InList(sanitizerName, globalSanitizerNames) |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 1195 | } |
| 1196 | |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1197 | func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1198 | // TODO(jiyong): move this info (the sanitizer name, the lib name, etc.) to cc/sanitize.go |
| 1199 | // Keep only the mechanism here. |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1200 | if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1201 | imageVariation := a.getImageVariation(ctx) |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1202 | for _, target := range ctx.MultiTargets() { |
| 1203 | if target.Arch.ArchType.Multilib == "lib64" { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1204 | addDependenciesForNativeModules(ctx, ApexNativeDependencies{ |
| 1205 | Native_shared_libs: []string{"libclang_rt.hwasan-aarch64-android"}, |
| 1206 | Tests: nil, |
| 1207 | Jni_libs: nil, |
| 1208 | Binaries: nil, |
| 1209 | }, target, imageVariation) |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1210 | break |
| 1211 | } |
| 1212 | } |
| 1213 | } |
| 1214 | } |
| 1215 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1216 | // apexFileFor<Type> functions below create an apexFile struct for a given Soong module. The |
| 1217 | // returned apexFile saves information about the Soong module that will be used for creating the |
| 1218 | // build rules. |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1219 | func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1220 | // Decide the APEX-local directory by the multilib of the library In the future, we may |
| 1221 | // query this to the module. |
| 1222 | // TODO(jiyong): use the new PackagingSpec |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1223 | var dirInApex string |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1224 | switch ccMod.Arch().ArchType.Multilib { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1225 | case "lib32": |
| 1226 | dirInApex = "lib" |
| 1227 | case "lib64": |
| 1228 | dirInApex = "lib64" |
| 1229 | } |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1230 | if ccMod.Target().NativeBridge == android.NativeBridgeEnabled { |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1231 | dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1232 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1233 | dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath()) |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1234 | if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1235 | // Special case for Bionic libs and other libs installed with them. This is to |
| 1236 | // prevent those libs from being included in the search path |
| 1237 | // /apex/com.android.runtime/${LIB}. This exclusion is required because those libs |
| 1238 | // in the Runtime APEX are available via the legacy paths in /system/lib/. By the |
| 1239 | // init process, the libs in the APEX are bind-mounted to the legacy paths and thus |
| 1240 | // will be loaded into the default linker namespace (aka "platform" namespace). If |
| 1241 | // the libs are directly in /apex/com.android.runtime/${LIB} then the same libs will |
| 1242 | // be loaded again into the runtime linker namespace, which will result in double |
| 1243 | // loading of them, which isn't supported. |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1244 | dirInApex = filepath.Join(dirInApex, "bionic") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1245 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1246 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1247 | fileToCopy := ccMod.OutputFile().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1248 | androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName |
| 1249 | return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1250 | } |
| 1251 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1252 | func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile { |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1253 | dirInApex := "bin" |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1254 | if cc.Target().NativeBridge == android.NativeBridgeEnabled { |
dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 1255 | dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath) |
Jiyong Park | acbf6c7 | 2019-07-09 16:19:16 +0900 | [diff] [blame] | 1256 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1257 | dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1258 | fileToCopy := cc.OutputFile().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1259 | androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName |
| 1260 | af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1261 | af.symlinks = cc.Symlinks() |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1262 | af.dataPaths = cc.DataPaths() |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1263 | return af |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1264 | } |
| 1265 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1266 | func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1267 | dirInApex := "bin" |
| 1268 | fileToCopy := py.HostToolPath().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1269 | return newApexFile(ctx, fileToCopy, py.BaseModuleName(), dirInApex, pyBinary, py) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1270 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1271 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1272 | func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1273 | dirInApex := "bin" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1274 | s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath()) |
| 1275 | if err != nil { |
| 1276 | ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1277 | return apexFile{} |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1278 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1279 | fileToCopy := android.PathForOutput(ctx, s) |
| 1280 | // NB: Since go binaries are static we don't need the module for anything here, which is |
| 1281 | // good since the go tool is a blueprint.Module not an android.Module like we would |
| 1282 | // normally use. |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1283 | return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1284 | } |
| 1285 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1286 | func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1287 | dirInApex := filepath.Join("bin", sh.SubDir()) |
| 1288 | fileToCopy := sh.OutputFile() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1289 | af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1290 | af.symlinks = sh.Symlinks() |
| 1291 | return af |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1292 | } |
| 1293 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1294 | func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile { |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 1295 | dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1296 | fileToCopy := prebuilt.OutputFile() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1297 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1298 | } |
| 1299 | |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1300 | func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile { |
| 1301 | dirInApex := filepath.Join("etc", config.SubDir()) |
| 1302 | fileToCopy := config.CompatConfig() |
| 1303 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config) |
| 1304 | } |
| 1305 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1306 | // javaModule is an interface to handle all Java modules (java_library, dex_import, etc) in the same |
| 1307 | // way. |
| 1308 | type javaModule interface { |
| 1309 | android.Module |
| 1310 | BaseModuleName() string |
| 1311 | DexJarBuildPath() android.Path |
| 1312 | JacocoReportClassesFile() android.Path |
| 1313 | LintDepSets() java.LintDepSets |
| 1314 | Stem() string |
| 1315 | } |
| 1316 | |
| 1317 | var _ javaModule = (*java.Library)(nil) |
| 1318 | var _ javaModule = (*java.SdkLibrary)(nil) |
| 1319 | var _ javaModule = (*java.DexImport)(nil) |
| 1320 | var _ javaModule = (*java.SdkLibraryImport)(nil) |
| 1321 | |
| 1322 | func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile { |
| 1323 | dirInApex := "javalib" |
| 1324 | fileToCopy := module.DexJarBuildPath() |
| 1325 | af := newApexFile(ctx, fileToCopy, module.BaseModuleName(), dirInApex, javaSharedLib, module) |
| 1326 | af.jacocoReportClassesFile = module.JacocoReportClassesFile() |
| 1327 | af.lintDepSets = module.LintDepSets() |
| 1328 | af.customStem = module.Stem() + ".jar" |
| 1329 | return af |
| 1330 | } |
| 1331 | |
| 1332 | // androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in |
| 1333 | // the same way. |
| 1334 | type androidApp interface { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1335 | android.Module |
| 1336 | Privileged() bool |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1337 | InstallApkName() string |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1338 | OutputFile() android.Path |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1339 | JacocoReportClassesFile() android.Path |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1340 | Certificate() java.Certificate |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1341 | BaseModuleName() string |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | var _ androidApp = (*java.AndroidApp)(nil) |
| 1345 | var _ androidApp = (*java.AndroidAppImport)(nil) |
| 1346 | |
| 1347 | func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexFile { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1348 | appDir := "app" |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1349 | if aapp.Privileged() { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1350 | appDir = "priv-app" |
| 1351 | } |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1352 | dirInApex := filepath.Join(appDir, aapp.InstallApkName()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1353 | fileToCopy := aapp.OutputFile() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1354 | af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp) |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1355 | af.jacocoReportClassesFile = aapp.JacocoReportClassesFile() |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1356 | af.certificate = aapp.Certificate() |
Jiyong Park | cfaa164 | 2020-02-28 16:51:07 +0900 | [diff] [blame] | 1357 | |
| 1358 | if app, ok := aapp.(interface { |
| 1359 | OverriddenManifestPackageName() string |
| 1360 | }); ok { |
| 1361 | af.overriddenPackageName = app.OverriddenManifestPackageName() |
| 1362 | } |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1363 | return af |
Dario Freni | cde2a03 | 2019-10-27 00:29:22 +0100 | [diff] [blame] | 1364 | } |
| 1365 | |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1366 | func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile { |
| 1367 | rroDir := "overlay" |
| 1368 | dirInApex := filepath.Join(rroDir, rro.Theme()) |
| 1369 | fileToCopy := rro.OutputFile() |
| 1370 | af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro) |
| 1371 | af.certificate = rro.Certificate() |
| 1372 | |
| 1373 | if a, ok := rro.(interface { |
| 1374 | OverriddenManifestPackageName() string |
| 1375 | }); ok { |
| 1376 | af.overriddenPackageName = a.OverriddenManifestPackageName() |
| 1377 | } |
| 1378 | return af |
| 1379 | } |
| 1380 | |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1381 | func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile { |
| 1382 | dirInApex := filepath.Join("etc", "bpf") |
| 1383 | return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram) |
| 1384 | } |
| 1385 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1386 | // WalyPayloadDeps visits dependencies that contributes to the payload of this APEX. For each of the |
| 1387 | // visited module, the `do` callback is executed. Returning true in the callback continues the visit |
| 1388 | // to the child modules. Returning false makes the visit to continue in the sibling or the parent |
| 1389 | // modules. This is used in check* functions below. |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1390 | func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) { |
Paul Duffin | df915ff | 2020-03-30 17:58:21 +0100 | [diff] [blame] | 1391 | ctx.WalkDeps(func(child, parent android.Module) bool { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1392 | am, ok := child.(android.ApexModule) |
| 1393 | if !ok || !am.CanHaveApexVariants() { |
| 1394 | return false |
| 1395 | } |
| 1396 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1397 | // Filter-out unwanted depedendencies |
| 1398 | depTag := ctx.OtherModuleDependencyTag(child) |
| 1399 | if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { |
| 1400 | return false |
| 1401 | } |
| 1402 | if dt, ok := depTag.(dependencyTag); ok && !dt.payload { |
Martin Stjernholm | 58c33f0 | 2020-07-06 22:56:01 +0100 | [diff] [blame] | 1403 | return false |
| 1404 | } |
| 1405 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1406 | ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo) |
| 1407 | externalDep := !android.InList(ctx.ModuleName(), ai.InApexes) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1408 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1409 | // Visit actually |
| 1410 | return do(ctx, parent, am, externalDep) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1411 | }) |
| 1412 | } |
| 1413 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1414 | // filesystem type of the apex_payload.img inside the APEX. Currently, ext4 and f2fs are supported. |
| 1415 | type fsType int |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1416 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1417 | const ( |
| 1418 | ext4 fsType = iota |
| 1419 | f2fs |
| 1420 | ) |
Artur Satayev | 849f844 | 2020-04-28 14:57:42 +0100 | [diff] [blame] | 1421 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1422 | func (f fsType) string() string { |
| 1423 | switch f { |
| 1424 | case ext4: |
| 1425 | return ext4FsType |
| 1426 | case f2fs: |
| 1427 | return f2fsFsType |
| 1428 | default: |
| 1429 | panic(fmt.Errorf("unknown APEX payload type %d", f)) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1430 | } |
| 1431 | } |
| 1432 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1433 | // Creates build rules for an APEX. It consists of the following major steps: |
| 1434 | // |
| 1435 | // 1) do some validity checks such as apex_available, min_sdk_version, etc. |
| 1436 | // 2) traverse the dependency tree to collect apexFile structs from them. |
| 1437 | // 3) some fields in apexBundle struct are configured |
| 1438 | // 4) generate the build rules to create the APEX. This is mostly done in builder.go. |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1439 | func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1440 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 1441 | // 1) do some validity checks such as apex_available, min_sdk_version, etc. |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1442 | a.checkApexAvailability(ctx) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1443 | a.checkUpdatable(ctx) |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1444 | a.checkMinSdkVersion(ctx) |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1445 | a.checkStaticLinkingToStubLibraries(ctx) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1446 | if len(a.properties.Tests) > 0 && !a.testApex { |
| 1447 | ctx.PropertyErrorf("tests", "property allowed only in apex_test module type") |
| 1448 | return |
| 1449 | } |
Jiyong Park | 678c881 | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1450 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1451 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 1452 | // 2) traverse the dependency tree to collect apexFile structs from them. |
| 1453 | |
| 1454 | // all the files that will be included in this APEX |
| 1455 | var filesInfo []apexFile |
Alex Light | fc0bd7c | 2019-01-29 18:31:59 -0800 | [diff] [blame] | 1456 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1457 | // native lib dependencies |
| 1458 | var provideNativeLibs []string |
| 1459 | var requireNativeLibs []string |
| 1460 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1461 | handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case) |
| 1462 | |
| 1463 | // TODO(jiyong): do this using WalkPayloadDeps |
| 1464 | // TODO(jiyong): make this clean!!! |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1465 | ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1466 | depTag := ctx.OtherModuleDependencyTag(child) |
Paul Duffin | dddd546 | 2020-04-07 15:25:44 +0100 | [diff] [blame] | 1467 | if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { |
| 1468 | return false |
| 1469 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1470 | depName := ctx.OtherModuleName(child) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1471 | if _, isDirectDep := parent.(*apexBundle); isDirectDep { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1472 | switch depTag { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1473 | case sharedLibTag, jniLibTag: |
| 1474 | isJniLib := depTag == jniLibTag |
Jooyung Han | faa2d5f | 2020-02-06 17:42:40 +0900 | [diff] [blame] | 1475 | if c, ok := child.(*cc.Module); ok { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1476 | fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs) |
| 1477 | fi.isJniLib = isJniLib |
| 1478 | filesInfo = append(filesInfo, fi) |
Jooyung Han | 45a9677 | 2020-06-15 14:59:42 +0900 | [diff] [blame] | 1479 | // Collect the list of stub-providing libs except: |
| 1480 | // - VNDK libs are only for vendors |
| 1481 | // - bootstrap bionic libs are treated as provided by system |
| 1482 | if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1483 | provideNativeLibs = append(provideNativeLibs, fi.stem()) |
Jiyong Park | f1493cc | 2020-05-29 21:29:20 +0900 | [diff] [blame] | 1484 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1485 | return true // track transitive dependencies |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1486 | } else { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1487 | propertyName := "native_shared_libs" |
| 1488 | if isJniLib { |
| 1489 | propertyName = "jni_libs" |
| 1490 | } |
| 1491 | ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1492 | } |
| 1493 | case executableTag: |
| 1494 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1495 | filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1496 | return true // track transitive dependencies |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1497 | } else if sh, ok := child.(*sh.ShBinary); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1498 | filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh)) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1499 | } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1500 | filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py)) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1501 | } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1502 | filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb)) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1503 | } else { |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1504 | ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1505 | } |
| 1506 | case javaLibTag: |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1507 | switch child.(type) { |
Paul Duffin | eedc5d5 | 2020-06-12 17:46:39 +0100 | [diff] [blame] | 1508 | case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport: |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1509 | af := apexFileForJavaModule(ctx, child.(javaModule)) |
| 1510 | if !af.ok() { |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 1511 | ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName) |
| 1512 | return false |
| 1513 | } |
| 1514 | filesInfo = append(filesInfo, af) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 1515 | return true // track transitive dependencies |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1516 | default: |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 1517 | ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child)) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1518 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1519 | case androidAppTag: |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1520 | if ap, ok := child.(*java.AndroidApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1521 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1522 | return true // track transitive dependencies |
| 1523 | } else if ap, ok := child.(*java.AndroidAppImport); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1524 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Dario Freni | 6f3937c | 2019-12-20 22:58:03 +0000 | [diff] [blame] | 1525 | } else if ap, ok := child.(*java.AndroidTestHelperApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1526 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Sasha Smundak | 18d98bc | 2020-05-27 16:36:07 -0700 | [diff] [blame] | 1527 | } else if ap, ok := child.(*java.AndroidAppSet); ok { |
| 1528 | appDir := "app" |
| 1529 | if ap.Privileged() { |
| 1530 | appDir = "priv-app" |
| 1531 | } |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1532 | af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), |
Sasha Smundak | 18d98bc | 2020-05-27 16:36:07 -0700 | [diff] [blame] | 1533 | filepath.Join(appDir, ap.BaseModuleName()), appSet, ap) |
| 1534 | af.certificate = java.PresignedCertificate |
| 1535 | filesInfo = append(filesInfo, af) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1536 | } else { |
| 1537 | ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) |
| 1538 | } |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1539 | case rroTag: |
| 1540 | if rro, ok := child.(java.RuntimeResourceOverlayModule); ok { |
| 1541 | filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro)) |
| 1542 | } else { |
| 1543 | ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName) |
| 1544 | } |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1545 | case bpfTag: |
| 1546 | if bpfProgram, ok := child.(bpf.BpfModule); ok { |
| 1547 | filesToCopy, _ := bpfProgram.OutputFiles("") |
| 1548 | for _, bpfFile := range filesToCopy { |
| 1549 | filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram)) |
| 1550 | } |
| 1551 | } else { |
| 1552 | ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName) |
| 1553 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1554 | case prebuiltTag: |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1555 | if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1556 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1557 | } else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok { |
| 1558 | filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName)) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1559 | } else { |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1560 | ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1561 | } |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1562 | case testTag: |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1563 | if ccTest, ok := child.(*cc.Module); ok { |
| 1564 | if ccTest.IsTestPerSrcAllTestsVariation() { |
| 1565 | // Multiple-output test module (where `test_per_src: true`). |
| 1566 | // |
| 1567 | // `ccTest` is the "" ("all tests") variation of a `test_per_src` module. |
| 1568 | // We do not add this variation to `filesInfo`, as it has no output; |
| 1569 | // however, we do add the other variations of this module as indirect |
| 1570 | // dependencies (see below). |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1571 | } else { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1572 | // Single-output test module (where `test_per_src: false`). |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1573 | af := apexFileForExecutable(ctx, ccTest) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1574 | af.class = nativeTest |
| 1575 | filesInfo = append(filesInfo, af) |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1576 | } |
Jiyong Park | af9539f | 2020-05-04 10:31:32 +0900 | [diff] [blame] | 1577 | return true // track transitive dependencies |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1578 | } else { |
| 1579 | ctx.PropertyErrorf("tests", "%q is not a cc module", depName) |
| 1580 | } |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1581 | case keyTag: |
| 1582 | if key, ok := child.(*apexKey); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1583 | a.private_key_file = key.private_key_file |
| 1584 | a.public_key_file = key.public_key_file |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1585 | } else { |
| 1586 | ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1587 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1588 | return false |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1589 | case certificateTag: |
| 1590 | if dep, ok := child.(*java.AndroidAppCertificate); ok { |
Jiyong Park | 0ca3ce8 | 2019-02-18 15:25:04 +0900 | [diff] [blame] | 1591 | a.container_certificate_file = dep.Certificate.Pem |
| 1592 | a.container_private_key_file = dep.Certificate.Key |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1593 | } else { |
| 1594 | ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName) |
| 1595 | } |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 1596 | case android.PrebuiltDepTag: |
| 1597 | // If the prebuilt is force disabled, remember to delete the prebuilt file |
| 1598 | // that might have been installed in the previous builds |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 1599 | if prebuilt, ok := child.(prebuilt); ok && prebuilt.isForceDisabled() { |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 1600 | a.prebuiltFileToDelete = prebuilt.InstallFilename() |
| 1601 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1602 | } |
Jooyung Han | 8aee204 | 2019-10-29 05:08:31 +0900 | [diff] [blame] | 1603 | } else if !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1604 | // indirect dependencies |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 1605 | if am, ok := child.(android.ApexModule); ok { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1606 | // We cannot use a switch statement on `depTag` here as the checked |
| 1607 | // tags used below are private (e.g. `cc.sharedDepTag`). |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 1608 | if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1609 | if cc, ok := child.(*cc.Module); ok { |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 1610 | if cc.UseVndk() && proptools.Bool(a.properties.Use_vndk_as_stable) && cc.IsVndk() { |
Jooyung Han | 6c4cc9c | 2020-07-29 16:00:54 +0900 | [diff] [blame] | 1611 | requireNativeLibs = append(requireNativeLibs, ":vndk") |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 1612 | return false |
| 1613 | } |
Jiyong Park | f1493cc | 2020-05-29 21:29:20 +0900 | [diff] [blame] | 1614 | af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs) |
| 1615 | af.transitiveDep = true |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1616 | abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo) |
| 1617 | if !a.Host() && !abInfo.Contents.DirectlyInApex(depName) && (cc.IsStubs() || cc.HasStubsVariants()) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1618 | // If the dependency is a stubs lib, don't include it in this APEX, |
| 1619 | // but make sure that the lib is installed on the device. |
| 1620 | // In case no APEX is having the lib, the lib is installed to the system |
| 1621 | // partition. |
| 1622 | // |
| 1623 | // Always include if we are a host-apex however since those won't have any |
| 1624 | // system libraries. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1625 | if !am.DirectlyInAnyApex() { |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 1626 | // we need a module name for Make |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1627 | name := cc.ImplementationModuleName(ctx) |
| 1628 | |
| 1629 | if !proptools.Bool(a.properties.Use_vendor) { |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 1630 | // we don't use subName(.vendor) for a "use_vendor: true" apex |
| 1631 | // which is supposed to be installed in /system |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1632 | name += cc.Properties.SubName |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 1633 | } |
| 1634 | if !android.InList(name, a.requiredDeps) { |
| 1635 | a.requiredDeps = append(a.requiredDeps, name) |
| 1636 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1637 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1638 | requireNativeLibs = append(requireNativeLibs, af.stem()) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1639 | // Don't track further |
| 1640 | return false |
| 1641 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1642 | filesInfo = append(filesInfo, af) |
| 1643 | return true // track transitive dependencies |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1644 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1645 | } else if cc.IsTestPerSrcDepTag(depTag) { |
| 1646 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1647 | af := apexFileForExecutable(ctx, cc) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1648 | // Handle modules created as `test_per_src` variations of a single test module: |
| 1649 | // use the name of the generated test binary (`fileToCopy`) instead of the name |
| 1650 | // of the original test module (`depName`, shared by all `test_per_src` |
| 1651 | // variations of that module). |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1652 | af.androidMkModuleName = filepath.Base(af.builtFile.String()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1653 | // these are not considered transitive dep |
| 1654 | af.transitiveDep = false |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1655 | filesInfo = append(filesInfo, af) |
| 1656 | return true // track transitive dependencies |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1657 | } |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 1658 | } else if java.IsJniDepTag(depTag) { |
Jooyung Han | b7bebe2 | 2020-02-25 16:59:29 +0900 | [diff] [blame] | 1659 | // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps |
| 1660 | return false |
Jiyong Park | e383388 | 2020-02-17 17:28:10 +0900 | [diff] [blame] | 1661 | } else if java.IsXmlPermissionsFileDepTag(depTag) { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1662 | if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { |
Jiyong Park | e383388 | 2020-02-17 17:28:10 +0900 | [diff] [blame] | 1663 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
| 1664 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1665 | } else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok { |
| 1666 | // nothing |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 1667 | } else if am.CanHaveApexVariants() && am.IsInstallableToApex() { |
Jiyong Park | 1c7e962 | 2020-05-07 16:12:13 +0900 | [diff] [blame] | 1668 | ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1669 | } |
| 1670 | } |
| 1671 | } |
| 1672 | return false |
| 1673 | }) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1674 | if a.private_key_file == nil { |
| 1675 | ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key)) |
| 1676 | return |
| 1677 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1678 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1679 | // Specific to the ART apex: dexpreopt artifacts for libcore Java libraries. Build rules are |
| 1680 | // generated by the dexpreopt singleton, and here we access build artifacts via the global |
| 1681 | // boot image config. |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1682 | if a.artApex { |
Tim Joines | c1ef1bb | 2020-03-18 18:00:41 +0000 | [diff] [blame] | 1683 | for arch, files := range java.DexpreoptedArtApexJars(ctx) { |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1684 | dirInApex := filepath.Join("javalib", arch.String()) |
| 1685 | for _, f := range files { |
| 1686 | localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String()) |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1687 | af := newApexFile(ctx, f, localModule, dirInApex, etc, nil) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1688 | filesInfo = append(filesInfo, af) |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 1689 | } |
| 1690 | } |
| 1691 | } |
| 1692 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1693 | // Remove duplicates in filesInfo |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1694 | removeDup := func(filesInfo []apexFile) []apexFile { |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1695 | encountered := make(map[string]apexFile) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1696 | for _, f := range filesInfo { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 1697 | dest := filepath.Join(f.installDir, f.builtFile.Base()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1698 | if e, ok := encountered[dest]; !ok { |
| 1699 | encountered[dest] = f |
| 1700 | } else { |
| 1701 | // If a module is directly included and also transitively depended on |
| 1702 | // consider it as directly included. |
| 1703 | e.transitiveDep = e.transitiveDep && f.transitiveDep |
| 1704 | encountered[dest] = e |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1705 | } |
| 1706 | } |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1707 | var result []apexFile |
| 1708 | for _, v := range encountered { |
| 1709 | result = append(result, v) |
| 1710 | } |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1711 | return result |
| 1712 | } |
| 1713 | filesInfo = removeDup(filesInfo) |
| 1714 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1715 | // Sort to have consistent build rules |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1716 | sort.Slice(filesInfo, func(i, j int) bool { |
| 1717 | return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String() |
| 1718 | }) |
| 1719 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1720 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 1721 | // 3) some fields in apexBundle struct are configured |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 1722 | a.installDir = android.PathForModuleInstall(ctx, "apex") |
| 1723 | a.filesInfo = filesInfo |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 1724 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1725 | // Set suffix and primaryApexType depending on the ApexType |
| 1726 | buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuildApps() |
| 1727 | switch a.properties.ApexType { |
| 1728 | case imageApex: |
| 1729 | if buildFlattenedAsDefault { |
| 1730 | a.suffix = imageApexSuffix |
| 1731 | } else { |
| 1732 | a.suffix = "" |
| 1733 | a.primaryApexType = true |
| 1734 | |
| 1735 | if ctx.Config().InstallExtraFlattenedApexes() { |
| 1736 | a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix) |
| 1737 | } |
| 1738 | } |
| 1739 | case zipApex: |
| 1740 | if proptools.String(a.properties.Payload_type) == "zip" { |
| 1741 | a.suffix = "" |
| 1742 | a.primaryApexType = true |
| 1743 | } else { |
| 1744 | a.suffix = zipApexSuffix |
| 1745 | } |
| 1746 | case flattenedApex: |
| 1747 | if buildFlattenedAsDefault { |
| 1748 | a.suffix = "" |
| 1749 | a.primaryApexType = true |
| 1750 | } else { |
| 1751 | a.suffix = flattenedSuffix |
| 1752 | } |
| 1753 | } |
| 1754 | |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 1755 | switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) { |
| 1756 | case ext4FsType: |
| 1757 | a.payloadFsType = ext4 |
| 1758 | case f2fsFsType: |
| 1759 | a.payloadFsType = f2fs |
| 1760 | default: |
| 1761 | ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs]", *a.properties.Payload_fs_type) |
| 1762 | } |
| 1763 | |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 1764 | // Optimization. If we are building bundled APEX, for the files that are gathered due to the |
| 1765 | // transitive dependencies, don't place them inside the APEX, but place a symlink pointing |
| 1766 | // the same library in the system partition, thus effectively sharing the same libraries |
| 1767 | // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed |
| 1768 | // in the APEX. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1769 | a.linkToSystemLib = !ctx.Config().UnbundledBuild() && a.installable() && !proptools.Bool(a.properties.Use_vendor) |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 1770 | |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1771 | // APEXes targeting other than system/system_ext partitions use vendor/product variants. |
| 1772 | // So we can't link them to /system/lib libs which are core variants. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1773 | if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) { |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 1774 | a.linkToSystemLib = false |
| 1775 | } |
| 1776 | |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 1777 | // We don't need the optimization for updatable APEXes, as it might give false signal |
| 1778 | // to the system health when the APEXes are still bundled (b/149805758) |
Artur Satayev | 849f844 | 2020-04-28 14:57:42 +0100 | [diff] [blame] | 1779 | if a.Updatable() && a.properties.ApexType == imageApex { |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 1780 | a.linkToSystemLib = false |
| 1781 | } |
| 1782 | |
Jiyong Park | 638d30e | 2020-02-26 18:27:19 +0900 | [diff] [blame] | 1783 | // We also don't want the optimization for host APEXes, because it doesn't make sense. |
| 1784 | if ctx.Host() { |
| 1785 | a.linkToSystemLib = false |
| 1786 | } |
| 1787 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1788 | a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx) |
| 1789 | |
| 1790 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 1791 | // 4) generate the build rules to create the APEX. This is done in builder.go. |
| 1792 | a.buildManifest(ctx, provideNativeLibs, requireNativeLibs) |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 1793 | if a.properties.ApexType == flattenedApex { |
| 1794 | a.buildFlattenedApex(ctx) |
| 1795 | } else { |
| 1796 | a.buildUnflattenedApex(ctx) |
| 1797 | } |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 1798 | a.buildApexDependencyInfo(ctx) |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 1799 | a.buildLintReports(ctx) |
Jiyong Park | b81b990 | 2020-11-24 19:51:18 +0900 | [diff] [blame] | 1800 | |
| 1801 | // Append meta-files to the filesInfo list so that they are reflected in Android.mk as well. |
| 1802 | if a.installable() { |
| 1803 | // For flattened APEX, make sure that APEX manifest and apex_pubkey are also copied |
| 1804 | // along with other ordinary files. (Note that this is done by apexer for |
| 1805 | // non-flattened APEXes) |
| 1806 | a.filesInfo = append(a.filesInfo, newApexFile(ctx, a.manifestPbOut, "apex_manifest.pb", ".", etc, nil)) |
| 1807 | |
| 1808 | // Place the public key as apex_pubkey. This is also done by apexer for |
| 1809 | // non-flattened APEXes case. |
| 1810 | // TODO(jiyong): Why do we need this CP rule? |
| 1811 | copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey") |
| 1812 | ctx.Build(pctx, android.BuildParams{ |
| 1813 | Rule: android.Cp, |
| 1814 | Input: a.public_key_file, |
| 1815 | Output: copiedPubkey, |
| 1816 | }) |
| 1817 | a.filesInfo = append(a.filesInfo, newApexFile(ctx, copiedPubkey, "apex_pubkey", ".", etc, nil)) |
| 1818 | } |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 1819 | } |
| 1820 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1821 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1822 | // Factory functions |
| 1823 | // |
| 1824 | |
| 1825 | func newApexBundle() *apexBundle { |
| 1826 | module := &apexBundle{} |
| 1827 | |
| 1828 | module.AddProperties(&module.properties) |
| 1829 | module.AddProperties(&module.targetProperties) |
| 1830 | module.AddProperties(&module.overridableProperties) |
| 1831 | |
| 1832 | android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
| 1833 | android.InitDefaultableModule(module) |
| 1834 | android.InitSdkAwareModule(module) |
| 1835 | android.InitOverridableModule(module, &module.overridableProperties.Overrides) |
| 1836 | return module |
| 1837 | } |
| 1838 | |
| 1839 | func ApexBundleFactory(testApex bool, artApex bool) android.Module { |
| 1840 | bundle := newApexBundle() |
| 1841 | bundle.testApex = testApex |
| 1842 | bundle.artApex = artApex |
| 1843 | return bundle |
| 1844 | } |
| 1845 | |
| 1846 | // apex_test is an APEX for testing. The difference from the ordinary apex module type is that |
| 1847 | // certain compatibility checks such as apex_available are not done for apex_test. |
| 1848 | func testApexBundleFactory() android.Module { |
| 1849 | bundle := newApexBundle() |
| 1850 | bundle.testApex = true |
| 1851 | return bundle |
| 1852 | } |
| 1853 | |
| 1854 | // apex packages other modules into an APEX file which is a packaging format for system-level |
| 1855 | // components like binaries, shared libraries, etc. |
| 1856 | func BundleFactory() android.Module { |
| 1857 | return newApexBundle() |
| 1858 | } |
| 1859 | |
| 1860 | type Defaults struct { |
| 1861 | android.ModuleBase |
| 1862 | android.DefaultsModuleBase |
| 1863 | } |
| 1864 | |
| 1865 | // apex_defaults provides defaultable properties to other apex modules. |
| 1866 | func defaultsFactory() android.Module { |
| 1867 | return DefaultsFactory() |
| 1868 | } |
| 1869 | |
| 1870 | func DefaultsFactory(props ...interface{}) android.Module { |
| 1871 | module := &Defaults{} |
| 1872 | |
| 1873 | module.AddProperties(props...) |
| 1874 | module.AddProperties( |
| 1875 | &apexBundleProperties{}, |
| 1876 | &apexTargetBundleProperties{}, |
| 1877 | &overridableProperties{}, |
| 1878 | ) |
| 1879 | |
| 1880 | android.InitDefaultsModule(module) |
| 1881 | return module |
| 1882 | } |
| 1883 | |
| 1884 | type OverrideApex struct { |
| 1885 | android.ModuleBase |
| 1886 | android.OverrideModuleBase |
| 1887 | } |
| 1888 | |
| 1889 | func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 1890 | // All the overrides happen in the base module. |
| 1891 | } |
| 1892 | |
| 1893 | // override_apex is used to create an apex module based on another apex module by overriding some of |
| 1894 | // its properties. |
| 1895 | func overrideApexFactory() android.Module { |
| 1896 | m := &OverrideApex{} |
| 1897 | |
| 1898 | m.AddProperties(&overridableProperties{}) |
| 1899 | |
| 1900 | android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 1901 | android.InitOverrideModule(m) |
| 1902 | return m |
| 1903 | } |
| 1904 | |
| 1905 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 1906 | // Vality check routines |
| 1907 | // |
| 1908 | // These are called in at the very beginning of GenerateAndroidBuildActions to flag an error when |
| 1909 | // certain conditions are not met. |
| 1910 | // |
| 1911 | // TODO(jiyong): move these checks to a separate go file. |
| 1912 | |
| 1913 | // Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version |
| 1914 | // of this apexBundle. |
| 1915 | func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) { |
| 1916 | if a.testApex || a.vndkApex { |
| 1917 | return |
| 1918 | } |
| 1919 | // Meaningless to check min_sdk_version when building use_vendor modules against non-Trebleized targets |
| 1920 | if proptools.Bool(a.properties.Use_vendor) && ctx.DeviceConfig().VndkVersion() == "" { |
| 1921 | return |
| 1922 | } |
| 1923 | // apexBundle::minSdkVersion reports its own errors. |
| 1924 | minSdkVersion := a.minSdkVersion(ctx) |
| 1925 | android.CheckMinSdkVersion(a, ctx, minSdkVersion) |
| 1926 | } |
| 1927 | |
| 1928 | func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel { |
| 1929 | ver := proptools.String(a.properties.Min_sdk_version) |
| 1930 | if ver == "" { |
| 1931 | return android.FutureApiLevel |
| 1932 | } |
| 1933 | apiLevel, err := android.ApiLevelFromUser(ctx, ver) |
| 1934 | if err != nil { |
| 1935 | ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) |
| 1936 | return android.NoneApiLevel |
| 1937 | } |
| 1938 | if apiLevel.IsPreview() { |
| 1939 | // All codenames should build against "current". |
| 1940 | return android.FutureApiLevel |
| 1941 | } |
| 1942 | return apiLevel |
| 1943 | } |
| 1944 | |
| 1945 | // Ensures that a lib providing stub isn't statically linked |
| 1946 | func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) { |
| 1947 | // Practically, we only care about regular APEXes on the device. |
| 1948 | if ctx.Host() || a.testApex || a.vndkApex { |
| 1949 | return |
| 1950 | } |
| 1951 | |
| 1952 | abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo) |
| 1953 | |
| 1954 | a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
| 1955 | if ccm, ok := to.(*cc.Module); ok { |
| 1956 | apexName := ctx.ModuleName() |
| 1957 | fromName := ctx.OtherModuleName(from) |
| 1958 | toName := ctx.OtherModuleName(to) |
| 1959 | |
| 1960 | // If `to` is not actually in the same APEX as `from` then it does not need |
| 1961 | // apex_available and neither do any of its dependencies. |
| 1962 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 1963 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 1964 | return false |
| 1965 | } |
| 1966 | |
| 1967 | // The dynamic linker and crash_dump tool in the runtime APEX is the only |
| 1968 | // exception to this rule. It can't make the static dependencies dynamic |
| 1969 | // because it can't do the dynamic linking for itself. |
| 1970 | if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump") { |
| 1971 | return false |
| 1972 | } |
| 1973 | |
| 1974 | isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName) |
| 1975 | if isStubLibraryFromOtherApex && !externalDep { |
| 1976 | ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+ |
| 1977 | "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false)) |
| 1978 | } |
| 1979 | |
| 1980 | } |
| 1981 | return true |
| 1982 | }) |
| 1983 | } |
| 1984 | |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 1985 | // Enforce that Java deps of the apex are using stable SDKs to compile |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1986 | func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { |
| 1987 | if a.Updatable() { |
| 1988 | if String(a.properties.Min_sdk_version) == "" { |
| 1989 | ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well") |
| 1990 | } |
| 1991 | a.checkJavaStableSdkVersion(ctx) |
| 1992 | } |
| 1993 | } |
| 1994 | |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 1995 | func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1996 | // Visit direct deps only. As long as we guarantee top-level deps are using stable SDKs, |
| 1997 | // java's checkLinkType guarantees correct usage for transitive deps |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 1998 | ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) { |
| 1999 | tag := ctx.OtherModuleDependencyTag(module) |
| 2000 | switch tag { |
| 2001 | case javaLibTag, androidAppTag: |
| 2002 | if m, ok := module.(interface{ CheckStableSdkVersion() error }); ok { |
| 2003 | if err := m.CheckStableSdkVersion(); err != nil { |
| 2004 | ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err) |
| 2005 | } |
| 2006 | } |
| 2007 | } |
| 2008 | }) |
| 2009 | } |
| 2010 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2011 | // Ensures that the all the dependencies are marked as available for this APEX |
| 2012 | func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { |
| 2013 | // Let's be practical. Availability for test, host, and the VNDK apex isn't important |
| 2014 | if ctx.Host() || a.testApex || a.vndkApex { |
| 2015 | return |
| 2016 | } |
| 2017 | |
| 2018 | // Because APEXes targeting other than system/system_ext partitions can't set |
| 2019 | // apex_available, we skip checks for these APEXes |
| 2020 | if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) { |
| 2021 | return |
| 2022 | } |
| 2023 | |
| 2024 | // Coverage build adds additional dependencies for the coverage-only runtime libraries. |
| 2025 | // Requiring them and their transitive depencies with apex_available is not right |
| 2026 | // because they just add noise. |
| 2027 | if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) { |
| 2028 | return |
| 2029 | } |
| 2030 | |
| 2031 | a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
| 2032 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 2033 | if externalDep { |
| 2034 | return false |
| 2035 | } |
| 2036 | |
| 2037 | apexName := ctx.ModuleName() |
| 2038 | fromName := ctx.OtherModuleName(from) |
| 2039 | toName := ctx.OtherModuleName(to) |
| 2040 | |
| 2041 | // If `to` is not actually in the same APEX as `from` then it does not need |
| 2042 | // apex_available and neither do any of its dependencies. |
| 2043 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 2044 | // As soon as the dependency graph crosses the APEX boundary, don't go |
| 2045 | // further. |
| 2046 | return false |
| 2047 | } |
| 2048 | |
| 2049 | if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) { |
| 2050 | return true |
| 2051 | } |
| 2052 | ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'. Dependency path:%s", |
| 2053 | fromName, toName, ctx.GetPathString(true)) |
| 2054 | // Visit this module's dependencies to check and report any issues with their availability. |
| 2055 | return true |
| 2056 | }) |
| 2057 | } |
| 2058 | |
| 2059 | var ( |
| 2060 | apexAvailBaseline = makeApexAvailableBaseline() |
| 2061 | inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline) |
| 2062 | ) |
| 2063 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 2064 | func baselineApexAvailable(apex, moduleName string) bool { |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2065 | key := apex |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2066 | moduleName = normalizeModuleName(moduleName) |
| 2067 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 2068 | if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) { |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2069 | return true |
| 2070 | } |
| 2071 | |
| 2072 | key = android.AvailableToAnyApex |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 2073 | if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) { |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2074 | return true |
| 2075 | } |
| 2076 | |
| 2077 | return false |
| 2078 | } |
| 2079 | |
| 2080 | func normalizeModuleName(moduleName string) string { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 2081 | // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build |
| 2082 | // system. Trim the prefix for the check since they are confusing |
| 2083 | moduleName = strings.TrimPrefix(moduleName, "prebuilt_") |
| 2084 | if strings.HasPrefix(moduleName, "libclang_rt.") { |
| 2085 | // This module has many arch variants that depend on the product being built. |
| 2086 | // We don't want to list them all |
| 2087 | moduleName = "libclang_rt" |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2088 | } |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame] | 2089 | if strings.HasPrefix(moduleName, "androidx.") { |
| 2090 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries |
| 2091 | moduleName = "androidx" |
| 2092 | } |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2093 | return moduleName |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2094 | } |
| 2095 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2096 | // Transform the map of apex -> modules to module -> apexes. |
| 2097 | func invertApexBaseline(m map[string][]string) map[string][]string { |
| 2098 | r := make(map[string][]string) |
| 2099 | for apex, modules := range m { |
| 2100 | for _, module := range modules { |
| 2101 | r[module] = append(r[module], apex) |
| 2102 | } |
| 2103 | } |
| 2104 | return r |
| 2105 | } |
| 2106 | |
| 2107 | // Retrieve the baseline of apexes to which the supplied module belongs. |
| 2108 | func BaselineApexAvailable(moduleName string) []string { |
| 2109 | return inverseApexAvailBaseline[normalizeModuleName(moduleName)] |
| 2110 | } |
| 2111 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2112 | // This is a map from apex to modules, which overrides the apex_available setting for that |
| 2113 | // particular module to make it available for the apex regardless of its setting. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2114 | // TODO(b/147364041): remove this |
| 2115 | func makeApexAvailableBaseline() map[string][]string { |
| 2116 | // The "Module separator"s below are employed to minimize merge conflicts. |
| 2117 | m := make(map[string][]string) |
| 2118 | // |
| 2119 | // Module separator |
| 2120 | // |
| 2121 | m["com.android.appsearch"] = []string{ |
| 2122 | "icing-java-proto-lite", |
| 2123 | "libprotobuf-java-lite", |
| 2124 | } |
| 2125 | // |
| 2126 | // Module separator |
| 2127 | // |
| 2128 | m["com.android.bluetooth.updatable"] = []string{ |
| 2129 | "android.hardware.audio.common@5.0", |
| 2130 | "android.hardware.bluetooth.a2dp@1.0", |
| 2131 | "android.hardware.bluetooth.audio@2.0", |
| 2132 | "android.hardware.bluetooth@1.0", |
| 2133 | "android.hardware.bluetooth@1.1", |
| 2134 | "android.hardware.graphics.bufferqueue@1.0", |
| 2135 | "android.hardware.graphics.bufferqueue@2.0", |
| 2136 | "android.hardware.graphics.common@1.0", |
| 2137 | "android.hardware.graphics.common@1.1", |
| 2138 | "android.hardware.graphics.common@1.2", |
| 2139 | "android.hardware.media@1.0", |
| 2140 | "android.hidl.safe_union@1.0", |
| 2141 | "android.hidl.token@1.0", |
| 2142 | "android.hidl.token@1.0-utils", |
| 2143 | "avrcp-target-service", |
| 2144 | "avrcp_headers", |
| 2145 | "bluetooth-protos-lite", |
| 2146 | "bluetooth.mapsapi", |
| 2147 | "com.android.vcard", |
| 2148 | "dnsresolver_aidl_interface-V2-java", |
| 2149 | "ipmemorystore-aidl-interfaces-V5-java", |
| 2150 | "ipmemorystore-aidl-interfaces-java", |
| 2151 | "internal_include_headers", |
| 2152 | "lib-bt-packets", |
| 2153 | "lib-bt-packets-avrcp", |
| 2154 | "lib-bt-packets-base", |
| 2155 | "libFraunhoferAAC", |
| 2156 | "libaudio-a2dp-hw-utils", |
| 2157 | "libaudio-hearing-aid-hw-utils", |
| 2158 | "libbinder_headers", |
| 2159 | "libbluetooth", |
| 2160 | "libbluetooth-types", |
| 2161 | "libbluetooth-types-header", |
| 2162 | "libbluetooth_gd", |
| 2163 | "libbluetooth_headers", |
| 2164 | "libbluetooth_jni", |
| 2165 | "libbt-audio-hal-interface", |
| 2166 | "libbt-bta", |
| 2167 | "libbt-common", |
| 2168 | "libbt-hci", |
| 2169 | "libbt-platform-protos-lite", |
| 2170 | "libbt-protos-lite", |
| 2171 | "libbt-sbc-decoder", |
| 2172 | "libbt-sbc-encoder", |
| 2173 | "libbt-stack", |
| 2174 | "libbt-utils", |
| 2175 | "libbtcore", |
| 2176 | "libbtdevice", |
| 2177 | "libbte", |
| 2178 | "libbtif", |
| 2179 | "libchrome", |
| 2180 | "libevent", |
| 2181 | "libfmq", |
| 2182 | "libg722codec", |
| 2183 | "libgui_headers", |
| 2184 | "libmedia_headers", |
| 2185 | "libmodpb64", |
| 2186 | "libosi", |
| 2187 | "libstagefright_foundation_headers", |
| 2188 | "libstagefright_headers", |
| 2189 | "libstatslog", |
| 2190 | "libstatssocket", |
| 2191 | "libtinyxml2", |
| 2192 | "libudrv-uipc", |
| 2193 | "libz", |
| 2194 | "media_plugin_headers", |
| 2195 | "net-utils-services-common", |
| 2196 | "netd_aidl_interface-unstable-java", |
| 2197 | "netd_event_listener_interface-java", |
| 2198 | "netlink-client", |
| 2199 | "networkstack-client", |
| 2200 | "sap-api-java-static", |
| 2201 | "services.net", |
| 2202 | } |
| 2203 | // |
| 2204 | // Module separator |
| 2205 | // |
| 2206 | m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"} |
| 2207 | // |
| 2208 | // Module separator |
| 2209 | // |
| 2210 | m["com.android.extservices"] = []string{ |
| 2211 | "error_prone_annotations", |
| 2212 | "ExtServices-core", |
| 2213 | "ExtServices", |
| 2214 | "libtextclassifier-java", |
| 2215 | "libz_current", |
| 2216 | "textclassifier-statsd", |
| 2217 | "TextClassifierNotificationLibNoManifest", |
| 2218 | "TextClassifierServiceLibNoManifest", |
| 2219 | } |
| 2220 | // |
| 2221 | // Module separator |
| 2222 | // |
| 2223 | m["com.android.neuralnetworks"] = []string{ |
| 2224 | "android.hardware.neuralnetworks@1.0", |
| 2225 | "android.hardware.neuralnetworks@1.1", |
| 2226 | "android.hardware.neuralnetworks@1.2", |
| 2227 | "android.hardware.neuralnetworks@1.3", |
| 2228 | "android.hidl.allocator@1.0", |
| 2229 | "android.hidl.memory.token@1.0", |
| 2230 | "android.hidl.memory@1.0", |
| 2231 | "android.hidl.safe_union@1.0", |
| 2232 | "libarect", |
| 2233 | "libbuildversion", |
| 2234 | "libmath", |
| 2235 | "libprocpartition", |
| 2236 | "libsync", |
| 2237 | } |
| 2238 | // |
| 2239 | // Module separator |
| 2240 | // |
| 2241 | m["com.android.media"] = []string{ |
| 2242 | "android.frameworks.bufferhub@1.0", |
| 2243 | "android.hardware.cas.native@1.0", |
| 2244 | "android.hardware.cas@1.0", |
| 2245 | "android.hardware.configstore-utils", |
| 2246 | "android.hardware.configstore@1.0", |
| 2247 | "android.hardware.configstore@1.1", |
| 2248 | "android.hardware.graphics.allocator@2.0", |
| 2249 | "android.hardware.graphics.allocator@3.0", |
| 2250 | "android.hardware.graphics.bufferqueue@1.0", |
| 2251 | "android.hardware.graphics.bufferqueue@2.0", |
| 2252 | "android.hardware.graphics.common@1.0", |
| 2253 | "android.hardware.graphics.common@1.1", |
| 2254 | "android.hardware.graphics.common@1.2", |
| 2255 | "android.hardware.graphics.mapper@2.0", |
| 2256 | "android.hardware.graphics.mapper@2.1", |
| 2257 | "android.hardware.graphics.mapper@3.0", |
| 2258 | "android.hardware.media.omx@1.0", |
| 2259 | "android.hardware.media@1.0", |
| 2260 | "android.hidl.allocator@1.0", |
| 2261 | "android.hidl.memory.token@1.0", |
| 2262 | "android.hidl.memory@1.0", |
| 2263 | "android.hidl.token@1.0", |
| 2264 | "android.hidl.token@1.0-utils", |
| 2265 | "bionic_libc_platform_headers", |
| 2266 | "exoplayer2-extractor", |
| 2267 | "exoplayer2-extractor-annotation-stubs", |
| 2268 | "gl_headers", |
| 2269 | "jsr305", |
| 2270 | "libEGL", |
| 2271 | "libEGL_blobCache", |
| 2272 | "libEGL_getProcAddress", |
| 2273 | "libFLAC", |
| 2274 | "libFLAC-config", |
| 2275 | "libFLAC-headers", |
| 2276 | "libGLESv2", |
| 2277 | "libaacextractor", |
| 2278 | "libamrextractor", |
| 2279 | "libarect", |
| 2280 | "libaudio_system_headers", |
| 2281 | "libaudioclient", |
| 2282 | "libaudioclient_headers", |
| 2283 | "libaudiofoundation", |
| 2284 | "libaudiofoundation_headers", |
| 2285 | "libaudiomanager", |
| 2286 | "libaudiopolicy", |
| 2287 | "libaudioutils", |
| 2288 | "libaudioutils_fixedfft", |
| 2289 | "libbinder_headers", |
| 2290 | "libbluetooth-types-header", |
| 2291 | "libbufferhub", |
| 2292 | "libbufferhub_headers", |
| 2293 | "libbufferhubqueue", |
| 2294 | "libc_malloc_debug_backtrace", |
| 2295 | "libcamera_client", |
| 2296 | "libcamera_metadata", |
| 2297 | "libdvr_headers", |
| 2298 | "libexpat", |
| 2299 | "libfifo", |
| 2300 | "libflacextractor", |
| 2301 | "libgrallocusage", |
| 2302 | "libgraphicsenv", |
| 2303 | "libgui", |
| 2304 | "libgui_headers", |
| 2305 | "libhardware_headers", |
| 2306 | "libinput", |
| 2307 | "liblzma", |
| 2308 | "libmath", |
| 2309 | "libmedia", |
| 2310 | "libmedia_codeclist", |
| 2311 | "libmedia_headers", |
| 2312 | "libmedia_helper", |
| 2313 | "libmedia_helper_headers", |
| 2314 | "libmedia_midiiowrapper", |
| 2315 | "libmedia_omx", |
| 2316 | "libmediautils", |
| 2317 | "libmidiextractor", |
| 2318 | "libmkvextractor", |
| 2319 | "libmp3extractor", |
| 2320 | "libmp4extractor", |
| 2321 | "libmpeg2extractor", |
| 2322 | "libnativebase_headers", |
| 2323 | "libnativewindow_headers", |
| 2324 | "libnblog", |
| 2325 | "liboggextractor", |
| 2326 | "libpackagelistparser", |
| 2327 | "libpdx", |
| 2328 | "libpdx_default_transport", |
| 2329 | "libpdx_headers", |
| 2330 | "libpdx_uds", |
| 2331 | "libprocinfo", |
| 2332 | "libspeexresampler", |
| 2333 | "libspeexresampler", |
| 2334 | "libstagefright_esds", |
| 2335 | "libstagefright_flacdec", |
| 2336 | "libstagefright_flacdec", |
| 2337 | "libstagefright_foundation", |
| 2338 | "libstagefright_foundation_headers", |
| 2339 | "libstagefright_foundation_without_imemory", |
| 2340 | "libstagefright_headers", |
| 2341 | "libstagefright_id3", |
| 2342 | "libstagefright_metadatautils", |
| 2343 | "libstagefright_mpeg2extractor", |
| 2344 | "libstagefright_mpeg2support", |
| 2345 | "libsync", |
| 2346 | "libui", |
| 2347 | "libui_headers", |
| 2348 | "libunwindstack", |
| 2349 | "libvibrator", |
| 2350 | "libvorbisidec", |
| 2351 | "libwavextractor", |
| 2352 | "libwebm", |
| 2353 | "media_ndk_headers", |
| 2354 | "media_plugin_headers", |
| 2355 | "updatable-media", |
| 2356 | } |
| 2357 | // |
| 2358 | // Module separator |
| 2359 | // |
| 2360 | m["com.android.media.swcodec"] = []string{ |
| 2361 | "android.frameworks.bufferhub@1.0", |
| 2362 | "android.hardware.common-ndk_platform", |
| 2363 | "android.hardware.configstore-utils", |
| 2364 | "android.hardware.configstore@1.0", |
| 2365 | "android.hardware.configstore@1.1", |
| 2366 | "android.hardware.graphics.allocator@2.0", |
| 2367 | "android.hardware.graphics.allocator@3.0", |
| 2368 | "android.hardware.graphics.allocator@4.0", |
| 2369 | "android.hardware.graphics.bufferqueue@1.0", |
| 2370 | "android.hardware.graphics.bufferqueue@2.0", |
| 2371 | "android.hardware.graphics.common-ndk_platform", |
| 2372 | "android.hardware.graphics.common@1.0", |
| 2373 | "android.hardware.graphics.common@1.1", |
| 2374 | "android.hardware.graphics.common@1.2", |
| 2375 | "android.hardware.graphics.mapper@2.0", |
| 2376 | "android.hardware.graphics.mapper@2.1", |
| 2377 | "android.hardware.graphics.mapper@3.0", |
| 2378 | "android.hardware.graphics.mapper@4.0", |
| 2379 | "android.hardware.media.bufferpool@2.0", |
| 2380 | "android.hardware.media.c2@1.0", |
| 2381 | "android.hardware.media.c2@1.1", |
| 2382 | "android.hardware.media.omx@1.0", |
| 2383 | "android.hardware.media@1.0", |
| 2384 | "android.hardware.media@1.0", |
| 2385 | "android.hidl.memory.token@1.0", |
| 2386 | "android.hidl.memory@1.0", |
| 2387 | "android.hidl.safe_union@1.0", |
| 2388 | "android.hidl.token@1.0", |
| 2389 | "android.hidl.token@1.0-utils", |
| 2390 | "libEGL", |
| 2391 | "libFLAC", |
| 2392 | "libFLAC-config", |
| 2393 | "libFLAC-headers", |
| 2394 | "libFraunhoferAAC", |
| 2395 | "libLibGuiProperties", |
| 2396 | "libarect", |
| 2397 | "libaudio_system_headers", |
| 2398 | "libaudioutils", |
| 2399 | "libaudioutils", |
| 2400 | "libaudioutils_fixedfft", |
| 2401 | "libavcdec", |
| 2402 | "libavcenc", |
| 2403 | "libavservices_minijail", |
| 2404 | "libavservices_minijail", |
| 2405 | "libbinder_headers", |
| 2406 | "libbinderthreadstateutils", |
| 2407 | "libbluetooth-types-header", |
| 2408 | "libbufferhub_headers", |
| 2409 | "libcodec2", |
| 2410 | "libcodec2_headers", |
| 2411 | "libcodec2_hidl@1.0", |
| 2412 | "libcodec2_hidl@1.1", |
| 2413 | "libcodec2_internal", |
| 2414 | "libcodec2_soft_aacdec", |
| 2415 | "libcodec2_soft_aacenc", |
| 2416 | "libcodec2_soft_amrnbdec", |
| 2417 | "libcodec2_soft_amrnbenc", |
| 2418 | "libcodec2_soft_amrwbdec", |
| 2419 | "libcodec2_soft_amrwbenc", |
| 2420 | "libcodec2_soft_av1dec_gav1", |
| 2421 | "libcodec2_soft_avcdec", |
| 2422 | "libcodec2_soft_avcenc", |
| 2423 | "libcodec2_soft_common", |
| 2424 | "libcodec2_soft_flacdec", |
| 2425 | "libcodec2_soft_flacenc", |
| 2426 | "libcodec2_soft_g711alawdec", |
| 2427 | "libcodec2_soft_g711mlawdec", |
| 2428 | "libcodec2_soft_gsmdec", |
| 2429 | "libcodec2_soft_h263dec", |
| 2430 | "libcodec2_soft_h263enc", |
| 2431 | "libcodec2_soft_hevcdec", |
| 2432 | "libcodec2_soft_hevcenc", |
| 2433 | "libcodec2_soft_mp3dec", |
| 2434 | "libcodec2_soft_mpeg2dec", |
| 2435 | "libcodec2_soft_mpeg4dec", |
| 2436 | "libcodec2_soft_mpeg4enc", |
| 2437 | "libcodec2_soft_opusdec", |
| 2438 | "libcodec2_soft_opusenc", |
| 2439 | "libcodec2_soft_rawdec", |
| 2440 | "libcodec2_soft_vorbisdec", |
| 2441 | "libcodec2_soft_vp8dec", |
| 2442 | "libcodec2_soft_vp8enc", |
| 2443 | "libcodec2_soft_vp9dec", |
| 2444 | "libcodec2_soft_vp9enc", |
| 2445 | "libcodec2_vndk", |
| 2446 | "libdvr_headers", |
| 2447 | "libfmq", |
| 2448 | "libfmq", |
| 2449 | "libgav1", |
| 2450 | "libgralloctypes", |
| 2451 | "libgrallocusage", |
| 2452 | "libgraphicsenv", |
| 2453 | "libgsm", |
| 2454 | "libgui_bufferqueue_static", |
| 2455 | "libgui_headers", |
| 2456 | "libhardware", |
| 2457 | "libhardware_headers", |
| 2458 | "libhevcdec", |
| 2459 | "libhevcenc", |
| 2460 | "libion", |
| 2461 | "libjpeg", |
| 2462 | "liblzma", |
| 2463 | "libmath", |
| 2464 | "libmedia_codecserviceregistrant", |
| 2465 | "libmedia_headers", |
| 2466 | "libmpeg2dec", |
| 2467 | "libnativebase_headers", |
| 2468 | "libnativewindow_headers", |
| 2469 | "libpdx_headers", |
| 2470 | "libscudo_wrapper", |
| 2471 | "libsfplugin_ccodec_utils", |
| 2472 | "libspeexresampler", |
| 2473 | "libstagefright_amrnb_common", |
| 2474 | "libstagefright_amrnbdec", |
| 2475 | "libstagefright_amrnbenc", |
| 2476 | "libstagefright_amrwbdec", |
| 2477 | "libstagefright_amrwbenc", |
| 2478 | "libstagefright_bufferpool@2.0.1", |
| 2479 | "libstagefright_bufferqueue_helper", |
| 2480 | "libstagefright_enc_common", |
| 2481 | "libstagefright_flacdec", |
| 2482 | "libstagefright_foundation", |
| 2483 | "libstagefright_foundation_headers", |
| 2484 | "libstagefright_headers", |
| 2485 | "libstagefright_m4vh263dec", |
| 2486 | "libstagefright_m4vh263enc", |
| 2487 | "libstagefright_mp3dec", |
| 2488 | "libsync", |
| 2489 | "libui", |
| 2490 | "libui_headers", |
| 2491 | "libunwindstack", |
| 2492 | "libvorbisidec", |
| 2493 | "libvpx", |
| 2494 | "libyuv", |
| 2495 | "libyuv_static", |
| 2496 | "media_ndk_headers", |
| 2497 | "media_plugin_headers", |
| 2498 | "mediaswcodec", |
| 2499 | } |
| 2500 | // |
| 2501 | // Module separator |
| 2502 | // |
| 2503 | m["com.android.mediaprovider"] = []string{ |
| 2504 | "MediaProvider", |
| 2505 | "MediaProviderGoogle", |
| 2506 | "fmtlib_ndk", |
| 2507 | "libbase_ndk", |
| 2508 | "libfuse", |
| 2509 | "libfuse_jni", |
| 2510 | } |
| 2511 | // |
| 2512 | // Module separator |
| 2513 | // |
| 2514 | m["com.android.permission"] = []string{ |
| 2515 | "car-ui-lib", |
| 2516 | "iconloader", |
| 2517 | "kotlin-annotations", |
| 2518 | "kotlin-stdlib", |
| 2519 | "kotlin-stdlib-jdk7", |
| 2520 | "kotlin-stdlib-jdk8", |
| 2521 | "kotlinx-coroutines-android", |
| 2522 | "kotlinx-coroutines-android-nodeps", |
| 2523 | "kotlinx-coroutines-core", |
| 2524 | "kotlinx-coroutines-core-nodeps", |
| 2525 | "permissioncontroller-statsd", |
| 2526 | "GooglePermissionController", |
| 2527 | "PermissionController", |
| 2528 | "SettingsLibActionBarShadow", |
| 2529 | "SettingsLibAppPreference", |
| 2530 | "SettingsLibBarChartPreference", |
| 2531 | "SettingsLibLayoutPreference", |
| 2532 | "SettingsLibProgressBar", |
| 2533 | "SettingsLibSearchWidget", |
| 2534 | "SettingsLibSettingsTheme", |
| 2535 | "SettingsLibRestrictedLockUtils", |
| 2536 | "SettingsLibHelpUtils", |
| 2537 | } |
| 2538 | // |
| 2539 | // Module separator |
| 2540 | // |
| 2541 | m["com.android.runtime"] = []string{ |
| 2542 | "bionic_libc_platform_headers", |
| 2543 | "libarm-optimized-routines-math", |
| 2544 | "libc_aeabi", |
| 2545 | "libc_bionic", |
| 2546 | "libc_bionic_ndk", |
| 2547 | "libc_bootstrap", |
| 2548 | "libc_common", |
| 2549 | "libc_common_shared", |
| 2550 | "libc_common_static", |
| 2551 | "libc_dns", |
| 2552 | "libc_dynamic_dispatch", |
| 2553 | "libc_fortify", |
| 2554 | "libc_freebsd", |
| 2555 | "libc_freebsd_large_stack", |
| 2556 | "libc_gdtoa", |
| 2557 | "libc_init_dynamic", |
| 2558 | "libc_init_static", |
| 2559 | "libc_jemalloc_wrapper", |
| 2560 | "libc_netbsd", |
| 2561 | "libc_nomalloc", |
| 2562 | "libc_nopthread", |
| 2563 | "libc_openbsd", |
| 2564 | "libc_openbsd_large_stack", |
| 2565 | "libc_openbsd_ndk", |
| 2566 | "libc_pthread", |
| 2567 | "libc_static_dispatch", |
| 2568 | "libc_syscalls", |
| 2569 | "libc_tzcode", |
| 2570 | "libc_unwind_static", |
| 2571 | "libdebuggerd", |
| 2572 | "libdebuggerd_common_headers", |
| 2573 | "libdebuggerd_handler_core", |
| 2574 | "libdebuggerd_handler_fallback", |
| 2575 | "libdl_static", |
| 2576 | "libjemalloc5", |
| 2577 | "liblinker_main", |
| 2578 | "liblinker_malloc", |
| 2579 | "liblz4", |
| 2580 | "liblzma", |
| 2581 | "libprocinfo", |
| 2582 | "libpropertyinfoparser", |
| 2583 | "libscudo", |
| 2584 | "libstdc++", |
| 2585 | "libsystemproperties", |
| 2586 | "libtombstoned_client_static", |
| 2587 | "libunwindstack", |
| 2588 | "libz", |
| 2589 | "libziparchive", |
| 2590 | } |
| 2591 | // |
| 2592 | // Module separator |
| 2593 | // |
| 2594 | m["com.android.tethering"] = []string{ |
| 2595 | "android.hardware.tetheroffload.config-V1.0-java", |
| 2596 | "android.hardware.tetheroffload.control-V1.0-java", |
| 2597 | "android.hidl.base-V1.0-java", |
| 2598 | "libcgrouprc", |
| 2599 | "libcgrouprc_format", |
| 2600 | "libtetherutilsjni", |
| 2601 | "libvndksupport", |
| 2602 | "net-utils-framework-common", |
| 2603 | "netd_aidl_interface-V3-java", |
| 2604 | "netlink-client", |
| 2605 | "networkstack-aidl-interfaces-java", |
| 2606 | "tethering-aidl-interfaces-java", |
| 2607 | "TetheringApiCurrentLib", |
| 2608 | } |
| 2609 | // |
| 2610 | // Module separator |
| 2611 | // |
| 2612 | m["com.android.wifi"] = []string{ |
| 2613 | "PlatformProperties", |
| 2614 | "android.hardware.wifi-V1.0-java", |
| 2615 | "android.hardware.wifi-V1.0-java-constants", |
| 2616 | "android.hardware.wifi-V1.1-java", |
| 2617 | "android.hardware.wifi-V1.2-java", |
| 2618 | "android.hardware.wifi-V1.3-java", |
| 2619 | "android.hardware.wifi-V1.4-java", |
| 2620 | "android.hardware.wifi.hostapd-V1.0-java", |
| 2621 | "android.hardware.wifi.hostapd-V1.1-java", |
| 2622 | "android.hardware.wifi.hostapd-V1.2-java", |
| 2623 | "android.hardware.wifi.supplicant-V1.0-java", |
| 2624 | "android.hardware.wifi.supplicant-V1.1-java", |
| 2625 | "android.hardware.wifi.supplicant-V1.2-java", |
| 2626 | "android.hardware.wifi.supplicant-V1.3-java", |
| 2627 | "android.hidl.base-V1.0-java", |
| 2628 | "android.hidl.manager-V1.0-java", |
| 2629 | "android.hidl.manager-V1.1-java", |
| 2630 | "android.hidl.manager-V1.2-java", |
| 2631 | "bouncycastle-unbundled", |
| 2632 | "dnsresolver_aidl_interface-V2-java", |
| 2633 | "error_prone_annotations", |
| 2634 | "framework-wifi-pre-jarjar", |
| 2635 | "framework-wifi-util-lib", |
| 2636 | "ipmemorystore-aidl-interfaces-V3-java", |
| 2637 | "ipmemorystore-aidl-interfaces-java", |
| 2638 | "ksoap2", |
| 2639 | "libnanohttpd", |
| 2640 | "libwifi-jni", |
| 2641 | "net-utils-services-common", |
| 2642 | "netd_aidl_interface-V2-java", |
| 2643 | "netd_aidl_interface-unstable-java", |
| 2644 | "netd_event_listener_interface-java", |
| 2645 | "netlink-client", |
| 2646 | "networkstack-client", |
| 2647 | "services.net", |
| 2648 | "wifi-lite-protos", |
| 2649 | "wifi-nano-protos", |
| 2650 | "wifi-service-pre-jarjar", |
| 2651 | "wifi-service-resources", |
| 2652 | } |
| 2653 | // |
| 2654 | // Module separator |
| 2655 | // |
| 2656 | m["com.android.sdkext"] = []string{ |
| 2657 | "fmtlib_ndk", |
| 2658 | "libbase_ndk", |
| 2659 | "libprotobuf-cpp-lite-ndk", |
| 2660 | } |
| 2661 | // |
| 2662 | // Module separator |
| 2663 | // |
| 2664 | m["com.android.os.statsd"] = []string{ |
| 2665 | "libstatssocket", |
| 2666 | } |
| 2667 | // |
| 2668 | // Module separator |
| 2669 | // |
| 2670 | m[android.AvailableToAnyApex] = []string{ |
| 2671 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries |
| 2672 | "androidx", |
| 2673 | "androidx-constraintlayout_constraintlayout", |
| 2674 | "androidx-constraintlayout_constraintlayout-nodeps", |
| 2675 | "androidx-constraintlayout_constraintlayout-solver", |
| 2676 | "androidx-constraintlayout_constraintlayout-solver-nodeps", |
| 2677 | "com.google.android.material_material", |
| 2678 | "com.google.android.material_material-nodeps", |
| 2679 | |
| 2680 | "libatomic", |
| 2681 | "libclang_rt", |
| 2682 | "libgcc_stripped", |
| 2683 | "libprofile-clang-extras", |
| 2684 | "libprofile-clang-extras_ndk", |
| 2685 | "libprofile-extras", |
| 2686 | "libprofile-extras_ndk", |
| 2687 | "libunwind_llvm", |
| 2688 | } |
| 2689 | return m |
| 2690 | } |
| 2691 | |
| 2692 | func init() { |
| 2693 | android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...) |
| 2694 | android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...) |
| 2695 | } |
| 2696 | |
| 2697 | func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule { |
| 2698 | rules := make([]android.Rule, 0, len(modules_packages)) |
| 2699 | for module_name, module_packages := range modules_packages { |
| 2700 | permitted_packages_rule := android.NeverAllow(). |
| 2701 | BootclasspathJar(). |
| 2702 | With("apex_available", module_name). |
| 2703 | WithMatcher("permitted_packages", android.NotInList(module_packages)). |
| 2704 | Because("jars that are part of the " + module_name + |
| 2705 | " module may only allow these packages: " + strings.Join(module_packages, ",") + |
| 2706 | ". Please jarjar or move code around.") |
| 2707 | rules = append(rules, permitted_packages_rule) |
| 2708 | } |
| 2709 | return rules |
| 2710 | } |
| 2711 | |
| 2712 | // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. |
| 2713 | // Adding code to the bootclasspath in new packages will cause issues on module update. |
| 2714 | func qModulesPackages() map[string][]string { |
| 2715 | return map[string][]string{ |
| 2716 | "com.android.conscrypt": []string{ |
| 2717 | "android.net.ssl", |
| 2718 | "com.android.org.conscrypt", |
| 2719 | }, |
| 2720 | "com.android.media": []string{ |
| 2721 | "android.media", |
| 2722 | }, |
| 2723 | } |
| 2724 | } |
| 2725 | |
| 2726 | // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. |
| 2727 | // Adding code to the bootclasspath in new packages will cause issues on module update. |
| 2728 | func rModulesPackages() map[string][]string { |
| 2729 | return map[string][]string{ |
| 2730 | "com.android.mediaprovider": []string{ |
| 2731 | "android.provider", |
| 2732 | }, |
| 2733 | "com.android.permission": []string{ |
| 2734 | "android.permission", |
| 2735 | "android.app.role", |
| 2736 | "com.android.permission", |
| 2737 | "com.android.role", |
| 2738 | }, |
| 2739 | "com.android.sdkext": []string{ |
| 2740 | "android.os.ext", |
| 2741 | }, |
| 2742 | "com.android.os.statsd": []string{ |
| 2743 | "android.app", |
| 2744 | "android.os", |
| 2745 | "android.util", |
| 2746 | "com.android.internal.statsd", |
| 2747 | "com.android.server.stats", |
| 2748 | }, |
| 2749 | "com.android.wifi": []string{ |
| 2750 | "com.android.server.wifi", |
| 2751 | "com.android.wifi.x", |
| 2752 | "android.hardware.wifi", |
| 2753 | "android.net.wifi", |
| 2754 | }, |
| 2755 | "com.android.tethering": []string{ |
| 2756 | "android.net", |
| 2757 | }, |
| 2758 | } |
| 2759 | } |