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" |
Jingwen Chen | 8ce1efc | 2022-04-19 13:57:01 +0000 | [diff] [blame^] | 22 | "regexp" |
Jiyong Park | ab3ceb3 | 2018-10-10 14:05:29 +0900 | [diff] [blame] | 23 | "sort" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 24 | "strings" |
| 25 | |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 26 | "github.com/google/blueprint" |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 27 | "github.com/google/blueprint/bootstrap" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 28 | "github.com/google/blueprint/proptools" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 29 | |
| 30 | "android/soong/android" |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 31 | "android/soong/bazel" |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 32 | "android/soong/bpf" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 33 | "android/soong/cc" |
| 34 | prebuilt_etc "android/soong/etc" |
Jiyong Park | 12a719c | 2021-01-07 15:31:24 +0900 | [diff] [blame] | 35 | "android/soong/filesystem" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 36 | "android/soong/java" |
| 37 | "android/soong/python" |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 38 | "android/soong/rust" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 39 | "android/soong/sh" |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 40 | ) |
| 41 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 42 | func init() { |
Paul Duffin | 667893c | 2021-03-09 22:34:13 +0000 | [diff] [blame] | 43 | registerApexBuildComponents(android.InitRegistrationContext) |
| 44 | } |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 45 | |
Paul Duffin | 667893c | 2021-03-09 22:34:13 +0000 | [diff] [blame] | 46 | func registerApexBuildComponents(ctx android.RegistrationContext) { |
| 47 | ctx.RegisterModuleType("apex", BundleFactory) |
| 48 | ctx.RegisterModuleType("apex_test", testApexBundleFactory) |
| 49 | ctx.RegisterModuleType("apex_vndk", vndkApexBundleFactory) |
| 50 | ctx.RegisterModuleType("apex_defaults", defaultsFactory) |
| 51 | ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory) |
| 52 | ctx.RegisterModuleType("override_apex", overrideApexFactory) |
| 53 | ctx.RegisterModuleType("apex_set", apexSetFactory) |
| 54 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 55 | ctx.PreArchMutators(registerPreArchMutators) |
Paul Duffin | 667893c | 2021-03-09 22:34:13 +0000 | [diff] [blame] | 56 | ctx.PreDepsMutators(RegisterPreDepsMutators) |
| 57 | ctx.PostDepsMutators(RegisterPostDepsMutators) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 58 | } |
| 59 | |
Paul Duffin | 5dda3e3 | 2021-05-05 14:13:27 +0100 | [diff] [blame] | 60 | func registerPreArchMutators(ctx android.RegisterMutatorsContext) { |
| 61 | ctx.TopDown("prebuilt_apex_module_creator", prebuiltApexModuleCreatorMutator).Parallel() |
| 62 | } |
| 63 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 64 | func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { |
| 65 | ctx.TopDown("apex_vndk", apexVndkMutator).Parallel() |
| 66 | ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel() |
| 67 | } |
| 68 | |
| 69 | func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { |
Paul Duffin | 949abc0 | 2020-12-08 10:34:30 +0000 | [diff] [blame] | 70 | ctx.TopDown("apex_info", apexInfoMutator).Parallel() |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 71 | ctx.BottomUp("apex_unique", apexUniqueVariationsMutator).Parallel() |
| 72 | ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator).Parallel() |
| 73 | ctx.BottomUp("apex_test_for", apexTestForMutator).Parallel() |
Paul Duffin | 28bf7ee | 2021-05-12 16:41:35 +0100 | [diff] [blame] | 74 | // Run mark_platform_availability before the apexMutator as the apexMutator needs to know whether |
| 75 | // it should create a platform variant. |
| 76 | ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel() |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 77 | ctx.BottomUp("apex", apexMutator).Parallel() |
| 78 | ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel() |
| 79 | ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel() |
Spandan Das | 6677325 | 2022-01-15 00:23:18 +0000 | [diff] [blame] | 80 | // Register after apex_info mutator so that it can use ApexVariationName |
| 81 | ctx.TopDown("apex_strict_updatability_lint", apexStrictUpdatibilityLintMutator).Parallel() |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | type apexBundleProperties struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 85 | // Json manifest file describing meta info of this APEX bundle. Refer to |
| 86 | // 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] | 87 | Manifest *string `android:"path"` |
| 88 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 89 | // AndroidManifest.xml file used for the zip container of this APEX bundle. If unspecified, |
| 90 | // a default one is automatically generated. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 91 | AndroidManifest *string `android:"path"` |
| 92 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 93 | // Canonical name of this APEX bundle. Used to determine the path to the activated APEX on |
| 94 | // device (/apex/<apex_name>). If unspecified, follows the name property. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 95 | Apex_name *string |
| 96 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 97 | // Determines the file contexts file for setting the security contexts to files in this APEX |
| 98 | // bundle. For platform APEXes, this should points to a file under /system/sepolicy Default: |
| 99 | // /system/sepolicy/apex/<module_name>_file_contexts. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 100 | File_contexts *string `android:"path"` |
| 101 | |
Jiyong Park | 038e852 | 2021-12-13 23:56:35 +0900 | [diff] [blame] | 102 | // Path to the canned fs config file for customizing file's uid/gid/mod/capabilities. The |
| 103 | // format is /<path_or_glob> <uid> <gid> <mode> [capabilities=0x<cap>], where path_or_glob is a |
| 104 | // path or glob pattern for a file or set of files, uid/gid are numerial values of user ID |
| 105 | // and group ID, mode is octal value for the file mode, and cap is hexadecimal value for the |
| 106 | // capability. If this property is not set, or a file is missing in the file, default config |
| 107 | // is used. |
| 108 | Canned_fs_config *string `android:"path"` |
| 109 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 110 | ApexNativeDependencies |
| 111 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 112 | Multilib apexMultilibProperties |
| 113 | |
Sundong Ahn | 80c0489 | 2021-11-23 00:57:19 +0000 | [diff] [blame] | 114 | // List of sh binaries that are embedded inside this APEX bundle. |
| 115 | Sh_binaries []string |
| 116 | |
Paul Duffin | 3abc174 | 2021-03-15 19:32:23 +0000 | [diff] [blame] | 117 | // List of platform_compat_config files that are embedded inside this APEX bundle. |
| 118 | Compat_configs []string |
| 119 | |
Jiyong Park | 12a719c | 2021-01-07 15:31:24 +0900 | [diff] [blame] | 120 | // List of filesystem images that are embedded inside this APEX bundle. |
| 121 | Filesystems []string |
| 122 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 123 | // The minimum SDK version that this APEX must support at minimum. This is usually set to |
| 124 | // the SDK version that the APEX was first introduced. |
| 125 | Min_sdk_version *string |
| 126 | |
| 127 | // Whether this APEX is considered updatable or not. When set to true, this will enforce |
| 128 | // additional rules for making sure that the APEX is truly updatable. To be updatable, |
| 129 | // min_sdk_version should be set as well. This will also disable the size optimizations like |
Mathew Inwood | f8dcf5e | 2021-02-16 11:40:16 +0000 | [diff] [blame] | 130 | // symlinking to the system libs. Default is true. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 131 | Updatable *bool |
| 132 | |
Jiyong Park | f402058 | 2021-11-29 12:37:10 +0900 | [diff] [blame] | 133 | // Marks that this APEX is designed to be updatable in the future, although it's not |
| 134 | // updatable yet. This is used to mimic some of the build behaviors that are applied only to |
| 135 | // updatable APEXes. Currently, this disables the size optimization, so that the size of |
| 136 | // APEX will not increase when the APEX is actually marked as truly updatable. Default is |
| 137 | // false. |
| 138 | Future_updatable *bool |
| 139 | |
Jiyong Park | 1bc8412 | 2021-06-22 20:23:05 +0900 | [diff] [blame] | 140 | // Whether this APEX can use platform APIs or not. Can be set to true only when `updatable: |
| 141 | // false`. Default is false. |
| 142 | Platform_apis *bool |
| 143 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 144 | // Whether this APEX is installable to one of the partitions like system, vendor, etc. |
| 145 | // Default: true. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 146 | Installable *bool |
| 147 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 148 | // If set true, VNDK libs are considered as stable libs and are not included in this APEX. |
| 149 | // Should be only used in non-system apexes (e.g. vendor: true). Default is false. |
| 150 | Use_vndk_as_stable *bool |
| 151 | |
Daniel Norman | 6cfb37af | 2021-11-16 20:28:29 +0000 | [diff] [blame] | 152 | // Whether this is multi-installed APEX should skip installing symbol files. |
| 153 | // Multi-installed APEXes share the same apex_name and are installed at the same time. |
| 154 | // Default is false. |
| 155 | // |
| 156 | // Should be set to true for all multi-installed APEXes except the singular |
| 157 | // default version within the multi-installed group. |
| 158 | // Only the default version can install symbol files in $(PRODUCT_OUT}/apex, |
| 159 | // or else conflicting build rules may be created. |
| 160 | Multi_install_skip_symbol_files *bool |
| 161 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 162 | // List of SDKs that are used to build this APEX. A reference to an SDK should be either |
| 163 | // `name#version` or `name` which is an alias for `name#current`. If left empty, |
| 164 | // `platform#current` is implied. This value affects all modules included in this APEX. In |
| 165 | // other words, they are also built with the SDKs specified here. |
| 166 | Uses_sdks []string |
| 167 | |
| 168 | // The type of APEX to build. Controls what the APEX payload is. Either 'image', 'zip' or |
| 169 | // 'both'. When set to image, contents are stored in a filesystem image inside a zip |
| 170 | // container. When set to zip, contents are stored in a zip container directly. This type is |
| 171 | // mostly for host-side debugging. When set to both, the two types are both built. Default |
| 172 | // is 'image'. |
| 173 | Payload_type *string |
| 174 | |
Huang Jianan | 13cac63 | 2021-08-02 15:02:17 +0800 | [diff] [blame] | 175 | // The type of filesystem to use when the payload_type is 'image'. Either 'ext4', 'f2fs' |
| 176 | // or 'erofs'. Default 'ext4'. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 177 | Payload_fs_type *string |
| 178 | |
| 179 | // For telling the APEX to ignore special handling for system libraries such as bionic. |
| 180 | // Default is false. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 181 | Ignore_system_library_special_case *bool |
| 182 | |
Nikita Ioffe | da6dc31 | 2021-06-09 19:43:46 +0100 | [diff] [blame] | 183 | // Whenever apex_payload.img of the APEX should include dm-verity hashtree. |
Nikita Ioffe | e261ae6 | 2021-06-16 18:15:03 +0100 | [diff] [blame] | 184 | // Default value is true. |
Nikita Ioffe | da6dc31 | 2021-06-09 19:43:46 +0100 | [diff] [blame] | 185 | Generate_hashtree *bool |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 186 | |
| 187 | // Whenever apex_payload.img of the APEX should not be dm-verity signed. Should be only |
| 188 | // used in tests. |
| 189 | Test_only_unsigned_payload *bool |
| 190 | |
Mohammad Samiul Islam | a8008f9 | 2020-12-22 10:47:50 +0000 | [diff] [blame] | 191 | // Whenever apex should be compressed, regardless of product flag used. Should be only |
| 192 | // used in tests. |
| 193 | Test_only_force_compression *bool |
| 194 | |
Jooyung Han | 09c11ad | 2021-10-27 03:45:31 +0900 | [diff] [blame] | 195 | // Put extra tags (signer=<value>) to apexkeys.txt, so that release tools can sign this apex |
| 196 | // with the tool to sign payload contents. |
| 197 | Custom_sign_tool *string |
| 198 | |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 199 | // Canonical name of this APEX bundle. Used to determine the path to the |
| 200 | // activated APEX on device (i.e. /apex/<apexVariationName>), and used for the |
| 201 | // apex mutator variations. For override_apex modules, this is the name of the |
| 202 | // overridden base module. |
| 203 | ApexVariationName string `blueprint:"mutated"` |
| 204 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 205 | IsCoverageVariant bool `blueprint:"mutated"` |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 206 | |
| 207 | // List of sanitizer names that this APEX is enabled for |
| 208 | SanitizerNames []string `blueprint:"mutated"` |
| 209 | |
| 210 | PreventInstall bool `blueprint:"mutated"` |
| 211 | |
| 212 | HideFromMake bool `blueprint:"mutated"` |
| 213 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 214 | // Internal package method for this APEX. When payload_type is image, this can be either |
| 215 | // imageApex or flattenedApex depending on Config.FlattenApex(). When payload_type is zip, |
| 216 | // this becomes zipApex. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 217 | ApexType apexPackaging `blueprint:"mutated"` |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | type ApexNativeDependencies struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 221 | // List of native libraries that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 222 | Native_shared_libs []string |
| 223 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 224 | // List of JNI libraries that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 225 | Jni_libs []string |
| 226 | |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 227 | // List of rust dyn libraries |
| 228 | Rust_dyn_libs []string |
| 229 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 230 | // List of native executables that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 231 | Binaries []string |
| 232 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 233 | // List of native tests that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 234 | Tests []string |
Jiyong Park | 0671146 | 2021-02-15 17:54:43 +0900 | [diff] [blame] | 235 | |
| 236 | // List of filesystem images that are embedded inside this APEX bundle. |
| 237 | Filesystems []string |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | type apexMultilibProperties struct { |
| 241 | // Native dependencies whose compile_multilib is "first" |
| 242 | First ApexNativeDependencies |
| 243 | |
| 244 | // Native dependencies whose compile_multilib is "both" |
| 245 | Both ApexNativeDependencies |
| 246 | |
| 247 | // Native dependencies whose compile_multilib is "prefer32" |
| 248 | Prefer32 ApexNativeDependencies |
| 249 | |
| 250 | // Native dependencies whose compile_multilib is "32" |
| 251 | Lib32 ApexNativeDependencies |
| 252 | |
| 253 | // Native dependencies whose compile_multilib is "64" |
| 254 | Lib64 ApexNativeDependencies |
| 255 | } |
| 256 | |
| 257 | type apexTargetBundleProperties struct { |
| 258 | Target struct { |
| 259 | // Multilib properties only for android. |
| 260 | Android struct { |
| 261 | Multilib apexMultilibProperties |
| 262 | } |
| 263 | |
| 264 | // Multilib properties only for host. |
| 265 | Host struct { |
| 266 | Multilib apexMultilibProperties |
| 267 | } |
| 268 | |
| 269 | // Multilib properties only for host linux_bionic. |
| 270 | Linux_bionic struct { |
| 271 | Multilib apexMultilibProperties |
| 272 | } |
| 273 | |
| 274 | // Multilib properties only for host linux_glibc. |
| 275 | Linux_glibc struct { |
| 276 | Multilib apexMultilibProperties |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
Jiyong Park | 5914030 | 2020-12-14 18:44:04 +0900 | [diff] [blame] | 281 | type apexArchBundleProperties struct { |
| 282 | Arch struct { |
| 283 | Arm struct { |
| 284 | ApexNativeDependencies |
| 285 | } |
| 286 | Arm64 struct { |
| 287 | ApexNativeDependencies |
| 288 | } |
| 289 | X86 struct { |
| 290 | ApexNativeDependencies |
| 291 | } |
| 292 | X86_64 struct { |
| 293 | ApexNativeDependencies |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 298 | // These properties can be used in override_apex to override the corresponding properties in the |
| 299 | // base apex. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 300 | type overridableProperties struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 301 | // List of APKs that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 302 | Apps []string |
| 303 | |
Daniel Norman | 5a3ce13 | 2021-08-26 15:44:43 -0700 | [diff] [blame] | 304 | // List of prebuilt files that are embedded inside this APEX bundle. |
| 305 | Prebuilts []string |
| 306 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 307 | // List of runtime resource overlays (RROs) that are embedded inside this APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 308 | Rros []string |
| 309 | |
markchien | 7c803b8 | 2021-08-26 22:10:06 +0800 | [diff] [blame] | 310 | // List of BPF programs inside this APEX bundle. |
| 311 | Bpfs []string |
| 312 | |
Remi NGUYEN VAN | be90172 | 2022-03-02 21:00:33 +0900 | [diff] [blame] | 313 | // List of bootclasspath fragments that are embedded inside this APEX bundle. |
| 314 | Bootclasspath_fragments []string |
| 315 | |
| 316 | // List of systemserverclasspath fragments that are embedded inside this APEX bundle. |
| 317 | Systemserverclasspath_fragments []string |
| 318 | |
| 319 | // List of java libraries that are embedded inside this APEX bundle. |
| 320 | Java_libs []string |
| 321 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 322 | // Names of modules to be overridden. Listed modules can only be other binaries (in Make or |
| 323 | // Soong). This does not completely prevent installation of the overridden binaries, but if |
| 324 | // both binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will |
| 325 | // be removed from PRODUCT_PACKAGES. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 326 | Overrides []string |
| 327 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 328 | // Logging parent value. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 329 | Logging_parent string |
| 330 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 331 | // Apex Container package name. Override value for attribute package:name in |
| 332 | // AndroidManifest.xml |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 333 | Package_name string |
| 334 | |
| 335 | // A txt file containing list of files that are allowed to be included in this APEX. |
| 336 | Allowed_files *string `android:"path"` |
Jaewoong Jung | 4cfdf7d | 2021-04-20 16:21:24 -0700 | [diff] [blame] | 337 | |
| 338 | // Name of the apex_key module that provides the private key to sign this APEX bundle. |
| 339 | Key *string |
| 340 | |
| 341 | // Specifies the certificate and the private key to sign the zip container of this APEX. If |
| 342 | // this is "foo", foo.x509.pem and foo.pk8 under PRODUCT_DEFAULT_DEV_CERTIFICATE are used |
| 343 | // as the certificate and the private key, respectively. If this is ":module", then the |
| 344 | // certificate and the private key are provided from the android_app_certificate module |
| 345 | // named "module". |
| 346 | Certificate *string |
Oriol Prieto Gasco | a07099d | 2021-10-14 15:33:41 -0400 | [diff] [blame] | 347 | |
| 348 | // Whether this APEX can be compressed or not. Setting this property to false means this |
| 349 | // APEX will never be compressed. When set to true, APEX will be compressed if other |
| 350 | // conditions, e.g., target device needs to support APEX compression, are also fulfilled. |
| 351 | // Default: false. |
| 352 | Compressible *bool |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | type apexBundle struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 356 | // Inherited structs |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 357 | android.ModuleBase |
| 358 | android.DefaultableModuleBase |
| 359 | android.OverridableModuleBase |
| 360 | android.SdkBase |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 361 | android.BazelModuleBase |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 362 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 363 | // Properties |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 364 | properties apexBundleProperties |
| 365 | targetProperties apexTargetBundleProperties |
Jiyong Park | 5914030 | 2020-12-14 18:44:04 +0900 | [diff] [blame] | 366 | archProperties apexArchBundleProperties |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 367 | overridableProperties overridableProperties |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 368 | vndkProperties apexVndkProperties // only for apex_vndk modules |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 369 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 370 | /////////////////////////////////////////////////////////////////////////////////////////// |
| 371 | // Inputs |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 372 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 373 | // Keys for apex_paylaod.img |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 374 | publicKeyFile android.Path |
| 375 | privateKeyFile android.Path |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 376 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 377 | // Cert/priv-key for the zip container |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 378 | containerCertificateFile android.Path |
| 379 | containerPrivateKeyFile android.Path |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 380 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 381 | // Flags for special variants of APEX |
| 382 | testApex bool |
| 383 | vndkApex bool |
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 | // Tells whether this variant of the APEX bundle is the primary one or not. Only the primary |
| 386 | // one gets installed to the device. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 387 | primaryApexType bool |
| 388 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 389 | // Suffix of module name in Android.mk ".flattened", ".apex", ".zipapex", or "" |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 390 | suffix string |
| 391 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 392 | // File system type of apex_payload.img |
| 393 | payloadFsType fsType |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 394 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 395 | // Whether to create symlink to the system file instead of having a file inside the apex or |
| 396 | // not |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 397 | linkToSystemLib bool |
| 398 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 399 | // List of files to be included in this APEX. This is filled in the first part of |
| 400 | // GenerateAndroidBuildActions. |
| 401 | filesInfo []apexFile |
| 402 | |
| 403 | // List of other module names that should be installed when this APEX gets installed. |
| 404 | requiredDeps []string |
| 405 | |
| 406 | /////////////////////////////////////////////////////////////////////////////////////////// |
| 407 | // Outputs (final and intermediates) |
| 408 | |
| 409 | // Processed apex manifest in JSONson format (for Q) |
| 410 | manifestJsonOut android.WritablePath |
| 411 | |
| 412 | // Processed apex manifest in PB format (for R+) |
| 413 | manifestPbOut android.WritablePath |
| 414 | |
| 415 | // Processed file_contexts files |
| 416 | fileContexts android.WritablePath |
| 417 | |
Bob Badour | de6a087 | 2022-04-01 18:00:00 +0000 | [diff] [blame] | 418 | // Path to notice file in html.gz format. |
| 419 | htmlGzNotice android.WritablePath |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 420 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 421 | // The built APEX file. This is the main product. |
Jooyung Han | a6d3667 | 2022-02-24 13:58:07 +0900 | [diff] [blame] | 422 | // Could be .apex or .capex |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 423 | outputFile android.WritablePath |
| 424 | |
Jooyung Han | a6d3667 | 2022-02-24 13:58:07 +0900 | [diff] [blame] | 425 | // The built uncompressed .apex file. |
| 426 | outputApexFile android.WritablePath |
| 427 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 428 | // The built APEX file in app bundle format. This file is not directly installed to the |
| 429 | // device. For an APEX, multiple app bundles are created each of which is for a specific ABI |
| 430 | // like arm, arm64, x86, etc. Then they are processed again (outside of the Android build |
| 431 | // system) to be merged into a single app bundle file that Play accepts. See |
| 432 | // vendor/google/build/build_unbundled_mainline_module.sh for more detail. |
| 433 | bundleModuleFile android.WritablePath |
| 434 | |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame] | 435 | // Target directory to install this APEX. Usually out/target/product/<device>/<partition>/apex. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 436 | installDir android.InstallPath |
| 437 | |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame] | 438 | // Path where this APEX was installed. |
| 439 | installedFile android.InstallPath |
| 440 | |
| 441 | // Installed locations of symlinks for backward compatibility. |
| 442 | compatSymlinks android.InstallPaths |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 443 | |
| 444 | // Text file having the list of individual files that are included in this APEX. Used for |
| 445 | // debugging purpose. |
| 446 | installedFilesFile android.WritablePath |
| 447 | |
| 448 | // List of module names that this APEX is including (to be shown via *-deps-info target). |
| 449 | // Used for debugging purpose. |
| 450 | android.ApexBundleDepsInfo |
| 451 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 452 | // Optional list of lint report zip files for apexes that contain java or app modules |
| 453 | lintReports android.Paths |
| 454 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 455 | prebuiltFileToDelete string |
sophiez | c80a2b3 | 2020-11-12 16:39:19 +0000 | [diff] [blame] | 456 | |
Mohammad Samiul Islam | 3cd005d | 2020-11-26 13:32:26 +0000 | [diff] [blame] | 457 | isCompressed bool |
| 458 | |
sophiez | c80a2b3 | 2020-11-12 16:39:19 +0000 | [diff] [blame] | 459 | // Path of API coverage generate file |
sophiez | 0234737 | 2021-11-02 17:58:02 -0700 | [diff] [blame] | 460 | nativeApisUsedByModuleFile android.ModuleOutPath |
| 461 | nativeApisBackedByModuleFile android.ModuleOutPath |
| 462 | javaApisUsedByModuleFile android.ModuleOutPath |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 463 | |
| 464 | // Collect the module directory for IDE info in java/jdeps.go. |
| 465 | modulePaths []string |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 466 | } |
| 467 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 468 | // apexFileClass represents a type of file that can be included in APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 469 | type apexFileClass int |
| 470 | |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 471 | const ( |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 472 | app apexFileClass = iota |
| 473 | appSet |
| 474 | etc |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 475 | goBinary |
| 476 | javaSharedLib |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 477 | nativeExecutable |
| 478 | nativeSharedLib |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 479 | nativeTest |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 480 | pyBinary |
| 481 | shBinary |
Jooyung Han | 72bd2f8 | 2019-10-23 16:46:38 +0900 | [diff] [blame] | 482 | ) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 483 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 484 | // apexFile represents a file in an APEX bundle. This is created during the first half of |
| 485 | // GenerateAndroidBuildActions by traversing the dependencies of the APEX. Then in the second half |
| 486 | // of the function, this is used to create commands that copies the files into a staging directory, |
| 487 | // where they are packaged into the APEX file. This struct is also used for creating Make modules |
| 488 | // for each of the files in case when the APEX is flattened. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 489 | type apexFile struct { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 490 | // buildFile is put in the installDir inside the APEX. |
Bob Badour | de6a087 | 2022-04-01 18:00:00 +0000 | [diff] [blame] | 491 | builtFile android.Path |
| 492 | installDir string |
| 493 | customStem string |
| 494 | symlinks []string // additional symlinks |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 495 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 496 | // Info for Android.mk Module name of `module` in AndroidMk. Note the generated AndroidMk |
| 497 | // module for apexFile is named something like <AndroidMk module name>.<apex name>[<apex |
| 498 | // suffix>] |
| 499 | androidMkModuleName string // becomes LOCAL_MODULE |
| 500 | class apexFileClass // becomes LOCAL_MODULE_CLASS |
| 501 | moduleDir string // becomes LOCAL_PATH |
| 502 | requiredModuleNames []string // becomes LOCAL_REQUIRED_MODULES |
| 503 | targetRequiredModuleNames []string // becomes LOCAL_TARGET_REQUIRED_MODULES |
| 504 | hostRequiredModuleNames []string // becomes LOCAL_HOST_REQUIRED_MODULES |
| 505 | dataPaths []android.DataPath // becomes LOCAL_TEST_DATA |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 506 | |
| 507 | jacocoReportClassesFile android.Path // only for javalibs and apps |
| 508 | lintDepSets java.LintDepSets // only for javalibs and apps |
| 509 | certificate java.Certificate // only for apps |
| 510 | overriddenPackageName string // only for apps |
| 511 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 512 | transitiveDep bool |
| 513 | isJniLib bool |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 514 | |
Jiyong Park | 57621b2 | 2021-01-20 20:33:11 +0900 | [diff] [blame] | 515 | multilib string |
| 516 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 517 | // TODO(jiyong): remove this |
| 518 | module android.Module |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 519 | } |
| 520 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 521 | // TODO(jiyong): shorten the arglist using an option struct |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 522 | func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile { |
| 523 | ret := apexFile{ |
| 524 | builtFile: builtFile, |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 525 | installDir: installDir, |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 526 | androidMkModuleName: androidMkModuleName, |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 527 | class: class, |
| 528 | module: module, |
| 529 | } |
| 530 | if module != nil { |
| 531 | ret.moduleDir = ctx.OtherModuleDir(module) |
| 532 | ret.requiredModuleNames = module.RequiredModuleNames() |
| 533 | ret.targetRequiredModuleNames = module.TargetRequiredModuleNames() |
| 534 | ret.hostRequiredModuleNames = module.HostRequiredModuleNames() |
Jiyong Park | 57621b2 | 2021-01-20 20:33:11 +0900 | [diff] [blame] | 535 | ret.multilib = module.Target().Arch.ArchType.Multilib |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 536 | } |
| 537 | return ret |
| 538 | } |
| 539 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 540 | func (af *apexFile) ok() bool { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 541 | return af.builtFile != nil && af.builtFile.String() != "" |
| 542 | } |
| 543 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 544 | // apexRelativePath returns the relative path of the given path from the install directory of this |
| 545 | // apexFile. |
| 546 | // TODO(jiyong): rename this |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 547 | func (af *apexFile) apexRelativePath(path string) string { |
| 548 | return filepath.Join(af.installDir, path) |
| 549 | } |
| 550 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 551 | // path returns path of this apex file relative to the APEX root |
| 552 | func (af *apexFile) path() string { |
| 553 | return af.apexRelativePath(af.stem()) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 554 | } |
| 555 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 556 | // stem returns the base filename of this apex file |
| 557 | func (af *apexFile) stem() string { |
| 558 | if af.customStem != "" { |
| 559 | return af.customStem |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 560 | } |
| 561 | return af.builtFile.Base() |
| 562 | } |
| 563 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 564 | // symlinkPaths returns paths of the symlinks (if any) relative to the APEX root |
| 565 | func (af *apexFile) symlinkPaths() []string { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 566 | var ret []string |
| 567 | for _, symlink := range af.symlinks { |
| 568 | ret = append(ret, af.apexRelativePath(symlink)) |
| 569 | } |
| 570 | return ret |
| 571 | } |
| 572 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 573 | // availableToPlatform tests whether this apexFile is from a module that can be installed to the |
| 574 | // platform. |
| 575 | func (af *apexFile) availableToPlatform() bool { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 576 | if af.module == nil { |
| 577 | return false |
| 578 | } |
| 579 | if am, ok := af.module.(android.ApexModule); ok { |
| 580 | return am.AvailableFor(android.AvailableToPlatform) |
| 581 | } |
| 582 | return false |
| 583 | } |
| 584 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 585 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 586 | // Mutators |
| 587 | // |
| 588 | // Brief description about mutators for APEX. The following three mutators are the most important |
| 589 | // ones. |
| 590 | // |
| 591 | // 1) DepsMutator: from the properties like native_shared_libs, java_libs, etc., modules are added |
| 592 | // to the (direct) dependencies of this APEX bundle. |
| 593 | // |
Paul Duffin | 949abc0 | 2020-12-08 10:34:30 +0000 | [diff] [blame] | 594 | // 2) apexInfoMutator: this is a post-deps mutator, so runs after DepsMutator. Its goal is to |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 595 | // collect modules that are direct and transitive dependencies of each APEX bundle. The collected |
| 596 | // modules are marked as being included in the APEX via BuildForApex(). |
| 597 | // |
Paul Duffin | 949abc0 | 2020-12-08 10:34:30 +0000 | [diff] [blame] | 598 | // 3) apexMutator: this is a post-deps mutator that runs after apexInfoMutator. For each module that |
| 599 | // are marked by the apexInfoMutator, apex variations are created using CreateApexVariations(). |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 600 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 601 | type dependencyTag struct { |
| 602 | blueprint.BaseDependencyTag |
| 603 | name string |
| 604 | |
| 605 | // Determines if the dependent will be part of the APEX payload. Can be false for the |
| 606 | // dependencies to the signing key module, etc. |
| 607 | payload bool |
Paul Duffin | 8c535da | 2021-03-17 14:51:03 +0000 | [diff] [blame] | 608 | |
| 609 | // True if the dependent can only be a source module, false if a prebuilt module is a suitable |
| 610 | // replacement. This is needed because some prebuilt modules do not provide all the information |
| 611 | // needed by the apex. |
| 612 | sourceOnly bool |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 613 | } |
| 614 | |
Paul Duffin | 8c535da | 2021-03-17 14:51:03 +0000 | [diff] [blame] | 615 | func (d dependencyTag) ReplaceSourceWithPrebuilt() bool { |
| 616 | return !d.sourceOnly |
| 617 | } |
| 618 | |
| 619 | var _ android.ReplaceSourceWithPrebuilt = &dependencyTag{} |
| 620 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 621 | var ( |
Paul Duffin | 0b81778 | 2021-03-17 15:02:19 +0000 | [diff] [blame] | 622 | androidAppTag = dependencyTag{name: "androidApp", payload: true} |
| 623 | bpfTag = dependencyTag{name: "bpf", payload: true} |
| 624 | certificateTag = dependencyTag{name: "certificate"} |
| 625 | executableTag = dependencyTag{name: "executable", payload: true} |
| 626 | fsTag = dependencyTag{name: "filesystem", payload: true} |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 627 | bcpfTag = dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true} |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 628 | sscpfTag = dependencyTag{name: "systemserverclasspathFragment", payload: true, sourceOnly: true} |
Paul Duffin | 1b29e00 | 2021-03-16 15:06:54 +0000 | [diff] [blame] | 629 | compatConfigTag = dependencyTag{name: "compatConfig", payload: true, sourceOnly: true} |
Paul Duffin | 0b81778 | 2021-03-17 15:02:19 +0000 | [diff] [blame] | 630 | javaLibTag = dependencyTag{name: "javaLib", payload: true} |
| 631 | jniLibTag = dependencyTag{name: "jniLib", payload: true} |
| 632 | keyTag = dependencyTag{name: "key"} |
| 633 | prebuiltTag = dependencyTag{name: "prebuilt", payload: true} |
| 634 | rroTag = dependencyTag{name: "rro", payload: true} |
| 635 | sharedLibTag = dependencyTag{name: "sharedLib", payload: true} |
| 636 | testForTag = dependencyTag{name: "test for"} |
| 637 | testTag = dependencyTag{name: "test", payload: true} |
Sundong Ahn | 80c0489 | 2021-11-23 00:57:19 +0000 | [diff] [blame] | 638 | shBinaryTag = dependencyTag{name: "shBinary", payload: true} |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 639 | ) |
| 640 | |
| 641 | // TODO(jiyong): shorten this function signature |
| 642 | func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeModules ApexNativeDependencies, target android.Target, imageVariation string) { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 643 | binVariations := target.Variations() |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 644 | libVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"}) |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 645 | rustLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "rust_libraries", Variation: "dylib"}) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 646 | |
| 647 | if ctx.Device() { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 648 | binVariations = append(binVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation}) |
Jiyong Park | f2cc1b7 | 2020-12-09 00:20:45 +0900 | [diff] [blame] | 649 | libVariations = append(libVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation}) |
| 650 | rustLibVariations = append(rustLibVariations, blueprint.Variation{Mutator: "image", Variation: imageVariation}) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 651 | } |
| 652 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 653 | // Use *FarVariation* to be able to depend on modules having conflicting variations with |
| 654 | // this module. This is required since arch variant of an APEX bundle is 'common' but it is |
| 655 | // 'arm' or 'arm64' for native shared libs. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 656 | ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 657 | ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 658 | ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...) |
| 659 | ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...) |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 660 | ctx.AddFarVariationDependencies(rustLibVariations, sharedLibTag, nativeModules.Rust_dyn_libs...) |
Jiyong Park | 0671146 | 2021-02-15 17:54:43 +0900 | [diff] [blame] | 661 | ctx.AddFarVariationDependencies(target.Variations(), fsTag, nativeModules.Filesystems...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 665 | if ctx.Device() { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 666 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil) |
| 667 | } else { |
| 668 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil) |
| 669 | if ctx.Os().Bionic() { |
| 670 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil) |
| 671 | } else { |
| 672 | proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil) |
| 673 | } |
| 674 | } |
| 675 | } |
| 676 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 677 | // getImageVariation returns the image variant name for this apexBundle. In most cases, it's simply |
| 678 | // android.CoreVariation, but gets complicated for the vendor APEXes and the VNDK APEX. |
| 679 | func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) string { |
| 680 | deviceConfig := ctx.DeviceConfig() |
| 681 | if a.vndkApex { |
| 682 | return cc.VendorVariationPrefix + a.vndkVersion(deviceConfig) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 683 | } |
| 684 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 685 | var prefix string |
| 686 | var vndkVersion string |
| 687 | if deviceConfig.VndkVersion() != "" { |
Steven Moreland | 2c4000c | 2021-04-27 02:08:49 +0000 | [diff] [blame] | 688 | if a.SocSpecific() || a.DeviceSpecific() { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 689 | prefix = cc.VendorVariationPrefix |
| 690 | vndkVersion = deviceConfig.VndkVersion() |
| 691 | } else if a.ProductSpecific() { |
| 692 | prefix = cc.ProductVariationPrefix |
| 693 | vndkVersion = deviceConfig.ProductVndkVersion() |
| 694 | } |
| 695 | } |
| 696 | if vndkVersion == "current" { |
| 697 | vndkVersion = deviceConfig.PlatformVndkVersion() |
| 698 | } |
| 699 | if vndkVersion != "" { |
| 700 | return prefix + vndkVersion |
| 701 | } |
| 702 | |
| 703 | return android.CoreVariation // The usual case |
| 704 | } |
| 705 | |
| 706 | func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 707 | // apexBundle is a multi-arch targets module. Arch variant of apexBundle is set to 'common'. |
| 708 | // arch-specific targets are enabled by the compile_multilib setting of the apex bundle. For |
| 709 | // each target os/architectures, appropriate dependencies are selected by their |
| 710 | // target.<os>.multilib.<type> groups and are added as (direct) dependencies. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 711 | targets := ctx.MultiTargets() |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 712 | imageVariation := a.getImageVariation(ctx) |
| 713 | |
| 714 | a.combineProperties(ctx) |
| 715 | |
| 716 | has32BitTarget := false |
| 717 | for _, target := range targets { |
| 718 | if target.Arch.ArchType.Multilib == "lib32" { |
| 719 | has32BitTarget = true |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 720 | } |
| 721 | } |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 722 | for i, target := range targets { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 723 | // Don't include artifacts for the host cross targets because there is no way for us |
| 724 | // to run those artifacts natively on host |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 725 | if target.HostCross { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 726 | continue |
| 727 | } |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 728 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 729 | var depsList []ApexNativeDependencies |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 730 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 731 | // Add native modules targeting both ABIs. When multilib.* is omitted for |
| 732 | // native_shared_libs/jni_libs/tests, it implies multilib.both |
| 733 | depsList = append(depsList, a.properties.Multilib.Both) |
| 734 | depsList = append(depsList, ApexNativeDependencies{ |
| 735 | Native_shared_libs: a.properties.Native_shared_libs, |
| 736 | Tests: a.properties.Tests, |
| 737 | Jni_libs: a.properties.Jni_libs, |
| 738 | Binaries: nil, |
| 739 | }) |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame] | 740 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 741 | // Add native modules targeting the first ABI When multilib.* is omitted for |
| 742 | // binaries, it implies multilib.first |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 743 | isPrimaryAbi := i == 0 |
| 744 | if isPrimaryAbi { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 745 | depsList = append(depsList, a.properties.Multilib.First) |
| 746 | depsList = append(depsList, ApexNativeDependencies{ |
| 747 | Native_shared_libs: nil, |
| 748 | Tests: nil, |
| 749 | Jni_libs: nil, |
| 750 | Binaries: a.properties.Binaries, |
| 751 | }) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 752 | } |
| 753 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 754 | // Add native modules targeting either 32-bit or 64-bit ABI |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 755 | switch target.Arch.ArchType.Multilib { |
| 756 | case "lib32": |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 757 | depsList = append(depsList, a.properties.Multilib.Lib32) |
| 758 | depsList = append(depsList, a.properties.Multilib.Prefer32) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 759 | case "lib64": |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 760 | depsList = append(depsList, a.properties.Multilib.Lib64) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 761 | if !has32BitTarget { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 762 | depsList = append(depsList, a.properties.Multilib.Prefer32) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 763 | } |
| 764 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 765 | |
Jiyong Park | 5914030 | 2020-12-14 18:44:04 +0900 | [diff] [blame] | 766 | // Add native modules targeting a specific arch variant |
| 767 | switch target.Arch.ArchType { |
| 768 | case android.Arm: |
| 769 | depsList = append(depsList, a.archProperties.Arch.Arm.ApexNativeDependencies) |
| 770 | case android.Arm64: |
| 771 | depsList = append(depsList, a.archProperties.Arch.Arm64.ApexNativeDependencies) |
| 772 | case android.X86: |
| 773 | depsList = append(depsList, a.archProperties.Arch.X86.ApexNativeDependencies) |
| 774 | case android.X86_64: |
| 775 | depsList = append(depsList, a.archProperties.Arch.X86_64.ApexNativeDependencies) |
| 776 | default: |
| 777 | panic(fmt.Errorf("unsupported arch %v\n", ctx.Arch().ArchType)) |
| 778 | } |
| 779 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 780 | for _, d := range depsList { |
| 781 | addDependenciesForNativeModules(ctx, d, target, imageVariation) |
| 782 | } |
Sundong Ahn | 80c0489 | 2021-11-23 00:57:19 +0000 | [diff] [blame] | 783 | ctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 784 | {Mutator: "os", Variation: target.OsVariation()}, |
| 785 | {Mutator: "arch", Variation: target.ArchVariation()}, |
| 786 | }, shBinaryTag, a.properties.Sh_binaries...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 787 | } |
| 788 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 789 | // Common-arch dependencies come next |
| 790 | commonVariation := ctx.Config().AndroidCommonTarget.Variations() |
Jiyong Park | 12a719c | 2021-01-07 15:31:24 +0900 | [diff] [blame] | 791 | ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...) |
Paul Duffin | 0b81778 | 2021-03-17 15:02:19 +0000 | [diff] [blame] | 792 | ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 793 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 794 | // Marks that this APEX (in fact all the modules in it) has to be built with the given SDKs. |
| 795 | // This field currently isn't used. |
| 796 | // TODO(jiyong): consider dropping this feature |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 797 | // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks |
| 798 | if len(a.properties.Uses_sdks) > 0 { |
| 799 | sdkRefs := []android.SdkRef{} |
| 800 | for _, str := range a.properties.Uses_sdks { |
| 801 | parsed := android.ParseSdkRef(ctx, str, "uses_sdks") |
| 802 | sdkRefs = append(sdkRefs, parsed) |
| 803 | } |
| 804 | a.BuildWithSdks(sdkRefs) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 805 | } |
| 806 | } |
| 807 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 808 | // DepsMutator for the overridden properties. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 809 | func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) { |
| 810 | if a.overridableProperties.Allowed_files != nil { |
| 811 | android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files) |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 812 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 813 | |
| 814 | commonVariation := ctx.Config().AndroidCommonTarget.Variations() |
| 815 | ctx.AddFarVariationDependencies(commonVariation, androidAppTag, a.overridableProperties.Apps...) |
markchien | 7c803b8 | 2021-08-26 22:10:06 +0800 | [diff] [blame] | 816 | ctx.AddFarVariationDependencies(commonVariation, bpfTag, a.overridableProperties.Bpfs...) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 817 | ctx.AddFarVariationDependencies(commonVariation, rroTag, a.overridableProperties.Rros...) |
Remi NGUYEN VAN | be90172 | 2022-03-02 21:00:33 +0900 | [diff] [blame] | 818 | ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.overridableProperties.Bootclasspath_fragments...) |
| 819 | ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.overridableProperties.Systemserverclasspath_fragments...) |
| 820 | ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.overridableProperties.Java_libs...) |
Daniel Norman | 5a3ce13 | 2021-08-26 15:44:43 -0700 | [diff] [blame] | 821 | if prebuilts := a.overridableProperties.Prebuilts; len(prebuilts) > 0 { |
| 822 | // For prebuilt_etc, use the first variant (64 on 64/32bit device, 32 on 32bit device) |
| 823 | // regardless of the TARGET_PREFER_* setting. See b/144532908 |
| 824 | arches := ctx.DeviceConfig().Arches() |
| 825 | if len(arches) != 0 { |
| 826 | archForPrebuiltEtc := arches[0] |
| 827 | for _, arch := range arches { |
| 828 | // Prefer 64-bit arch if there is any |
| 829 | if arch.ArchType.Multilib == "lib64" { |
| 830 | archForPrebuiltEtc = arch |
| 831 | break |
| 832 | } |
| 833 | } |
| 834 | ctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 835 | {Mutator: "os", Variation: ctx.Os().String()}, |
| 836 | {Mutator: "arch", Variation: archForPrebuiltEtc.String()}, |
| 837 | }, prebuiltTag, prebuilts...) |
| 838 | } |
| 839 | } |
Jaewoong Jung | 4cfdf7d | 2021-04-20 16:21:24 -0700 | [diff] [blame] | 840 | |
| 841 | // Dependencies for signing |
| 842 | if String(a.overridableProperties.Key) == "" { |
| 843 | ctx.PropertyErrorf("key", "missing") |
| 844 | return |
| 845 | } |
| 846 | ctx.AddDependency(ctx.Module(), keyTag, String(a.overridableProperties.Key)) |
| 847 | |
| 848 | cert := android.SrcIsModule(a.getCertString(ctx)) |
| 849 | if cert != "" { |
| 850 | ctx.AddDependency(ctx.Module(), certificateTag, cert) |
| 851 | // empty cert is not an error. Cert and private keys will be directly found under |
| 852 | // PRODUCT_DEFAULT_DEV_CERTIFICATE |
| 853 | } |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 854 | } |
| 855 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 856 | type ApexBundleInfo struct { |
| 857 | Contents *android.ApexContents |
Andrei Onea | 115e7e7 | 2020-06-05 21:14:03 +0100 | [diff] [blame] | 858 | } |
| 859 | |
Paul Duffin | 949abc0 | 2020-12-08 10:34:30 +0000 | [diff] [blame] | 860 | var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_info") |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 861 | |
Paul Duffin | a7d6a89 | 2020-12-07 17:39:59 +0000 | [diff] [blame] | 862 | var _ ApexInfoMutator = (*apexBundle)(nil) |
| 863 | |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 864 | func (a *apexBundle) ApexVariationName() string { |
| 865 | return a.properties.ApexVariationName |
| 866 | } |
| 867 | |
Paul Duffin | a7d6a89 | 2020-12-07 17:39:59 +0000 | [diff] [blame] | 868 | // ApexInfoMutator is responsible for collecting modules that need to have apex variants. They are |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 869 | // identified by doing a graph walk starting from an apexBundle. Basically, all the (direct and |
| 870 | // indirect) dependencies are collected. But a few types of modules that shouldn't be included in |
| 871 | // the apexBundle (e.g. stub libraries) are not collected. Note that a single module can be depended |
| 872 | // on by multiple apexBundles. In that case, the module is collected for all of the apexBundles. |
Paul Duffin | 949abc0 | 2020-12-08 10:34:30 +0000 | [diff] [blame] | 873 | // |
| 874 | // For each dependency between an apex and an ApexModule an ApexInfo object describing the apex |
| 875 | // is passed to that module's BuildForApex(ApexInfo) method which collates them all in a list. |
| 876 | // The apexMutator uses that list to create module variants for the apexes to which it belongs. |
| 877 | // The relationship between module variants and apexes is not one-to-one as variants will be |
| 878 | // shared between compatible apexes. |
Paul Duffin | a7d6a89 | 2020-12-07 17:39:59 +0000 | [diff] [blame] | 879 | func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 880 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 881 | // The VNDK APEX is special. For the APEX, the membership is described in a very different |
| 882 | // way. There is no dependency from the VNDK APEX to the VNDK libraries. Instead, VNDK |
| 883 | // libraries are self-identified by their vndk.enabled properties. There is no need to run |
| 884 | // this mutator for the APEX as nothing will be collected. So, let's return fast. |
| 885 | if a.vndkApex { |
| 886 | return |
| 887 | } |
| 888 | |
| 889 | // Special casing for APEXes on non-system (e.g., vendor, odm, etc.) partitions. They are |
| 890 | // provided with a property named use_vndk_as_stable, which when set to true doesn't collect |
| 891 | // VNDK libraries as transitive dependencies. This option is useful for reducing the size of |
| 892 | // the non-system APEXes because the VNDK libraries won't be included (and duped) in the |
| 893 | // APEX, but shared across APEXes via the VNDK APEX. |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 894 | useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface()) |
| 895 | excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) |
Jooyung Han | c5a9676 | 2022-02-04 11:54:50 +0900 | [diff] [blame] | 896 | if proptools.Bool(a.properties.Use_vndk_as_stable) { |
| 897 | if !useVndk { |
| 898 | mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes") |
| 899 | } |
| 900 | mctx.VisitDirectDepsWithTag(sharedLibTag, func(dep android.Module) { |
| 901 | if c, ok := dep.(*cc.Module); ok && c.IsVndk() { |
| 902 | mctx.PropertyErrorf("use_vndk_as_stable", "Trying to include a VNDK library(%s) while use_vndk_as_stable is true.", dep.Name()) |
| 903 | } |
| 904 | }) |
| 905 | if mctx.Failed() { |
| 906 | return |
| 907 | } |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 908 | } |
| 909 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 910 | continueApexDepsWalk := func(child, parent android.Module) bool { |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 911 | am, ok := child.(android.ApexModule) |
| 912 | if !ok || !am.CanHaveApexVariants() { |
| 913 | return false |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 914 | } |
Paul Duffin | 573989d | 2021-03-17 13:25:29 +0000 | [diff] [blame] | 915 | depTag := mctx.OtherModuleDependencyTag(child) |
| 916 | |
| 917 | // Check to see if the tag always requires that the child module has an apex variant for every |
| 918 | // apex variant of the parent module. If it does not then it is still possible for something |
| 919 | // else, e.g. the DepIsInSameApex(...) method to decide that a variant is required. |
| 920 | if required, ok := depTag.(android.AlwaysRequireApexVariantTag); ok && required.AlwaysRequireApexVariant() { |
| 921 | return true |
| 922 | } |
Paul Duffin | 4c3e8e2 | 2021-03-18 15:41:29 +0000 | [diff] [blame] | 923 | if !android.IsDepInSameApex(mctx, parent, child) { |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 924 | return false |
| 925 | } |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 926 | if excludeVndkLibs { |
| 927 | if c, ok := child.(*cc.Module); ok && c.IsVndk() { |
| 928 | return false |
| 929 | } |
| 930 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 931 | // By default, all the transitive dependencies are collected, unless filtered out |
| 932 | // above. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 933 | return true |
| 934 | } |
| 935 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 936 | // Records whether a certain module is included in this apexBundle via direct dependency or |
| 937 | // inndirect dependency. |
| 938 | contents := make(map[string]android.ApexMembership) |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 939 | mctx.WalkDeps(func(child, parent android.Module) bool { |
| 940 | if !continueApexDepsWalk(child, parent) { |
| 941 | return false |
| 942 | } |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 943 | // If the parent is apexBundle, this child is directly depended. |
| 944 | _, directDep := parent.(*apexBundle) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 945 | depName := mctx.OtherModuleName(child) |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 946 | contents[depName] = contents[depName].Add(directDep) |
| 947 | return true |
| 948 | }) |
| 949 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 950 | // The membership information is saved for later access |
Jiyong Park | e4758ed | 2020-11-18 01:34:22 +0900 | [diff] [blame] | 951 | apexContents := android.NewApexContents(contents) |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 952 | mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{ |
| 953 | Contents: apexContents, |
| 954 | }) |
| 955 | |
Jooyung Han | ed124c3 | 2021-01-26 11:43:46 +0900 | [diff] [blame] | 956 | minSdkVersion := a.minSdkVersion(mctx) |
| 957 | // When min_sdk_version is not set, the apex is built against FutureApiLevel. |
| 958 | if minSdkVersion.IsNone() { |
| 959 | minSdkVersion = android.FutureApiLevel |
| 960 | } |
| 961 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 962 | // This is the main part of this mutator. Mark the collected dependencies that they need to |
| 963 | // be built for this apexBundle. |
Jiyong Park | 78349b5 | 2021-05-12 17:13:56 +0900 | [diff] [blame] | 964 | |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 965 | apexVariationName := proptools.StringDefault(a.properties.Apex_name, mctx.ModuleName()) // could be com.android.foo |
| 966 | a.properties.ApexVariationName = apexVariationName |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 967 | apexInfo := android.ApexInfo{ |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 968 | ApexVariationName: apexVariationName, |
Jiyong Park | 4eab21d | 2021-04-15 15:17:54 +0900 | [diff] [blame] | 969 | MinSdkVersion: minSdkVersion, |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 970 | RequiredSdks: a.RequiredSdks(), |
| 971 | Updatable: a.Updatable(), |
Jiyong Park | 1bc8412 | 2021-06-22 20:23:05 +0900 | [diff] [blame] | 972 | UsePlatformApis: a.UsePlatformApis(), |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 973 | InApexVariants: []string{apexVariationName}, |
| 974 | InApexModules: []string{a.Name()}, // could be com.mycompany.android.foo |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 975 | ApexContents: []*android.ApexContents{apexContents}, |
| 976 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 977 | mctx.WalkDeps(func(child, parent android.Module) bool { |
| 978 | if !continueApexDepsWalk(child, parent) { |
| 979 | return false |
| 980 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 981 | child.(android.ApexModule).BuildForApex(apexInfo) // leave a mark! |
Jooyung Han | 698dd9f | 2020-07-22 15:17:19 +0900 | [diff] [blame] | 982 | return true |
Jiyong Park | f760cae | 2020-02-12 07:53:12 +0900 | [diff] [blame] | 983 | }) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 984 | } |
| 985 | |
Paul Duffin | a7d6a89 | 2020-12-07 17:39:59 +0000 | [diff] [blame] | 986 | type ApexInfoMutator interface { |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 987 | // ApexVariationName returns the name of the APEX variation to use in the apex |
| 988 | // mutator etc. It is the same name as ApexInfo.ApexVariationName. |
| 989 | ApexVariationName() string |
| 990 | |
Paul Duffin | a7d6a89 | 2020-12-07 17:39:59 +0000 | [diff] [blame] | 991 | // ApexInfoMutator implementations must call BuildForApex(ApexInfo) on any modules that are |
| 992 | // depended upon by an apex and which require an apex specific variant. |
| 993 | ApexInfoMutator(android.TopDownMutatorContext) |
| 994 | } |
| 995 | |
| 996 | // apexInfoMutator delegates the work of identifying which modules need an ApexInfo and apex |
| 997 | // specific variant to modules that support the ApexInfoMutator. |
| 998 | func apexInfoMutator(mctx android.TopDownMutatorContext) { |
| 999 | if !mctx.Module().Enabled() { |
| 1000 | return |
| 1001 | } |
| 1002 | |
| 1003 | if a, ok := mctx.Module().(ApexInfoMutator); ok { |
| 1004 | a.ApexInfoMutator(mctx) |
| 1005 | return |
| 1006 | } |
| 1007 | } |
| 1008 | |
Spandan Das | 6677325 | 2022-01-15 00:23:18 +0000 | [diff] [blame] | 1009 | // apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module |
| 1010 | // This check is enforced for updatable modules |
| 1011 | func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) { |
| 1012 | if !mctx.Module().Enabled() { |
| 1013 | return |
| 1014 | } |
Spandan Das | 08c911f | 2022-01-21 22:07:26 +0000 | [diff] [blame] | 1015 | if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() { |
Spandan Das | 6677325 | 2022-01-15 00:23:18 +0000 | [diff] [blame] | 1016 | mctx.WalkDeps(func(child, parent android.Module) bool { |
Spandan Das | d9c23ab | 2022-02-10 02:34:13 +0000 | [diff] [blame] | 1017 | // b/208656169 Do not propagate strict updatability linting to libcore/ |
| 1018 | // These libs are available on the classpath during compilation |
| 1019 | // These libs are transitive deps of the sdk. See java/sdk.go:decodeSdkDep |
| 1020 | // Only skip libraries defined in libcore root, not subdirectories |
| 1021 | if mctx.OtherModuleDir(child) == "libcore" { |
| 1022 | // Do not traverse transitive deps of libcore/ libs |
| 1023 | return false |
| 1024 | } |
Spandan Das | 2cf278e | 2022-03-24 20:19:35 +0000 | [diff] [blame] | 1025 | if android.InList(child.Name(), skipLintJavalibAllowlist) { |
| 1026 | return false |
| 1027 | } |
Spandan Das | 6677325 | 2022-01-15 00:23:18 +0000 | [diff] [blame] | 1028 | if lintable, ok := child.(java.LintDepSetsIntf); ok { |
| 1029 | lintable.SetStrictUpdatabilityLinting(true) |
| 1030 | } |
| 1031 | // visit transitive deps |
| 1032 | return true |
| 1033 | }) |
| 1034 | } |
| 1035 | } |
| 1036 | |
Spandan Das | 08c911f | 2022-01-21 22:07:26 +0000 | [diff] [blame] | 1037 | // TODO: b/215736885 Whittle the denylist |
| 1038 | // Transitive deps of certain mainline modules baseline NewApi errors |
| 1039 | // Skip these mainline modules for now |
| 1040 | var ( |
| 1041 | skipStrictUpdatabilityLintAllowlist = []string{ |
| 1042 | "com.android.art", |
| 1043 | "com.android.art.debug", |
| 1044 | "com.android.conscrypt", |
| 1045 | "com.android.media", |
| 1046 | // test apexes |
| 1047 | "test_com.android.art", |
| 1048 | "test_com.android.conscrypt", |
| 1049 | "test_com.android.media", |
| 1050 | "test_jitzygote_com.android.art", |
| 1051 | } |
Spandan Das | 2cf278e | 2022-03-24 20:19:35 +0000 | [diff] [blame] | 1052 | |
| 1053 | // TODO: b/215736885 Remove this list |
| 1054 | skipLintJavalibAllowlist = []string{ |
| 1055 | "conscrypt.module.platform.api.stubs", |
| 1056 | "conscrypt.module.public.api.stubs", |
| 1057 | "conscrypt.module.public.api.stubs.system", |
| 1058 | "conscrypt.module.public.api.stubs.module_lib", |
| 1059 | "framework-media.stubs", |
| 1060 | "framework-media.stubs.system", |
| 1061 | "framework-media.stubs.module_lib", |
| 1062 | } |
Spandan Das | 08c911f | 2022-01-21 22:07:26 +0000 | [diff] [blame] | 1063 | ) |
| 1064 | |
| 1065 | func (a *apexBundle) checkStrictUpdatabilityLinting() bool { |
| 1066 | return a.Updatable() && !android.InList(a.ApexVariationName(), skipStrictUpdatabilityLintAllowlist) |
| 1067 | } |
| 1068 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1069 | // apexUniqueVariationsMutator checks if any dependencies use unique apex variations. If so, use |
| 1070 | // unique apex variations for this module. See android/apex.go for more about unique apex variant. |
| 1071 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | aede88c | 2020-08-11 12:17:01 -0700 | [diff] [blame] | 1072 | func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { |
| 1073 | if !mctx.Module().Enabled() { |
| 1074 | return |
| 1075 | } |
| 1076 | if am, ok := mctx.Module().(android.ApexModule); ok { |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1077 | android.UpdateUniqueApexVariationsForDeps(mctx, am) |
| 1078 | } |
| 1079 | } |
| 1080 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1081 | // apexTestForDepsMutator checks if this module is a test for an apex. If so, add a dependency on |
| 1082 | // the apex in order to retrieve its contents later. |
| 1083 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1084 | func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { |
| 1085 | if !mctx.Module().Enabled() { |
| 1086 | return |
| 1087 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1088 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 1089 | if testFor := am.TestFor(); len(testFor) > 0 { |
| 1090 | mctx.AddFarVariationDependencies([]blueprint.Variation{ |
| 1091 | {Mutator: "os", Variation: am.Target().OsVariation()}, |
| 1092 | {"arch", "common"}, |
| 1093 | }, testForTag, testFor...) |
| 1094 | } |
| 1095 | } |
| 1096 | } |
| 1097 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1098 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1099 | func apexTestForMutator(mctx android.BottomUpMutatorContext) { |
| 1100 | if !mctx.Module().Enabled() { |
| 1101 | return |
| 1102 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1103 | if _, ok := mctx.Module().(android.ApexModule); ok { |
| 1104 | var contents []*android.ApexContents |
| 1105 | for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) { |
| 1106 | abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo) |
| 1107 | contents = append(contents, abInfo.Contents) |
| 1108 | } |
| 1109 | mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{ |
| 1110 | ApexContents: contents, |
| 1111 | }) |
Colin Cross | aede88c | 2020-08-11 12:17:01 -0700 | [diff] [blame] | 1112 | } |
| 1113 | } |
| 1114 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1115 | // markPlatformAvailability marks whether or not a module can be available to platform. A module |
| 1116 | // cannot be available to platform if 1) it is explicitly marked as not available (i.e. |
| 1117 | // "//apex_available:platform" is absent) or 2) it depends on another module that isn't (or can't |
| 1118 | // be) available to platform |
| 1119 | // TODO(jiyong): move this to android/apex.go? |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 1120 | func markPlatformAvailability(mctx android.BottomUpMutatorContext) { |
| 1121 | // Host and recovery are not considered as platform |
| 1122 | if mctx.Host() || mctx.Module().InstallInRecovery() { |
| 1123 | return |
| 1124 | } |
| 1125 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1126 | am, ok := mctx.Module().(android.ApexModule) |
| 1127 | if !ok { |
| 1128 | return |
| 1129 | } |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 1130 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1131 | availableToPlatform := am.AvailableFor(android.AvailableToPlatform) |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 1132 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1133 | // If any of the dep is not available to platform, this module is also considered as being |
| 1134 | // not available to platform even if it has "//apex_available:platform" |
| 1135 | mctx.VisitDirectDeps(func(child android.Module) { |
Paul Duffin | 4c3e8e2 | 2021-03-18 15:41:29 +0000 | [diff] [blame] | 1136 | if !android.IsDepInSameApex(mctx, am, child) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1137 | // if the dependency crosses apex boundary, don't consider it |
| 1138 | return |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 1139 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1140 | if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() { |
| 1141 | availableToPlatform = false |
| 1142 | // TODO(b/154889534) trigger an error when 'am' has |
| 1143 | // "//apex_available:platform" |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 1144 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1145 | }) |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 1146 | |
Paul Duffin | b5769c1 | 2021-05-12 16:16:51 +0100 | [diff] [blame] | 1147 | // Exception 1: check to see if the module always requires it. |
| 1148 | if am.AlwaysRequiresPlatformApexVariant() { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1149 | availableToPlatform = true |
| 1150 | } |
| 1151 | |
| 1152 | // Exception 2: bootstrap bionic libraries are also always available to platform |
| 1153 | if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) { |
| 1154 | availableToPlatform = true |
| 1155 | } |
| 1156 | |
| 1157 | if !availableToPlatform { |
| 1158 | am.SetNotAvailableForPlatform() |
Jiyong Park | 89e850a | 2020-04-07 16:37:39 +0900 | [diff] [blame] | 1159 | } |
| 1160 | } |
| 1161 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1162 | // apexMutator visits each module and creates apex variations if the module was marked in the |
Paul Duffin | 949abc0 | 2020-12-08 10:34:30 +0000 | [diff] [blame] | 1163 | // previous run of apexInfoMutator. |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1164 | func apexMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 1165 | if !mctx.Module().Enabled() { |
| 1166 | return |
| 1167 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1168 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1169 | // This is the usual path. |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1170 | if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1171 | android.CreateApexVariations(mctx, am) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1172 | return |
| 1173 | } |
| 1174 | |
| 1175 | // apexBundle itself is mutated so that it and its dependencies have the same apex variant. |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 1176 | if ai, ok := mctx.Module().(ApexInfoMutator); ok && apexModuleTypeRequiresVariant(ai) { |
| 1177 | apexBundleName := ai.ApexVariationName() |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1178 | mctx.CreateVariations(apexBundleName) |
Martin Stjernholm | ec00900 | 2021-03-27 15:18:31 +0000 | [diff] [blame] | 1179 | if strings.HasPrefix(apexBundleName, "com.android.art") { |
| 1180 | // Create an alias from the platform variant. This is done to make |
| 1181 | // test_for dependencies work for modules that are split by the APEX |
| 1182 | // mutator, since test_for dependencies always go to the platform variant. |
| 1183 | // This doesn't happen for normal APEXes that are disjunct, so only do |
| 1184 | // this for the overlapping ART APEXes. |
| 1185 | // TODO(b/183882457): Remove this if the test_for functionality is |
| 1186 | // refactored to depend on the proper APEX variants instead of platform. |
| 1187 | mctx.CreateAliasVariation("", apexBundleName) |
| 1188 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1189 | } else if o, ok := mctx.Module().(*OverrideApex); ok { |
| 1190 | apexBundleName := o.GetOverriddenModuleName() |
| 1191 | if apexBundleName == "" { |
| 1192 | mctx.ModuleErrorf("base property is not set") |
| 1193 | return |
| 1194 | } |
| 1195 | mctx.CreateVariations(apexBundleName) |
Martin Stjernholm | ec00900 | 2021-03-27 15:18:31 +0000 | [diff] [blame] | 1196 | if strings.HasPrefix(apexBundleName, "com.android.art") { |
| 1197 | // TODO(b/183882457): See note for CreateAliasVariation above. |
| 1198 | mctx.CreateAliasVariation("", apexBundleName) |
| 1199 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1200 | } |
| 1201 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 1202 | |
Paul Duffin | 6717d88 | 2021-06-15 19:09:41 +0100 | [diff] [blame] | 1203 | // apexModuleTypeRequiresVariant determines whether the module supplied requires an apex specific |
| 1204 | // variant. |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 1205 | func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool { |
Paul Duffin | 6717d88 | 2021-06-15 19:09:41 +0100 | [diff] [blame] | 1206 | if a, ok := module.(*apexBundle); ok { |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 1207 | // TODO(jiyong): document the reason why the VNDK APEX is an exception here. |
Paul Duffin | 6717d88 | 2021-06-15 19:09:41 +0100 | [diff] [blame] | 1208 | return !a.vndkApex |
| 1209 | } |
| 1210 | |
Martin Stjernholm | bfffae7 | 2021-06-24 14:37:13 +0100 | [diff] [blame] | 1211 | return true |
Paul Duffin | 6717d88 | 2021-06-15 19:09:41 +0100 | [diff] [blame] | 1212 | } |
| 1213 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1214 | // See android.UpdateDirectlyInAnyApex |
| 1215 | // TODO(jiyong): move this to android/apex.go? |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 1216 | func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { |
| 1217 | if !mctx.Module().Enabled() { |
| 1218 | return |
| 1219 | } |
| 1220 | if am, ok := mctx.Module().(android.ApexModule); ok { |
| 1221 | android.UpdateDirectlyInAnyApex(mctx, am) |
| 1222 | } |
| 1223 | } |
| 1224 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1225 | // apexPackaging represents a specific packaging method for an APEX. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 1226 | type apexPackaging int |
| 1227 | |
| 1228 | const ( |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1229 | // imageApex is a packaging method where contents are included in a filesystem image which |
| 1230 | // 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] | 1231 | imageApex apexPackaging = iota |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1232 | |
| 1233 | // zipApex is a packaging method where contents are directly included in the zip container. |
| 1234 | // This is used for host-side testing - because the contents are easily accessible by |
| 1235 | // unzipping the container. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 1236 | zipApex |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1237 | |
| 1238 | // flattendApex is a packaging method where contents are not included in the APEX file, but |
| 1239 | // installed to /apex/<apexname> directory on the device. This packaging method is used for |
| 1240 | // old devices where the filesystem-based APEX file can't be supported. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 1241 | flattenedApex |
| 1242 | ) |
| 1243 | |
| 1244 | const ( |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1245 | // File extensions of an APEX for different packaging methods |
Samiul Islam | 7c02e26 | 2021-09-08 17:48:28 +0100 | [diff] [blame] | 1246 | imageApexSuffix = ".apex" |
| 1247 | imageCapexSuffix = ".capex" |
| 1248 | zipApexSuffix = ".zipapex" |
| 1249 | flattenedSuffix = ".flattened" |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 1250 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1251 | // variant names each of which is for a packaging method |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 1252 | imageApexType = "image" |
| 1253 | zipApexType = "zip" |
| 1254 | flattenedApexType = "flattened" |
| 1255 | |
Dan Willemsen | 47e1a75 | 2021-10-16 18:36:13 -0700 | [diff] [blame] | 1256 | ext4FsType = "ext4" |
| 1257 | f2fsFsType = "f2fs" |
Huang Jianan | 13cac63 | 2021-08-02 15:02:17 +0800 | [diff] [blame] | 1258 | erofsFsType = "erofs" |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 1259 | ) |
| 1260 | |
| 1261 | // The suffix for the output "file", not the module |
| 1262 | func (a apexPackaging) suffix() string { |
| 1263 | switch a { |
| 1264 | case imageApex: |
| 1265 | return imageApexSuffix |
| 1266 | case zipApex: |
| 1267 | return zipApexSuffix |
| 1268 | default: |
| 1269 | panic(fmt.Errorf("unknown APEX type %d", a)) |
| 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | func (a apexPackaging) name() string { |
| 1274 | switch a { |
| 1275 | case imageApex: |
| 1276 | return imageApexType |
| 1277 | case zipApex: |
| 1278 | return zipApexType |
| 1279 | default: |
| 1280 | panic(fmt.Errorf("unknown APEX type %d", a)) |
| 1281 | } |
| 1282 | } |
| 1283 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1284 | // apexFlattenedMutator creates one or more variations each of which is for a packaging method. |
| 1285 | // TODO(jiyong): give a better name to this mutator |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 1286 | func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { |
Jooyung Han | 49f6701 | 2020-04-17 13:43:10 +0900 | [diff] [blame] | 1287 | if !mctx.Module().Enabled() { |
| 1288 | return |
| 1289 | } |
Sundong Ahn | e8fb724 | 2019-09-17 13:50:45 +0900 | [diff] [blame] | 1290 | if ab, ok := mctx.Module().(*apexBundle); ok { |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1291 | var variants []string |
| 1292 | switch proptools.StringDefault(ab.properties.Payload_type, "image") { |
| 1293 | case "image": |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1294 | // This is the normal case. Note that both image and flattend APEXes are |
| 1295 | // created. The image type is installed to the system partition, while the |
| 1296 | // flattened APEX is (optionally) installed to the system_ext partition. |
| 1297 | // This is mostly for GSI which has to support wide range of devices. If GSI |
| 1298 | // is installed on a newer (APEX-capable) device, the image APEX in the |
| 1299 | // system will be used. However, if the same GSI is installed on an old |
| 1300 | // device which can't support image APEX, the flattened APEX in the |
| 1301 | // system_ext partion (which still is part of GSI) is used instead. |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1302 | variants = append(variants, imageApexType, flattenedApexType) |
| 1303 | case "zip": |
| 1304 | variants = append(variants, zipApexType) |
| 1305 | case "both": |
| 1306 | variants = append(variants, imageApexType, zipApexType, flattenedApexType) |
| 1307 | default: |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1308 | 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] | 1309 | return |
| 1310 | } |
| 1311 | |
| 1312 | modules := mctx.CreateLocalVariations(variants...) |
| 1313 | |
| 1314 | for i, v := range variants { |
| 1315 | switch v { |
| 1316 | case imageApexType: |
| 1317 | modules[i].(*apexBundle).properties.ApexType = imageApex |
| 1318 | case zipApexType: |
| 1319 | modules[i].(*apexBundle).properties.ApexType = zipApex |
| 1320 | case flattenedApexType: |
| 1321 | modules[i].(*apexBundle).properties.ApexType = flattenedApex |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1322 | // See the comment above for why system_ext. |
Jooyung Han | 91df208 | 2019-11-20 01:49:42 +0900 | [diff] [blame] | 1323 | if !mctx.Config().FlattenApex() && ab.Platform() { |
Sundong Ahn | d95aa2d | 2019-10-08 19:34:03 +0900 | [diff] [blame] | 1324 | modules[i].(*apexBundle).MakeAsSystemExt() |
| 1325 | } |
Sundong Ahn | abb6443 | 2019-10-22 13:58:29 +0900 | [diff] [blame] | 1326 | } |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 1327 | } |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1328 | } else if _, ok := mctx.Module().(*OverrideApex); ok { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1329 | // payload_type is forcibly overridden to "image" |
| 1330 | // TODO(jiyong): is this the right decision? |
Jiyong Park | 5d790c3 | 2019-11-15 18:40:32 +0900 | [diff] [blame] | 1331 | mctx.CreateVariations(imageApexType, flattenedApexType) |
Sundong Ahn | e9b5572 | 2019-09-06 17:37:42 +0900 | [diff] [blame] | 1332 | } |
| 1333 | } |
| 1334 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1335 | var _ android.DepIsInSameApex = (*apexBundle)(nil) |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 1336 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1337 | // Implements android.DepInInSameApex |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 1338 | func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
| 1339 | // 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] | 1340 | // 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] | 1341 | return true |
| 1342 | } |
| 1343 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1344 | var _ android.OutputFileProducer = (*apexBundle)(nil) |
| 1345 | |
| 1346 | // Implements android.OutputFileProducer |
| 1347 | func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) { |
| 1348 | switch tag { |
Paul Duffin | 74f0559 | 2020-11-25 16:37:46 +0000 | [diff] [blame] | 1349 | case "", android.DefaultDistTag: |
| 1350 | // This is the default dist path. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1351 | return android.Paths{a.outputFile}, nil |
Jooyung Han | a6d3667 | 2022-02-24 13:58:07 +0900 | [diff] [blame] | 1352 | case imageApexSuffix: |
| 1353 | // uncompressed one |
| 1354 | if a.outputApexFile != nil { |
| 1355 | return android.Paths{a.outputApexFile}, nil |
| 1356 | } |
| 1357 | fallthrough |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1358 | default: |
| 1359 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | var _ cc.Coverage = (*apexBundle)(nil) |
| 1364 | |
| 1365 | // Implements cc.Coverage |
| 1366 | func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool { |
| 1367 | return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled() |
| 1368 | } |
| 1369 | |
| 1370 | // Implements cc.Coverage |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 1371 | func (a *apexBundle) SetPreventInstall() { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1372 | a.properties.PreventInstall = true |
| 1373 | } |
| 1374 | |
| 1375 | // Implements cc.Coverage |
| 1376 | func (a *apexBundle) HideFromMake() { |
| 1377 | a.properties.HideFromMake = true |
Colin Cross | e6a83e6 | 2020-12-17 18:22:34 -0800 | [diff] [blame] | 1378 | // This HideFromMake is shadowing the ModuleBase one, call through to it for now. |
| 1379 | // TODO(ccross): untangle these |
| 1380 | a.ModuleBase.HideFromMake() |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | // Implements cc.Coverage |
| 1384 | func (a *apexBundle) MarkAsCoverageVariant(coverage bool) { |
| 1385 | a.properties.IsCoverageVariant = coverage |
| 1386 | } |
| 1387 | |
| 1388 | // Implements cc.Coverage |
| 1389 | func (a *apexBundle) EnableCoverageIfNeeded() {} |
| 1390 | |
| 1391 | var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil) |
| 1392 | |
Oriol Prieto Gasco | a07099d | 2021-10-14 15:33:41 -0400 | [diff] [blame] | 1393 | // Implements android.ApexBundleDepsInfoIntf |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1394 | func (a *apexBundle) Updatable() bool { |
Mathew Inwood | f8dcf5e | 2021-02-16 11:40:16 +0000 | [diff] [blame] | 1395 | return proptools.BoolDefault(a.properties.Updatable, true) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1396 | } |
| 1397 | |
Jiyong Park | f402058 | 2021-11-29 12:37:10 +0900 | [diff] [blame] | 1398 | func (a *apexBundle) FutureUpdatable() bool { |
| 1399 | return proptools.BoolDefault(a.properties.Future_updatable, false) |
| 1400 | } |
| 1401 | |
Jiyong Park | 1bc8412 | 2021-06-22 20:23:05 +0900 | [diff] [blame] | 1402 | func (a *apexBundle) UsePlatformApis() bool { |
| 1403 | return proptools.BoolDefault(a.properties.Platform_apis, false) |
| 1404 | } |
| 1405 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1406 | // getCertString returns the name of the cert that should be used to sign this APEX. This is |
| 1407 | // 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] | 1408 | func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string { |
Jooyung Han | 27151d9 | 2019-12-16 17:45:32 +0900 | [diff] [blame] | 1409 | moduleName := ctx.ModuleName() |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1410 | // VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the |
| 1411 | // OVERRIDE_* list, we check with the pseudo module name to see if its certificate is |
| 1412 | // overridden. |
Jooyung Han | 27151d9 | 2019-12-16 17:45:32 +0900 | [diff] [blame] | 1413 | if a.vndkApex { |
| 1414 | moduleName = vndkApexName |
| 1415 | } |
| 1416 | certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName) |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1417 | if overridden { |
Jaewoong Jung | acb6db3 | 2019-02-28 16:22:30 +0000 | [diff] [blame] | 1418 | return ":" + certificate |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1419 | } |
Jaewoong Jung | 4cfdf7d | 2021-04-20 16:21:24 -0700 | [diff] [blame] | 1420 | return String(a.overridableProperties.Certificate) |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1421 | } |
| 1422 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1423 | // See the installable property |
Jiyong Park | 92c0f9c | 2018-12-13 23:14:57 +0900 | [diff] [blame] | 1424 | func (a *apexBundle) installable() bool { |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 1425 | 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] | 1426 | } |
| 1427 | |
Nikita Ioffe | da6dc31 | 2021-06-09 19:43:46 +0100 | [diff] [blame] | 1428 | // See the generate_hashtree property |
| 1429 | func (a *apexBundle) shouldGenerateHashtree() bool { |
Nikita Ioffe | e261ae6 | 2021-06-16 18:15:03 +0100 | [diff] [blame] | 1430 | return proptools.BoolDefault(a.properties.Generate_hashtree, true) |
Nikita Ioffe | c72b5dd | 2019-12-07 17:30:22 +0000 | [diff] [blame] | 1431 | } |
| 1432 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1433 | // See the test_only_unsigned_payload property |
Dario Freni | ca91339 | 2020-04-27 18:21:11 +0100 | [diff] [blame] | 1434 | func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool { |
| 1435 | return proptools.Bool(a.properties.Test_only_unsigned_payload) |
| 1436 | } |
| 1437 | |
Mohammad Samiul Islam | a8008f9 | 2020-12-22 10:47:50 +0000 | [diff] [blame] | 1438 | // See the test_only_force_compression property |
| 1439 | func (a *apexBundle) testOnlyShouldForceCompression() bool { |
| 1440 | return proptools.Bool(a.properties.Test_only_force_compression) |
| 1441 | } |
| 1442 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1443 | // These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its |
| 1444 | // members) can be sanitized, either forcibly, or by the global configuration. For some of the |
| 1445 | // sanitizers, extra dependencies can be forcibly added as well. |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 1446 | |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1447 | func (a *apexBundle) EnableSanitizer(sanitizerName string) { |
| 1448 | if !android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1449 | a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName) |
| 1450 | } |
| 1451 | } |
| 1452 | |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1453 | func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool { |
Jiyong Park | f97782b | 2019-02-13 20:28:58 +0900 | [diff] [blame] | 1454 | if android.InList(sanitizerName, a.properties.SanitizerNames) { |
| 1455 | return true |
Jiyong Park | 235e67c | 2019-02-09 11:50:56 +0900 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | // Then follow the global setting |
Jiyong Park | 388ef3f | 2019-01-28 19:47:32 +0900 | [diff] [blame] | 1459 | globalSanitizerNames := []string{} |
| 1460 | if a.Host() { |
| 1461 | globalSanitizerNames = ctx.Config().SanitizeHost() |
| 1462 | } else { |
| 1463 | arches := ctx.Config().SanitizeDeviceArch() |
| 1464 | if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) { |
| 1465 | globalSanitizerNames = ctx.Config().SanitizeDevice() |
| 1466 | } |
| 1467 | } |
| 1468 | return android.InList(sanitizerName, globalSanitizerNames) |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 1469 | } |
| 1470 | |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1471 | func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1472 | // TODO(jiyong): move this info (the sanitizer name, the lib name, etc.) to cc/sanitize.go |
| 1473 | // Keep only the mechanism here. |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1474 | if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1475 | imageVariation := a.getImageVariation(ctx) |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1476 | for _, target := range ctx.MultiTargets() { |
| 1477 | if target.Arch.ArchType.Multilib == "lib64" { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1478 | addDependenciesForNativeModules(ctx, ApexNativeDependencies{ |
Colin Cross | 4c4c1be | 2022-02-10 11:41:18 -0800 | [diff] [blame] | 1479 | Native_shared_libs: []string{"libclang_rt.hwasan"}, |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1480 | Tests: nil, |
| 1481 | Jni_libs: nil, |
| 1482 | Binaries: nil, |
| 1483 | }, target, imageVariation) |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1484 | break |
| 1485 | } |
| 1486 | } |
| 1487 | } |
| 1488 | } |
| 1489 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1490 | // apexFileFor<Type> functions below create an apexFile struct for a given Soong module. The |
| 1491 | // returned apexFile saves information about the Soong module that will be used for creating the |
| 1492 | // build rules. |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1493 | func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1494 | // Decide the APEX-local directory by the multilib of the library In the future, we may |
| 1495 | // query this to the module. |
| 1496 | // TODO(jiyong): use the new PackagingSpec |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1497 | var dirInApex string |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1498 | switch ccMod.Arch().ArchType.Multilib { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1499 | case "lib32": |
| 1500 | dirInApex = "lib" |
| 1501 | case "lib64": |
| 1502 | dirInApex = "lib64" |
| 1503 | } |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1504 | if ccMod.Target().NativeBridge == android.NativeBridgeEnabled { |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1505 | dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1506 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1507 | dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath()) |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1508 | if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1509 | // Special case for Bionic libs and other libs installed with them. This is to |
| 1510 | // prevent those libs from being included in the search path |
| 1511 | // /apex/com.android.runtime/${LIB}. This exclusion is required because those libs |
| 1512 | // in the Runtime APEX are available via the legacy paths in /system/lib/. By the |
| 1513 | // init process, the libs in the APEX are bind-mounted to the legacy paths and thus |
| 1514 | // will be loaded into the default linker namespace (aka "platform" namespace). If |
| 1515 | // the libs are directly in /apex/com.android.runtime/${LIB} then the same libs will |
| 1516 | // be loaded again into the runtime linker namespace, which will result in double |
| 1517 | // loading of them, which isn't supported. |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1518 | dirInApex = filepath.Join(dirInApex, "bionic") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1519 | } |
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 | fileToCopy := ccMod.OutputFile().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1522 | androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName |
| 1523 | return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1524 | } |
| 1525 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1526 | func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile { |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1527 | dirInApex := "bin" |
Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1528 | if cc.Target().NativeBridge == android.NativeBridgeEnabled { |
dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 1529 | dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath) |
Jiyong Park | acbf6c7 | 2019-07-09 16:19:16 +0900 | [diff] [blame] | 1530 | } |
Jooyung Han | 35155c4 | 2020-02-06 17:33:20 +0900 | [diff] [blame] | 1531 | dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1532 | fileToCopy := cc.OutputFile().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1533 | androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName |
| 1534 | af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1535 | af.symlinks = cc.Symlinks() |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1536 | af.dataPaths = cc.DataPaths() |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1537 | return af |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1538 | } |
| 1539 | |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 1540 | func apexFileForRustExecutable(ctx android.BaseModuleContext, rustm *rust.Module) apexFile { |
| 1541 | dirInApex := "bin" |
| 1542 | if rustm.Target().NativeBridge == android.NativeBridgeEnabled { |
| 1543 | dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath) |
| 1544 | } |
| 1545 | fileToCopy := rustm.OutputFile().Path() |
| 1546 | androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName |
| 1547 | af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, rustm) |
| 1548 | return af |
| 1549 | } |
| 1550 | |
| 1551 | func apexFileForRustLibrary(ctx android.BaseModuleContext, rustm *rust.Module) apexFile { |
| 1552 | // Decide the APEX-local directory by the multilib of the library |
| 1553 | // In the future, we may query this to the module. |
| 1554 | var dirInApex string |
| 1555 | switch rustm.Arch().ArchType.Multilib { |
| 1556 | case "lib32": |
| 1557 | dirInApex = "lib" |
| 1558 | case "lib64": |
| 1559 | dirInApex = "lib64" |
| 1560 | } |
| 1561 | if rustm.Target().NativeBridge == android.NativeBridgeEnabled { |
| 1562 | dirInApex = filepath.Join(dirInApex, rustm.Target().NativeBridgeRelativePath) |
| 1563 | } |
| 1564 | fileToCopy := rustm.OutputFile().Path() |
| 1565 | androidMkModuleName := rustm.BaseModuleName() + rustm.Properties.SubName |
| 1566 | return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, rustm) |
| 1567 | } |
| 1568 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1569 | func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1570 | dirInApex := "bin" |
| 1571 | fileToCopy := py.HostToolPath().Path() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1572 | return newApexFile(ctx, fileToCopy, py.BaseModuleName(), dirInApex, pyBinary, py) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1573 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1574 | |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1575 | func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1576 | dirInApex := "bin" |
Colin Cross | a44551f | 2021-10-25 15:36:21 -0700 | [diff] [blame] | 1577 | fileToCopy := android.PathForGoBinary(ctx, gb) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1578 | // NB: Since go binaries are static we don't need the module for anything here, which is |
| 1579 | // good since the go tool is a blueprint.Module not an android.Module like we would |
| 1580 | // normally use. |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1581 | return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1582 | } |
| 1583 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1584 | func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1585 | dirInApex := filepath.Join("bin", sh.SubDir()) |
Sundong Ahn | 80c0489 | 2021-11-23 00:57:19 +0000 | [diff] [blame] | 1586 | if sh.Target().NativeBridge == android.NativeBridgeEnabled { |
| 1587 | dirInApex = filepath.Join(dirInApex, sh.Target().NativeBridgeRelativePath) |
| 1588 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1589 | fileToCopy := sh.OutputFile() |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1590 | af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1591 | af.symlinks = sh.Symlinks() |
| 1592 | return af |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1593 | } |
| 1594 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1595 | func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile { |
Jooyung Han | 0703fd8 | 2020-08-26 22:11:53 +0900 | [diff] [blame] | 1596 | dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir()) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1597 | fileToCopy := prebuilt.OutputFile() |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1598 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1599 | } |
| 1600 | |
atrost | 6e12625 | 2020-01-27 17:01:16 +0000 | [diff] [blame] | 1601 | func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile { |
| 1602 | dirInApex := filepath.Join("etc", config.SubDir()) |
| 1603 | fileToCopy := config.CompatConfig() |
| 1604 | return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config) |
| 1605 | } |
| 1606 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1607 | // javaModule is an interface to handle all Java modules (java_library, dex_import, etc) in the same |
| 1608 | // way. |
| 1609 | type javaModule interface { |
| 1610 | android.Module |
| 1611 | BaseModuleName() string |
Martin Stjernholm | 8be1e6d | 2021-09-15 03:34:04 +0100 | [diff] [blame] | 1612 | DexJarBuildPath() java.OptionalDexJarPath |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1613 | JacocoReportClassesFile() android.Path |
| 1614 | LintDepSets() java.LintDepSets |
| 1615 | Stem() string |
| 1616 | } |
| 1617 | |
| 1618 | var _ javaModule = (*java.Library)(nil) |
Bill Peckham | a41a696 | 2021-01-11 10:58:54 -0800 | [diff] [blame] | 1619 | var _ javaModule = (*java.Import)(nil) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1620 | var _ javaModule = (*java.SdkLibrary)(nil) |
| 1621 | var _ javaModule = (*java.DexImport)(nil) |
| 1622 | var _ javaModule = (*java.SdkLibraryImport)(nil) |
| 1623 | |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 1624 | // apexFileForJavaModule creates an apexFile for a java module's dex implementation jar. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1625 | func apexFileForJavaModule(ctx android.BaseModuleContext, module javaModule) apexFile { |
Martin Stjernholm | 8be1e6d | 2021-09-15 03:34:04 +0100 | [diff] [blame] | 1626 | return apexFileForJavaModuleWithFile(ctx, module, module.DexJarBuildPath().PathOrNil()) |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 1627 | } |
| 1628 | |
| 1629 | // apexFileForJavaModuleWithFile creates an apexFile for a java module with the supplied file. |
| 1630 | func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaModule, dexImplementationJar android.Path) apexFile { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1631 | dirInApex := "javalib" |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 1632 | af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1633 | af.jacocoReportClassesFile = module.JacocoReportClassesFile() |
| 1634 | af.lintDepSets = module.LintDepSets() |
| 1635 | af.customStem = module.Stem() + ".jar" |
Jiakai Zhang | 519c5c8 | 2021-09-16 06:15:39 +0000 | [diff] [blame] | 1636 | if dexpreopter, ok := module.(java.DexpreopterInterface); ok { |
| 1637 | for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() { |
| 1638 | af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName()) |
| 1639 | } |
| 1640 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1641 | return af |
| 1642 | } |
| 1643 | |
| 1644 | // androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in |
| 1645 | // the same way. |
| 1646 | type androidApp interface { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1647 | android.Module |
| 1648 | Privileged() bool |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1649 | InstallApkName() string |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1650 | OutputFile() android.Path |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1651 | JacocoReportClassesFile() android.Path |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1652 | Certificate() java.Certificate |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1653 | BaseModuleName() string |
Colin Cross | 8355c15 | 2021-08-10 19:24:07 -0700 | [diff] [blame] | 1654 | LintDepSets() java.LintDepSets |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1655 | } |
| 1656 | |
| 1657 | var _ androidApp = (*java.AndroidApp)(nil) |
| 1658 | var _ androidApp = (*java.AndroidAppImport)(nil) |
| 1659 | |
Jingwen Chen | 8ce1efc | 2022-04-19 13:57:01 +0000 | [diff] [blame^] | 1660 | func sanitizedBuildIdForPath(ctx android.BaseModuleContext) string { |
| 1661 | buildId := ctx.Config().BuildId() |
| 1662 | |
| 1663 | // The build ID is used as a suffix for a filename, so ensure that |
| 1664 | // the set of characters being used are sanitized. |
| 1665 | // - any word character: [a-zA-Z0-9_] |
| 1666 | // - dots: . |
| 1667 | // - dashes: - |
| 1668 | validRegex := regexp.MustCompile(`^[\w\.\-\_]+$`) |
| 1669 | if !validRegex.MatchString(buildId) { |
| 1670 | ctx.ModuleErrorf("Unable to use build id %s as filename suffix, valid characters are [a-z A-Z 0-9 _ . -].", buildId) |
| 1671 | } |
| 1672 | return buildId |
| 1673 | } |
| 1674 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1675 | func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexFile { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1676 | appDir := "app" |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1677 | if aapp.Privileged() { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 1678 | appDir = "priv-app" |
| 1679 | } |
Jingwen Chen | 8ce1efc | 2022-04-19 13:57:01 +0000 | [diff] [blame^] | 1680 | |
| 1681 | // TODO(b/224589412, b/226559955): Ensure that the subdirname is suffixed |
| 1682 | // so that PackageManager correctly invalidates the existing installed apk |
| 1683 | // in favour of the new APK-in-APEX. See bugs for more information. |
| 1684 | dirInApex := filepath.Join(appDir, aapp.InstallApkName()+"@"+sanitizedBuildIdForPath(ctx)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1685 | fileToCopy := aapp.OutputFile() |
Jingwen Chen | 8ce1efc | 2022-04-19 13:57:01 +0000 | [diff] [blame^] | 1686 | |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 1687 | af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp) |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1688 | af.jacocoReportClassesFile = aapp.JacocoReportClassesFile() |
Colin Cross | 8355c15 | 2021-08-10 19:24:07 -0700 | [diff] [blame] | 1689 | af.lintDepSets = aapp.LintDepSets() |
Colin Cross | 503c1d0 | 2020-01-28 14:00:53 -0800 | [diff] [blame] | 1690 | af.certificate = aapp.Certificate() |
Jiyong Park | cfaa164 | 2020-02-28 16:51:07 +0900 | [diff] [blame] | 1691 | |
| 1692 | if app, ok := aapp.(interface { |
| 1693 | OverriddenManifestPackageName() string |
| 1694 | }); ok { |
| 1695 | af.overriddenPackageName = app.OverriddenManifestPackageName() |
| 1696 | } |
Jiyong Park | 618922e | 2020-01-08 13:35:43 +0900 | [diff] [blame] | 1697 | return af |
Dario Freni | cde2a03 | 2019-10-27 00:29:22 +0100 | [diff] [blame] | 1698 | } |
| 1699 | |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1700 | func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile { |
| 1701 | rroDir := "overlay" |
| 1702 | dirInApex := filepath.Join(rroDir, rro.Theme()) |
| 1703 | fileToCopy := rro.OutputFile() |
| 1704 | af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro) |
| 1705 | af.certificate = rro.Certificate() |
| 1706 | |
| 1707 | if a, ok := rro.(interface { |
| 1708 | OverriddenManifestPackageName() string |
| 1709 | }); ok { |
| 1710 | af.overriddenPackageName = a.OverriddenManifestPackageName() |
| 1711 | } |
| 1712 | return af |
| 1713 | } |
| 1714 | |
Ken Chen | fad7f9d | 2021-11-10 22:02:57 +0800 | [diff] [blame] | 1715 | func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, apex_sub_dir string, bpfProgram bpf.BpfModule) apexFile { |
| 1716 | dirInApex := filepath.Join("etc", "bpf", apex_sub_dir) |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1717 | return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram) |
| 1718 | } |
| 1719 | |
Jiyong Park | 12a719c | 2021-01-07 15:31:24 +0900 | [diff] [blame] | 1720 | func apexFileForFilesystem(ctx android.BaseModuleContext, buildFile android.Path, fs filesystem.Filesystem) apexFile { |
| 1721 | dirInApex := filepath.Join("etc", "fs") |
| 1722 | return newApexFile(ctx, buildFile, buildFile.Base(), dirInApex, etc, fs) |
| 1723 | } |
| 1724 | |
Paul Duffin | 064b70c | 2020-11-02 17:32:38 +0000 | [diff] [blame] | 1725 | // WalkPayloadDeps visits dependencies that contributes to the payload of this APEX. For each of the |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1726 | // visited module, the `do` callback is executed. Returning true in the callback continues the visit |
| 1727 | // to the child modules. Returning false makes the visit to continue in the sibling or the parent |
| 1728 | // modules. This is used in check* functions below. |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 1729 | func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) { |
Paul Duffin | df915ff | 2020-03-30 17:58:21 +0100 | [diff] [blame] | 1730 | ctx.WalkDeps(func(child, parent android.Module) bool { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1731 | am, ok := child.(android.ApexModule) |
| 1732 | if !ok || !am.CanHaveApexVariants() { |
| 1733 | return false |
| 1734 | } |
| 1735 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1736 | // Filter-out unwanted depedendencies |
| 1737 | depTag := ctx.OtherModuleDependencyTag(child) |
| 1738 | if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { |
| 1739 | return false |
| 1740 | } |
| 1741 | if dt, ok := depTag.(dependencyTag); ok && !dt.payload { |
Martin Stjernholm | 58c33f0 | 2020-07-06 22:56:01 +0100 | [diff] [blame] | 1742 | return false |
| 1743 | } |
| 1744 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1745 | ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo) |
Jiyong Park | ab50b07 | 2021-05-12 17:13:56 +0900 | [diff] [blame] | 1746 | externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1747 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1748 | // Visit actually |
| 1749 | return do(ctx, parent, am, externalDep) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 1750 | }) |
| 1751 | } |
| 1752 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1753 | // filesystem type of the apex_payload.img inside the APEX. Currently, ext4 and f2fs are supported. |
| 1754 | type fsType int |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1755 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1756 | const ( |
| 1757 | ext4 fsType = iota |
| 1758 | f2fs |
Huang Jianan | 13cac63 | 2021-08-02 15:02:17 +0800 | [diff] [blame] | 1759 | erofs |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1760 | ) |
Artur Satayev | 849f844 | 2020-04-28 14:57:42 +0100 | [diff] [blame] | 1761 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1762 | func (f fsType) string() string { |
| 1763 | switch f { |
| 1764 | case ext4: |
| 1765 | return ext4FsType |
| 1766 | case f2fs: |
| 1767 | return f2fsFsType |
Huang Jianan | 13cac63 | 2021-08-02 15:02:17 +0800 | [diff] [blame] | 1768 | case erofs: |
| 1769 | return erofsFsType |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1770 | default: |
| 1771 | panic(fmt.Errorf("unknown APEX payload type %d", f)) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1772 | } |
| 1773 | } |
| 1774 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1775 | // Creates build rules for an APEX. It consists of the following major steps: |
| 1776 | // |
| 1777 | // 1) do some validity checks such as apex_available, min_sdk_version, etc. |
| 1778 | // 2) traverse the dependency tree to collect apexFile structs from them. |
| 1779 | // 3) some fields in apexBundle struct are configured |
| 1780 | // 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] | 1781 | func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1782 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 1783 | // 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] | 1784 | a.checkApexAvailability(ctx) |
Jooyung Han | 548640b | 2020-04-27 12:10:30 +0900 | [diff] [blame] | 1785 | a.checkUpdatable(ctx) |
satayev | b3fd411 | 2021-12-02 13:59:35 +0000 | [diff] [blame] | 1786 | a.CheckMinSdkVersion(ctx) |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 1787 | a.checkStaticLinkingToStubLibraries(ctx) |
Jiyong Park | 192600a | 2021-08-03 07:52:17 +0000 | [diff] [blame] | 1788 | a.checkStaticExecutables(ctx) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1789 | if len(a.properties.Tests) > 0 && !a.testApex { |
| 1790 | ctx.PropertyErrorf("tests", "property allowed only in apex_test module type") |
| 1791 | return |
| 1792 | } |
Jiyong Park | 678c881 | 2020-02-07 17:25:49 +0900 | [diff] [blame] | 1793 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1794 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 1795 | // 2) traverse the dependency tree to collect apexFile structs from them. |
| 1796 | |
| 1797 | // all the files that will be included in this APEX |
| 1798 | var filesInfo []apexFile |
Alex Light | fc0bd7c | 2019-01-29 18:31:59 -0800 | [diff] [blame] | 1799 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1800 | // native lib dependencies |
| 1801 | var provideNativeLibs []string |
| 1802 | var requireNativeLibs []string |
| 1803 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1804 | handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case) |
| 1805 | |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 1806 | // Collect the module directory for IDE info in java/jdeps.go. |
| 1807 | a.modulePaths = append(a.modulePaths, ctx.ModuleDir()) |
| 1808 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1809 | // TODO(jiyong): do this using WalkPayloadDeps |
| 1810 | // TODO(jiyong): make this clean!!! |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1811 | ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1812 | depTag := ctx.OtherModuleDependencyTag(child) |
Paul Duffin | dddd546 | 2020-04-07 15:25:44 +0100 | [diff] [blame] | 1813 | if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { |
| 1814 | return false |
| 1815 | } |
Dan Willemsen | 47e1a75 | 2021-10-16 18:36:13 -0700 | [diff] [blame] | 1816 | if mod, ok := child.(android.Module); ok && !mod.Enabled() { |
| 1817 | return false |
| 1818 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1819 | depName := ctx.OtherModuleName(child) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1820 | if _, isDirectDep := parent.(*apexBundle); isDirectDep { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1821 | switch depTag { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1822 | case sharedLibTag, jniLibTag: |
| 1823 | isJniLib := depTag == jniLibTag |
Jooyung Han | faa2d5f | 2020-02-06 17:42:40 +0900 | [diff] [blame] | 1824 | if c, ok := child.(*cc.Module); ok { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1825 | fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs) |
| 1826 | fi.isJniLib = isJniLib |
| 1827 | filesInfo = append(filesInfo, fi) |
Jooyung Han | 45a9677 | 2020-06-15 14:59:42 +0900 | [diff] [blame] | 1828 | // Collect the list of stub-providing libs except: |
| 1829 | // - VNDK libs are only for vendors |
| 1830 | // - bootstrap bionic libs are treated as provided by system |
| 1831 | if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1832 | provideNativeLibs = append(provideNativeLibs, fi.stem()) |
Jiyong Park | f1493cc | 2020-05-29 21:29:20 +0900 | [diff] [blame] | 1833 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1834 | return true // track transitive dependencies |
Jiyong Park | f2cc1b7 | 2020-12-09 00:20:45 +0900 | [diff] [blame] | 1835 | } else if r, ok := child.(*rust.Module); ok { |
| 1836 | fi := apexFileForRustLibrary(ctx, r) |
Benjamin Brittain | 9edc375 | 2021-11-30 13:38:13 -0500 | [diff] [blame] | 1837 | fi.isJniLib = isJniLib |
Jiyong Park | f2cc1b7 | 2020-12-09 00:20:45 +0900 | [diff] [blame] | 1838 | filesInfo = append(filesInfo, fi) |
Jiyong Park | 34d5c33 | 2022-02-24 18:02:44 +0900 | [diff] [blame] | 1839 | return true // track transitive dependencies |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1840 | } else { |
Jooyung Han | 643adc4 | 2020-02-27 13:50:06 +0900 | [diff] [blame] | 1841 | propertyName := "native_shared_libs" |
| 1842 | if isJniLib { |
| 1843 | propertyName = "jni_libs" |
| 1844 | } |
| 1845 | 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] | 1846 | } |
| 1847 | case executableTag: |
| 1848 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1849 | filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1850 | return true // track transitive dependencies |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1851 | } else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1852 | filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py)) |
Alex Light | 778127a | 2019-02-27 14:19:50 -0800 | [diff] [blame] | 1853 | } else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() { |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1854 | filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb)) |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 1855 | } else if rust, ok := child.(*rust.Module); ok { |
| 1856 | filesInfo = append(filesInfo, apexFileForRustExecutable(ctx, rust)) |
| 1857 | return true // track transitive dependencies |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1858 | } else { |
Sundong Ahn | 80c0489 | 2021-11-23 00:57:19 +0000 | [diff] [blame] | 1859 | ctx.PropertyErrorf("binaries", "%q is neither cc_binary, rust_binary, (embedded) py_binary, (host) blueprint_go_binary, nor (host) bootstrap_go_binary", depName) |
| 1860 | } |
| 1861 | case shBinaryTag: |
| 1862 | if sh, ok := child.(*sh.ShBinary); ok { |
| 1863 | filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh)) |
| 1864 | } else { |
| 1865 | ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1866 | } |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 1867 | case bcpfTag: |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 1868 | { |
Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 1869 | bcpfModule, ok := child.(*java.BootclasspathFragmentModule) |
| 1870 | if !ok { |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 1871 | ctx.PropertyErrorf("bootclasspath_fragments", "%q is not a bootclasspath_fragment module", depName) |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 1872 | return false |
| 1873 | } |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 1874 | |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 1875 | filesToAdd := apexBootclasspathFragmentFiles(ctx, child) |
| 1876 | filesInfo = append(filesInfo, filesToAdd...) |
Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 1877 | for _, makeModuleName := range bcpfModule.BootImageDeviceInstallMakeModules() { |
| 1878 | a.requiredDeps = append(a.requiredDeps, makeModuleName) |
| 1879 | } |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 1880 | return true |
Paul Duffin | a1d6025 | 2021-01-21 18:13:43 +0000 | [diff] [blame] | 1881 | } |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 1882 | case sscpfTag: |
| 1883 | { |
| 1884 | if _, ok := child.(*java.SystemServerClasspathModule); !ok { |
| 1885 | ctx.PropertyErrorf("systemserverclasspath_fragments", "%q is not a systemserverclasspath_fragment module", depName) |
| 1886 | return false |
| 1887 | } |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 1888 | if af := apexClasspathFragmentProtoFile(ctx, child); af != nil { |
| 1889 | filesInfo = append(filesInfo, *af) |
| 1890 | } |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 1891 | return true |
| 1892 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1893 | case javaLibTag: |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1894 | switch child.(type) { |
Bill Peckham | a41a696 | 2021-01-11 10:58:54 -0800 | [diff] [blame] | 1895 | case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport, *java.Import: |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 1896 | af := apexFileForJavaModule(ctx, child.(javaModule)) |
| 1897 | if !af.ok() { |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 1898 | ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName) |
| 1899 | return false |
| 1900 | } |
| 1901 | filesInfo = append(filesInfo, af) |
Jooyung Han | 58f26ab | 2019-12-18 15:34:32 +0900 | [diff] [blame] | 1902 | return true // track transitive dependencies |
Jiyong Park | 77acec6 | 2020-06-01 21:39:15 +0900 | [diff] [blame] | 1903 | default: |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 1904 | 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] | 1905 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1906 | case androidAppTag: |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1907 | if ap, ok := child.(*java.AndroidApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1908 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1909 | return true // track transitive dependencies |
| 1910 | } else if ap, ok := child.(*java.AndroidAppImport); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1911 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Dario Freni | 6f3937c | 2019-12-20 22:58:03 +0000 | [diff] [blame] | 1912 | } else if ap, ok := child.(*java.AndroidTestHelperApp); ok { |
Jooyung Han | 39ee119 | 2020-03-23 20:21:11 +0900 | [diff] [blame] | 1913 | filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap)) |
Sasha Smundak | 18d98bc | 2020-05-27 16:36:07 -0700 | [diff] [blame] | 1914 | } else if ap, ok := child.(*java.AndroidAppSet); ok { |
| 1915 | appDir := "app" |
| 1916 | if ap.Privileged() { |
| 1917 | appDir = "priv-app" |
| 1918 | } |
Jingwen Chen | 8ce1efc | 2022-04-19 13:57:01 +0000 | [diff] [blame^] | 1919 | // TODO(b/224589412, b/226559955): Ensure that the dirname is |
| 1920 | // suffixed so that PackageManager correctly invalidates the |
| 1921 | // existing installed apk in favour of the new APK-in-APEX. |
| 1922 | // See bugs for more information. |
| 1923 | appDirName := filepath.Join(appDir, ap.BaseModuleName()+"@"+sanitizedBuildIdForPath(ctx)) |
| 1924 | af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap) |
Sasha Smundak | 18d98bc | 2020-05-27 16:36:07 -0700 | [diff] [blame] | 1925 | af.certificate = java.PresignedCertificate |
| 1926 | filesInfo = append(filesInfo, af) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1927 | } else { |
| 1928 | ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) |
| 1929 | } |
Jiyong Park | 69aeba9 | 2020-04-24 21:16:36 +0900 | [diff] [blame] | 1930 | case rroTag: |
| 1931 | if rro, ok := child.(java.RuntimeResourceOverlayModule); ok { |
| 1932 | filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro)) |
| 1933 | } else { |
| 1934 | ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName) |
| 1935 | } |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1936 | case bpfTag: |
| 1937 | if bpfProgram, ok := child.(bpf.BpfModule); ok { |
| 1938 | filesToCopy, _ := bpfProgram.OutputFiles("") |
Ken Chen | fad7f9d | 2021-11-10 22:02:57 +0800 | [diff] [blame] | 1939 | apex_sub_dir := bpfProgram.SubDir() |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1940 | for _, bpfFile := range filesToCopy { |
Ken Chen | fad7f9d | 2021-11-10 22:02:57 +0800 | [diff] [blame] | 1941 | filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, apex_sub_dir, bpfProgram)) |
markchien | 2f59ec9 | 2020-09-02 16:23:38 +0800 | [diff] [blame] | 1942 | } |
| 1943 | } else { |
| 1944 | ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName) |
| 1945 | } |
Jiyong Park | 12a719c | 2021-01-07 15:31:24 +0900 | [diff] [blame] | 1946 | case fsTag: |
| 1947 | if fs, ok := child.(filesystem.Filesystem); ok { |
| 1948 | filesInfo = append(filesInfo, apexFileForFilesystem(ctx, fs.OutputPath(), fs)) |
| 1949 | } else { |
| 1950 | ctx.PropertyErrorf("filesystems", "%q is not a filesystem module", depName) |
| 1951 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1952 | case prebuiltTag: |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 1953 | if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1954 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1955 | } else { |
Paul Duffin | 1bc21dc | 2021-03-15 19:43:17 +0000 | [diff] [blame] | 1956 | ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName) |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1957 | } |
Paul Duffin | 0b81778 | 2021-03-17 15:02:19 +0000 | [diff] [blame] | 1958 | case compatConfigTag: |
Paul Duffin | 3abc174 | 2021-03-15 19:32:23 +0000 | [diff] [blame] | 1959 | if compatConfig, ok := child.(java.PlatformCompatConfigIntf); ok { |
| 1960 | filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, compatConfig, depName)) |
| 1961 | } else { |
| 1962 | ctx.PropertyErrorf("compat_configs", "%q is not a platform_compat_config module", depName) |
| 1963 | } |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1964 | case testTag: |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1965 | if ccTest, ok := child.(*cc.Module); ok { |
| 1966 | if ccTest.IsTestPerSrcAllTestsVariation() { |
| 1967 | // Multiple-output test module (where `test_per_src: true`). |
| 1968 | // |
| 1969 | // `ccTest` is the "" ("all tests") variation of a `test_per_src` module. |
| 1970 | // We do not add this variation to `filesInfo`, as it has no output; |
| 1971 | // however, we do add the other variations of this module as indirect |
| 1972 | // dependencies (see below). |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1973 | } else { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1974 | // Single-output test module (where `test_per_src: false`). |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 1975 | af := apexFileForExecutable(ctx, ccTest) |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1976 | af.class = nativeTest |
| 1977 | filesInfo = append(filesInfo, af) |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1978 | } |
Jiyong Park | af9539f | 2020-05-04 10:31:32 +0900 | [diff] [blame] | 1979 | return true // track transitive dependencies |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1980 | } else { |
| 1981 | ctx.PropertyErrorf("tests", "%q is not a cc module", depName) |
| 1982 | } |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1983 | case keyTag: |
| 1984 | if key, ok := child.(*apexKey); ok { |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 1985 | a.privateKeyFile = key.privateKeyFile |
| 1986 | a.publicKeyFile = key.publicKeyFile |
Jiyong Park | ff1458f | 2018-10-12 21:49:38 +0900 | [diff] [blame] | 1987 | } else { |
| 1988 | ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 1989 | } |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 1990 | return false |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1991 | case certificateTag: |
| 1992 | if dep, ok := child.(*java.AndroidAppCertificate); ok { |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 1993 | a.containerCertificateFile = dep.Certificate.Pem |
| 1994 | a.containerPrivateKeyFile = dep.Certificate.Key |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 1995 | } else { |
| 1996 | ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName) |
| 1997 | } |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 1998 | case android.PrebuiltDepTag: |
| 1999 | // If the prebuilt is force disabled, remember to delete the prebuilt file |
| 2000 | // that might have been installed in the previous builds |
Jiyong Park | 10e926b | 2020-07-16 21:38:56 +0900 | [diff] [blame] | 2001 | if prebuilt, ok := child.(prebuilt); ok && prebuilt.isForceDisabled() { |
Jiyong Park | 03b68dd | 2019-07-26 23:20:40 +0900 | [diff] [blame] | 2002 | a.prebuiltFileToDelete = prebuilt.InstallFilename() |
| 2003 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2004 | } |
Jooyung Han | 8aee204 | 2019-10-29 05:08:31 +0900 | [diff] [blame] | 2005 | } else if !a.vndkApex { |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2006 | // indirect dependencies |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 2007 | if am, ok := child.(android.ApexModule); ok { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2008 | // We cannot use a switch statement on `depTag` here as the checked |
| 2009 | // tags used below are private (e.g. `cc.sharedDepTag`). |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 2010 | if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2011 | if cc, ok := child.(*cc.Module); ok { |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 2012 | 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] | 2013 | requireNativeLibs = append(requireNativeLibs, ":vndk") |
Jooyung Han | df78e21 | 2020-07-22 15:54:47 +0900 | [diff] [blame] | 2014 | return false |
| 2015 | } |
Jiyong Park | f1493cc | 2020-05-29 21:29:20 +0900 | [diff] [blame] | 2016 | af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs) |
| 2017 | af.transitiveDep = true |
Martin Stjernholm | f2635ec | 2020-12-16 01:01:59 +0000 | [diff] [blame] | 2018 | |
| 2019 | // Always track transitive dependencies for host. |
| 2020 | if a.Host() { |
| 2021 | filesInfo = append(filesInfo, af) |
| 2022 | return true |
| 2023 | } |
| 2024 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 2025 | abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo) |
Martin Stjernholm | f2635ec | 2020-12-16 01:01:59 +0000 | [diff] [blame] | 2026 | if !abInfo.Contents.DirectlyInApex(depName) && (cc.IsStubs() || cc.HasStubsVariants()) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2027 | // If the dependency is a stubs lib, don't include it in this APEX, |
| 2028 | // but make sure that the lib is installed on the device. |
| 2029 | // In case no APEX is having the lib, the lib is installed to the system |
| 2030 | // partition. |
| 2031 | // |
| 2032 | // Always include if we are a host-apex however since those won't have any |
| 2033 | // system libraries. |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 2034 | if !am.DirectlyInAnyApex() { |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 2035 | // we need a module name for Make |
Steven Moreland | 2c4000c | 2021-04-27 02:08:49 +0000 | [diff] [blame] | 2036 | name := cc.ImplementationModuleNameForMake(ctx) + cc.Properties.SubName |
Jooyung Han | efb184e | 2020-06-25 17:14:25 +0900 | [diff] [blame] | 2037 | if !android.InList(name, a.requiredDeps) { |
| 2038 | a.requiredDeps = append(a.requiredDeps, name) |
| 2039 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2040 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2041 | requireNativeLibs = append(requireNativeLibs, af.stem()) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2042 | // Don't track further |
| 2043 | return false |
| 2044 | } |
Jiyong Park | e386754 | 2020-12-03 17:28:25 +0900 | [diff] [blame] | 2045 | |
| 2046 | // If the dep is not considered to be in the same |
| 2047 | // apex, don't add it to filesInfo so that it is not |
| 2048 | // included in this APEX. |
| 2049 | // TODO(jiyong): move this to at the top of the |
| 2050 | // else-if clause for the indirect dependencies. |
| 2051 | // Currently, that's impossible because we would |
| 2052 | // like to record requiredNativeLibs even when |
Martin Stjernholm | f2635ec | 2020-12-16 01:01:59 +0000 | [diff] [blame] | 2053 | // DepIsInSameAPex is false. We also shouldn't do |
| 2054 | // this for host. |
Paul Duffin | 4c3e8e2 | 2021-03-18 15:41:29 +0000 | [diff] [blame] | 2055 | // |
| 2056 | // TODO(jiyong): explain why the same module is passed in twice. |
| 2057 | // Switching the first am to parent breaks lots of tests. |
| 2058 | if !android.IsDepInSameApex(ctx, am, am) { |
Jiyong Park | e386754 | 2020-12-03 17:28:25 +0900 | [diff] [blame] | 2059 | return false |
| 2060 | } |
| 2061 | |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2062 | filesInfo = append(filesInfo, af) |
| 2063 | return true // track transitive dependencies |
Jiyong Park | f2cc1b7 | 2020-12-09 00:20:45 +0900 | [diff] [blame] | 2064 | } else if rm, ok := child.(*rust.Module); ok { |
| 2065 | af := apexFileForRustLibrary(ctx, rm) |
| 2066 | af.transitiveDep = true |
| 2067 | filesInfo = append(filesInfo, af) |
| 2068 | return true // track transitive dependencies |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2069 | } |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2070 | } else if cc.IsTestPerSrcDepTag(depTag) { |
| 2071 | if cc, ok := child.(*cc.Module); ok { |
Jiyong Park | 1833cef | 2019-12-13 13:28:36 +0900 | [diff] [blame] | 2072 | af := apexFileForExecutable(ctx, cc) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2073 | // Handle modules created as `test_per_src` variations of a single test module: |
| 2074 | // use the name of the generated test binary (`fileToCopy`) instead of the name |
| 2075 | // of the original test module (`depName`, shared by all `test_per_src` |
| 2076 | // variations of that module). |
Yo Chiang | e812805 | 2020-07-23 20:09:18 +0800 | [diff] [blame] | 2077 | af.androidMkModuleName = filepath.Base(af.builtFile.String()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2078 | // these are not considered transitive dep |
| 2079 | af.transitiveDep = false |
Jiyong Park | f653b05 | 2019-11-18 15:39:01 +0900 | [diff] [blame] | 2080 | filesInfo = append(filesInfo, af) |
| 2081 | return true // track transitive dependencies |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2082 | } |
Jiyong Park | 1ad8e16 | 2020-12-01 23:40:09 +0900 | [diff] [blame] | 2083 | } else if cc.IsHeaderDepTag(depTag) { |
| 2084 | // nothing |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame] | 2085 | } else if java.IsJniDepTag(depTag) { |
Jooyung Han | b7bebe2 | 2020-02-25 16:59:29 +0900 | [diff] [blame] | 2086 | // Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps |
| 2087 | return false |
Jiyong Park | e383388 | 2020-02-17 17:28:10 +0900 | [diff] [blame] | 2088 | } else if java.IsXmlPermissionsFileDepTag(depTag) { |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 2089 | if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { |
Jiyong Park | e383388 | 2020-02-17 17:28:10 +0900 | [diff] [blame] | 2090 | filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) |
| 2091 | } |
Jiyong Park | 99644e9 | 2020-11-17 22:21:02 +0900 | [diff] [blame] | 2092 | } else if rust.IsDylibDepTag(depTag) { |
| 2093 | if rustm, ok := child.(*rust.Module); ok && rustm.IsInstallableToApex() { |
| 2094 | af := apexFileForRustLibrary(ctx, rustm) |
| 2095 | af.transitiveDep = true |
| 2096 | filesInfo = append(filesInfo, af) |
| 2097 | return true // track transitive dependencies |
| 2098 | } |
Jiyong Park | 94e22fd | 2021-04-08 18:19:15 +0900 | [diff] [blame] | 2099 | } else if rust.IsRlibDepTag(depTag) { |
| 2100 | // Rlib is statically linked, but it might have shared lib |
| 2101 | // dependencies. Track them. |
| 2102 | return true |
Paul Duffin | 6589805 | 2021-04-20 22:47:03 +0100 | [diff] [blame] | 2103 | } else if java.IsBootclasspathFragmentContentDepTag(depTag) { |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 2104 | // Add the contents of the bootclasspath fragment to the apex. |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 2105 | switch child.(type) { |
| 2106 | case *java.Library, *java.SdkLibrary: |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 2107 | javaModule := child.(javaModule) |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 2108 | af := apexFileForBootclasspathFragmentContentModule(ctx, parent, javaModule) |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 2109 | if !af.ok() { |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 2110 | ctx.PropertyErrorf("bootclasspath_fragments", "bootclasspath_fragment content %q is not configured to be compiled into dex", depName) |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 2111 | return false |
| 2112 | } |
| 2113 | filesInfo = append(filesInfo, af) |
| 2114 | return true // track transitive dependencies |
| 2115 | default: |
Paul Duffin | 94f1963 | 2021-04-20 12:40:07 +0100 | [diff] [blame] | 2116 | ctx.PropertyErrorf("bootclasspath_fragments", "bootclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child)) |
Paul Duffin | 4d101b6 | 2021-03-24 15:42:20 +0000 | [diff] [blame] | 2117 | } |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 2118 | } else if java.IsSystemServerClasspathFragmentContentDepTag(depTag) { |
| 2119 | // Add the contents of the systemserverclasspath fragment to the apex. |
| 2120 | switch child.(type) { |
| 2121 | case *java.Library, *java.SdkLibrary: |
| 2122 | af := apexFileForJavaModule(ctx, child.(javaModule)) |
| 2123 | filesInfo = append(filesInfo, af) |
| 2124 | return true // track transitive dependencies |
| 2125 | default: |
| 2126 | ctx.PropertyErrorf("systemserverclasspath_fragments", "systemserverclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child)) |
| 2127 | } |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 2128 | } else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok { |
| 2129 | // nothing |
Dan Willemsen | 4745007 | 2021-10-19 20:24:49 -0700 | [diff] [blame] | 2130 | } else if depTag == android.DarwinUniversalVariantTag { |
| 2131 | // nothing |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 2132 | } else if am.CanHaveApexVariants() && am.IsInstallableToApex() { |
Jiyong Park | 1c7e962 | 2020-05-07 16:12:13 +0900 | [diff] [blame] | 2133 | 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] | 2134 | } |
| 2135 | } |
| 2136 | } |
| 2137 | return false |
| 2138 | }) |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 2139 | if a.privateKeyFile == nil { |
Jaewoong Jung | 4cfdf7d | 2021-04-20 16:21:24 -0700 | [diff] [blame] | 2140 | ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.overridableProperties.Key)) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2141 | return |
| 2142 | } |
Jiyong Park | 48ca7dc | 2018-10-10 14:01:00 +0900 | [diff] [blame] | 2143 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2144 | // Remove duplicates in filesInfo |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2145 | removeDup := func(filesInfo []apexFile) []apexFile { |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2146 | encountered := make(map[string]apexFile) |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2147 | for _, f := range filesInfo { |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 2148 | dest := filepath.Join(f.installDir, f.builtFile.Base()) |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2149 | if e, ok := encountered[dest]; !ok { |
| 2150 | encountered[dest] = f |
| 2151 | } else { |
| 2152 | // If a module is directly included and also transitively depended on |
| 2153 | // consider it as directly included. |
| 2154 | e.transitiveDep = e.transitiveDep && f.transitiveDep |
| 2155 | encountered[dest] = e |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2156 | } |
| 2157 | } |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2158 | var result []apexFile |
| 2159 | for _, v := range encountered { |
| 2160 | result = append(result, v) |
| 2161 | } |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2162 | return result |
| 2163 | } |
| 2164 | filesInfo = removeDup(filesInfo) |
| 2165 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2166 | // Sort to have consistent build rules |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2167 | sort.Slice(filesInfo, func(i, j int) bool { |
Paul Duffin | 5606029 | 2021-05-15 19:34:05 +0100 | [diff] [blame] | 2168 | // Sort by destination path so as to ensure consistent ordering even if the source of the files |
| 2169 | // changes. |
| 2170 | return filesInfo[i].path() < filesInfo[j].path() |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2171 | }) |
| 2172 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2173 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 2174 | // 3) some fields in apexBundle struct are configured |
Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 2175 | a.installDir = android.PathForModuleInstall(ctx, "apex") |
| 2176 | a.filesInfo = filesInfo |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 2177 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2178 | // Set suffix and primaryApexType depending on the ApexType |
Martin Stjernholm | cb3ff1e | 2021-05-25 00:28:27 +0100 | [diff] [blame] | 2179 | buildFlattenedAsDefault := ctx.Config().FlattenApex() |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2180 | switch a.properties.ApexType { |
| 2181 | case imageApex: |
| 2182 | if buildFlattenedAsDefault { |
| 2183 | a.suffix = imageApexSuffix |
| 2184 | } else { |
| 2185 | a.suffix = "" |
| 2186 | a.primaryApexType = true |
| 2187 | |
| 2188 | if ctx.Config().InstallExtraFlattenedApexes() { |
| 2189 | a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix) |
| 2190 | } |
| 2191 | } |
| 2192 | case zipApex: |
| 2193 | if proptools.String(a.properties.Payload_type) == "zip" { |
| 2194 | a.suffix = "" |
| 2195 | a.primaryApexType = true |
| 2196 | } else { |
| 2197 | a.suffix = zipApexSuffix |
| 2198 | } |
| 2199 | case flattenedApex: |
| 2200 | if buildFlattenedAsDefault { |
| 2201 | a.suffix = "" |
| 2202 | a.primaryApexType = true |
| 2203 | } else { |
| 2204 | a.suffix = flattenedSuffix |
| 2205 | } |
| 2206 | } |
| 2207 | |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 2208 | switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) { |
| 2209 | case ext4FsType: |
| 2210 | a.payloadFsType = ext4 |
| 2211 | case f2fsFsType: |
| 2212 | a.payloadFsType = f2fs |
Huang Jianan | 13cac63 | 2021-08-02 15:02:17 +0800 | [diff] [blame] | 2213 | case erofsFsType: |
| 2214 | a.payloadFsType = erofs |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 2215 | default: |
Huang Jianan | 13cac63 | 2021-08-02 15:02:17 +0800 | [diff] [blame] | 2216 | ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs, erofs]", *a.properties.Payload_fs_type) |
Theotime Combes | 4ba38c1 | 2020-06-12 12:46:59 +0000 | [diff] [blame] | 2217 | } |
| 2218 | |
Jiyong Park | 7cd10e3 | 2020-01-14 09:22:18 +0900 | [diff] [blame] | 2219 | // Optimization. If we are building bundled APEX, for the files that are gathered due to the |
| 2220 | // transitive dependencies, don't place them inside the APEX, but place a symlink pointing |
| 2221 | // the same library in the system partition, thus effectively sharing the same libraries |
| 2222 | // across the APEX boundary. For unbundled APEX, all the gathered files are actually placed |
| 2223 | // in the APEX. |
Steven Moreland | 2c4000c | 2021-04-27 02:08:49 +0000 | [diff] [blame] | 2224 | a.linkToSystemLib = !ctx.Config().UnbundledBuild() && a.installable() |
Jooyung Han | 54aca7b | 2019-11-20 02:26:02 +0900 | [diff] [blame] | 2225 | |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 2226 | // APEXes targeting other than system/system_ext partitions use vendor/product variants. |
| 2227 | // 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] | 2228 | if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) { |
Jooyung Han | 85d6176 | 2020-06-24 23:50:26 +0900 | [diff] [blame] | 2229 | a.linkToSystemLib = false |
| 2230 | } |
| 2231 | |
Jiyong Park | 4da0797 | 2021-01-05 21:01:11 +0900 | [diff] [blame] | 2232 | forced := ctx.Config().ForceApexSymlinkOptimization() |
Jiyong Park | f402058 | 2021-11-29 12:37:10 +0900 | [diff] [blame] | 2233 | updatable := a.Updatable() || a.FutureUpdatable() |
Jiyong Park | 4da0797 | 2021-01-05 21:01:11 +0900 | [diff] [blame] | 2234 | |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 2235 | // We don't need the optimization for updatable APEXes, as it might give false signal |
Jiyong Park | 4da0797 | 2021-01-05 21:01:11 +0900 | [diff] [blame] | 2236 | // to the system health when the APEXes are still bundled (b/149805758). |
Jiyong Park | f402058 | 2021-11-29 12:37:10 +0900 | [diff] [blame] | 2237 | if !forced && updatable && a.properties.ApexType == imageApex { |
Jiyong Park | 9d67720 | 2020-02-19 16:29:35 +0900 | [diff] [blame] | 2238 | a.linkToSystemLib = false |
| 2239 | } |
| 2240 | |
Jiyong Park | 638d30e | 2020-02-26 18:27:19 +0900 | [diff] [blame] | 2241 | // We also don't want the optimization for host APEXes, because it doesn't make sense. |
| 2242 | if ctx.Host() { |
| 2243 | a.linkToSystemLib = false |
| 2244 | } |
| 2245 | |
Colin Cross | 6340ea5 | 2021-11-04 12:01:18 -0700 | [diff] [blame] | 2246 | if a.properties.ApexType != zipApex { |
| 2247 | a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx, a.primaryApexType) |
| 2248 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2249 | |
| 2250 | //////////////////////////////////////////////////////////////////////////////////////////// |
| 2251 | // 4) generate the build rules to create the APEX. This is done in builder.go. |
| 2252 | a.buildManifest(ctx, provideNativeLibs, requireNativeLibs) |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 2253 | if a.properties.ApexType == flattenedApex { |
| 2254 | a.buildFlattenedApex(ctx) |
| 2255 | } else { |
| 2256 | a.buildUnflattenedApex(ctx) |
| 2257 | } |
Jiyong Park | 956305c | 2020-01-09 12:32:06 +0900 | [diff] [blame] | 2258 | a.buildApexDependencyInfo(ctx) |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 2259 | a.buildLintReports(ctx) |
Jiyong Park | b81b990 | 2020-11-24 19:51:18 +0900 | [diff] [blame] | 2260 | |
| 2261 | // Append meta-files to the filesInfo list so that they are reflected in Android.mk as well. |
| 2262 | if a.installable() { |
| 2263 | // For flattened APEX, make sure that APEX manifest and apex_pubkey are also copied |
| 2264 | // along with other ordinary files. (Note that this is done by apexer for |
| 2265 | // non-flattened APEXes) |
| 2266 | a.filesInfo = append(a.filesInfo, newApexFile(ctx, a.manifestPbOut, "apex_manifest.pb", ".", etc, nil)) |
| 2267 | |
| 2268 | // Place the public key as apex_pubkey. This is also done by apexer for |
| 2269 | // non-flattened APEXes case. |
| 2270 | // TODO(jiyong): Why do we need this CP rule? |
| 2271 | copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey") |
| 2272 | ctx.Build(pctx, android.BuildParams{ |
| 2273 | Rule: android.Cp, |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 2274 | Input: a.publicKeyFile, |
Jiyong Park | b81b990 | 2020-11-24 19:51:18 +0900 | [diff] [blame] | 2275 | Output: copiedPubkey, |
| 2276 | }) |
| 2277 | a.filesInfo = append(a.filesInfo, newApexFile(ctx, copiedPubkey, "apex_pubkey", ".", etc, nil)) |
| 2278 | } |
Jooyung Han | 01a3ee2 | 2019-11-02 02:52:25 +0900 | [diff] [blame] | 2279 | } |
| 2280 | |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 2281 | // apexBootclasspathFragmentFiles returns the list of apexFile structures defining the files that |
| 2282 | // the bootclasspath_fragment contributes to the apex. |
| 2283 | func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint.Module) []apexFile { |
| 2284 | bootclasspathFragmentInfo := ctx.OtherModuleProvider(module, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo) |
| 2285 | var filesToAdd []apexFile |
| 2286 | |
| 2287 | // Add the boot image files, e.g. .art, .oat and .vdex files. |
Jiakai Zhang | 6decef9 | 2022-01-12 17:56:19 +0000 | [diff] [blame] | 2288 | if bootclasspathFragmentInfo.ShouldInstallBootImageInApex() { |
| 2289 | for arch, files := range bootclasspathFragmentInfo.AndroidBootImageFilesByArchType() { |
| 2290 | dirInApex := filepath.Join("javalib", arch.String()) |
| 2291 | for _, f := range files { |
| 2292 | androidMkModuleName := "javalib_" + arch.String() + "_" + filepath.Base(f.String()) |
| 2293 | // TODO(b/177892522) - consider passing in the bootclasspath fragment module here instead of nil |
| 2294 | af := newApexFile(ctx, f, androidMkModuleName, dirInApex, etc, nil) |
| 2295 | filesToAdd = append(filesToAdd, af) |
| 2296 | } |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 2297 | } |
| 2298 | } |
| 2299 | |
satayev | 3db3547 | 2021-05-06 23:59:58 +0100 | [diff] [blame] | 2300 | // Add classpaths.proto config. |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 2301 | if af := apexClasspathFragmentProtoFile(ctx, module); af != nil { |
| 2302 | filesToAdd = append(filesToAdd, *af) |
| 2303 | } |
satayev | 3db3547 | 2021-05-06 23:59:58 +0100 | [diff] [blame] | 2304 | |
Jiakai Zhang | 49b1eb6 | 2021-11-26 18:09:27 +0000 | [diff] [blame] | 2305 | if pathInApex := bootclasspathFragmentInfo.ProfileInstallPathInApex(); pathInApex != "" { |
| 2306 | pathOnHost := bootclasspathFragmentInfo.ProfilePathOnHost() |
| 2307 | tempPath := android.PathForModuleOut(ctx, "boot_image_profile", pathInApex) |
| 2308 | |
| 2309 | if pathOnHost != nil { |
| 2310 | // We need to copy the profile to a temporary path with the right filename because the apexer |
| 2311 | // will take the filename as is. |
| 2312 | ctx.Build(pctx, android.BuildParams{ |
| 2313 | Rule: android.Cp, |
| 2314 | Input: pathOnHost, |
| 2315 | Output: tempPath, |
| 2316 | }) |
| 2317 | } else { |
| 2318 | // At this point, the boot image profile cannot be generated. It is probably because the boot |
| 2319 | // image profile source file does not exist on the branch, or it is not available for the |
| 2320 | // current build target. |
| 2321 | // However, we cannot enforce the boot image profile to be generated because some build |
| 2322 | // targets (such as module SDK) do not need it. It is only needed when the APEX is being |
| 2323 | // built. Therefore, we create an error rule so that an error will occur at the ninja phase |
| 2324 | // only if the APEX is being built. |
| 2325 | ctx.Build(pctx, android.BuildParams{ |
| 2326 | Rule: android.ErrorRule, |
| 2327 | Output: tempPath, |
| 2328 | Args: map[string]string{ |
| 2329 | "error": "Boot image profile cannot be generated", |
| 2330 | }, |
| 2331 | }) |
| 2332 | } |
| 2333 | |
| 2334 | androidMkModuleName := filepath.Base(pathInApex) |
| 2335 | af := newApexFile(ctx, tempPath, androidMkModuleName, filepath.Dir(pathInApex), etc, nil) |
| 2336 | filesToAdd = append(filesToAdd, af) |
| 2337 | } |
| 2338 | |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 2339 | return filesToAdd |
| 2340 | } |
| 2341 | |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 2342 | // apexClasspathFragmentProtoFile returns *apexFile structure defining the classpath.proto config that |
| 2343 | // the module contributes to the apex; or nil if the proto config was not generated. |
| 2344 | func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) *apexFile { |
| 2345 | info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo) |
| 2346 | if !info.ClasspathFragmentProtoGenerated { |
| 2347 | return nil |
| 2348 | } |
| 2349 | classpathProtoOutput := info.ClasspathFragmentProtoOutput |
| 2350 | af := newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), info.ClasspathFragmentProtoInstallDir.Rel(), etc, nil) |
| 2351 | return &af |
satayev | 14e4913 | 2021-05-17 21:03:07 +0100 | [diff] [blame] | 2352 | } |
| 2353 | |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 2354 | // apexFileForBootclasspathFragmentContentModule creates an apexFile for a bootclasspath_fragment |
| 2355 | // content module, i.e. a library that is part of the bootclasspath. |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 2356 | func apexFileForBootclasspathFragmentContentModule(ctx android.ModuleContext, fragmentModule blueprint.Module, javaModule javaModule) apexFile { |
| 2357 | bootclasspathFragmentInfo := ctx.OtherModuleProvider(fragmentModule, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo) |
| 2358 | |
| 2359 | // Get the dexBootJar from the bootclasspath_fragment as that is responsible for performing the |
| 2360 | // hidden API encpding. |
Paul Duffin | 1a8010a | 2021-05-15 12:39:23 +0100 | [diff] [blame] | 2361 | dexBootJar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(javaModule) |
| 2362 | if err != nil { |
| 2363 | ctx.ModuleErrorf("%s", err) |
| 2364 | } |
Paul Duffin | 190fdef | 2021-04-26 10:33:59 +0100 | [diff] [blame] | 2365 | |
| 2366 | // Create an apexFile as for a normal java module but with the dex boot jar provided by the |
| 2367 | // bootclasspath_fragment. |
| 2368 | af := apexFileForJavaModuleWithFile(ctx, javaModule, dexBootJar) |
| 2369 | return af |
Paul Duffin | cc33ec8 | 2021-04-25 23:14:55 +0100 | [diff] [blame] | 2370 | } |
| 2371 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2372 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2373 | // Factory functions |
| 2374 | // |
| 2375 | |
| 2376 | func newApexBundle() *apexBundle { |
| 2377 | module := &apexBundle{} |
| 2378 | |
| 2379 | module.AddProperties(&module.properties) |
| 2380 | module.AddProperties(&module.targetProperties) |
Jiyong Park | 5914030 | 2020-12-14 18:44:04 +0900 | [diff] [blame] | 2381 | module.AddProperties(&module.archProperties) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2382 | module.AddProperties(&module.overridableProperties) |
| 2383 | |
| 2384 | android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) |
| 2385 | android.InitDefaultableModule(module) |
| 2386 | android.InitSdkAwareModule(module) |
| 2387 | android.InitOverridableModule(module, &module.overridableProperties.Overrides) |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame] | 2388 | android.InitBazelModule(module) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2389 | return module |
| 2390 | } |
| 2391 | |
Paul Duffin | eb8051d | 2021-10-18 17:49:39 +0100 | [diff] [blame] | 2392 | func ApexBundleFactory(testApex bool) android.Module { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2393 | bundle := newApexBundle() |
| 2394 | bundle.testApex = testApex |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2395 | return bundle |
| 2396 | } |
| 2397 | |
| 2398 | // apex_test is an APEX for testing. The difference from the ordinary apex module type is that |
| 2399 | // certain compatibility checks such as apex_available are not done for apex_test. |
| 2400 | func testApexBundleFactory() android.Module { |
| 2401 | bundle := newApexBundle() |
| 2402 | bundle.testApex = true |
| 2403 | return bundle |
| 2404 | } |
| 2405 | |
| 2406 | // apex packages other modules into an APEX file which is a packaging format for system-level |
| 2407 | // components like binaries, shared libraries, etc. |
| 2408 | func BundleFactory() android.Module { |
| 2409 | return newApexBundle() |
| 2410 | } |
| 2411 | |
| 2412 | type Defaults struct { |
| 2413 | android.ModuleBase |
| 2414 | android.DefaultsModuleBase |
| 2415 | } |
| 2416 | |
| 2417 | // apex_defaults provides defaultable properties to other apex modules. |
| 2418 | func defaultsFactory() android.Module { |
| 2419 | return DefaultsFactory() |
| 2420 | } |
| 2421 | |
| 2422 | func DefaultsFactory(props ...interface{}) android.Module { |
| 2423 | module := &Defaults{} |
| 2424 | |
| 2425 | module.AddProperties(props...) |
| 2426 | module.AddProperties( |
| 2427 | &apexBundleProperties{}, |
| 2428 | &apexTargetBundleProperties{}, |
| 2429 | &overridableProperties{}, |
| 2430 | ) |
| 2431 | |
| 2432 | android.InitDefaultsModule(module) |
| 2433 | return module |
| 2434 | } |
| 2435 | |
| 2436 | type OverrideApex struct { |
| 2437 | android.ModuleBase |
| 2438 | android.OverrideModuleBase |
| 2439 | } |
| 2440 | |
| 2441 | func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 2442 | // All the overrides happen in the base module. |
| 2443 | } |
| 2444 | |
| 2445 | // override_apex is used to create an apex module based on another apex module by overriding some of |
| 2446 | // its properties. |
| 2447 | func overrideApexFactory() android.Module { |
| 2448 | m := &OverrideApex{} |
| 2449 | |
| 2450 | m.AddProperties(&overridableProperties{}) |
| 2451 | |
| 2452 | android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 2453 | android.InitOverrideModule(m) |
| 2454 | return m |
| 2455 | } |
| 2456 | |
| 2457 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2458 | // Vality check routines |
| 2459 | // |
| 2460 | // These are called in at the very beginning of GenerateAndroidBuildActions to flag an error when |
| 2461 | // certain conditions are not met. |
| 2462 | // |
| 2463 | // TODO(jiyong): move these checks to a separate go file. |
| 2464 | |
satayev | ad99149 | 2021-12-03 18:58:32 +0000 | [diff] [blame] | 2465 | var _ android.ModuleWithMinSdkVersionCheck = (*apexBundle)(nil) |
| 2466 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2467 | // Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version |
| 2468 | // of this apexBundle. |
satayev | b3fd411 | 2021-12-02 13:59:35 +0000 | [diff] [blame] | 2469 | func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2470 | if a.testApex || a.vndkApex { |
| 2471 | return |
| 2472 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2473 | // apexBundle::minSdkVersion reports its own errors. |
| 2474 | minSdkVersion := a.minSdkVersion(ctx) |
satayev | b3fd411 | 2021-12-02 13:59:35 +0000 | [diff] [blame] | 2475 | android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2476 | } |
| 2477 | |
Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 2478 | // Returns apex's min_sdk_version string value, honoring overrides |
| 2479 | func (a *apexBundle) minSdkVersionValue(ctx android.EarlyModuleContext) string { |
| 2480 | // Only override the minSdkVersion value on Apexes which already specify |
| 2481 | // a min_sdk_version (it's optional for non-updatable apexes), and that its |
| 2482 | // min_sdk_version value is lower than the one to override with. |
| 2483 | overrideMinSdkValue := ctx.DeviceConfig().ApexGlobalMinSdkVersionOverride() |
| 2484 | overrideApiLevel := minSdkVersionFromValue(ctx, overrideMinSdkValue) |
| 2485 | originalMinApiLevel := minSdkVersionFromValue(ctx, proptools.String(a.properties.Min_sdk_version)) |
| 2486 | isMinSdkSet := a.properties.Min_sdk_version != nil |
| 2487 | isOverrideValueHigher := overrideApiLevel.CompareTo(originalMinApiLevel) > 0 |
| 2488 | if overrideMinSdkValue != "" && isMinSdkSet && isOverrideValueHigher { |
| 2489 | return overrideMinSdkValue |
| 2490 | } |
| 2491 | |
| 2492 | return proptools.String(a.properties.Min_sdk_version) |
| 2493 | } |
| 2494 | |
| 2495 | // Returns apex's min_sdk_version SdkSpec, honoring overrides |
satayev | ad99149 | 2021-12-03 18:58:32 +0000 | [diff] [blame] | 2496 | func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { |
| 2497 | return android.SdkSpec{ |
| 2498 | Kind: android.SdkNone, |
| 2499 | ApiLevel: a.minSdkVersion(ctx), |
Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 2500 | Raw: a.minSdkVersionValue(ctx), |
satayev | ad99149 | 2021-12-03 18:58:32 +0000 | [diff] [blame] | 2501 | } |
| 2502 | } |
| 2503 | |
Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 2504 | // Returns apex's min_sdk_version ApiLevel, honoring overrides |
satayev | ad99149 | 2021-12-03 18:58:32 +0000 | [diff] [blame] | 2505 | func (a *apexBundle) minSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { |
Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 2506 | return minSdkVersionFromValue(ctx, a.minSdkVersionValue(ctx)) |
| 2507 | } |
| 2508 | |
| 2509 | // Construct ApiLevel object from min_sdk_version string value |
| 2510 | func minSdkVersionFromValue(ctx android.EarlyModuleContext, value string) android.ApiLevel { |
| 2511 | if value == "" { |
Jooyung Han | ed124c3 | 2021-01-26 11:43:46 +0900 | [diff] [blame] | 2512 | return android.NoneApiLevel |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2513 | } |
Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 2514 | apiLevel, err := android.ApiLevelFromUser(ctx, value) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2515 | if err != nil { |
| 2516 | ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) |
| 2517 | return android.NoneApiLevel |
| 2518 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2519 | return apiLevel |
| 2520 | } |
| 2521 | |
| 2522 | // Ensures that a lib providing stub isn't statically linked |
| 2523 | func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) { |
| 2524 | // Practically, we only care about regular APEXes on the device. |
| 2525 | if ctx.Host() || a.testApex || a.vndkApex { |
| 2526 | return |
| 2527 | } |
| 2528 | |
| 2529 | abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo) |
| 2530 | |
| 2531 | a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
| 2532 | if ccm, ok := to.(*cc.Module); ok { |
| 2533 | apexName := ctx.ModuleName() |
| 2534 | fromName := ctx.OtherModuleName(from) |
| 2535 | toName := ctx.OtherModuleName(to) |
| 2536 | |
| 2537 | // If `to` is not actually in the same APEX as `from` then it does not need |
| 2538 | // apex_available and neither do any of its dependencies. |
Paul Duffin | 4c3e8e2 | 2021-03-18 15:41:29 +0000 | [diff] [blame] | 2539 | // |
| 2540 | // It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps(). |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2541 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 2542 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 2543 | return false |
| 2544 | } |
| 2545 | |
| 2546 | // The dynamic linker and crash_dump tool in the runtime APEX is the only |
| 2547 | // exception to this rule. It can't make the static dependencies dynamic |
| 2548 | // because it can't do the dynamic linking for itself. |
Kiyoung Kim | 4098c7e | 2020-11-30 14:42:14 +0900 | [diff] [blame] | 2549 | // Same rule should be applied to linkerconfig, because it should be executed |
| 2550 | // only with static linked libraries before linker is available with ld.config.txt |
| 2551 | if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump" || fromName == "linkerconfig") { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2552 | return false |
| 2553 | } |
| 2554 | |
| 2555 | isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName) |
| 2556 | if isStubLibraryFromOtherApex && !externalDep { |
| 2557 | ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+ |
| 2558 | "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false)) |
| 2559 | } |
| 2560 | |
| 2561 | } |
| 2562 | return true |
| 2563 | }) |
| 2564 | } |
| 2565 | |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 2566 | // checkUpdatable enforces APEX and its transitive dep properties to have desired values for updatable APEXes. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2567 | func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { |
| 2568 | if a.Updatable() { |
Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 2569 | if a.minSdkVersionValue(ctx) == "" { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2570 | ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well") |
| 2571 | } |
Jiyong Park | 1bc8412 | 2021-06-22 20:23:05 +0900 | [diff] [blame] | 2572 | if a.UsePlatformApis() { |
| 2573 | ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs") |
| 2574 | } |
Daniel Norman | 6910911 | 2021-12-02 12:52:42 -0800 | [diff] [blame] | 2575 | if a.SocSpecific() || a.DeviceSpecific() { |
| 2576 | ctx.PropertyErrorf("updatable", "vendor APEXes are not updatable") |
| 2577 | } |
Jiyong Park | f402058 | 2021-11-29 12:37:10 +0900 | [diff] [blame] | 2578 | if a.FutureUpdatable() { |
| 2579 | ctx.PropertyErrorf("future_updatable", "Already updatable. Remove `future_updatable: true:`") |
| 2580 | } |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2581 | a.checkJavaStableSdkVersion(ctx) |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 2582 | a.checkClasspathFragments(ctx) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2583 | } |
| 2584 | } |
| 2585 | |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 2586 | // checkClasspathFragments enforces that all classpath fragments in deps generate classpaths.proto config. |
| 2587 | func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) { |
| 2588 | ctx.VisitDirectDeps(func(module android.Module) { |
| 2589 | if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag { |
| 2590 | info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo) |
| 2591 | if !info.ClasspathFragmentProtoGenerated { |
| 2592 | ctx.OtherModuleErrorf(module, "is included in updatable apex %v, it must not set generate_classpaths_proto to false", ctx.ModuleName()) |
| 2593 | } |
| 2594 | } |
| 2595 | }) |
| 2596 | } |
| 2597 | |
| 2598 | // checkJavaStableSdkVersion enforces that all Java deps are using stable SDKs to compile. |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 2599 | func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) { |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2600 | // Visit direct deps only. As long as we guarantee top-level deps are using stable SDKs, |
| 2601 | // java's checkLinkType guarantees correct usage for transitive deps |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 2602 | ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) { |
| 2603 | tag := ctx.OtherModuleDependencyTag(module) |
| 2604 | switch tag { |
| 2605 | case javaLibTag, androidAppTag: |
Jiyong Park | dbd710c | 2021-04-02 08:45:46 +0900 | [diff] [blame] | 2606 | if m, ok := module.(interface { |
| 2607 | CheckStableSdkVersion(ctx android.BaseModuleContext) error |
| 2608 | }); ok { |
| 2609 | if err := m.CheckStableSdkVersion(ctx); err != nil { |
Artur Satayev | 8cf899a | 2020-04-15 17:29:42 +0100 | [diff] [blame] | 2610 | ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err) |
| 2611 | } |
| 2612 | } |
| 2613 | } |
| 2614 | }) |
| 2615 | } |
| 2616 | |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 2617 | // checkApexAvailability ensures that the all the dependencies are marked as available for this APEX. |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2618 | func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { |
| 2619 | // Let's be practical. Availability for test, host, and the VNDK apex isn't important |
| 2620 | if ctx.Host() || a.testApex || a.vndkApex { |
| 2621 | return |
| 2622 | } |
| 2623 | |
| 2624 | // Because APEXes targeting other than system/system_ext partitions can't set |
| 2625 | // apex_available, we skip checks for these APEXes |
| 2626 | if a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) { |
| 2627 | return |
| 2628 | } |
| 2629 | |
| 2630 | // Coverage build adds additional dependencies for the coverage-only runtime libraries. |
| 2631 | // Requiring them and their transitive depencies with apex_available is not right |
| 2632 | // because they just add noise. |
| 2633 | if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) { |
| 2634 | return |
| 2635 | } |
| 2636 | |
| 2637 | a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { |
| 2638 | // As soon as the dependency graph crosses the APEX boundary, don't go further. |
| 2639 | if externalDep { |
| 2640 | return false |
| 2641 | } |
| 2642 | |
| 2643 | apexName := ctx.ModuleName() |
| 2644 | fromName := ctx.OtherModuleName(from) |
| 2645 | toName := ctx.OtherModuleName(to) |
| 2646 | |
| 2647 | // If `to` is not actually in the same APEX as `from` then it does not need |
| 2648 | // apex_available and neither do any of its dependencies. |
Paul Duffin | 4c3e8e2 | 2021-03-18 15:41:29 +0000 | [diff] [blame] | 2649 | // |
| 2650 | // It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps(). |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2651 | if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { |
| 2652 | // As soon as the dependency graph crosses the APEX boundary, don't go |
| 2653 | // further. |
| 2654 | return false |
| 2655 | } |
| 2656 | |
| 2657 | if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) { |
| 2658 | return true |
| 2659 | } |
Jiyong Park | 767dbd9 | 2021-03-04 13:03:10 +0900 | [diff] [blame] | 2660 | ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'."+ |
| 2661 | "\n\nDependency path:%s\n\n"+ |
| 2662 | "Consider adding %q to 'apex_available' property of %q", |
| 2663 | fromName, toName, ctx.GetPathString(true), apexName, toName) |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2664 | // Visit this module's dependencies to check and report any issues with their availability. |
| 2665 | return true |
| 2666 | }) |
| 2667 | } |
| 2668 | |
Jiyong Park | 192600a | 2021-08-03 07:52:17 +0000 | [diff] [blame] | 2669 | // checkStaticExecutable ensures that executables in an APEX are not static. |
| 2670 | func (a *apexBundle) checkStaticExecutables(ctx android.ModuleContext) { |
Jiyong Park | d12979d | 2021-08-03 13:36:09 +0900 | [diff] [blame] | 2671 | // No need to run this for host APEXes |
| 2672 | if ctx.Host() { |
| 2673 | return |
| 2674 | } |
| 2675 | |
Jiyong Park | 192600a | 2021-08-03 07:52:17 +0000 | [diff] [blame] | 2676 | ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) { |
| 2677 | if ctx.OtherModuleDependencyTag(module) != executableTag { |
| 2678 | return |
| 2679 | } |
Jiyong Park | d12979d | 2021-08-03 13:36:09 +0900 | [diff] [blame] | 2680 | |
| 2681 | if l, ok := module.(cc.LinkableInterface); ok && l.StaticExecutable() { |
Jiyong Park | 192600a | 2021-08-03 07:52:17 +0000 | [diff] [blame] | 2682 | apex := a.ApexVariationName() |
| 2683 | exec := ctx.OtherModuleName(module) |
| 2684 | if isStaticExecutableAllowed(apex, exec) { |
| 2685 | return |
| 2686 | } |
| 2687 | ctx.ModuleErrorf("executable %s is static", ctx.OtherModuleName(module)) |
| 2688 | } |
| 2689 | }) |
| 2690 | } |
| 2691 | |
| 2692 | // A small list of exceptions where static executables are allowed in APEXes. |
| 2693 | func isStaticExecutableAllowed(apex string, exec string) bool { |
| 2694 | m := map[string][]string{ |
| 2695 | "com.android.runtime": []string{ |
| 2696 | "linker", |
| 2697 | "linkerconfig", |
| 2698 | }, |
| 2699 | } |
| 2700 | execNames, ok := m[apex] |
| 2701 | return ok && android.InList(exec, execNames) |
| 2702 | } |
| 2703 | |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 2704 | // Collect information for opening IDE project files in java/jdeps.go. |
| 2705 | func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) { |
Remi NGUYEN VAN | be90172 | 2022-03-02 21:00:33 +0900 | [diff] [blame] | 2706 | dpInfo.Deps = append(dpInfo.Deps, a.overridableProperties.Java_libs...) |
| 2707 | dpInfo.Deps = append(dpInfo.Deps, a.overridableProperties.Bootclasspath_fragments...) |
| 2708 | dpInfo.Deps = append(dpInfo.Deps, a.overridableProperties.Systemserverclasspath_fragments...) |
bralee | b0c1f0c | 2021-06-07 22:49:13 +0800 | [diff] [blame] | 2709 | dpInfo.Paths = append(dpInfo.Paths, a.modulePaths...) |
| 2710 | } |
| 2711 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2712 | var ( |
| 2713 | apexAvailBaseline = makeApexAvailableBaseline() |
| 2714 | inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline) |
| 2715 | ) |
| 2716 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 2717 | func baselineApexAvailable(apex, moduleName string) bool { |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2718 | key := apex |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2719 | moduleName = normalizeModuleName(moduleName) |
| 2720 | |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 2721 | if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) { |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2722 | return true |
| 2723 | } |
| 2724 | |
| 2725 | key = android.AvailableToAnyApex |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 2726 | if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) { |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2727 | return true |
| 2728 | } |
| 2729 | |
| 2730 | return false |
| 2731 | } |
| 2732 | |
| 2733 | func normalizeModuleName(moduleName string) string { |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 2734 | // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build |
| 2735 | // system. Trim the prefix for the check since they are confusing |
Paul Duffin | d23c726 | 2020-12-11 18:13:08 +0000 | [diff] [blame] | 2736 | moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName) |
Jiyong Park | 0f80c18 | 2020-01-31 02:49:53 +0900 | [diff] [blame] | 2737 | if strings.HasPrefix(moduleName, "libclang_rt.") { |
| 2738 | // This module has many arch variants that depend on the product being built. |
| 2739 | // We don't want to list them all |
| 2740 | moduleName = "libclang_rt" |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2741 | } |
Jooyung Han | acc7bbe | 2020-05-20 09:06:00 +0900 | [diff] [blame] | 2742 | if strings.HasPrefix(moduleName, "androidx.") { |
| 2743 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries |
| 2744 | moduleName = "androidx" |
| 2745 | } |
Paul Duffin | 7d74e7b | 2020-03-06 12:30:13 +0000 | [diff] [blame] | 2746 | return moduleName |
Anton Hansson | eec79eb | 2020-01-10 15:12:39 +0000 | [diff] [blame] | 2747 | } |
| 2748 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2749 | // Transform the map of apex -> modules to module -> apexes. |
| 2750 | func invertApexBaseline(m map[string][]string) map[string][]string { |
| 2751 | r := make(map[string][]string) |
| 2752 | for apex, modules := range m { |
| 2753 | for _, module := range modules { |
| 2754 | r[module] = append(r[module], apex) |
| 2755 | } |
| 2756 | } |
| 2757 | return r |
| 2758 | } |
| 2759 | |
| 2760 | // Retrieve the baseline of apexes to which the supplied module belongs. |
| 2761 | func BaselineApexAvailable(moduleName string) []string { |
| 2762 | return inverseApexAvailBaseline[normalizeModuleName(moduleName)] |
| 2763 | } |
| 2764 | |
Jiyong Park | c0ec6f9 | 2020-11-19 23:00:52 +0900 | [diff] [blame] | 2765 | // This is a map from apex to modules, which overrides the apex_available setting for that |
| 2766 | // 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] | 2767 | // TODO(b/147364041): remove this |
| 2768 | func makeApexAvailableBaseline() map[string][]string { |
| 2769 | // The "Module separator"s below are employed to minimize merge conflicts. |
| 2770 | m := make(map[string][]string) |
| 2771 | // |
| 2772 | // Module separator |
| 2773 | // |
| 2774 | m["com.android.appsearch"] = []string{ |
| 2775 | "icing-java-proto-lite", |
| 2776 | "libprotobuf-java-lite", |
| 2777 | } |
| 2778 | // |
| 2779 | // Module separator |
| 2780 | // |
Etienne Ruffieux | 1651267 | 2021-12-15 15:49:04 +0000 | [diff] [blame] | 2781 | m["com.android.bluetooth"] = []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2782 | "android.hardware.audio.common@5.0", |
| 2783 | "android.hardware.bluetooth.a2dp@1.0", |
| 2784 | "android.hardware.bluetooth.audio@2.0", |
| 2785 | "android.hardware.bluetooth@1.0", |
| 2786 | "android.hardware.bluetooth@1.1", |
| 2787 | "android.hardware.graphics.bufferqueue@1.0", |
| 2788 | "android.hardware.graphics.bufferqueue@2.0", |
| 2789 | "android.hardware.graphics.common@1.0", |
| 2790 | "android.hardware.graphics.common@1.1", |
| 2791 | "android.hardware.graphics.common@1.2", |
| 2792 | "android.hardware.media@1.0", |
| 2793 | "android.hidl.safe_union@1.0", |
| 2794 | "android.hidl.token@1.0", |
| 2795 | "android.hidl.token@1.0-utils", |
| 2796 | "avrcp-target-service", |
| 2797 | "avrcp_headers", |
| 2798 | "bluetooth-protos-lite", |
| 2799 | "bluetooth.mapsapi", |
| 2800 | "com.android.vcard", |
| 2801 | "dnsresolver_aidl_interface-V2-java", |
| 2802 | "ipmemorystore-aidl-interfaces-V5-java", |
| 2803 | "ipmemorystore-aidl-interfaces-java", |
| 2804 | "internal_include_headers", |
| 2805 | "lib-bt-packets", |
| 2806 | "lib-bt-packets-avrcp", |
| 2807 | "lib-bt-packets-base", |
| 2808 | "libFraunhoferAAC", |
| 2809 | "libaudio-a2dp-hw-utils", |
| 2810 | "libaudio-hearing-aid-hw-utils", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2811 | "libbluetooth", |
| 2812 | "libbluetooth-types", |
| 2813 | "libbluetooth-types-header", |
| 2814 | "libbluetooth_gd", |
| 2815 | "libbluetooth_headers", |
| 2816 | "libbluetooth_jni", |
| 2817 | "libbt-audio-hal-interface", |
| 2818 | "libbt-bta", |
| 2819 | "libbt-common", |
| 2820 | "libbt-hci", |
| 2821 | "libbt-platform-protos-lite", |
| 2822 | "libbt-protos-lite", |
| 2823 | "libbt-sbc-decoder", |
| 2824 | "libbt-sbc-encoder", |
| 2825 | "libbt-stack", |
| 2826 | "libbt-utils", |
| 2827 | "libbtcore", |
| 2828 | "libbtdevice", |
| 2829 | "libbte", |
| 2830 | "libbtif", |
| 2831 | "libchrome", |
| 2832 | "libevent", |
| 2833 | "libfmq", |
| 2834 | "libg722codec", |
| 2835 | "libgui_headers", |
| 2836 | "libmedia_headers", |
| 2837 | "libmodpb64", |
| 2838 | "libosi", |
| 2839 | "libstagefright_foundation_headers", |
| 2840 | "libstagefright_headers", |
| 2841 | "libstatslog", |
| 2842 | "libstatssocket", |
| 2843 | "libtinyxml2", |
| 2844 | "libudrv-uipc", |
| 2845 | "libz", |
| 2846 | "media_plugin_headers", |
| 2847 | "net-utils-services-common", |
| 2848 | "netd_aidl_interface-unstable-java", |
| 2849 | "netd_event_listener_interface-java", |
| 2850 | "netlink-client", |
| 2851 | "networkstack-client", |
| 2852 | "sap-api-java-static", |
| 2853 | "services.net", |
| 2854 | } |
| 2855 | // |
| 2856 | // Module separator |
| 2857 | // |
| 2858 | m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"} |
| 2859 | // |
| 2860 | // Module separator |
| 2861 | // |
| 2862 | m["com.android.extservices"] = []string{ |
| 2863 | "error_prone_annotations", |
| 2864 | "ExtServices-core", |
| 2865 | "ExtServices", |
| 2866 | "libtextclassifier-java", |
| 2867 | "libz_current", |
| 2868 | "textclassifier-statsd", |
| 2869 | "TextClassifierNotificationLibNoManifest", |
| 2870 | "TextClassifierServiceLibNoManifest", |
| 2871 | } |
| 2872 | // |
| 2873 | // Module separator |
| 2874 | // |
| 2875 | m["com.android.neuralnetworks"] = []string{ |
| 2876 | "android.hardware.neuralnetworks@1.0", |
| 2877 | "android.hardware.neuralnetworks@1.1", |
| 2878 | "android.hardware.neuralnetworks@1.2", |
| 2879 | "android.hardware.neuralnetworks@1.3", |
| 2880 | "android.hidl.allocator@1.0", |
| 2881 | "android.hidl.memory.token@1.0", |
| 2882 | "android.hidl.memory@1.0", |
| 2883 | "android.hidl.safe_union@1.0", |
| 2884 | "libarect", |
| 2885 | "libbuildversion", |
| 2886 | "libmath", |
| 2887 | "libprocpartition", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2888 | } |
| 2889 | // |
| 2890 | // Module separator |
| 2891 | // |
| 2892 | m["com.android.media"] = []string{ |
| 2893 | "android.frameworks.bufferhub@1.0", |
| 2894 | "android.hardware.cas.native@1.0", |
| 2895 | "android.hardware.cas@1.0", |
| 2896 | "android.hardware.configstore-utils", |
| 2897 | "android.hardware.configstore@1.0", |
| 2898 | "android.hardware.configstore@1.1", |
| 2899 | "android.hardware.graphics.allocator@2.0", |
| 2900 | "android.hardware.graphics.allocator@3.0", |
| 2901 | "android.hardware.graphics.bufferqueue@1.0", |
| 2902 | "android.hardware.graphics.bufferqueue@2.0", |
| 2903 | "android.hardware.graphics.common@1.0", |
| 2904 | "android.hardware.graphics.common@1.1", |
| 2905 | "android.hardware.graphics.common@1.2", |
| 2906 | "android.hardware.graphics.mapper@2.0", |
| 2907 | "android.hardware.graphics.mapper@2.1", |
| 2908 | "android.hardware.graphics.mapper@3.0", |
| 2909 | "android.hardware.media.omx@1.0", |
| 2910 | "android.hardware.media@1.0", |
| 2911 | "android.hidl.allocator@1.0", |
| 2912 | "android.hidl.memory.token@1.0", |
| 2913 | "android.hidl.memory@1.0", |
| 2914 | "android.hidl.token@1.0", |
| 2915 | "android.hidl.token@1.0-utils", |
| 2916 | "bionic_libc_platform_headers", |
| 2917 | "exoplayer2-extractor", |
| 2918 | "exoplayer2-extractor-annotation-stubs", |
| 2919 | "gl_headers", |
| 2920 | "jsr305", |
| 2921 | "libEGL", |
| 2922 | "libEGL_blobCache", |
| 2923 | "libEGL_getProcAddress", |
| 2924 | "libFLAC", |
| 2925 | "libFLAC-config", |
| 2926 | "libFLAC-headers", |
| 2927 | "libGLESv2", |
| 2928 | "libaacextractor", |
| 2929 | "libamrextractor", |
| 2930 | "libarect", |
| 2931 | "libaudio_system_headers", |
| 2932 | "libaudioclient", |
| 2933 | "libaudioclient_headers", |
| 2934 | "libaudiofoundation", |
| 2935 | "libaudiofoundation_headers", |
| 2936 | "libaudiomanager", |
| 2937 | "libaudiopolicy", |
| 2938 | "libaudioutils", |
| 2939 | "libaudioutils_fixedfft", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2940 | "libbluetooth-types-header", |
| 2941 | "libbufferhub", |
| 2942 | "libbufferhub_headers", |
| 2943 | "libbufferhubqueue", |
| 2944 | "libc_malloc_debug_backtrace", |
| 2945 | "libcamera_client", |
| 2946 | "libcamera_metadata", |
| 2947 | "libdvr_headers", |
| 2948 | "libexpat", |
| 2949 | "libfifo", |
| 2950 | "libflacextractor", |
| 2951 | "libgrallocusage", |
| 2952 | "libgraphicsenv", |
| 2953 | "libgui", |
| 2954 | "libgui_headers", |
| 2955 | "libhardware_headers", |
| 2956 | "libinput", |
| 2957 | "liblzma", |
| 2958 | "libmath", |
| 2959 | "libmedia", |
| 2960 | "libmedia_codeclist", |
| 2961 | "libmedia_headers", |
| 2962 | "libmedia_helper", |
| 2963 | "libmedia_helper_headers", |
| 2964 | "libmedia_midiiowrapper", |
| 2965 | "libmedia_omx", |
| 2966 | "libmediautils", |
| 2967 | "libmidiextractor", |
| 2968 | "libmkvextractor", |
| 2969 | "libmp3extractor", |
| 2970 | "libmp4extractor", |
| 2971 | "libmpeg2extractor", |
| 2972 | "libnativebase_headers", |
| 2973 | "libnativewindow_headers", |
| 2974 | "libnblog", |
| 2975 | "liboggextractor", |
| 2976 | "libpackagelistparser", |
| 2977 | "libpdx", |
| 2978 | "libpdx_default_transport", |
| 2979 | "libpdx_headers", |
| 2980 | "libpdx_uds", |
| 2981 | "libprocinfo", |
| 2982 | "libspeexresampler", |
| 2983 | "libspeexresampler", |
| 2984 | "libstagefright_esds", |
| 2985 | "libstagefright_flacdec", |
| 2986 | "libstagefright_flacdec", |
| 2987 | "libstagefright_foundation", |
| 2988 | "libstagefright_foundation_headers", |
| 2989 | "libstagefright_foundation_without_imemory", |
| 2990 | "libstagefright_headers", |
| 2991 | "libstagefright_id3", |
| 2992 | "libstagefright_metadatautils", |
| 2993 | "libstagefright_mpeg2extractor", |
| 2994 | "libstagefright_mpeg2support", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 2995 | "libui", |
| 2996 | "libui_headers", |
| 2997 | "libunwindstack", |
| 2998 | "libvibrator", |
| 2999 | "libvorbisidec", |
| 3000 | "libwavextractor", |
| 3001 | "libwebm", |
| 3002 | "media_ndk_headers", |
| 3003 | "media_plugin_headers", |
| 3004 | "updatable-media", |
| 3005 | } |
| 3006 | // |
| 3007 | // Module separator |
| 3008 | // |
| 3009 | m["com.android.media.swcodec"] = []string{ |
| 3010 | "android.frameworks.bufferhub@1.0", |
| 3011 | "android.hardware.common-ndk_platform", |
| 3012 | "android.hardware.configstore-utils", |
| 3013 | "android.hardware.configstore@1.0", |
| 3014 | "android.hardware.configstore@1.1", |
| 3015 | "android.hardware.graphics.allocator@2.0", |
| 3016 | "android.hardware.graphics.allocator@3.0", |
| 3017 | "android.hardware.graphics.allocator@4.0", |
| 3018 | "android.hardware.graphics.bufferqueue@1.0", |
| 3019 | "android.hardware.graphics.bufferqueue@2.0", |
| 3020 | "android.hardware.graphics.common-ndk_platform", |
| 3021 | "android.hardware.graphics.common@1.0", |
| 3022 | "android.hardware.graphics.common@1.1", |
| 3023 | "android.hardware.graphics.common@1.2", |
| 3024 | "android.hardware.graphics.mapper@2.0", |
| 3025 | "android.hardware.graphics.mapper@2.1", |
| 3026 | "android.hardware.graphics.mapper@3.0", |
| 3027 | "android.hardware.graphics.mapper@4.0", |
| 3028 | "android.hardware.media.bufferpool@2.0", |
| 3029 | "android.hardware.media.c2@1.0", |
| 3030 | "android.hardware.media.c2@1.1", |
| 3031 | "android.hardware.media.omx@1.0", |
| 3032 | "android.hardware.media@1.0", |
| 3033 | "android.hardware.media@1.0", |
| 3034 | "android.hidl.memory.token@1.0", |
| 3035 | "android.hidl.memory@1.0", |
| 3036 | "android.hidl.safe_union@1.0", |
| 3037 | "android.hidl.token@1.0", |
| 3038 | "android.hidl.token@1.0-utils", |
| 3039 | "libEGL", |
| 3040 | "libFLAC", |
| 3041 | "libFLAC-config", |
| 3042 | "libFLAC-headers", |
| 3043 | "libFraunhoferAAC", |
| 3044 | "libLibGuiProperties", |
| 3045 | "libarect", |
| 3046 | "libaudio_system_headers", |
| 3047 | "libaudioutils", |
| 3048 | "libaudioutils", |
| 3049 | "libaudioutils_fixedfft", |
| 3050 | "libavcdec", |
| 3051 | "libavcenc", |
| 3052 | "libavservices_minijail", |
| 3053 | "libavservices_minijail", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3054 | "libbinderthreadstateutils", |
| 3055 | "libbluetooth-types-header", |
| 3056 | "libbufferhub_headers", |
| 3057 | "libcodec2", |
| 3058 | "libcodec2_headers", |
| 3059 | "libcodec2_hidl@1.0", |
| 3060 | "libcodec2_hidl@1.1", |
| 3061 | "libcodec2_internal", |
| 3062 | "libcodec2_soft_aacdec", |
| 3063 | "libcodec2_soft_aacenc", |
| 3064 | "libcodec2_soft_amrnbdec", |
| 3065 | "libcodec2_soft_amrnbenc", |
| 3066 | "libcodec2_soft_amrwbdec", |
| 3067 | "libcodec2_soft_amrwbenc", |
| 3068 | "libcodec2_soft_av1dec_gav1", |
| 3069 | "libcodec2_soft_avcdec", |
| 3070 | "libcodec2_soft_avcenc", |
| 3071 | "libcodec2_soft_common", |
| 3072 | "libcodec2_soft_flacdec", |
| 3073 | "libcodec2_soft_flacenc", |
| 3074 | "libcodec2_soft_g711alawdec", |
| 3075 | "libcodec2_soft_g711mlawdec", |
| 3076 | "libcodec2_soft_gsmdec", |
| 3077 | "libcodec2_soft_h263dec", |
| 3078 | "libcodec2_soft_h263enc", |
| 3079 | "libcodec2_soft_hevcdec", |
| 3080 | "libcodec2_soft_hevcenc", |
| 3081 | "libcodec2_soft_mp3dec", |
| 3082 | "libcodec2_soft_mpeg2dec", |
| 3083 | "libcodec2_soft_mpeg4dec", |
| 3084 | "libcodec2_soft_mpeg4enc", |
| 3085 | "libcodec2_soft_opusdec", |
| 3086 | "libcodec2_soft_opusenc", |
| 3087 | "libcodec2_soft_rawdec", |
| 3088 | "libcodec2_soft_vorbisdec", |
| 3089 | "libcodec2_soft_vp8dec", |
| 3090 | "libcodec2_soft_vp8enc", |
| 3091 | "libcodec2_soft_vp9dec", |
| 3092 | "libcodec2_soft_vp9enc", |
| 3093 | "libcodec2_vndk", |
| 3094 | "libdvr_headers", |
| 3095 | "libfmq", |
| 3096 | "libfmq", |
| 3097 | "libgav1", |
| 3098 | "libgralloctypes", |
| 3099 | "libgrallocusage", |
| 3100 | "libgraphicsenv", |
| 3101 | "libgsm", |
| 3102 | "libgui_bufferqueue_static", |
| 3103 | "libgui_headers", |
| 3104 | "libhardware", |
| 3105 | "libhardware_headers", |
| 3106 | "libhevcdec", |
| 3107 | "libhevcenc", |
| 3108 | "libion", |
| 3109 | "libjpeg", |
| 3110 | "liblzma", |
| 3111 | "libmath", |
| 3112 | "libmedia_codecserviceregistrant", |
| 3113 | "libmedia_headers", |
| 3114 | "libmpeg2dec", |
| 3115 | "libnativebase_headers", |
| 3116 | "libnativewindow_headers", |
| 3117 | "libpdx_headers", |
| 3118 | "libscudo_wrapper", |
| 3119 | "libsfplugin_ccodec_utils", |
| 3120 | "libspeexresampler", |
| 3121 | "libstagefright_amrnb_common", |
| 3122 | "libstagefright_amrnbdec", |
| 3123 | "libstagefright_amrnbenc", |
| 3124 | "libstagefright_amrwbdec", |
| 3125 | "libstagefright_amrwbenc", |
| 3126 | "libstagefright_bufferpool@2.0.1", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3127 | "libstagefright_enc_common", |
| 3128 | "libstagefright_flacdec", |
| 3129 | "libstagefright_foundation", |
| 3130 | "libstagefright_foundation_headers", |
| 3131 | "libstagefright_headers", |
| 3132 | "libstagefright_m4vh263dec", |
| 3133 | "libstagefright_m4vh263enc", |
| 3134 | "libstagefright_mp3dec", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3135 | "libui", |
| 3136 | "libui_headers", |
| 3137 | "libunwindstack", |
| 3138 | "libvorbisidec", |
| 3139 | "libvpx", |
| 3140 | "libyuv", |
| 3141 | "libyuv_static", |
| 3142 | "media_ndk_headers", |
| 3143 | "media_plugin_headers", |
| 3144 | "mediaswcodec", |
| 3145 | } |
| 3146 | // |
| 3147 | // Module separator |
| 3148 | // |
| 3149 | m["com.android.mediaprovider"] = []string{ |
| 3150 | "MediaProvider", |
| 3151 | "MediaProviderGoogle", |
| 3152 | "fmtlib_ndk", |
| 3153 | "libbase_ndk", |
| 3154 | "libfuse", |
| 3155 | "libfuse_jni", |
| 3156 | } |
| 3157 | // |
| 3158 | // Module separator |
| 3159 | // |
| 3160 | m["com.android.permission"] = []string{ |
| 3161 | "car-ui-lib", |
| 3162 | "iconloader", |
| 3163 | "kotlin-annotations", |
| 3164 | "kotlin-stdlib", |
| 3165 | "kotlin-stdlib-jdk7", |
| 3166 | "kotlin-stdlib-jdk8", |
| 3167 | "kotlinx-coroutines-android", |
| 3168 | "kotlinx-coroutines-android-nodeps", |
| 3169 | "kotlinx-coroutines-core", |
| 3170 | "kotlinx-coroutines-core-nodeps", |
| 3171 | "permissioncontroller-statsd", |
| 3172 | "GooglePermissionController", |
| 3173 | "PermissionController", |
| 3174 | "SettingsLibActionBarShadow", |
| 3175 | "SettingsLibAppPreference", |
| 3176 | "SettingsLibBarChartPreference", |
| 3177 | "SettingsLibLayoutPreference", |
| 3178 | "SettingsLibProgressBar", |
| 3179 | "SettingsLibSearchWidget", |
| 3180 | "SettingsLibSettingsTheme", |
| 3181 | "SettingsLibRestrictedLockUtils", |
| 3182 | "SettingsLibHelpUtils", |
| 3183 | } |
| 3184 | // |
| 3185 | // Module separator |
| 3186 | // |
| 3187 | m["com.android.runtime"] = []string{ |
| 3188 | "bionic_libc_platform_headers", |
| 3189 | "libarm-optimized-routines-math", |
| 3190 | "libc_aeabi", |
| 3191 | "libc_bionic", |
| 3192 | "libc_bionic_ndk", |
| 3193 | "libc_bootstrap", |
| 3194 | "libc_common", |
| 3195 | "libc_common_shared", |
| 3196 | "libc_common_static", |
| 3197 | "libc_dns", |
| 3198 | "libc_dynamic_dispatch", |
| 3199 | "libc_fortify", |
| 3200 | "libc_freebsd", |
| 3201 | "libc_freebsd_large_stack", |
| 3202 | "libc_gdtoa", |
| 3203 | "libc_init_dynamic", |
| 3204 | "libc_init_static", |
| 3205 | "libc_jemalloc_wrapper", |
| 3206 | "libc_netbsd", |
| 3207 | "libc_nomalloc", |
| 3208 | "libc_nopthread", |
| 3209 | "libc_openbsd", |
| 3210 | "libc_openbsd_large_stack", |
| 3211 | "libc_openbsd_ndk", |
| 3212 | "libc_pthread", |
| 3213 | "libc_static_dispatch", |
| 3214 | "libc_syscalls", |
| 3215 | "libc_tzcode", |
| 3216 | "libc_unwind_static", |
| 3217 | "libdebuggerd", |
| 3218 | "libdebuggerd_common_headers", |
| 3219 | "libdebuggerd_handler_core", |
| 3220 | "libdebuggerd_handler_fallback", |
| 3221 | "libdl_static", |
| 3222 | "libjemalloc5", |
| 3223 | "liblinker_main", |
| 3224 | "liblinker_malloc", |
| 3225 | "liblz4", |
| 3226 | "liblzma", |
| 3227 | "libprocinfo", |
| 3228 | "libpropertyinfoparser", |
| 3229 | "libscudo", |
| 3230 | "libstdc++", |
| 3231 | "libsystemproperties", |
| 3232 | "libtombstoned_client_static", |
| 3233 | "libunwindstack", |
| 3234 | "libz", |
| 3235 | "libziparchive", |
| 3236 | } |
| 3237 | // |
| 3238 | // Module separator |
| 3239 | // |
| 3240 | m["com.android.tethering"] = []string{ |
| 3241 | "android.hardware.tetheroffload.config-V1.0-java", |
| 3242 | "android.hardware.tetheroffload.control-V1.0-java", |
| 3243 | "android.hidl.base-V1.0-java", |
| 3244 | "libcgrouprc", |
| 3245 | "libcgrouprc_format", |
| 3246 | "libtetherutilsjni", |
| 3247 | "libvndksupport", |
| 3248 | "net-utils-framework-common", |
| 3249 | "netd_aidl_interface-V3-java", |
| 3250 | "netlink-client", |
| 3251 | "networkstack-aidl-interfaces-java", |
| 3252 | "tethering-aidl-interfaces-java", |
| 3253 | "TetheringApiCurrentLib", |
| 3254 | } |
| 3255 | // |
| 3256 | // Module separator |
| 3257 | // |
| 3258 | m["com.android.wifi"] = []string{ |
| 3259 | "PlatformProperties", |
| 3260 | "android.hardware.wifi-V1.0-java", |
| 3261 | "android.hardware.wifi-V1.0-java-constants", |
| 3262 | "android.hardware.wifi-V1.1-java", |
| 3263 | "android.hardware.wifi-V1.2-java", |
| 3264 | "android.hardware.wifi-V1.3-java", |
| 3265 | "android.hardware.wifi-V1.4-java", |
| 3266 | "android.hardware.wifi.hostapd-V1.0-java", |
| 3267 | "android.hardware.wifi.hostapd-V1.1-java", |
| 3268 | "android.hardware.wifi.hostapd-V1.2-java", |
| 3269 | "android.hardware.wifi.supplicant-V1.0-java", |
| 3270 | "android.hardware.wifi.supplicant-V1.1-java", |
| 3271 | "android.hardware.wifi.supplicant-V1.2-java", |
| 3272 | "android.hardware.wifi.supplicant-V1.3-java", |
| 3273 | "android.hidl.base-V1.0-java", |
| 3274 | "android.hidl.manager-V1.0-java", |
| 3275 | "android.hidl.manager-V1.1-java", |
| 3276 | "android.hidl.manager-V1.2-java", |
| 3277 | "bouncycastle-unbundled", |
| 3278 | "dnsresolver_aidl_interface-V2-java", |
| 3279 | "error_prone_annotations", |
| 3280 | "framework-wifi-pre-jarjar", |
| 3281 | "framework-wifi-util-lib", |
| 3282 | "ipmemorystore-aidl-interfaces-V3-java", |
| 3283 | "ipmemorystore-aidl-interfaces-java", |
| 3284 | "ksoap2", |
| 3285 | "libnanohttpd", |
| 3286 | "libwifi-jni", |
| 3287 | "net-utils-services-common", |
| 3288 | "netd_aidl_interface-V2-java", |
| 3289 | "netd_aidl_interface-unstable-java", |
| 3290 | "netd_event_listener_interface-java", |
| 3291 | "netlink-client", |
| 3292 | "networkstack-client", |
| 3293 | "services.net", |
| 3294 | "wifi-lite-protos", |
| 3295 | "wifi-nano-protos", |
| 3296 | "wifi-service-pre-jarjar", |
| 3297 | "wifi-service-resources", |
| 3298 | } |
| 3299 | // |
| 3300 | // Module separator |
| 3301 | // |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3302 | m["com.android.os.statsd"] = []string{ |
| 3303 | "libstatssocket", |
| 3304 | } |
| 3305 | // |
| 3306 | // Module separator |
| 3307 | // |
| 3308 | m[android.AvailableToAnyApex] = []string{ |
| 3309 | // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries |
| 3310 | "androidx", |
| 3311 | "androidx-constraintlayout_constraintlayout", |
| 3312 | "androidx-constraintlayout_constraintlayout-nodeps", |
| 3313 | "androidx-constraintlayout_constraintlayout-solver", |
| 3314 | "androidx-constraintlayout_constraintlayout-solver-nodeps", |
| 3315 | "com.google.android.material_material", |
| 3316 | "com.google.android.material_material-nodeps", |
| 3317 | |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3318 | "libclang_rt", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3319 | "libprofile-clang-extras", |
| 3320 | "libprofile-clang-extras_ndk", |
| 3321 | "libprofile-extras", |
| 3322 | "libprofile-extras_ndk", |
Ryan Prichard | b35a85e | 2021-01-13 19:18:53 -0800 | [diff] [blame] | 3323 | "libunwind", |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3324 | } |
| 3325 | return m |
| 3326 | } |
| 3327 | |
| 3328 | func init() { |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3329 | android.AddNeverAllowRules(createBcpPermittedPackagesRules(qBcpPackages())...) |
| 3330 | android.AddNeverAllowRules(createBcpPermittedPackagesRules(rBcpPackages())...) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3331 | } |
| 3332 | |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3333 | func createBcpPermittedPackagesRules(bcpPermittedPackages map[string][]string) []android.Rule { |
| 3334 | rules := make([]android.Rule, 0, len(bcpPermittedPackages)) |
| 3335 | for jar, permittedPackages := range bcpPermittedPackages { |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 3336 | permittedPackagesRule := android.NeverAllow(). |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3337 | With("name", jar). |
| 3338 | WithMatcher("permitted_packages", android.NotInList(permittedPackages)). |
| 3339 | Because(jar + |
| 3340 | " bootjar may only use these package prefixes: " + strings.Join(permittedPackages, ",") + |
Anton Hansson | e1b1836 | 2021-12-23 15:05:38 +0000 | [diff] [blame] | 3341 | ". Please consider the following alternatives:\n" + |
Andrei Onea | d967aee | 2022-01-19 15:36:40 +0000 | [diff] [blame] | 3342 | " 1. If the offending code is from a statically linked library, consider " + |
| 3343 | "removing that dependency and using an alternative already in the " + |
| 3344 | "bootclasspath, or perhaps a shared library." + |
| 3345 | " 2. Move the offending code into an allowed package.\n" + |
| 3346 | " 3. Jarjar the offending code. Please be mindful of the potential system " + |
| 3347 | "health implications of bundling that code, particularly if the offending jar " + |
| 3348 | "is part of the bootclasspath.") |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3349 | |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 3350 | rules = append(rules, permittedPackagesRule) |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3351 | } |
| 3352 | return rules |
| 3353 | } |
| 3354 | |
Anton Hansson | e1b1836 | 2021-12-23 15:05:38 +0000 | [diff] [blame] | 3355 | // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3356 | // Adding code to the bootclasspath in new packages will cause issues on module update. |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3357 | func qBcpPackages() map[string][]string { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3358 | return map[string][]string{ |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3359 | "conscrypt": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3360 | "android.net.ssl", |
| 3361 | "com.android.org.conscrypt", |
| 3362 | }, |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3363 | "updatable-media": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3364 | "android.media", |
| 3365 | }, |
| 3366 | } |
| 3367 | } |
| 3368 | |
Anton Hansson | e1b1836 | 2021-12-23 15:05:38 +0000 | [diff] [blame] | 3369 | // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3370 | // Adding code to the bootclasspath in new packages will cause issues on module update. |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3371 | func rBcpPackages() map[string][]string { |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3372 | return map[string][]string{ |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3373 | "framework-mediaprovider": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3374 | "android.provider", |
| 3375 | }, |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3376 | "framework-permission": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3377 | "android.permission", |
| 3378 | "android.app.role", |
| 3379 | "com.android.permission", |
| 3380 | "com.android.role", |
| 3381 | }, |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3382 | "framework-sdkextensions": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3383 | "android.os.ext", |
| 3384 | }, |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3385 | "framework-statsd": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3386 | "android.app", |
| 3387 | "android.os", |
| 3388 | "android.util", |
| 3389 | "com.android.internal.statsd", |
| 3390 | "com.android.server.stats", |
| 3391 | }, |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3392 | "framework-wifi": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3393 | "com.android.server.wifi", |
| 3394 | "com.android.wifi.x", |
| 3395 | "android.hardware.wifi", |
| 3396 | "android.net.wifi", |
| 3397 | }, |
Spandan Das | f14e254 | 2021-11-12 00:01:37 +0000 | [diff] [blame] | 3398 | "framework-tethering": []string{ |
Jiyong Park | 8e6d52f | 2020-11-19 14:37:47 +0900 | [diff] [blame] | 3399 | "android.net", |
| 3400 | }, |
| 3401 | } |
| 3402 | } |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3403 | |
| 3404 | // For Bazel / bp2build |
| 3405 | |
| 3406 | type bazelApexBundleAttributes struct { |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 3407 | Manifest bazel.LabelAttribute |
| 3408 | Android_manifest bazel.LabelAttribute |
| 3409 | File_contexts bazel.LabelAttribute |
| 3410 | Key bazel.LabelAttribute |
| 3411 | Certificate bazel.LabelAttribute |
| 3412 | Min_sdk_version *string |
| 3413 | Updatable bazel.BoolAttribute |
| 3414 | Installable bazel.BoolAttribute |
| 3415 | Binaries bazel.LabelListAttribute |
| 3416 | Prebuilts bazel.LabelListAttribute |
| 3417 | Native_shared_libs_32 bazel.LabelListAttribute |
| 3418 | Native_shared_libs_64 bazel.LabelListAttribute |
Wei Li | f034cb4 | 2022-01-19 15:54:31 -0800 | [diff] [blame] | 3419 | Compressible bazel.BoolAttribute |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 3420 | } |
| 3421 | |
| 3422 | type convertedNativeSharedLibs struct { |
| 3423 | Native_shared_libs_32 bazel.LabelListAttribute |
| 3424 | Native_shared_libs_64 bazel.LabelListAttribute |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3425 | } |
| 3426 | |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3427 | // ConvertWithBp2build performs bp2build conversion of an apex |
| 3428 | func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) { |
| 3429 | // We do not convert apex_test modules at this time |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3430 | if ctx.ModuleType() != "apex" { |
| 3431 | return |
| 3432 | } |
| 3433 | |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3434 | var manifestLabelAttribute bazel.LabelAttribute |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3435 | if a.properties.Manifest != nil { |
| 3436 | manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.Manifest)) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3437 | } |
| 3438 | |
| 3439 | var androidManifestLabelAttribute bazel.LabelAttribute |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3440 | if a.properties.AndroidManifest != nil { |
| 3441 | androidManifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.AndroidManifest)) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3442 | } |
| 3443 | |
| 3444 | var fileContextsLabelAttribute bazel.LabelAttribute |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3445 | if a.properties.File_contexts != nil { |
| 3446 | fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.properties.File_contexts)) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3447 | } |
| 3448 | |
Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 3449 | // TODO(b/219503907) this would need to be set to a.MinSdkVersionValue(ctx) but |
| 3450 | // given it's coming via config, we probably don't want to put it in here. |
Liz Kammer | 46fb7ab | 2021-12-01 10:09:34 -0500 | [diff] [blame] | 3451 | var minSdkVersion *string |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3452 | if a.properties.Min_sdk_version != nil { |
| 3453 | minSdkVersion = a.properties.Min_sdk_version |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3454 | } |
| 3455 | |
| 3456 | var keyLabelAttribute bazel.LabelAttribute |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3457 | if a.overridableProperties.Key != nil { |
| 3458 | keyLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.overridableProperties.Key)) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3459 | } |
| 3460 | |
| 3461 | var certificateLabelAttribute bazel.LabelAttribute |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3462 | if a.overridableProperties.Certificate != nil { |
| 3463 | certificateLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.overridableProperties.Certificate)) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3464 | } |
| 3465 | |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 3466 | nativeSharedLibs := &convertedNativeSharedLibs{ |
| 3467 | Native_shared_libs_32: bazel.LabelListAttribute{}, |
| 3468 | Native_shared_libs_64: bazel.LabelListAttribute{}, |
| 3469 | } |
| 3470 | compileMultilib := "both" |
| 3471 | if a.CompileMultilib() != nil { |
| 3472 | compileMultilib = *a.CompileMultilib() |
| 3473 | } |
| 3474 | |
| 3475 | // properties.Native_shared_libs is treated as "both" |
| 3476 | convertBothLibs(ctx, compileMultilib, a.properties.Native_shared_libs, nativeSharedLibs) |
| 3477 | convertBothLibs(ctx, compileMultilib, a.properties.Multilib.Both.Native_shared_libs, nativeSharedLibs) |
| 3478 | convert32Libs(ctx, compileMultilib, a.properties.Multilib.Lib32.Native_shared_libs, nativeSharedLibs) |
| 3479 | convert64Libs(ctx, compileMultilib, a.properties.Multilib.Lib64.Native_shared_libs, nativeSharedLibs) |
| 3480 | convertFirstLibs(ctx, compileMultilib, a.properties.Multilib.First.Native_shared_libs, nativeSharedLibs) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3481 | |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3482 | prebuilts := a.overridableProperties.Prebuilts |
Rupert Shuttleworth | 9447e1e | 2021-07-28 05:53:42 -0400 | [diff] [blame] | 3483 | prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts) |
| 3484 | prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList) |
| 3485 | |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3486 | binaries := android.BazelLabelForModuleDeps(ctx, a.properties.ApexNativeDependencies.Binaries) |
Jingwen Chen | b07c901 | 2021-12-08 10:05:45 +0000 | [diff] [blame] | 3487 | binariesLabelListAttribute := bazel.MakeLabelListAttribute(binaries) |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3488 | |
| 3489 | var updatableAttribute bazel.BoolAttribute |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3490 | if a.properties.Updatable != nil { |
| 3491 | updatableAttribute.Value = a.properties.Updatable |
Rupert Shuttleworth | 6e4950a | 2021-07-27 01:34:59 -0400 | [diff] [blame] | 3492 | } |
| 3493 | |
| 3494 | var installableAttribute bazel.BoolAttribute |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3495 | if a.properties.Installable != nil { |
| 3496 | installableAttribute.Value = a.properties.Installable |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3497 | } |
| 3498 | |
Wei Li | f034cb4 | 2022-01-19 15:54:31 -0800 | [diff] [blame] | 3499 | var compressibleAttribute bazel.BoolAttribute |
| 3500 | if a.overridableProperties.Compressible != nil { |
| 3501 | compressibleAttribute.Value = a.overridableProperties.Compressible |
| 3502 | } |
| 3503 | |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3504 | attrs := &bazelApexBundleAttributes{ |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 3505 | Manifest: manifestLabelAttribute, |
| 3506 | Android_manifest: androidManifestLabelAttribute, |
| 3507 | File_contexts: fileContextsLabelAttribute, |
| 3508 | Min_sdk_version: minSdkVersion, |
| 3509 | Key: keyLabelAttribute, |
| 3510 | Certificate: certificateLabelAttribute, |
| 3511 | Updatable: updatableAttribute, |
| 3512 | Installable: installableAttribute, |
| 3513 | Native_shared_libs_32: nativeSharedLibs.Native_shared_libs_32, |
| 3514 | Native_shared_libs_64: nativeSharedLibs.Native_shared_libs_64, |
| 3515 | Binaries: binariesLabelListAttribute, |
| 3516 | Prebuilts: prebuiltsLabelListAttribute, |
Wei Li | f034cb4 | 2022-01-19 15:54:31 -0800 | [diff] [blame] | 3517 | Compressible: compressibleAttribute, |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3518 | } |
| 3519 | |
| 3520 | props := bazel.BazelTargetModuleProperties{ |
| 3521 | Rule_class: "apex", |
| 3522 | Bzl_load_location: "//build/bazel/rules:apex.bzl", |
| 3523 | } |
| 3524 | |
Liz Kammer | be46fcc | 2021-11-01 15:32:43 -0400 | [diff] [blame] | 3525 | ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: a.Name()}, attrs) |
Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 3526 | } |
Yu Liu | 4ae55d1 | 2022-01-05 17:17:23 -0800 | [diff] [blame] | 3527 | |
| 3528 | // The following conversions are based on this table where the rows are the compile_multilib |
| 3529 | // values and the columns are the properties.Multilib.*.Native_shared_libs. Each cell |
| 3530 | // represents how the libs should be compiled for a 64-bit/32-bit device: 32 means it |
| 3531 | // should be compiled as 32-bit, 64 means it should be compiled as 64-bit, none means it |
| 3532 | // should not be compiled. |
| 3533 | // multib/compile_multilib, 32, 64, both, first |
| 3534 | // 32, 32/32, none/none, 32/32, none/32 |
| 3535 | // 64, none/none, 64/none, 64/none, 64/none |
| 3536 | // both, 32/32, 64/none, 32&64/32, 64/32 |
| 3537 | // first, 32/32, 64/none, 64/32, 64/32 |
| 3538 | |
| 3539 | func convert32Libs(ctx android.TopDownMutatorContext, compileMultilb string, |
| 3540 | libs []string, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3541 | libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) |
| 3542 | switch compileMultilb { |
| 3543 | case "both", "32": |
| 3544 | makeNoConfig32SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3545 | case "first": |
| 3546 | make32SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3547 | case "64": |
| 3548 | // Incompatible, ignore |
| 3549 | default: |
| 3550 | invalidCompileMultilib(ctx, compileMultilb) |
| 3551 | } |
| 3552 | } |
| 3553 | |
| 3554 | func convert64Libs(ctx android.TopDownMutatorContext, compileMultilb string, |
| 3555 | libs []string, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3556 | libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) |
| 3557 | switch compileMultilb { |
| 3558 | case "both", "64", "first": |
| 3559 | make64SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3560 | case "32": |
| 3561 | // Incompatible, ignore |
| 3562 | default: |
| 3563 | invalidCompileMultilib(ctx, compileMultilb) |
| 3564 | } |
| 3565 | } |
| 3566 | |
| 3567 | func convertBothLibs(ctx android.TopDownMutatorContext, compileMultilb string, |
| 3568 | libs []string, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3569 | libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) |
| 3570 | switch compileMultilb { |
| 3571 | case "both": |
| 3572 | makeNoConfig32SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3573 | make64SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3574 | case "first": |
| 3575 | makeFirstSharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3576 | case "32": |
| 3577 | makeNoConfig32SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3578 | case "64": |
| 3579 | make64SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3580 | default: |
| 3581 | invalidCompileMultilib(ctx, compileMultilb) |
| 3582 | } |
| 3583 | } |
| 3584 | |
| 3585 | func convertFirstLibs(ctx android.TopDownMutatorContext, compileMultilb string, |
| 3586 | libs []string, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3587 | libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) |
| 3588 | switch compileMultilb { |
| 3589 | case "both", "first": |
| 3590 | makeFirstSharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3591 | case "32": |
| 3592 | make32SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3593 | case "64": |
| 3594 | make64SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3595 | default: |
| 3596 | invalidCompileMultilib(ctx, compileMultilb) |
| 3597 | } |
| 3598 | } |
| 3599 | |
| 3600 | func makeFirstSharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3601 | make32SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3602 | make64SharedLibsAttributes(libsLabelList, nativeSharedLibs) |
| 3603 | } |
| 3604 | |
| 3605 | func makeNoConfig32SharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3606 | list := bazel.LabelListAttribute{} |
| 3607 | list.SetSelectValue(bazel.NoConfigAxis, "", libsLabelList) |
| 3608 | nativeSharedLibs.Native_shared_libs_32.Append(list) |
| 3609 | } |
| 3610 | |
| 3611 | func make32SharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3612 | makeSharedLibsAttributes("x86", libsLabelList, &nativeSharedLibs.Native_shared_libs_32) |
| 3613 | makeSharedLibsAttributes("arm", libsLabelList, &nativeSharedLibs.Native_shared_libs_32) |
| 3614 | } |
| 3615 | |
| 3616 | func make64SharedLibsAttributes(libsLabelList bazel.LabelList, nativeSharedLibs *convertedNativeSharedLibs) { |
| 3617 | makeSharedLibsAttributes("x86_64", libsLabelList, &nativeSharedLibs.Native_shared_libs_64) |
| 3618 | makeSharedLibsAttributes("arm64", libsLabelList, &nativeSharedLibs.Native_shared_libs_64) |
| 3619 | } |
| 3620 | |
| 3621 | func makeSharedLibsAttributes(config string, libsLabelList bazel.LabelList, |
| 3622 | labelListAttr *bazel.LabelListAttribute) { |
| 3623 | list := bazel.LabelListAttribute{} |
| 3624 | list.SetSelectValue(bazel.ArchConfigurationAxis, config, libsLabelList) |
| 3625 | labelListAttr.Append(list) |
| 3626 | } |
| 3627 | |
| 3628 | func invalidCompileMultilib(ctx android.TopDownMutatorContext, value string) { |
| 3629 | ctx.PropertyErrorf("compile_multilib", "Invalid value: %s", value) |
| 3630 | } |