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