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