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